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):
636636 return self .affine
637637
638638 @classmethod
639- def from_image (klass , img ):
639+ def from_image (klass , img , data = None ):
640640 ''' Class method to create new instance of own class from `img`
641641
642642 Parameters
@@ -650,7 +650,7 @@ def from_image(klass, img):
650650 cimg : ``spatialimage`` instance
651651 Image, of our own class
652652 '''
653- return klass (img .dataobj ,
653+ return klass (img .dataobj if data is None else data ,
654654 img .affine ,
655655 klass .header_class .from_header (img .header ),
656656 extra = img .extra .copy ())
@@ -667,5 +667,4 @@ def image_like(img, data):
667667 ''' Create new SpatialImage with metadata of `img`, and data
668668 contained in `data`.
669669 '''
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