Created
January 28, 2022 16:41
-
-
Save bthirion/61630ace721c639e16f459ea212b3e94 to your computer and use it in GitHub Desktop.
How to get a difumo label for a given position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nilearn.datasets import fetch_atlas_difumo | |
from nilearn.input_data import NiftiSpheresMasker | |
import numpy as np | |
d256 = fetch_atlas_difumo(dimension=256) | |
seeds = [[-52, 14, 0]] # this is your position, you may pick any you wish | |
masker = NiftiSpheresMasker(seeds=seeds, radius=2).fit() | |
weights = masker.transform(d256.maps) | |
label = d256.labels[np.argmax(weights)] | |
print('label:', label) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment