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):
537
537
return self .affine
538
538
539
539
@classmethod
540
- def from_image (klass , img ):
540
+ def from_image (klass , img , data = None ):
541
541
''' Class method to create new instance of own class from `img`
542
542
543
543
Parameters
@@ -551,7 +551,7 @@ def from_image(klass, img):
551
551
cimg : ``spatialimage`` instance
552
552
Image, of our own class
553
553
'''
554
- return klass (img .dataobj ,
554
+ return klass (img .dataobj if data is None else data ,
555
555
img .affine ,
556
556
klass .header_class .from_header (img .header ),
557
557
extra = img .extra .copy ())
@@ -641,5 +641,4 @@ def image_like(img, data):
641
641
''' Create new SpatialImage with metadata of `img`, and data
642
642
contained in `data`.
643
643
'''
644
- return img .__class__ (data , img .affine , img .header .copy (),
645
- extra = img .extra .copy ())
644
+ return img .from_image (img , data )
You can’t perform that action at this time.
0 commit comments