using collapse_mask() on the attached nifti file (which contains 16 mask images) adds more unique mask values than should exist (26, where there should be 16). Subsequently calling expand_mask() therefore expands out to a Brain_Data instance with shape[0] == 26 instead of 16.
dat = Brain_Data(fName)
collapsed = collapse_mask(dat)
len(np.unique(collapse.data) # this is wrong, too many
expanded = expand_mask(collapsed)
expanded.shape()[0] # this is wrong, too many
The following doesn't seem to help either:
#Assure masks are binary
newMasks = dat.empty()
for ma in dat:
newMasks = newMasks.append(ma.threshold(0,binarize=True))
collapsed = collapse_mask(newMasks)
expanded = expand_masks(collapsed)
expanded.shape()[0] #still wrong
This is probably a consequence of overlapping masks. We could add an option to automatically remove overlapping areas, but not sure if this is a good idea. Maybe we should just note this in the documentation.
using
collapse_mask()
on the attached nifti file (which contains 16 mask images) adds more unique mask values than should exist (26, where there should be 16). Subsequently callingexpand_mask()
therefore expands out to a Brain_Data instance with shape[0] == 26 instead of 16.Using the following file as fName: compiled_masks.nii.gz
Example code:
The following doesn't seem to help either: