Skip to content

Commit 8233f44

Browse files
committed
fixed bug with create sphere and mask
Former-commit-id: b9f8116
1 parent 077839f commit 8233f44

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nltools/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def __init__(self, data=None, Y=None, X=None, mask=None, output_file=None, **kwa
8787
if type(mask) is str:
8888
if os.path.isfile(mask):
8989
mask = nib.load(mask)
90-
else:
91-
raise ValueError("mask is not a nibabel instance")
90+
else:
91+
raise ValueError("mask is not a nibabel instance or a valid file name")
9292
self.mask = mask
9393
else:
9494
self.mask = nib.load(os.path.join(get_resource_path(),'MNI152_T1_2mm_brain_mask.nii.gz'))

nltools/mask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def sphere(r, p, mask):
8282
coordinates = [coordinates]
8383
if (type(radius)) is list and (type(coordinates) is list) and (len(radius) == len(coordinates)):
8484
A = np.zeros_like(mask.get_data())
85-
A = Brain_Data(nib.Nifti1Image(A,affine=mask.get_affine()))
85+
A = Brain_Data(nib.Nifti1Image(A,affine=mask.affine),mask=mask)
8686
for i in xrange(len(radius)):
87-
A = A + Brain_Data(sphere(radius[i], coordinates[i], mask))
87+
A = A + Brain_Data(sphere(radius[i], coordinates[i], mask),mask=mask)
8888
# B,translation_affine = sphere(radius[i], coordinates[i], mask)
8989
# A = np.add(A, B)
9090
# A = np.add(A, sphere(radius[i], coordinates[i], mask))

0 commit comments

Comments
 (0)