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):
637637 return self .affine
638638
639639 @classmethod
640- def from_image (klass , img ):
640+ def from_image (klass , img , data = None ):
641641 ''' Class method to create new instance of own class from `img`
642642
643643 Parameters
@@ -651,7 +651,7 @@ def from_image(klass, img):
651651 cimg : ``spatialimage`` instance
652652 Image, of our own class
653653 '''
654- return klass (img .dataobj ,
654+ return klass (img .dataobj if data is None else data ,
655655 img .affine ,
656656 klass .header_class .from_header (img .header ),
657657 extra = img .extra .copy ())
@@ -684,5 +684,4 @@ def image_like(img, data):
684684 ''' Create new SpatialImage with metadata of `img`, and data
685685 contained in `data`.
686686 '''
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