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 @@ -636,7 +636,7 @@ def get_affine(self):
636
636
return self .affine
637
637
638
638
@classmethod
639
- def from_image (klass , img ):
639
+ def from_image (klass , img , data = None ):
640
640
''' Class method to create new instance of own class from `img`
641
641
642
642
Parameters
@@ -650,7 +650,7 @@ def from_image(klass, img):
650
650
cimg : ``spatialimage`` instance
651
651
Image, of our own class
652
652
'''
653
- return klass (img .dataobj ,
653
+ return klass (img .dataobj if data is None else data ,
654
654
img .affine ,
655
655
klass .header_class .from_header (img .header ),
656
656
extra = img .extra .copy ())
@@ -667,5 +667,4 @@ def image_like(img, data):
667
667
''' Create new SpatialImage with metadata of `img`, and data
668
668
contained in `data`.
669
669
'''
670
- return img .__class__ (data , img .affine , img .header .copy (),
671
- extra = img .extra .copy ())
670
+ return img .from_image (img , data )
You can’t perform that action at this time.
0 commit comments