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 @@ -442,7 +442,7 @@ def get_affine(self):
442442 return self .affine
443443
444444 @classmethod
445- def from_image (klass , img ):
445+ def from_image (klass , img , data = None ):
446446 ''' Class method to create new instance of own class from `img`
447447
448448 Parameters
@@ -456,7 +456,7 @@ def from_image(klass, img):
456456 cimg : ``spatialimage`` instance
457457 Image, of our own class
458458 '''
459- return klass (img .dataobj ,
459+ return klass (img .dataobj if data is None else data ,
460460 img .affine ,
461461 klass .header_class .from_header (img .header ),
462462 extra = img .extra .copy ())
@@ -520,5 +520,4 @@ def image_like(img, data):
520520 ''' Create new SpatialImage with metadata of `img`, and data
521521 contained in `data`.
522522 '''
523- return img .__class__ (data , img .affine , img .header .copy (),
524- extra = img .extra .copy ())
523+ return img .from_image (img , data )
You can’t perform that action at this time.
0 commit comments