Visual Neuroscience Lab
  • Home
  • Neurodesktop
  • Behavioral
  • Labmeeting
  • DICOM to GLM
  • MRI
  • People
  • Other Topics
  • Archive
  1. MRI
  2. 7T anatomical analysis on neurodesk
  • Home
  • Neurodesktop
  • MRI: from DICOM to GLM Analysis
    • 01 - DICOM to BIDS
    • 02 - T1w for PBn
    • 03 - Defacing
    • 04 - Removing Noise Scan
    • 05 - fmriprep
    • 06 - first level GLM
    • Troubleshooting
  • MRI
    • Retinotopic Mapping
    • 3D printing a brain
    • 7T anatomical analysis on neurodesk
    • MRI BIDS and OSF
    • fMRIprep analysis
    • Old MRI setup
    • Update to the MRI lab setup
    • Physiological noise correction
  • Behavioral
    • Vision tests
    • BIDS for behavioral studies
    • Custom-built chin rests
  • People
    • Stipends and prizes for master students
    • Coffee time
    • Participant compensation
    • Things to do if you are leaving the lab
    • Scientific writing in practice
    • Interns
    • Pflichtpraktikum
  • Other Topics
    • Calculating a priori sample size using G Power
    • Gamma correction
    • Contribute to the website
    • Lab Members Only!!!
  • Labmeeting
  • Archive

On this page

  • Basics
    • What software is needed for 7T anatomical analysis?
  • Neurodesk and containers
  • How to run the script?
  • Troubleshooting
  1. MRI
  2. 7T anatomical analysis on neurodesk

7T anatomical analysis on neurodesk

MRI
7T
Analysis
Neurodesk
How to run 7 Tesla anatomy analysis on neurodesk
Author

AC

Published

January 27, 2025

Basics

After converting the data from DICOMS to niftis (BIDS format) you will notice that unlike 3T data, you might have collected 3 different anatomical scans:

  • INV1 (1st inversion)
  • INV2 (2nd inversion)
  • UNI (MP2RAGE)

The files we really care about for the anatomical analysis are INV2 and UNI (MP2RAGE)

When opening an MP2RAGE scan it is clear that there is a lot of noise that we do not get at 3T.

This means that we first need to get rid of this noise before using recon-all (recon-all will fail if trying to pass it these noisy images).

  • This means there are a few extra pieces of software that is needed to be able to run the anatomical analysis

What software is needed for 7T anatomical analysis?

  • Presurfer (uses MATLAB/ SPM12)
  • CAT12
  • FreeSurfer (to use recon-all)

Neurodesk and containers

Containers are explained in more detail here.

  • Put simply, currently on neurodesk we cannot load 2 or 3 pieces of software at once and this means that the anatomical analysis of 7T data is a bit tricky.

  • Luckily Denis Chaimow (link to github) has created a container in which we can run the analysis.

  • The container and scripts I edited to allow the use of processing anatomical results for a single subject with multiple sessions

How to run the script?

  • The script should be located in /shared/7T_analysis/anatomy

0. Open a terminal:

Opening a terminal on neurodesk

 

1. Start the container

  • The container can be started like so:

singularity run --bind /path/to/output:/derivatives /shared/7T_analysis/anatomy/mp2rage_recon-all.sif

  • Here we need to make sure that the /path/to/output is exactly where our data is stored.

For example:

  • Here my anatomical data folder is stored in /home/jovyan/7t_auditory/bids/sub-a001/ses-1

Locating where the data is stored
  • This means that I want to mount this folder to the container so my command will be like so:

singularity run --bind /home/jovyan/7t_auditory/bids/sub-a001/ses-1/:/derivatives /shared/7T_analysis/anatomy/mp2rage_recon-all.sif

  • This then means that once in side the container the path to my data is now mounted to a folder called /derivative

  • Put simply I create a link from my local folder /home/jovyan/7t_auditory/bids/sub-a001/ses-1/ to a folder inside the container called /derivatives

2. Once inside the container

  • To know if you are in the container or not you will see the following:

Inside the container
  • This means that we are in our own environment and that we can run the command necessary to start the anatomical preprocessing

3. Export FreeSurfer subjects directory

  • This command should be the same for everyone

export $SUBJECTS_DIR=/derivatives/mprage_recon-all/freesurfer

4. Run the script

  • We need to now start the preprocessing script
Recall
  • Remember that we have mounted a folder to this folder: /derivatives

  • This means that everything you see inside of your local directory e.g. /home/jovyan/7t_auditory/bids/sub-a001/ses-1/ is mirrored inside the container

  • Therefore, we can run the script like so:

mp2rage_recon-all.py --inv2 /derivatives/anat/inv2.nii --uni /derivatives/anat/uni.nii

5. The script will now start and run everything needed to run the anatomical analysis

multiple sessions?
  • If you have multiple sessions you need to make sure that all anatomical scans sessions are inside just 1 folder

  • You can then run the command:

mp2rage_recon-all.py --inv2 /derivatives/anat/inv2_session1.nii /derivatives/anat/inv2_session2.nii --uni /derivatives/anat/uni_session1.nii /derivatives/anat/uni_session2.nii

Troubleshooting

  • The files will need to be unzipped first. This is becuase the script uses SPM12 and that this is only able to read files that end in .nii and not .nii.gz

Run the commands in a new terminal window:

ml freesurfer

mri_convert /path/to/file.nii.gz /path/to/file.nii

ValueError: substring not found

OSError: This docstring was not generated by Nipype!

This error occurs for unknown reasons. The suggested fix is export FORCE_SPMMCR as an environment variable. So run this in the terminal:


export FORCE_SPMMCR=1

https://neurostars.org/t/valueerror-substring-not-found-when-running-spm-spmcommand-version-with-spm-standalone-and-mcr-installation/24082

Back to top