{"id":761,"date":"2026-10-20T14:29:26","date_gmt":"2026-10-20T14:29:26","guid":{"rendered":"https:\/\/ni.cmu.edu\/computing\/?post_type=ht_kb&#038;p=761"},"modified":"2026-10-20T14:40:23","modified_gmt":"2026-10-20T14:40:23","slug":"shared-neuroimaging-resources-guide-templates-atlases","status":"publish","type":"ht_kb","link":"https:\/\/ni.cmu.edu\/computing\/knowledge-base\/shared-neuroimaging-resources-guide-templates-atlases\/","title":{"rendered":"Shared Neuroimaging Resources Guide: Templates &#038; Atlases"},"content":{"rendered":"<p data-path-to-node=\"1\">This guide provides instructions for accessing shared neuroimaging reference templates and atlases stored on the cluster at <code data-path-to-node=\"1\" data-index-in-node=\"124\">\/lab_data\/hawk\/resources\/neuroimaging\/<\/code>.<\/p>\n<h2 data-path-to-node=\"3\">1. Available Resources &amp; Directory Paths<\/h2>\n<table data-path-to-node=\"4\">\n<thead>\n<tr>\n<td><strong>Resource<\/strong><\/td>\n<td><strong>File Path \/ Location<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><span data-path-to-node=\"4,1,0,0\"><b data-path-to-node=\"4,1,0,0\" data-index-in-node=\"0\">TemplateFlow Cache<\/b><\/span><\/td>\n<td><span data-path-to-node=\"4,1,1,0\"><code data-path-to-node=\"4,1,1,0\" data-index-in-node=\"0\">\/lab_data\/hawk\/resources\/neuroimaging\/templateflow<\/code><\/span><\/td>\n<td><span data-path-to-node=\"4,1,2,0\">Central offline cache containing <code data-path-to-node=\"4,1,2,0\" data-index-in-node=\"33\">MNI152NLin2009cAsym<\/code> and standard templates.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span data-path-to-node=\"4,2,0,0\"><b data-path-to-node=\"4,2,0,0\" data-index-in-node=\"0\">Glasser Atlas (Volumetric)<\/b><\/span><\/td>\n<td><span data-path-to-node=\"4,2,1,0\"><code data-path-to-node=\"4,2,1,0\" data-index-in-node=\"0\">\/lab_data\/hawk\/resources\/neuroimaging\/atlases\/glasser\/<\/code><\/span><\/td>\n<td><span data-path-to-node=\"4,2,2,0\">HCP-MMP1.0 converted to 3D NIfTI volume in MNI space (<code data-path-to-node=\"4,2,2,0\" data-index-in-node=\"54\">.nii.gz<\/code> + labels).<\/span><\/td>\n<\/tr>\n<tr>\n<td><span data-path-to-node=\"4,3,0,0\"><b data-path-to-node=\"4,3,0,0\" data-index-in-node=\"0\">Glasser Atlas (Surface)<\/b><\/span><\/td>\n<td><span data-path-to-node=\"4,3,1,0\"><code data-path-to-node=\"4,3,1,0\" data-index-in-node=\"0\">\/lab_data\/hawk\/resources\/neuroimaging\/atlases\/glasser\/HCP-MMP1_32k_fs_LR.dlabel.nii<\/code><\/span><\/td>\n<td><span data-path-to-node=\"4,3,2,0\">Native CIFTI surface parcellation for <code data-path-to-node=\"4,3,2,0\" data-index-in-node=\"38\">fsLR_32k<\/code> mesh analysis.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 data-path-to-node=\"6\">2. Environment Setup<\/h2>\n<p data-path-to-node=\"7\">You should route processing tools (such as <b data-path-to-node=\"7\" data-index-in-node=\"120\">fMRIPrep<\/b> or <b data-path-to-node=\"7\" data-index-in-node=\"132\">QSIPrep<\/b>) to use the shared TemplateFlow directory.<\/p>\n<p data-path-to-node=\"8\">Add these environment variables to your <code data-path-to-node=\"8\" data-index-in-node=\"40\">~\/.bashrc<\/code> file or load them inside your Slurm submission scripts:<\/p>\n<div class=\"code-block ng-tns-c2064491107-200 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c2064491107-200\">\n<div class=\"animated-opacity ng-tns-c2064491107-200\">\n<div class=\"code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c2064491107-200 ng-star-inserted\">\n<p><span class=\"ng-tns-c2064491107-200\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c2064491107-200 ng-star-inserted\"><\/div>\n<\/div>\n<pre class=\"ng-tns-c2064491107-200\"><code class=\"code-container formatted ng-tns-c2064491107-200\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-comment\"># Point local Python pipelines to the shared TemplateFlow directory<\/span>\r\n<span class=\"hljs-built_in\">export<\/span> TEMPLATEFLOW_HOME=\/lab_data\/hawk\/resources\/neuroimaging\/templateflow\r\n\r\n<span class=\"hljs-comment\"># Bind environment variable for Singularity\/Apptainer containers<\/span>\r\n<span class=\"hljs-built_in\">export<\/span> APPTAINERENV_TEMPLATEFLOW_HOME=\/opt\/templateflow\r\n<span class=\"hljs-built_in\">export<\/span> SINGULARITYENV_TEMPLATEFLOW_HOME=\/opt\/templateflow\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-path-to-node=\"11\">3. Preprocessing with fMRIPrep (Slurm Submission)<\/h2>\n<p data-path-to-node=\"12\">When running containerized pipelines via Apptainer\/Singularity, bind the shared template directory into <code data-path-to-node=\"12\" data-index-in-node=\"104\">\/opt\/templateflow<\/code> inside the container.<\/p>\n<div class=\"code-block ng-tns-c2064491107-201 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c2064491107-201\">\n<div class=\"animated-opacity ng-tns-c2064491107-201\">\n<div class=\"code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c2064491107-201 ng-star-inserted\">\n<p><span class=\"ng-tns-c2064491107-201\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c2064491107-201 ng-star-inserted\"><\/div>\n<\/div>\n<pre class=\"ng-tns-c2064491107-201\"><code class=\"code-container formatted ng-tns-c2064491107-201\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-meta\">#!\/bin\/bash<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --job-name=fmriprep_job<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --nodes=1<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --cpus-per-task=8<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --mem=32G<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --time=12:00:00<\/span>\r\n<span class=\"hljs-comment\">#SBATCH --output=logs\/fmriprep_%j.log<\/span>\r\n\r\n<span class=\"hljs-comment\"># 1. Load required modules (adjust according to system module names)<\/span>\r\nmodule load apptainer\r\n\r\n<span class=\"hljs-comment\"># 2. Define environment variables<\/span>\r\n<span class=\"hljs-built_in\">export<\/span> TEMPLATEFLOW_HOME=\/lab_data\/hawk\/resources\/neuroimaging\/templateflow\r\n<span class=\"hljs-built_in\">export<\/span> APPTAINERENV_TEMPLATEFLOW_HOME=\/opt\/templateflow\r\n\r\n<span class=\"hljs-comment\"># 3. Execute fMRIPrep using shared templates<\/span>\r\napptainer run --cleanenv \\\r\n  -B \/lab_data\/hawk:\/lab_data\/hawk \\\r\n  -B \/lab_data\/hawk\/resources\/neuroimaging\/templateflow:\/opt\/templateflow \\\r\n  \/lab_data\/hawk\/software\/fmriprep.sif \\\r\n  \/lab_data\/hawk\/data\/bids \\\r\n  \/lab_data\/hawk\/data\/derivatives \\\r\n  participant \\\r\n  --participant-label 01 \\\r\n  --output-spaces MNI152NLin2009cAsym:res-2 \\\r\n  --notrack\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-path-to-node=\"15\">4. Extracting Brain Signals with the Glasser Atlas<\/h2>\n<h3 data-path-to-node=\"16\">Option A: 3D Volumetric NIfTI Signal Extraction (Python &amp; Nilearn)<\/h3>\n<p data-path-to-node=\"17\">Use <b data-path-to-node=\"17\" data-index-in-node=\"4\">Nilearn<\/b> to regress out confounds (motion, white matter, CSF) and extract timeseries across the 360 Glasser cortical regions:<\/p>\n<div class=\"code-block ng-tns-c2064491107-202 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c2064491107-202\">\n<div class=\"animated-opacity ng-tns-c2064491107-202\">\n<div class=\"code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c2064491107-202 ng-star-inserted\">\n<p><span class=\"ng-tns-c2064491107-202\">Python<\/span><\/p>\n<div class=\"buttons ng-tns-c2064491107-202 ng-star-inserted\"><\/div>\n<\/div>\n<pre class=\"ng-tns-c2064491107-202\"><code class=\"code-container formatted ng-tns-c2064491107-202\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\r\n<span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\r\n<span class=\"hljs-keyword\">from<\/span> nilearn.maskers <span class=\"hljs-keyword\">import<\/span> NiftiLabelsMasker\r\n<span class=\"hljs-keyword\">from<\/span> nilearn.connectome <span class=\"hljs-keyword\">import<\/span> ConnectivityMeasure\r\n\r\n<span class=\"hljs-comment\"># Paths<\/span>\r\nfunc_file = <span class=\"hljs-string\">\"\/lab_data\/hawk\/data\/derivatives\/fmriprep\/sub-01\/func\/sub-01_task-rest_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz\"<\/span>\r\nconfounds_file = <span class=\"hljs-string\">\"\/lab_data\/hawk\/data\/derivatives\/fmriprep\/sub-01\/func\/sub-01_task-rest_desc-confounds_timeseries.tsv\"<\/span>\r\nglasser_atlas = <span class=\"hljs-string\">\"\/lab_data\/hawk\/resources\/neuroimaging\/atlases\/glasser\/HCP-MMP1_on_MNI152NLin2009cAsym.nii.gz\"<\/span>\r\n\r\n<span class=\"hljs-comment\"># Configure Masker<\/span>\r\nmasker = NiftiLabelsMasker(\r\n    labels_img=glasser_atlas,\r\n    standardize=<span class=\"hljs-string\">\"zscore_sample\"<\/span>,\r\n    memory=<span class=\"hljs-string\">\"nilearn_cache\"<\/span>,\r\n    verbose=<span class=\"hljs-number\">0<\/span>\r\n)\r\n\r\n<span class=\"hljs-comment\"># Extract confounds and transform BOLD data<\/span>\r\nconfounds_df = pd.read_csv(confounds_file, sep=<span class=\"hljs-string\">'\\t'<\/span>)\r\nselected_confounds = confounds_df[[<span class=\"hljs-string\">'trans_x'<\/span>, <span class=\"hljs-string\">'trans_y'<\/span>, <span class=\"hljs-string\">'trans_z'<\/span>, <span class=\"hljs-string\">'rot_x'<\/span>, <span class=\"hljs-string\">'rot_y'<\/span>, <span class=\"hljs-string\">'rot_z'<\/span>, <span class=\"hljs-string\">'csf'<\/span>, <span class=\"hljs-string\">'white_matter'<\/span>]]\r\n\r\n<span class=\"hljs-comment\"># Time-series shape: (n_volumes, 360)<\/span>\r\ntime_series = masker.fit_transform(func_file, confounds=selected_confounds)\r\n\r\n<span class=\"hljs-comment\"># Compute 360x360 Functional Connectivity correlation matrix<\/span>\r\ncorrelation_measure = ConnectivityMeasure(kind=<span class=\"hljs-string\">\"correlation\"<\/span>)\r\nfc_matrix = correlation_measure.fit_transform([time_series])[<span class=\"hljs-number\">0<\/span>]\r\n\r\n<span class=\"hljs-comment\"># Save output<\/span>\r\nnp.save(<span class=\"hljs-string\">\"sub-01_glasser_fc_matrix.npy\"<\/span>, fc_matrix)\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h3 data-path-to-node=\"19\">Option B: Surface\/CIFTI Parcellation (Connectome Workbench)<\/h3>\n<p data-path-to-node=\"20\">If your output data is in CIFTI space (<code data-path-to-node=\"20\" data-index-in-node=\"39\">.dtseries.nii<\/code>), use Connectome Workbench (<code data-path-to-node=\"20\" data-index-in-node=\"81\">wb_command<\/code>):<\/p>\n<div class=\"code-block ng-tns-c2064491107-203 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c2064491107-203\">\n<div class=\"animated-opacity ng-tns-c2064491107-203\">\n<div class=\"code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c2064491107-203 ng-star-inserted\">\n<p><span class=\"ng-tns-c2064491107-203\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c2064491107-203 ng-star-inserted\"><\/div>\n<\/div>\n<pre class=\"ng-tns-c2064491107-203\"><code class=\"code-container formatted ng-tns-c2064491107-203\" role=\"text\" data-test-id=\"code-content\">wb_command -cifti-parcellate \\\r\n  \/lab_data\/hawk\/data\/derivatives\/fmriprep\/sub-01\/func\/sub-01_task-rest_space-fsLR_den-32k_bold.dtseries.nii \\\r\n  \/lab_data\/hawk\/resources\/neuroimaging\/atlases\/glasser\/HCP-MMP1_32k_fs_LR.dlabel.nii \\\r\n  COLUMN \\\r\n  sub-01_task-rest_glasser_parcellated.ptseries.nii\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-path-to-node=\"23\">5. Support &amp; Troubleshooting<\/h2>\n<ul data-path-to-node=\"24\">\n<li>\n<p data-path-to-node=\"24,0,0\"><b data-path-to-node=\"24,0,0\" data-index-in-node=\"0\">Missing Template Errors:<\/b> If your pipeline attempts to connect to the internet to download a template, ensure <code data-path-to-node=\"24,0,0\" data-index-in-node=\"109\">TEMPLATEFLOW_HOME<\/code> and <code data-path-to-node=\"24,0,0\" data-index-in-node=\"131\">APPTAINERENV_TEMPLATEFLOW_HOME<\/code> are correctly exported in your submission script.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"24,1,0\"><b data-path-to-node=\"24,1,0\" data-index-in-node=\"0\">Permission Issues:<\/b> All files under <code data-path-to-node=\"24,1,0\" data-index-in-node=\"35\">\/lab_data\/hawk\/resources\/neuroimaging\/<\/code> are configured with read-only permissions (<code data-path-to-node=\"24,1,0\" data-index-in-node=\"117\">755<\/code>) for all cluster users.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This guide provides instructions for accessing shared neuroimaging reference templates and atlases stored on the cluster at \/lab_data\/hawk\/resources\/neuroimaging\/. 1. Available Resources &amp; Directory Paths Resource File Path \/ Location Description TemplateFlow Cache \/lab_data\/hawk\/resources\/neuroimaging\/templateflow Central offline cache containing MNI152NLin2009cAsym and standard templates. Glasser Atlas (Volumetric) \/lab_data\/hawk\/resources\/neuroimaging\/atlases\/glasser\/ HCP-MMP1.0 converted to 3D NIfTI&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[21],"ht-kb-tag":[],"class_list":["post-761","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-data"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/comments?post=761"}],"version-history":[{"count":4,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/761\/revisions"}],"predecessor-version":[{"id":769,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/761\/revisions\/769"}],"wp:attachment":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/media?parent=761"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-category?post=761"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-tag?post=761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}