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 @@ -537,7 +537,7 @@ def get_affine(self):
537537 return self .affine
538538
539539 @classmethod
540- def from_image (klass , img ):
540+ def from_image (klass , img , data = None ):
541541 ''' Class method to create new instance of own class from `img`
542542
543543 Parameters
@@ -551,7 +551,7 @@ def from_image(klass, img):
551551 cimg : ``spatialimage`` instance
552552 Image, of our own class
553553 '''
554- return klass (img .dataobj ,
554+ return klass (img .dataobj if data is None else data ,
555555 img .affine ,
556556 klass .header_class .from_header (img .header ),
557557 extra = img .extra .copy ())
@@ -640,5 +640,4 @@ def image_like(img, data):
640640 ''' Create new SpatialImage with metadata of `img`, and data
641641 contained in `data`.
642642 '''
643- return img .__class__ (data , img .affine , img .header .copy (),
644- extra = img .extra .copy ())
643+ return img .from_image (img , data )
You can’t perform that action at this time.
0 commit comments