nltools icon indicating copy to clipboard operation
nltools copied to clipboard

Working with probabilistic atlas

Open orduek opened this issue 4 years ago • 5 comments

I tried to use Brain_Data to load a mask based on DiFuMo atlas (https://parietal-inria.github.io/DiFuMo/) Using the standard method (loading mask with Brain_Data and using expand_mask) doesn't work. When looking at the loaded atlas, I find that it is already loaded as expanded. But then, trying to use roi_to_brain doesn't work as well.

a = nilearn.datasets.fetch_atlas_difumo(dimension=256)
mask = Brain_Data(a.maps)

orduek avatar Apr 14 '21 06:04 orduek

Hi @orduek, most of our mask functions are not designed to work with probabilistic masks, only binary ones. It's easy to convert to binary using the dat.threshold() method. However, without knowing any of the details of those images, finding an appropriate threshold might be tricky with that particular mask.

Here is an example for how to binarize a single map, mask[0].threshold(upper=.0001, binarize=True), or all of them if you can use the same threshold mask_bin = mask.threshold(upper=.0001, binarize=True)

ljchang avatar Apr 14 '21 13:04 ljchang

@ejolly should we consider adding in a weighted mean for probablistic maps at some point?

ljchang avatar Apr 14 '21 18:04 ljchang

I'm willing to help with implementation if needed

orduek avatar Apr 14 '21 19:04 orduek

That would be great @orduek if you're up for it! I think at this point, it probably makes the most sense to add this to the extract_roi method see source code.

It's going to be a little tricky to think through how a weighted mask would work with all of the options. We currently have 3 methods implemented, mean, median, and PCA. Mean is pretty straightforward, if it is non-binary, it would compute the weighted mean. This should automatically normalize so not a big deal if probabilities don't sum to 1. For median, we might try something like a weighted median. PCA is going to be a bit trickier. I might recommend just outputting a Not Currently Supported error if someone tries that.

Unfortunately, for apply_mask, expand_mask, etc. It is going to be pretty tricky to get those to work well with probabilistic masks. For the moment, I think I would prefer having people explicitly convert their probabilistic mask to binary before inputting them into apply_mask so that everything is transparent about how the thresholding is being done. An easy thing to help others, would be to add a quick example to the sphinx gallery tutorial.

ljchang avatar Apr 15 '21 14:04 ljchang

Sounds good. I'll have a go at it and let you know once I stumble into some issues.

orduek avatar Apr 15 '21 15:04 orduek