atlasreader
is a Python interface that generates coordinate tables and region labels from statistical MRI images.
This notebook will show you how to install AtlasReader, how to run the toolbox and what the different parameters allow you to do.
Provided you have pip
at your disposal, installing AtlasReader is as simple as this:
pip install atlasreader
If you want to install AtlasReader directly from the source code, use the following code:
git clone https://github.com/miykael/atlasreader.git
cd atlasreader
python setup.py install
Before showcasing the toolbox, we want to point to the particular license issue that you need to consider when you are using AtlasReader.
AtlasReader itself is licensed under the BSD-3 license, but the included atlases that are used to lookup the coordinate labels are under their own license terms. For this reason, we ask you to inform yourself about the atlas specific license terms under https://github.com/miykael/atlasreader/tree/master/atlasreader/data and to cite the corresponding papers should you use AtlasReader in a publication.
We've included the following information message after every first module import, to make sure that users are aware about this issue:
The Python package you are importing, AtlasReader, is licensed under the
BSD-3 license; however, the atlases it uses are separately licensed under more
restrictive frameworks.
By using AtlasReader, you agree to abide by the license terms of the
individual atlases. Information on these terms can be found online at:
https://github.com/miykael/atlasreader/tree/master/atlasreader/data
If you use AtlasReader in your publication, please cite the following paper:
Notter M. P., Gale D., Herholz P., Markello R. D., Notter-Bielser M.-L., & Whitaker K. (2019). AtlasReader: A Python package to generate coordinate tables, region labels, and informative figures from statistical MRI images. *Journal of Open Source Software, 4(34), 1257*, [https://doi.org/10.21105/joss.01257](https://doi.org/10.21105/joss.01257)
AtlasReader can either be run through the command line interface, or directly within Python. To showcase both of those examples, let's first import relevant plotting functions for this notebook.
%matplotlib inline
from nilearn.plotting import plot_glass_brain
from IPython.display import Image
Next, let's grab an example stat map. We'll use nilearn
to grab a motor task stat map from neurovault and to threshold it at a value of 3 to create some clusters. Note that you'll need the most up to date version of nilearn
in order to run fetch_neurovault_motor_task()
.
# Get a stat map from neurovault using nilearn
from nilearn.datasets import fetch_neurovault_motor_task
motor_images = fetch_neurovault_motor_task()
stat_img = motor_images.images[0]
# Threshold image at a value of 3 to create clusters
from nilearn.image import threshold_img
stat_img = threshold_img(stat_img, threshold=3)
# Save the thresholded image into a NIfTI file
file_name = "stat_img.nii.gz"
stat_img.to_filename(file_name)
And what does our example data look like?
plot_glass_brain(
file_name,
black_bg=True,
colorbar=True,
plot_abs=False,
display_mode="lyrz",
title="Finger tapping task",
);
Ok, so we can see that there are a few particular clusters, if we threshold the data at a value of 3. But how big are they and in which regions are they?
To answer these questions, you can use AtlasReader. It gives you the opportunity to better understand where the peaks of those clusters are, over which regions the clusters extend, and much more. So, how is it done?
If you want to run AtlasReader directly in Python, just import the create_output()
function, and you're good to go:
from atlasreader import create_output
The Python package you are importing, AtlasReader, is licensed under the BSD-3 license; however, the atlases it uses are separately licensed under more restrictive frameworks. By using AtlasReader, you agree to abide by the license terms of the individual atlases. Information on these terms can be found online at: https://github.com/miykael/atlasreader/tree/master/atlasreader/data
Great, so now we can run AtlasReader. The only thing that we have to provide is our stat map (either the file_name
or the image object) and the cluster extent, which specifies the minimum number of contiguous voxels required for a cluster to be considered for the analysis. For this example, let's set the cluster_extent
to 5.
create_output(file_name, cluster_extent=5, direction="both")
After execution, we get four different kind of files:
So, let's take a closer look at those outputs:
The overview figure shows all clusters through the brain, plotted on a glass brain plot. The name of file is the name of provided statistical image, but with the file ending .png
Image("stat_img.png")
AtlasReader creates for each cluster an informative figure, showing the cluster center in the three anatomical planes: sagittal, coronal and trasnveral. The name of those files all end in _clusterXY.png
, i.e. _cluster01.png
, _cluster02.png
, ...:
Image("stat_img_cluster01.png")
Image("stat_img_cluster03.png")
The csv file ending with _peaks.csv
contains the location of each cluster's peak, it's signal value at this location, the cluster extend (in mm, not in number of voxels) and the atlas correspondence of the peak:
import pandas as pd
pd.read_csv("stat_img_peaks.csv")
cluster_id | peak_x | peak_y | peak_z | peak_value | volume_mm | aal | desikan_killiany | harvard_oxford | |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 55 | 7.94135 | 60399 | Postcentral_R | Right-Cerebral-White-Matter | 48% Right_Postcentral_Gyrus; 12% Right_Precent... |
1 | 2 | -36 | -25 | 55 | -7.94144 | 19386 | Postcentral_L | Left-Cerebral-White-Matter | 30% Left_Postcentral_Gyrus; 30% Left_Precentra... |
2 | 3 | -15 | -52 | -26 | 7.94135 | 10260 | no_label | Left-Cerebellum-Cortex | 0% no_label |
3 | 4 | 18 | -55 | -23 | -7.94144 | 8964 | Cerebelum_6_R | Right-Cerebellum-Cortex | 0% no_label |
4 | 5 | -36 | -19 | 19 | -6.21808 | 1215 | Insula_L | Unknown | 37% Left_Central_Opercular_Cortex; 37% Left_In... |
5 | 6 | -6 | -19 | 49 | -5.03538 | 1215 | Cingulate_Mid_L | ctx-lh-paracentral | 50% Left_Precentral_Gyrus; 9% Left_Juxtapositi... |
6 | 7 | -30 | -10 | -2 | -4.65454 | 378 | Putamen_L | Left-Putamen | 98% Left_Putamen |
7 | 8 | -15 | -55 | 16 | -3.57240 | 351 | Precuneus_L | Left-Cerebral-White-Matter | 35% Left_Precuneous_Cortex |
8 | 9 | -66 | -25 | 31 | 3.33892 | 351 | SupraMarginal_L | ctx-lh-supramarginal | 42% Left_Supramarginal_Gyrus_anterior_division... |
9 | 10 | -21 | 41 | 46 | -3.41921 | 162 | Frontal_Sup_2_L | Unknown | 51% Left_Frontal_Pole; 19% Left_Superior_Front... |
The csv file ending with _clusters.csv
contains the location of each cluster's peak, the mean value within the cluster, the cluster extend (in mm, not in number of voxels), as well as the membership of each cluster, given a particular atlas.
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | aal | desikan_killiany | harvard_oxford | |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 55 | 5.71861 | 60399 | 28.39% Postcentral_R; 14.75% Precentral_R; 9.1... | 31.47% Unknown; 27.09% Right-Cerebral-White-Ma... | 28.07% Right_Postcentral_Gyrus; 19.18% Right_P... |
1 | 2 | -36 | -25 | 55 | -5.92288 | 19386 | 60.17% Postcentral_L; 26.32% Precentral_L; 6.2... | 47.49% Left-Cerebral-White-Matter; 18.80% ctx-... | 60.58% Left_Postcentral_Gyrus; 35.38% Left_Pre... |
2 | 3 | -15 | -52 | -26 | 5.28665 | 10260 | 43.68% Cerebelum_6_L; 32.63% Cerebelum_4_5_L; ... | 76.05% Left-Cerebellum-Cortex; 19.21% Left-Cer... | 78.16% no_label; 10.53% Left_Lingual_Gyrus; 5.... |
3 | 4 | 18 | -55 | -23 | -4.93921 | 8964 | 32.53% Cerebelum_4_5_R; 31.02% Cerebelum_6_R; ... | 75.60% Right-Cerebellum-Cortex; 12.95% Right-C... | 81.93% no_label; 15.96% Right_Lingual_Gyrus |
4 | 5 | -36 | -19 | 19 | -4.30705 | 1215 | 71.11% Rolandic_Oper_L; 28.89% Insula_L | 46.67% Unknown; 28.89% ctx-lh-supramarginal; 1... | 57.78% Left_Central_Opercular_Cortex; 24.44% L... |
5 | 6 | -6 | -19 | 49 | -3.76954 | 1215 | 51.11% Cingulate_Mid_L; 37.78% Supp_Motor_Area... | 40.00% ctx-lh-paracentral; 31.11% Unknown; 15.... | 68.89% Left_Precentral_Gyrus; 20.00% Left_Juxt... |
6 | 7 | -30 | -10 | -2 | -3.67586 | 378 | 92.86% Putamen_L; 7.14% no_label | 100.00% Left-Putamen | 100.00% Left_Putamen |
7 | 8 | -15 | -55 | 16 | -3.21501 | 351 | 84.62% Precuneus_L; 7.69% Cuneus_L; 7.69% Calc... | 38.46% ctx-lh-precuneus; 38.46% Left-Cerebral-... | 100.00% Left_Precuneous_Cortex |
8 | 9 | -66 | -25 | 31 | 3.10147 | 351 | 84.62% SupraMarginal_L; 15.38% no_label | 76.92% ctx-lh-supramarginal; 23.08% Left-Cereb... | 69.23% Left_Supramarginal_Gyrus_anterior_divis... |
9 | 10 | -21 | 41 | 46 | -3.18072 | 162 | 100.00% Frontal_Sup_2_L | 66.67% Unknown; 16.67% ctx-lh-superiorfrontal;... | 66.67% Left_Frontal_Pole; 33.33% Left_Superior... |
For example, in the csv table shown above, we know that 60.17% of the second cluster is in the left postcentral and 26.32% is in the left precentral area, according to the AAL atlas.
As mentioned before, atlasreader.create_output
has many additional parameters that allow you to change the way the clusters are generated and what kind of outputs are generated. So, let's have a closer look:
filename
'default'
stat_img
. Use direction
to specify the
directionality of the threshold. If a negative number is provided a
percentile threshold is used instead, where the percentile is determined
by the equation 100 - voxel_thresh
. *Default*: 1.96
voxel_thresh
should be applied. Possible
values are 'both'
, 'pos'
or 'neg'
. *Default*: 'both'
atlas
, if it is
probabilistic. *Default*: 5
None
filename
. *Default*: None
nilearn.plotting.plot_glass_brain
.nilearn.plotting.plot_stat_map
.The first two, we've already used in the previous example, but let's take a closer look at the others.
atlas
and voxel_thresh
¶First, let's change the atlas and the voxel_thresh parameters:
create_output(
file_name, cluster_extent=5, atlas=["destrieux", "marsatlas"], voxel_thresh=6
)
As you can see, the usage of a higher voxel threshold created smaller clusters and caused the clusters with below threshold voxels to disappear.
Image("stat_img.png")
Additionally, the csv files now contain the information about the destrieux
and marsatlas
.
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | destrieux | marsatlas | |
---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 58 | 7.62272 | 22869 | 33.06% Right-Cerebral-White-Matter; 31.17% Unk... | 65.41% no_label; 13.34% Right_Dorsolateral_Som... |
1 | 2 | -36 | -25 | 55 | -7.61916 | 9639 | 49.86% Left-Cerebral-White-Matter; 18.77% Unkn... | 66.67% no_label; 13.73% Left_Dorsolateral_Soma... |
2 | 3 | -15 | -52 | -26 | 7.39954 | 3429 | 82.68% Left-Cerebellum-Cortex; 17.32% Left-Cer... | 100.00% no_label |
3 | 4 | 45 | -19 | 16 | 7.30833 | 2754 | 44.12% Unknown; 17.65% ctx_rh_G_and_S_subcentr... | 53.92% no_label; 34.31% Right_Ventral_Inferior... |
4 | 5 | 18 | -55 | -23 | -7.25811 | 2133 | 94.94% Right-Cerebellum-Cortex; 5.06% Right-Ce... | 100.00% no_label |
5 | 6 | 6 | -10 | 52 | 6.78709 | 1053 | 38.46% ctx_rh_G_front_sup; 23.08% Unknown; 20.... | 35.90% no_label; 30.77% Right_Dorsomedial_Moto... |
6 | 7 | 33 | -7 | -2 | 6.74001 | 243 | 100.00% Right-Putamen | 100.00% Right_Puttamen |
Note: The three atlases from the previous example, aal
, desikan_killiany
, harvard_oxford
are the default atlases, which can either be specified with atlas='default'
, atlas=['aal', 'desikan_killiany', 'harvard_oxford']
or by just omitting the atlas
parameter.
If a negative number is provided for voxel_thresh
, a percentile threshold is used instead, where the percentile is determined by the equation 100 - voxel_thresh
. So, let's threshold the data at 99%.
create_output(file_name, cluster_extent=5, voxel_thresh=-1)
Image("stat_img.png")
Note: This percentage term is misleading if the statistical images contains negative values. For example, 99% in the above example, is the 99 percentile of all values between -7.9 to 7.9.
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | aal | desikan_killiany | harvard_oxford | |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 58 | 7.19965 | 28215 | 50.91% Postcentral_R; 28.33% Precentral_R; 6.8... | 34.16% Right-Cerebral-White-Matter; 29.67% Unk... | 48.33% Right_Postcentral_Gyrus; 29.47% Right_P... |
1 | 2 | -36 | -25 | 55 | -7.13494 | 12285 | 64.40% Postcentral_L; 32.53% Precentral_L | 48.79% Left-Cerebral-White-Matter; 18.02% ctx-... | 63.30% Left_Postcentral_Gyrus; 36.48% Left_Pre... |
2 | 3 | -15 | -52 | -26 | 6.70928 | 5265 | 43.59% Cerebelum_6_L; 38.97% Cerebelum_4_5_L; ... | 79.49% Left-Cerebellum-Cortex; 20.00% Left-Cer... | 88.72% no_label; 5.13% Left_Lingual_Gyrus |
3 | 4 | 45 | -19 | 16 | 6.55843 | 4509 | 63.47% Rolandic_Oper_R; 14.97% Insula_R; 8.98%... | 44.31% Unknown; 29.34% ctx-rh-supramarginal; 1... | 37.72% Right_Parietal_Operculum_Cortex; 37.13%... |
4 | 5 | 18 | -55 | -23 | -6.41416 | 3834 | 48.59% Cerebelum_4_5_R; 39.44% Cerebelum_6_R | 82.39% Right-Cerebellum-Cortex; 9.15% Right-Ce... | 87.32% no_label; 11.97% Right_Lingual_Gyrus |
5 | 6 | 6 | -10 | 52 | 5.88783 | 2970 | 64.55% Supp_Motor_Area_R; 35.45% Cingulate_Mid_R | 38.18% ctx-rh-paracentral; 33.64% Unknown; 17.... | 60.91% Right_Juxtapositional_Lobule_Cortex_(fo... |
6 | 7 | 33 | -7 | -2 | 6.20878 | 405 | 86.67% Putamen_R; 6.67% Pallidum_R; 6.67% no_l... | 100.00% Right-Putamen | 80.00% Right_Putamen; 20.00% Right_Insular_Cortex |
7 | 8 | -36 | -19 | 19 | -5.61900 | 297 | 63.64% Rolandic_Oper_L; 36.36% Insula_L | 45.45% Unknown; 27.27% ctx-lh-postcentral; 18.... | 90.91% Left_Central_Opercular_Cortex; 9.09% Le... |
8 | 9 | 6 | -70 | -38 | -5.08795 | 162 | 100.00% Vermis_8 | 100.00% Right-Cerebellum-Cortex | 100.00% no_label |
direction
¶The direction parameter allows you to specify the directionality of the thresholding. By default, the directionality is 'both'
, which means that the voxel_thresh
value is applied to positive and negative values. Changing direction
to 'pos'
or 'neg'
allows you to apply the threshold only to one direction and ignore everything else in the other direction.
create_output(
file_name, cluster_extent=5, atlas=["aal"], voxel_thresh=4, direction="both"
)
Image("stat_img.png")
create_output(file_name, cluster_extent=5, atlas=["aal"], voxel_thresh=4, direction="pos")
Image("stat_img.png")
create_output(file_name, cluster_extent=5, atlas=["aal"], voxel_thresh=4, direction="neg")
Image("stat_img.png")
This thresholding directionality is of course also preserved in the tables.
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | aal | |
---|---|---|---|---|---|---|---|
0 | 1 | -36 | -25 | 55 | -6.63604 | 15012 | 63.67% Postcentral_L; 30.40% Precentral_L |
1 | 2 | 18 | -55 | -23 | -5.90086 | 5184 | 43.23% Cerebelum_4_5_R; 38.54% Cerebelum_6_R; ... |
2 | 3 | -36 | -19 | 19 | -5.00687 | 648 | 70.83% Rolandic_Oper_L; 29.17% Insula_L |
3 | 4 | 6 | -70 | -38 | -4.60103 | 459 | 47.06% Vermis_8; 41.18% Cerebelum_8_R; 11.76% ... |
4 | 5 | -6 | -19 | 49 | -4.41695 | 351 | 53.85% Cingulate_Mid_L; 46.15% Supp_Motor_Area_L |
prob_thresh
¶The prob_thresh parameter can be used to restrict the information in the cluster table to a given probability value. This will only influence the information in the table, but won't change the cluster size or any other outcome.
So let's take again an example from before and set the probability threshold to 33%
create_output(file_name, cluster_extent=5, prob_thresh=33.0)
As you can see, the cluster table has now fewer entries in the atlas column, as atlas corresponances below 33% where omitted. Be careful, if this threshold is set to high, no atlas corresponance will survive. In which case the entry is replaces by NaN
.
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | aal | desikan_killiany | harvard_oxford | |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 55 | 5.71861 | 60399 | NaN | NaN | NaN |
1 | 2 | -36 | -25 | 55 | -5.92288 | 19386 | 60.17% Postcentral_L | 47.49% Left-Cerebral-White-Matter | 60.58% Left_Postcentral_Gyrus; 35.24% Left_Pre... |
2 | 3 | -15 | -52 | -26 | 5.28665 | 10260 | 43.68% Cerebelum_6_L | 76.05% Left-Cerebellum-Cortex | 78.16% no_label |
3 | 4 | 18 | -55 | -23 | -4.93921 | 8964 | NaN | 75.60% Right-Cerebellum-Cortex | 81.93% no_label |
4 | 5 | -36 | -19 | 19 | -4.30705 | 1215 | 71.11% Rolandic_Oper_L | 46.67% Unknown | 57.78% Left_Central_Opercular_Cortex |
5 | 6 | -6 | -19 | 49 | -3.76954 | 1215 | 51.11% Cingulate_Mid_L; 37.78% Supp_Motor_Area_L | 40.00% ctx-lh-paracentral | 68.89% Left_Precentral_Gyrus |
6 | 7 | -30 | -10 | -2 | -3.67586 | 378 | 92.86% Putamen_L | 100.00% Left-Putamen | 100.00% Left_Putamen |
7 | 8 | -15 | -55 | 16 | -3.21501 | 351 | 84.62% Precuneus_L | 38.46% ctx-lh-precuneus; 38.46% Left-Cerebral-... | 100.00% Left_Precuneous_Cortex |
8 | 9 | -66 | -25 | 31 | 3.10147 | 351 | 84.62% SupraMarginal_L | 76.92% ctx-lh-supramarginal | 69.23% Left_Supramarginal_Gyrus_anterior_division |
9 | 10 | -21 | 41 | 46 | -3.18072 | 162 | 100.00% Frontal_Sup_2_L | 66.67% Unknown | 66.67% Left_Frontal_Pole; 33.33% Left_Superior... |
min_distance
¶By default, AtlasReader only shows information of the main peak in the peak table. But some clusters might be rather big with many different peaks. If you also want to extract peak information of other peaks within a given cluster, you can use the min_distance
parameter. This parameter specifies the minimum distance required between sub-peaks in a cluster.
To better illustrate this example, let's focus only on the big four cluster in our dataset (i.e. we will set cluster_extent=100
).
create_output(file_name, cluster_extent=100, atlas="aal", min_distance=10)
Image("stat_img.png")
Setting the minimum distance between peaks to 10, means that the peak table will now include multiple peaks withini a cluster, if they have a euclidean distance of at least 10mm.
pd.read_csv("stat_img_peaks.csv")
cluster_id | peak_x | peak_y | peak_z | peak_value | volume_mm | aal | |
---|---|---|---|---|---|---|---|
0 | 1 | 6 | -10 | 52 | 7.94135 | 60399 | Supp_Motor_Area_R |
1 | 1 | 45 | -19 | 16 | 7.94135 | 60399 | Rolandic_Oper_R |
2 | 1 | 42 | -25 | 58 | 7.94135 | 60399 | Postcentral_R |
3 | 1 | 33 | -7 | -2 | 7.90531 | 60399 | Putamen_R |
4 | 1 | 42 | -1 | 13 | 5.47070 | 60399 | Rolandic_Oper_R |
5 | 1 | 9 | 2 | 73 | 3.56015 | 60399 | Supp_Motor_Area_R |
6 | 2 | -30 | -19 | 67 | -7.94144 | 19386 | Precentral_L |
7 | 2 | -36 | -25 | 55 | -7.94144 | 19386 | Postcentral_L |
8 | 3 | -15 | -52 | -26 | 7.94135 | 10260 | no_label |
9 | 3 | -6 | -70 | -38 | 4.26074 | 10260 | Cerebelum_8_L |
10 | 4 | 18 | -55 | -23 | -7.94144 | 8964 | Cerebelum_6_R |
11 | 4 | 6 | -70 | -38 | -5.30572 | 8964 | Vermis_8 |
Note: The usage of the min_distance
parameter has only an effect on the peak table, and will not influence any other output file.
outdir
¶The outdir parameter allows you to store the output files of AtlasReader at a particular location. If none is specified, then AtlasReader will store the results at the same location, as the input image.
As an example, let's store the output at /tmp/example
:
create_output(file_name, cluster_extent=100, outdir="/tmp/example")
ls /tmp/example/
stat_img_cluster01.png stat_img_cluster04.png stat_img.png stat_img_cluster02.png stat_img_clusters.csv stat_img_cluster03.png stat_img_peaks.csv
glass_plot_kws
and stat_plot_kws
¶The last two parameters allow you to adjust the style of the output plots. Let's say that we want to tweak the default plotting style to have a white background, or adjust the colormap used to convey the clusters. This customization is done separately for the glass brain plot and the cluster plots using the _kws
arguments in create_output
. These parameters are dictionaries that contain keyword arguments for the nilearn
functions used to create these plots (see the keyword arguments for plot_glass_brain and plot_stat_map).
For example:
create_output(
file_name,
cluster_extent=100,
glass_plot_kws={"black_bg": False, "vmax": 20, "colorbar": False},
stat_plot_kws={"black_bg": False, "title": None},
)
This sets the background color to white, sets the maximum value of the colorbar to 20 and removes the colorbar from the overview plot.
Image("stat_img.png")
The cluster specific plots also have now a white background and the image title is removed from the figure.
# Title is now removed for all cluster plots
Image("stat_img_cluster01.png")
This is all super exciting! But as promised before, AtlasReader can also be run directly from the command line. Assuming you installed it via pip
.
Let's begin with running the help
argument so we can look at the input parameters.
%%bash
atlasreader -h
The Python package you are importing, AtlasReader, is licensed under the BSD-3 license; however, the atlases it uses are separately licensed under more restrictive frameworks. By using AtlasReader, you agree to abide by the license terms of the individual atlases. Information on these terms can be found online at: https://github.com/miykael/atlasreader/tree/master/atlasreader/data usage: atlasreader [-h] [-a atlas [atlas ...]] [-t threshold] [-x direction] [-p threshold] [-o outdir] [-d distance] file min_cluster_size positional arguments: file The full or relative path to the statistical map from which cluster information should be extracted. min_cluster_size Number of contiguous voxels required for a cluster to be considered for analysis. optional arguments: -h, --help show this help message and exit -a atlas [atlas ...], --atlas atlas [atlas ...] Atlas(es) to use for examining anatomical delineation of clusters in provided statistical map. Default: AAL, Desikan-Killiany & Harvard-Oxford. -t threshold, --threshold threshold Value threshold that voxels in provided file must surpass in order to be considered in cluster extraction. Use `direction` to specify the directionallity of the threshold. If a negative number is provided a percentile threshold is used instead, where the percentile is determined by the equation `100 - voxel_thresh`. Default: 1.96 -x direction, --direction direction Specifies the direction in which the threshold should be applied. Possible values are 'both', 'pos' or 'neg'. Default: 'both' -p threshold, --probability threshold Threshold to consider when using a probabilistic atlas for extracting anatomical cluster locations. Value will apply to all request probabilistic atlases, and should range between 0 and 100. Default: 5 -o outdir, --outdir outdir Output directory for created files. If it is not specified, then output files are created in the same directory as the statistical map that is provided. Default: None -d distance, --mindist distance If specified, the program will attempt to find subpeaks within detected clusters, rather than a single peak per cluster. The specified value will determine the minimum distance (in mm) required between subpeaks. Default: None
Perfect! As you can see, first, we have again the information about the license terms, followed by the description of the software. The parameters that you can specify are the same input parameters as if we would run AtlasReader within Python.
So let's try it out. Let's say we want to set the probability threshold to 20%
to remove small probabilities, use all
atlases to extract information from, threshold the image at 3
and only keep clusters with more than 10
voxels:
%%bash
atlasreader -a all -t 3 -p 20 stat_img.nii.gz 10
The Python package you are importing, AtlasReader, is licensed under the BSD-3 license; however, the atlases it uses are separately licensed under more restrictive frameworks. By using AtlasReader, you agree to abide by the license terms of the individual atlases. Information on these terms can be found online at: https://github.com/miykael/atlasreader/tree/master/atlasreader/data
The overview plot and cluster specific plots look similar to what we saw before. Great!
Image("stat_img.png")
Image("stat_img_cluster01.png")
But because we set atlas
to all
we now have much more information in the peak and cluster tables (you need to scroll to the right to see all of them).
pd.read_csv("stat_img_peaks.csv")
cluster_id | peak_x | peak_y | peak_z | peak_value | volume_mm | aal | aicha | desikan_killiany | destrieux | harvard_oxford | juelich | marsatlas | neuromorphometrics | talairach_ba | talairach_gyrus | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 55 | 7.94135 | 60399 | Postcentral_R | S_Rolando-3-R | Right-Cerebral-White-Matter | Right-Cerebral-White-Matter | 48% Right_Postcentral_Gyrus | 90% GM_Primary_somatosensory_cortex_BA3b_R; 27... | no_label | Right_Cerebral_White_Matter | Background | Postcentral_Gyrus |
1 | 2 | -36 | -25 | 55 | -7.94144 | 19386 | Postcentral_L | S_Rolando-3-L | Left-Cerebral-White-Matter | Left-Cerebral-White-Matter | 30% Left_Postcentral_Gyrus; 30% Left_Precentra... | 37% GM_Primary_motor_cortex_BA4p_L; 34% GM_Pri... | Left_Dorsolateral_Motor_Cortex(BA_4) | Left_PrG_precentral_gyrus | Brodmann_area_4 | Precentral_Gyrus |
2 | 3 | -15 | -52 | -26 | 7.94135 | 10260 | no_label | no_label | Left-Cerebellum-Cortex | Left-Cerebellum-Cortex | 0% no_label | 0% no_label | no_label | Left_Cerebellum_White_Matter | Dentate | Background |
3 | 4 | 18 | -55 | -23 | -7.94144 | 8964 | Cerebelum_6_R | no_label | Right-Cerebellum-Cortex | Right-Cerebellum-Cortex | 0% no_label | 0% no_label | no_label | Right_Cerebellum_Exterior | Dentate | Background |
4 | 5 | -36 | -19 | 19 | -6.21808 | 1215 | Insula_L | G_Insula-posterior-1-L | Unknown | Unknown | 37% Left_Central_Opercular_Cortex; 37% Left_In... | 70% GM_Secondary_somatosensory_cortex_/_Pariet... | Left_Ventral_Inferior_Parietal_Cortex(BA_40) | Left_CO_central_operculum | Brodmann_area_13 | Insula |
5 | 6 | -6 | -19 | 49 | -5.03538 | 1215 | Cingulate_Mid_L | G_Paracentral_Lobule-1-L | ctx-lh-paracentral | ctx_lh_G_front_sup | 50% Left_Precentral_Gyrus | 48% GM_Premotor_cortex_BA6_L; 47% GM_Primary_m... | no_label | Left_MPrG_precentral_gyrus_medial_segment | Background | Medial_Frontal_Gyrus |
6 | 7 | -30 | -10 | -2 | -4.65454 | 378 | Putamen_L | N_Putamen-3-L | Left-Putamen | Left-Putamen | 98% Left_Putamen | 0% no_label | Left_Puttamen | Left_Putamen | Putamen | Lentiform_Nucleus |
7 | 8 | -15 | -55 | 16 | -3.57240 | 351 | Precuneus_L | G_Precuneus-1-L | Left-Cerebral-White-Matter | Left-Cerebral-White-Matter | 35% Left_Precuneous_Cortex | 29% WM_Callosal_body | Left_Cuneus(BA_18/19) | Left_PCu_precuneus | Background | Posterior_Cingulate |
8 | 9 | -66 | -25 | 31 | 3.33892 | 351 | SupraMarginal_L | G_Supramarginal-3-L | ctx-lh-supramarginal | ctx_lh_G_pariet_inf-Supramar | 42% Left_Supramarginal_Gyrus_anterior_division... | 30% GM_Inferior_parietal_lobule_PF_L; 22% GM_S... | Left_Ventral_Inferior_Parietal_Cortex(BA_40) | Left_SMG_supramarginal_gyrus | Background | Background |
pd.read_csv("stat_img_clusters.csv")
cluster_id | peak_x | peak_y | peak_z | cluster_mean | volume_mm | aal | aicha | desikan_killiany | destrieux | harvard_oxford | juelich | marsatlas | neuromorphometrics | talairach_ba | talairach_gyrus | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 42 | -25 | 55 | 5.71861 | 60399 | 28.39% Postcentral_R | NaN | 31.47% Unknown; 27.09% Right-Cerebral-White-Ma... | 31.47% Unknown; 27.09% Right-Cerebral-White-Ma... | 28.07% Right_Postcentral_Gyrus | 28.12% GM_Premotor_cortex_BA6_R | 56.01% no_label | NaN | 65.13% Background | 23.96% Postcentral_Gyrus; 22.71% Background |
1 | 2 | -36 | -25 | 55 | -5.92288 | 19386 | 60.17% Postcentral_L; 26.32% Precentral_L | 29.39% S_Rolando-4-L; 28.83% S_Rolando-3-L | 47.49% Left-Cerebral-White-Matter | 47.49% Left-Cerebral-White-Matter | 60.58% Left_Postcentral_Gyrus; 35.38% Left_Pre... | 22.98% GM_Primary_somatosensory_cortex_BA1_L; ... | 67.83% no_label | 48.33% Left_PoG_postcentral_gyrus; 24.51% Left... | 64.35% Background | 42.20% Postcentral_Gyrus; 33.01% Background; 2... |
2 | 3 | -15 | -52 | -26 | 5.28665 | 10260 | 43.68% Cerebelum_6_L; 32.63% Cerebelum_4_5_L | 100.00% no_label | 76.05% Left-Cerebellum-Cortex | 76.05% Left-Cerebellum-Cortex | 78.16% no_label | 100.00% no_label | 100.00% no_label | 66.05% Left_Cerebellum_Exterior; 20.79% Left_C... | 86.32% Background | 33.16% Background; 27.37% Culmen; 20.79% Declive |
3 | 4 | 18 | -55 | -23 | -4.93921 | 8964 | 32.53% Cerebelum_4_5_R; 31.02% Cerebelum_6_R | 100.00% no_label | 75.60% Right-Cerebellum-Cortex | 75.60% Right-Cerebellum-Cortex | 81.93% no_label | 99.10% no_label | 100.00% no_label | 66.57% Right_Cerebellum_Exterior | 85.54% Background | 32.23% Background; 29.52% Culmen |
4 | 5 | -36 | -19 | 19 | -4.30705 | 1215 | 71.11% Rolandic_Oper_L; 28.89% Insula_L | 100.00% G_Insula-posterior-1-L | 46.67% Unknown; 28.89% ctx-lh-supramarginal | 46.67% Unknown | 57.78% Left_Central_Opercular_Cortex; 24.44% L... | 44.44% GM_Secondary_somatosensory_cortex_/_Par... | 55.56% Left_Ventral_Inferior_Parietal_Cortex(B... | 46.67% Left_CO_central_operculum; 31.11% Left_... | 62.22% Background; 35.56% Brodmann_area_13 | 77.78% Insula |
5 | 6 | -6 | -19 | 49 | -3.76954 | 1215 | 51.11% Cingulate_Mid_L; 37.78% Supp_Motor_Area_L | 62.22% G_Paracentral_Lobule-1-L; 22.22% S_Cing... | 40.00% ctx-lh-paracentral; 31.11% Unknown | 40.00% ctx_lh_G_front_sup; 31.11% Unknown | 68.89% Left_Precentral_Gyrus; 20.00% Left_Juxt... | 77.78% GM_Premotor_cortex_BA6_L; 20.00% GM_Pri... | 37.78% no_label; 35.56% Left_Dorsomedial_Motor... | 48.89% Left_MPrG_precentral_gyrus_medial_segme... | 46.67% Brodmann_area_6; 40.00% Background | 60.00% Medial_Frontal_Gyrus; 40.00% Paracentra... |
6 | 7 | -30 | -10 | -2 | -3.67586 | 378 | 92.86% Putamen_L | 100.00% N_Putamen-3-L | 100.00% Left-Putamen | 100.00% Left-Putamen | 100.00% Left_Putamen | 64.29% GM_Insula_Id1_L; 21.43% no_label | 100.00% Left_Puttamen | 64.29% Left_Putamen; 35.71% Left_Cerebral_Whit... | 64.29% Background; 35.71% Putamen | 64.29% Extra-Nuclear; 35.71% Lentiform_Nucleus |
7 | 8 | -15 | -55 | 16 | -3.21501 | 351 | 84.62% Precuneus_L | 84.62% G_Precuneus-1-L | 38.46% ctx-lh-precuneus; 38.46% Left-Cerebral-... | 38.46% Left-Cerebral-White-Matter; 23.08% ctx_... | 100.00% Left_Precuneous_Cortex | 38.46% WM_Callosal_body; 38.46% no_label | 30.77% Left_Cuneus(BA_18/19); 30.77% no_label;... | 92.31% Left_PCu_precuneus | 100.00% Background | 84.62% Posterior_Cingulate |
8 | 9 | -66 | -25 | 31 | 3.10147 | 351 | 84.62% SupraMarginal_L | 69.23% G_Supramarginal-3-L | 76.92% ctx-lh-supramarginal; 23.08% Left-Cereb... | 76.92% ctx_lh_G_pariet_inf-Supramar; 23.08% Le... | 69.23% Left_Supramarginal_Gyrus_anterior_divis... | 61.54% GM_Inferior_parietal_lobule_PF_L; 23.08... | 53.85% no_label; 46.15% Left_Ventral_Inferior_... | 69.23% Left_SMG_supramarginal_gyrus; 23.08% no... | 76.92% Background | 61.54% Background; 23.08% Postcentral_Gyrus |
queryatlas
¶Last but certainly not least: If you install AtlasReader via pip
, then you will also have access to the queryatlas
tool. This command line interface is based on the main functions in AtlasReader and allows you to get the atlas information at a particular location.
Let's for example say, we want to know which atlas corresponance the MNI coordinate 32.3, -14.8, -18.5 has:
%%bash
queryatlas 32.3 -14.8 -18.5
The Python package you are importing, AtlasReader, is licensed under the BSD-3 license; however, the atlases it uses are separately licensed under more restrictive frameworks. By using AtlasReader, you agree to abide by the license terms of the individual atlases. Information on these terms can be found online at: https://github.com/miykael/atlasreader/tree/master/atlasreader/data Atlas Label ========== ========== aal Hippocampus_R aicha G_Temporal_Pole_Mid-3-R desikan_killiany Right-Hippocampus destrieux Right-Hippocampus harvard_oxford 93% Right_Hippocampus juelich 90% GM_Hippocampus_cornu_ammonis_R 72% GM_Hippocampus_dentate_gyrus_R 12% GM_Hippocampus_subiculum_R marsatlas Right_Hippocampus neuromorphometrics Right_Hippocampus talairach_ba Background talairach_gyrus Parahippocampal_Gyrus
As before, you first get again the license term information, followed by the atlas name and the corresponding label at the given location.
As before, queryatlas
gives you also some optional parameters. Use the -h
flag to see them:
%%bash
queryatlas -h
The Python package you are importing, AtlasReader, is licensed under the BSD-3 license; however, the atlases it uses are separately licensed under more restrictive frameworks. By using AtlasReader, you agree to abide by the license terms of the individual atlases. Information on these terms can be found online at: https://github.com/miykael/atlasreader/tree/master/atlasreader/data usage: queryatlas [-h] [-a atlas [atlas ...]] [-p threshold] coordinate coordinate coordinate positional arguments: coordinate The coordinate (in MNI space) for which to query atlases. Should be provided as space-delimited x y z coordinates, e.g., -10.5 -30.0 15.3. optional arguments: -h, --help show this help message and exit -a atlas [atlas ...], --atlas atlas [atlas ...] Atlas(es) to use for examining anatomical delineation of clusters in provided statistical map. Default: all available atlases. -p threshold, --probability threshold Threshold to consider when using a probabilistic atlas for extracting anatomical cluster locations. Value will apply to all requested probabilistic atlases, and should range between 0 and 100. Default: 5