Cannot identify the area of the brain regions

nilearn
fmri
neuroimaging
#1

Hello,
i am trying to extract the regions coordinates from spm12 atlas. the problem that i can’t extract the regions’ area out of the atlas . what i manged to do is extracting the center of the regions (x,y,z) . but i want the area so that when i get a voxel, i could identify in which regions this voxel falls in.

from nilearn import datasets, image, plotting
import xlwt
import xlsxwriter
aal_atlas = datasets.fetch_atlas_aal('SPM12')
labels = aal_atlas.labels
coords,coords_indices = plotting.find_parcellation_cut_coords(aal_atlas['maps'],0,True)
workbook = xlsxwriter.Workbook('SPM12_Atlas_Data.xlsx')
 # add_sheet is used to create sheet.
 worksheet = workbook.add_worksheet()
 worksheet.write('A1', 'Region Name')
 worksheet.write('B1', 'Region_indices')
 worksheet.write('C1', 'Coordinates_center')
 for i in range(0, len(coords_indices)):
    labelTemp = aal_atlas.labels[aal_atlas.indices.index(str(coords_indices[i]))]
    worksheet.write('A'+str(i+2), str(labelTemp))
    worksheet.write('B'+str(i+2), str(coords_indices[i]))
    worksheet.write('C'+str(i+2), str(coords[i]))

 workbook.close()
#2

Ahoi hoi @Ahmed_Shaaban,

thanks for the post and welcome to Neurostars, it’s great to have you here.

I’m not sure if I totally got what you’re trying to do, hence my answer might not
be super helpful, sorry. I think there are different ways to approach this.
You could use nipype’s PickAtlas to extract the ROIs of a given atlas as masks in .nii and then check (e.g., visually) if your (I assume) activation patterns fall within that/those region(s). On of the other options would be to use atlasreader (joss paper & demo on binder) to get useful informations about your activation patterns (e.g., localization/extent of peaks and clusters, etc.).

HTH, cheers, Peer

1 Like
#3

Alternately, I made a simple script with example which tries to identify brain areas provided coordinates.
Take a look at here: https://gist.github.com/KamalakerDadi/39167adb02cb2dc387a96b8f02a36517
The example is based on harvard oxford.

I just uploaded the script I had. I hope it works.

HTH

1 Like
#4

your post didn’t satisfy my question but i find it quite useful.
many thanks

#5

it works fine on the Harvard atlases but i tried to apply it on spm12 but it didn’t work. I need to know how to identify the range of each area. the problem of the atlas you used. it contains 49 on the other hand SPM12 contains 116 labeled areas.
many thanks.