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):
442
442
return self .affine
443
443
444
444
@classmethod
445
- def from_image (klass , img ):
445
+ def from_image (klass , img , data = None ):
446
446
''' Class method to create new instance of own class from `img`
447
447
448
448
Parameters
@@ -456,7 +456,7 @@ def from_image(klass, img):
456
456
cimg : ``spatialimage`` instance
457
457
Image, of our own class
458
458
'''
459
- return klass (img .dataobj ,
459
+ return klass (img .dataobj if data is None else data ,
460
460
img .affine ,
461
461
klass .header_class .from_header (img .header ),
462
462
extra = img .extra .copy ())
@@ -520,5 +520,4 @@ def image_like(img, data):
520
520
''' Create new SpatialImage with metadata of `img`, and data
521
521
contained in `data`.
522
522
'''
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