Skip to content

Commit

Permalink
region labelling and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ccraddock committed May 18, 2013
1 parent 0da69de commit b4ba9dc
Show file tree
Hide file tree
Showing 8 changed files with 1,774 additions and 181 deletions.
48 changes: 48 additions & 0 deletions harvardoxford_cortical_labels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
1,Frontal Pole
2,Insular Cortex
3,Superior Frontal Gyrus
4,Middle Frontal Gyrus
5,Inferior Frontal Gyrus; pars triangularis
6,Inferior Frontal Gyrus; pars opercularis
7,Precentral Gyrus
8,Temporal Pole
9,Superior Temporal Gyrus; anterior division
10,Superior Temporal Gyrus; posterior division
11,Middle Temporal Gyrus; anterior division
12,Middle Temporal Gyrus; posterior division
13,Middle Temporal Gyrus; temporooccipital part
14,Inferior Temporal Gyrus; anterior division
15,Inferior Temporal Gyrus; posterior division
16,Inferior Temporal Gyrus; temporooccipital part
17,Postcentral Gyrus
18,Superior Parietal Lobule
19,Supramarginal Gyrus; anterior division
20,Supramarginal Gyrus; posterior division
21,Angular Gyrus
22,Lateral Occipital Cortex; superior division
23,Lateral Occipital Cortex; inferior division
24,Intracalcarine Cortex
25,Frontal Medial Cortex
26,Juxtapositional Lobule Cortex (formerly Supplementary Motor Cortex)
27,Subcallosal Cortex
28,Paracingulate Gyrus
29,Cingulate Gyrus; anterior division
30,Cingulate Gyrus; posterior division
31,Precuneous Cortex
32,Cuneal Cortex
33,Frontal Orbital Cortex
34,Parahippocampal Gyrus; anterior division
35,Parahippocampal Gyrus; posterior division
36,Lingual Gyrus
37,Temporal Fusiform Cortex; anterior division
38,Temporal Fusiform Cortex; posterior division
39,Temporal Occipital Fusiform Cortex
40,Occipital Fusiform Gyrus
41,Frontal Operculum Cortex
42,Central Opercular Cortex
43,Parietal Operculum Cortex
44,Planum Polare
45,Heschl's Gyrus (includes H1 and H2)
46,Planum Temporale
47,Supracalcarine Cortex
48,Occipital Pole
21 changes: 21 additions & 0 deletions harvardoxford_subcortical_labels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
2,Left Cerebral White Matter
3,Left Cerebral Cortex
4,Left Lateral Ventrical
10,Left Thalamus
11,Left Caudate
12,Left Putamen
13,Left Pallidum
16,Brain-Stem
17,Left Hippocampus
18,Left Amygdala
26,Left Accumbens
41,Right Cerebral White Matter
42,Right Cerebral Cortex
43,Right Lateral Ventricle
49,Right Thalamus
50,Right Caudate
51,Right Putamen
52,Right Pallidum
53,Right Hippocampus
54,Right Amygdala
58,Right Accumbens
121 changes: 121 additions & 0 deletions juelich_labels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
1,GM Anterior intra-parietal sulcus hIP1 L
2,GM Anterior intra-parietal sulcus hIP1 R
3,GM Anterior intra-parietal sulcus hIP2 L
4,GM Anterior intra-parietal sulcus hIP2 R
5,GM Anterior intra-parietal sulcus hIP3 L
6,GM Anterior intra-parietal sulcus hIP3 R
7,GM Amygdala_centromedial group L
8,GM Amygdala_centromedial group R
9,GM Amygdala_laterobasal group L
10,GM Amygdala_laterobasal group R
11,GM Amygdala_superficial group L
12,GM Amygdala_superficial group R
13,GM Broca's area BA44 L
14,GM Broca's area BA44 R
15,GM Broca's area BA45 L
16,GM Broca's area BA45 R
17,GM Hippocampus cornu ammonis L
18,GM Hippocampus cornu ammonis R
19,GM Hippocampus entorhinal cortex L
20,GM Hippocampus entorhinal cortex R
21,GM Hippocampus dentate gyrus L
22,GM Hippocampus dentate gyrus R
23,GM Hippocampus hippocampal-amygdaloid transition area L
24,GM Hippocampus hippocampal-amygdaloid transition area R
25,GM Hippocampus subiculum L
26,GM Hippocampus subiculum R
27,GM Inferior parietal lobule PF L
28,GM Inferior parietal lobule PF R
29,GM Inferior parietal lobule PFcm L
30,GM Inferior parietal lobule PFcm R
31,GM Inferior parietal lobule PFm L
32,GM Inferior parietal lobule PFm R
33,GM Inferior parietal lobule PFop L
34,GM Inferior parietal lobule PFop R
35,GM Inferior parietal lobule PFt L
36,GM Inferior parietal lobule PFt R
37,GM Inferior parietal lobule Pga L
38,GM Inferior parietal lobule Pga R
39,GM Inferior parietal lobule PGp L
40,GM Inferior parietal lobule PGp R
41,GM Primary auditory cortex TE1.0 L
42,GM Primary auditory cortex TE1.0 R
43,GM Primary auditory cortex TE1.1 L
44,GM Primary auditory cortex TE1.1 R
45,GM Primary auditory cortex TE1.2 L
46,GM Primary auditory cortex TE1.2 R
47,GM Primary motor cortex BA4a L
48,GM Primary motor cortex BA4a R
49,GM Primary motor cortex BA4p L
50,GM Primary motor cortex BA4p R
51,GM Primary somatosensory cortex BA1 L
52,GM Primary somatosensory cortex BA1 R
53,GM Primary somatosensory cortex BA2 L
54,GM Primary somatosensory cortex BA2 R
55,GM Primary somatosensory cortex BA3a L
56,GM Primary somatosensory cortex BA3a R
57,GM Primary somatosensory cortex BA3b L
58,GM Primary somatosensory cortex BA3b R
59,GM Secondary somatosensory cortex / Parietal operculum OP1 L
60,GM Secondary somatosensory cortex / Parietal operculum OP1 R
61,GM Secondary somatosensory cortex / Parietal operculum OP2 L
62,GM Secondary somatosensory cortex / Parietal operculum OP2 R
63,GM Secondary somatosensory cortex / Parietal operculum OP3 L
64,GM Secondary somatosensory cortex / Parietal operculum OP3 R
65,GM Secondary somatosensory cortex / Parietal operculum OP4 L
66,GM Secondary somatosensory cortex / Parietal operculum OP4 R
67,GM Superior parietal lobule 5Ci L
68,GM Superior parietal lobule 5Ci R
69,GM Superior parietal lobule 5L L
70,GM Superior parietal lobule 5L R
71,GM Superior parietal lobule 5M L
72,GM Superior parietal lobule 5M R
73,GM Superior parietal lobule 7A L
74,GM Superior parietal lobule 7A R
75,GM Superior parietal lobule 7M L
76,GM Superior parietal lobule 7M R
77,GM Superior parietal lobule 7PC L
78,GM Superior parietal lobule 7PC R
79,GM Superior parietal lobule 7P L
80,GM Superior parietal lobule 7P R
81,GM Visual cortex V1 BA17 L
82,GM Visual cortex V1 BA17 R
83,GM Visual cortex V2 BA18 L
84,GM Visual cortex V2 BA18 R
85,GM Visual cortex V3V L
86,GM Visual cortex V3V R
87,GM Visual cortex V4 L
88,GM Visual cortex V4 R
89,GM Visual cortex V5 L
90,GM Visual cortex V5 R
91,GM Premotor cortex BA6 L
92,GM Premotor cortex BA6 R
93,WM Acoustic radiation R
94,WM Acoustic radiation L
95,WM Callosal body
96,WM Cingulum R
97,WM Cingulum L
98,WM Corticospinal tract R
99,WM Corticospinal tract L
100,WM Fornix
101,WM Inferior occipito-frontal fascicle R
102,WM Inferior occipito-frontal fascicle L
103,GM Lateral geniculate body R
104,GM Lateral geniculate body L
105,GM Mamillary body
106,GM Medial geniculate body R
107,GM Medial geniculate body L
108,WM Optic radiation R
109,WM Optic radiation L
110,WM Superior longitudinal fascicle R
111,WM Superior longitudinal fascicle L
112,WM Superior occipito-frontal fascicle R
113,WM Superior occipito-frontal fascicle L
114,WM Uncinate fascicle R
115,WM Uncinate fascicle L
116,GM Insula Id1 L
117,GM Insula Id1 R
118,GM Insula Ig1 L
119,GM Insula Ig1 R
120,GM Insula Ig2 L
121,GM Insula Ig2 R
107 changes: 62 additions & 45 deletions make_image_from_bin.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
#### make_image_from_bin.py
# Copyright (C) 2010 R. Cameron Craddock ([email protected])
#
# This script is a part of the pyClusterROI python toolbox for the spatially constrained clustering of fMRI
# data. It converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or
# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
# number of the cluster to which it belongs.
# This script is a part of the pyClusterROI python toolbox for the spatially
# constrained clustering of fMRI data. It converts a NPY file generated by
# binfile_parcellation.py, group_binfile_parcellation.py, or
# group_mean_binfile_parcellation.npy into a nifti file where each voxels
# intensity corresponds to the number of the cluster to which it belongs.
#
# For more information refer to:
#
# Craddock, R. C., James, G. A., Holtzheimer, P. E., Hu, X. P., & Mayberg, H. S. (2011). A whole
# brain fMRI atlas generated via spatially constrained spectral clustering. Human brain mapping,
# doi: 10.1002/hbm.21333.
# Craddock, R. C.; James, G. A.; Holtzheimer, P. E.; Hu, X. P. & Mayberg, H. S.
# A whole brain fMRI atlas generated via spatially constrained spectral
# clustering Human Brain Mapping, 2012, 33, 1914-1928 doi: 10.1002/hbm.21333.
#
# Documentation, updated source code and other information can be found at the NITRC web page:
# http://www.nitrc.org/projects/cluster_roi/
# ARTICLE{Craddock2012,
# author = {Craddock, R C and James, G A and Holtzheimer, P E and Hu, X P and
# Mayberg, H S},
# title = {{A whole brain fMRI atlas generated via spatially constrained
# spectral clustering}},
# journal = {Human Brain Mapping},
# year = {2012},
# volume = {33},
# pages = {1914--1928},
# number = {8},
# address = {Department of Neuroscience, Baylor College of Medicine, Houston,
# TX, United States},
# pmid = {21769991},
# }
#
# Documentation, updated source code and other information can be found at the
# NITRC web page: http://www.nitrc.org/projects/cluster_roi/ and on github at
# https://github.com/ccraddock/cluster_roi
#
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -30,50 +47,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
####

# this scripts requires NumPy (numpy.scipy.org), and PyNIfTI
# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
# accessible through PythonPath
from nifti import NiftiImage
# this scripts requires NumPy (numpy.scipy.org), and NiBabel
# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory
# that is accessible through PythonPath
import nibabel as nb
from numpy import *

# make_image_from_bin( image, binfile, mask )
#
# Converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or
# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
# number of the cluster to which it belongs.
# Converts a NPY file generated by binfile_parcellation.py,
# group_binfile_parcellation.py, or group_mean_binfile_parcellation.npy into a
# nifti file where each voxels intensity corresponds to the number of the
# cluster to which it belongs.
# image: The name of the nifti file to be written.
# binfile: The binfile to be converted. The file contains a n_voxel x 1 vector that is
# converted to a nifti file.
# mask: Mask describing the space of the nifti file. This should correspond to the
# mask originally used to create the connectivity matrices used for parcellation.
# binfile: The binfile to be converted. The file contains a n_voxel x 1
# vector that is converted to a nifti file.
# mask: Mask describing the space of the nifti file. This should
# correspond to the mask originally used to create the
# connectivity matrices used for parcellation.
#
def make_image_from_bin( image, binfile, mask ):

# read in the mask
nim=NiftiImage(mask)
sz=shape(nim.data)
# read in the mask
nim=nb.load(mask)

# read in the binary data
if( binfile.endswith(".npy") ):
print "Reading",binfile,"as a npy filetype"
a=load(binfile)
else:
print "Reading",binfile,"as a binary file of doubles"
a=fromfile(binfile)

imdat=nim.get_data()
print "shape",shape(a)
print "sum",sum(imdat)

# read in the binary data
# a=fromfile(binfile,'uint32')
if( binfile.endswith(".npy") ):
print "Reading",binfile,"as a npy filetype"
a=load(binfile)
#a=((a.tolist()).toarray())[:,0]
else:
print "Reading",binfile,"as a binary file of doubles"
a=fromfile(binfile)
# map the binary data to mask
print "shape2",shape(a[0:sum(imdat)])
imdat[imdat>0]=short(a[0:sum(imdat)].flatten())

imdat=nim.data
print "shape",shape(a)
print "sum",sum(imdat)
# map the binary data to mask
print "shape2",shape(a[0:sum(imdat)])
imdat[imdat>0]=short(a[0:sum(imdat)].flatten())
# write out the image as nifti
thdr=nim.header
thdr['scl_slope']=1

# write out the image as nifti
thdr=nim.header
thdr['scl_slope']=1

nim_out=NiftiImage(imdat)
nim_out.updateFromDict(thdr)
nim_out.save(image)
nim_out = nb.Nifti1Image(imdat, nim.get_affine())
nim_out.set_data_dtype('int16')
nim_out.to_filename(image)
Loading

0 comments on commit b4ba9dc

Please sign in to comment.