-
Notifications
You must be signed in to change notification settings - Fork 576
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
[ENH] Add function that allows to map values onto atlas regions #3824
Comments
Thx. |
Ah, true. Note, however, that this method would also work if you just have one vector and an atlas image (e.g. your colleague gives you the coefficients and the atlas image that they used throughout their analysis). A masker object must always be fitted before being able to call |
That is true but I don't see why is that a problem to Bertrand's suggestion. Here's how you do it with a test to show it works import numpy as np
from nilearn.datasets import fetch_atlas_basc_multiscale_2015
from nilearn.maskers import NiftiLabelsMasker
from nilearn.image import load_img
mist = fetch_atlas_basc_multiscale_2015(resolution=12)
mist_nii = load_img(mist.map)
new_values = np.random.randint(100, size=12)
old_values = np.unique(mist_nii.dataobj)[1:] # the first unique value is 0 (background)
# replace value
mist_masker = NiftiLabelsMasker(mist.map).fit()
new_mask_nii= mist_masker.inverse_transform(new_values)
# test if the first old value has been replaced by the first new assigned value
index_of_original = np.where(mist_nii.dataobj == old_values[0])
index_of_new = np.where(new_mask_nii.dataobj == new_values[0])
for i in range(len(index_of_original)):
np.testing.assert_array_equal(index_of_new[i], index_of_original[i]) |
You're right! Haven't thought about the fact, that you don't need to pass anything to |
Hey, I am gonna re-open this issue because I do think there's a use-case for my function. A lot of my brain-behavior analyses contain penalization techniques or other steps where certain brain regions are being discarded. In this case, I |
Thx for reponing the discussion. |
Is there an existing issue for this?
Describe your proposed enhancement in detail.
When working with parcellated brain data one often wants to visualize statistical coefficients for each atlas region (e.g. brain region-behavior relationships). For that one needs to map those coefficients on the atlas indices to obtain a brain image that can then be visualized. I wrote a function that can do this. I am not sure if this is of interest to the Nilearn package? If yes, I could send a PR
Benefits to the change
Function is quite fast thanks to this thread:
https://stackoverflow.com/a/16993364/8792159
Pseudocode for the new behavior, if applicable
The text was updated successfully, but these errors were encountered: