Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with probabilistic atlas #386

Open
orduek opened this issue Apr 14, 2021 · 5 comments
Open

Working with probabilistic atlas #386

orduek opened this issue Apr 14, 2021 · 5 comments

Comments

@orduek
Copy link

orduek commented Apr 14, 2021

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)
@ljchang
Copy link
Member

ljchang commented Apr 14, 2021

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
Copy link
Member

ljchang commented Apr 14, 2021

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

@orduek
Copy link
Author

orduek commented Apr 14, 2021

I'm willing to help with implementation if needed

@ljchang
Copy link
Member

ljchang commented Apr 15, 2021

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.

@orduek
Copy link
Author

orduek commented Apr 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants