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

ENH: Add parcellations (FS's annot files) #5

Merged
merged 15 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions scripts/get_annot_tsv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
#
# Copyright 2024 The NiPreps Developers <nipreps@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# We support and encourage derived works from this project, please read
# about our expectations at
#
# https://www.nipreps.org/community/licensing/
#
from pathlib import Path
import click
import numpy as np
import pandas as pd
import nibabel as nb


@click.command()
@click.argument("input_annot", type=click.Path(exists=True))
@click.argument("output_tsv", type=click.Path())
def run(input_annot, output_tsv):
vert_lab, reg_ctable, reg_names = nb.freesurfer.read_annot(input_annot)

df = pd.DataFrame(
reg_ctable.byteswap().newbyteorder(),
columns={
"red": np.uint8,
"green": np.uint8,
"blue": np.uint8,
"transparency": np.uint8,
"index": np.uint32,
}
)
df["name"] = [n.decode() for n in reg_names]
df["alpha"] = 255 - df.transparency
df["color"] = df.loc[:, ("red", "green", "blue", "alpha")].apply(
lambda r: "#{:02x}{:02x}{:02x}{:02x}".format(*r),
axis=1
)
df[["index", "name", "color"]].to_csv(output_tsv, sep="\t", index=None)

if __name__ == '__main__':
run()

26 changes: 26 additions & 0 deletions tpl-fsaverage_atlas-Desikan2006_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"Authors":
[
"Desikan RS",
"Killiany RJ"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"DescriptionEntity":
{
"original": "Contains the file as converted with `mris_convert` directly from FreeSurfer's distribution",
"curated": "The 'original' version after manual correction of errors by Aleman-Gomez Y."
},
"Identifier": "Desikan2006",
"License": "See LICENSE file",
"Name": "Desikan-Killiany Atlas distributed by FreeSurfer 7",
"Provenance": "Converted with `mris_convert` from `$FREESURFER_HOME/subjects/fsaverage{,3,4,5,6}/label/{l,r}h.aparc.annot`",
"ReferencesAndLinks":
[
"https://doi.org/10.1016/j.neuroimage.2006.01.021",
"https://surfer.nmr.mgh.harvard.edu/fswiki/CorticalParcellation"
]
}
25 changes: 25 additions & 0 deletions tpl-fsaverage_atlas-Destrieux2005_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Authors":
[
"Destrieux C",
"Fischl B",
"Dale AM",
"Halgren E"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Destrieux2005",
"License": "See LICENSE file",
"Name": "Destrieux Atlas (2005) distributed by FreeSurfer 7",
"DeprecationNote": "This atlas was updated in 2009 and Destrieux2009 SHOULD be used instead",
"Provenance": "Converted with `mris_convert` from `$FREESURFER_HOME/subjects/fsaverage{,3,4,5,6}/label/{l,r}h.aparc.a2005s.annot`",
"ReferencesAndLinks":
[
"https://doi.org/10.1016/j.neuroimage.2010.06.010",
"https://doi.org/10.1016/S1053-8119(09)71561-7",
"https://surfer.nmr.mgh.harvard.edu/fswiki/DestrieuxAtlasChanges"
]
}
24 changes: 24 additions & 0 deletions tpl-fsaverage_atlas-Destrieux2009_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Authors":
[
"Destrieux C",
"Fischl B",
"Dale AM",
"Halgren E"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Destrieux2009",
"License": "See LICENSE file",
"Name": "Destrieux Atlas (updated 2009) distributed by FreeSurfer 7",
"Provenance": "Converted with `mris_convert` from `$FREESURFER_HOME/subjects/fsaverage{,3,4,5,6}/label/{l,r}h.aparc.a2009s.annot`",
"ReferencesAndLinks":
[
"https://doi.org/10.1016/j.neuroimage.2010.06.010",
"https://doi.org/10.1016/S1053-8119(09)71561-7",
"https://surfer.nmr.mgh.harvard.edu/fswiki/DestrieuxAtlasChanges"
]
}
21 changes: 21 additions & 0 deletions tpl-fsaverage_atlas-Lausanne2018_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Authors":
[
"Aleman-Gomez Y",
"Cammoun L",
"Hagmann P"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Lausanne2018",
"License": "CC-BY-4",
"Name": "Lausanne multi-scale cortical parcellation",
"Description": "Symmetric version of the original parcellation by (Cammoun et al., 2012)",
"ReferencesAndLinks":
[
"https://doi.org/10.1016/j.jneumeth.2011.09.031"
]
}
20 changes: 20 additions & 0 deletions tpl-fsaverage_atlas-Sabuncu2011_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Authors":
[
"Sabuncu MR"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Sabuncu2011",
"License": "See LICENSE file",
"Name": "'Cortical Hubs' (CHubs) from the OASIS template, distributed by FreeSurfer 7",
"Provenance": "Converted with `mris_convert` from `$FREESURFER_HOME/subjects/fsaverage{,3,4,5,6}/label/{l,r}h.oasis.chubs.annot`",
"ReferencesAndLinks":
[
"https://doi.org/10.1001/archneurol.2011.167",
"https://surfer.nmr.mgh.harvard.edu/fswiki/Chubs"
]
}
21 changes: 21 additions & 0 deletions tpl-fsaverage_atlas-Schaefer2018_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Authors":
[
"Schaefer A",
"Yeo BT"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Schaefer2018",
"License": "See LICENSE file",
"Name": "Local-Global Parcellation of the Human Cerebral Cortex from Intrinsic Functional Connectivity MRI",
"Description": "Multi-scale cortical parcellation — ten scales going from 100 to 1000 parcels that are matched with Yeo2011's networks.",
"IsDerivedFrom": "Yeo2011",
"ReferencesAndLinks":
[
"https://doi.org/10.1093/cercor/bhx179"
]
}
21 changes: 21 additions & 0 deletions tpl-fsaverage_atlas-Yeo2011_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Authors":
[
"Yeo BT",
"Buckner RL"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "Yeo2011",
"License": "See LICENSE file",
"Name": "Cortical Parcellation Estimated by Intrinsic Functional Connectivity, distributed by FreeSurfer 7",
"Provenance": "Converted with `mris_convert` from `$FREESURFER_HOME/subjects/fsaverage{,3,4,5,6}/label/{l,r}h.Yeo2011_{,1}7Networks_N1000.annot`",
"ReferencesAndLinks":
[
"https://doi.org/10.1152/jn.00338.2011",
"https://surfer.nmr.mgh.harvard.edu/fswiki/CorticalParcellation_Yeo2011"
]
}
18 changes: 18 additions & 0 deletions tpl-fsaverage_atlas-brainnetome_dseg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Authors":
[
"Fan L"
],
"Curators":
[
"Aleman-Gomez Y",
"Esteban O"
],
"Identifier": "brainnetome",
"License": "The atlas' data and metadata are the property of the Brainnetome Center. The Brainnetome makes this information available to researchers, scientists and others at colleges, universities, not-for-profit foundations and other similar institutions free of charge, subject to proper attribution and an agreement to share alike, for use for non-commercial purposes. Brainetome Center will consider granting a license to individuals and entities that wish to use the information, images and data for commercial purposes. Such requests should be made to Dr. Lingzhong Fan by e-mail:brainnetome.atlas@nlpr.ia.ac.cn",
"Name": "Brainnetome cortical parcellation",
"ReferencesAndLinks":
[
"https://doi.org/10.1093/cercor/bhw157"
]
}
37 changes: 37 additions & 0 deletions tpl-fsaverage_hemi-L_atlas-Desikan2006_seg-aparc.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
index name color
1639705 unknown #190519ff
2647065 bankssts #196428ff
10511485 caudalanteriorcingulate #7d64a0ff
6500 caudalmiddlefrontal #641900ff
3294840 corpuscallosum #784632ff
6558940 cuneus #dc1464ff
660700 entorhinal #dc140aff
9231540 fusiform #b4dc8cff
14433500 inferiorparietal #dc3cdcff
7874740 inferiortemporal #b42878ff
9180300 isthmuscingulate #8c148cff
9182740 lateraloccipital #141e8cff
3296035 lateralorbitofrontal #234b32ff
9211105 lingual #e18c8cff
4924360 medialorbitofrontal #c8234bff
3302560 middletemporal #a06432ff
3988500 parahippocampal #14dc3cff
3988540 paracentral #3cdc3cff
9221340 parsopercularis #dcb48cff
3302420 parsorbitalis #146432ff
1326300 parstriangularis #dc3c14ff
3957880 pericalcarine #78643cff
1316060 postcentral #dc1414ff
14464220 posteriorcingulate #dcb4dcff
14423100 precentral #3c14dcff
11832480 precuneus #a08cb4ff
9180240 rostralanteriorcingulate #50148cff
8204875 rostralmiddlefrontal #4b327dff
10542100 superiorfrontal #14dca0ff
9221140 superiorparietal #14b48cff
14474380 superiortemporal #8cdcdcff
1351760 supramarginal #50a014ff
6553700 frontalpole #640064ff
11146310 temporalpole #4614aaff
13145750 transversetemporal #9696c8ff
2146559 insula #ffc020ff
83 changes: 83 additions & 0 deletions tpl-fsaverage_hemi-L_atlas-Destrieux2005_dseg.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
index name color
0 Unknown #000000ff
3289650 Corpus_callosum #323232ff
1971380 G_and_S_Insula_ONLY_AVERAGE #b4141eff
1644860 G_cingulate-Isthmus #3c1919ff
3947545 G_cingulate-Main_part #193c3cff
1316020 G_cuneus #b41414ff
6558940 G_frontal_inf-Opercular_part #dc1464ff
3947660 G_frontal_inf-Orbital_part #8c3c3cff
9231540 G_frontal_inf-Triangular_part #b4dc8cff
11822220 G_frontal_middle #8c64b4ff
9180340 G_frontal_superior #b4148cff
9180300 G_frontomarginal #8c148cff
657941 G_insular_long #150a0aff
9211105 G_insular_short #e18c8cff
11811863 G_and_S_occipital_inferior #173cb4ff
11812020 G_occipital_middle #b43cb4ff
3988500 G_occipital_superior #14dc3cff
9180220 G_occipit-temp_lat-Or_fusiform #3c148cff
9221340 G_occipit-temp_med-Lingual_part #dcb48cff
1336385 G_occipit-temp_med-Parahippocampal_part #416414ff
1326300 G_orbital #dc3c14ff
3957820 G_paracentral #3c643cff
14433300 G_parietal_inferior-Angular_part #143cdcff
3957860 G_parietal_inferior-Supramarginal_part #64643cff
14464220 G_parietal_superior #dcb4dcff
9221140 G_postcentral #14b48cff
11832380 G_precentral #3c8cb4ff
9180185 G_precuneus #19148cff
6568980 G_rectus #143c64ff
1367100 G_subcallosal #3cdc14ff
14423100 G_subcentral #3c14dcff
6610140 G_temporal_inferior #dcdc64ff
3947700 G_temporal_middle #b43c3cff
14433340 G_temp_sup-G_temp_transv_and_interm_S #3c3cdcff
14433500 G_temp_sup-Lateral_aspect #dc3cdcff
3988545 G_temp_sup-Planum_polare #41dc3cff
1346585 G_temp_sup-Planum_tempolare #198c14ff
16384013 G_and_S_transverse_frontopolar #0d00faff
14423101 Lat_Fissure-ant_sgt-ramus_horizontal #3d14dcff
3937341 Lat_Fissure-ant_sgt-ramus_vertical #3d143cff
6569021 Lat_Fissure-post_sgt #3d3c64ff
1644825 Medial_wall #191919ff
3937420 Pole_occipital #8c143cff
1357020 Pole_temporal #dcb414ff
11842623 S_calcarine #3fb4b4ff
660701 S_central #dd140aff
1367061 S_central_insula #15dc14ff
1336503 S_cingulate-Main_part_and_Intracingulate #b76414ff
6558941 S_cingulate-Marginalis_part #dd1464ff
9190621 S_circular_insula_anterior #dd3c8cff
14423261 S_circular_insula_inferior #dd14dcff
14474301 S_circular_insula_superior #3ddcdcff
13158500 S_collateral_transverse_ant #64c8c8ff
13158410 S_collateral_transverse_post #0ac8c8ff
1367261 S_frontal_inferior #dddc14ff
6558861 S_frontal_middle #8d1464ff
6609981 S_frontal_superior #3ddc64ff
3988501 S_frontomarginal #15dc3cff
1326221 S_intermedius_primus-Jensen #8d3c14ff
14423183 S_intraparietal-and_Parietal_transverse #8f14dcff
11801661 S_occipital_anterior #3d14b4ff
14433381 S_occipital_middle_and_Lunatus #653cdcff
9180181 S_occipital_superior_and_transversalis #15148cff
1346781 S_occipito-temporal_lateral #dd8c14ff
14443661 S_occipito-temporal_medial_and_S_Lingual #8d64dcff
1315941 S_orbital-H_shapped #651414ff
1336541 S_orbital_lateral #dd6414ff
1362101 S_orbital_medial-Or_olfactory #b5c814ff
9221141 S_paracentral #15b48cff
11822181 S_parieto_occipital #6564b4ff
1367221 S_pericallosal #b5dc14ff
13143061 S_postcentral #158cc8ff
15733781 S_precentral-Inferior-part #1514f0ff
13112341 S_precentral-Superior-part #1514c8ff
3978301 S_subcentral_ant #3db43cff
16430141 S_subcentral_post #3db4faff
3937301 S_suborbital #15143cff
3947621 S_subparietal #653c3cff
14474261 S_supracingulate #15dcdcff
11842581 S_temporal_inferior #15b4b4ff
3988703 S_temporal_superior #dfdc3cff
3947741 S_temporal_transverse #dd3c3cff
Loading