File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -637,7 +637,7 @@ def get_affine(self):
637
637
return self .affine
638
638
639
639
@classmethod
640
- def from_image (klass , img ):
640
+ def from_image (klass , img , data = None ):
641
641
''' Class method to create new instance of own class from `img`
642
642
643
643
Parameters
@@ -651,7 +651,7 @@ def from_image(klass, img):
651
651
cimg : ``spatialimage`` instance
652
652
Image, of our own class
653
653
'''
654
- return klass (img .dataobj ,
654
+ return klass (img .dataobj if data is None else data ,
655
655
img .affine ,
656
656
klass .header_class .from_header (img .header ),
657
657
extra = img .extra .copy ())
@@ -684,5 +684,4 @@ def image_like(img, data):
684
684
''' Create new SpatialImage with metadata of `img`, and data
685
685
contained in `data`.
686
686
'''
687
- return img .__class__ (data , img .affine , img .header .copy (),
688
- extra = img .extra .copy ())
687
+ return img .from_image (img , data )
You can’t perform that action at this time.
0 commit comments