nltools icon indicating copy to clipboard operation
nltools copied to clipboard

Expand/collapse mask sometimes creates extra mask values

Open ejolly opened this issue 8 years ago • 1 comments

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.

Using the following file as fName: compiled_masks.nii.gz

Example code:

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

ejolly avatar Apr 18 '17 00:04 ejolly

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.

ljchang avatar Apr 23 '17 14:04 ljchang