source code: https://github.com/AlanKuurstra/mousefMRIPrep/tree/subclassing
container: https://hub.docker.com/repository/docker/akuurstr/mousefmriprep
Developer will watch for topic posts with the tag: mousefmriprep
Documentation (Under Development):
Preprocess mouse resting state scans and register to an atlas. Compute correlation of resting state signals.
Steps:
- functional preprocessing
- motion correction (antsMotionCorr)
- brain extraction (BrainSuite, Template, or Mask)
- slice timing correction (afni tshift)
- spatial smoothing (fsl SUSAN)
- temporal filtering (fslmaths -bptf)
- register functional to anatomical (ants)
- register anatomical to atlas (ants)
- use transforms to register functional to atlas (ants)
- use atlas labels to extract average resting state signals from anatomic regions
- compute a correlation matrix (allow for time shifts that maximize correlation)
Running the bids app:
running the bids app container:
singularity run \
-B /host/path/to/bids:/bids \
-B /host/path/to/bids/derivatives:/derivatives \
-B /host/path/to/store/nipype/working/directory:/nipype \
-B /host/path/to/atlases:/atlases \
mousefmriprep_latest.sif \
/bids /derivatives participant \
--participant_label Nl311f9 \
--func_session_labels 2020021001 \
--func_run_label 01 \
--anat_brain_extract_method USER_PROVIDED_MASK \
--anat_mask /derivatives/CreateInitialMasks/sub-Nl311f9/ses-2020021001/anat/sub-Nl311f9_ses-2020021001_acq-TurboRARE_run-1_desc-ManualBrainMask_T2w.nii.gz \
--atlas /atlases/AMBMC_model_downsampled.nii.gz \
--atlas_mask /atlases/AMBMC_model_downsampled_mask.nii.gz \
--label_mapping /atlases/label_mapping.txt \
--nipype_processing_dir /nipype \
--keep_unnecessary_outputs
label_mapping.txt
label_mapping.txt contains the anatomical regions that will be extracted and used in the correlation matrix. The file has the following format:
<label_name> </path/to/label/image> <integer value in label image>
If two lines have the same label name, then the regions will be combined together to make a single label (in the example below, Acb is a new label combining AcbC and AcbSh).
eg.
aca /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 1
AcbC /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 2
AcbSh /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 3
Acb /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 2
Acb /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 3
acp /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 4
ASt /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 5
B /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 6
cc/ec /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 7
Ce /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 8
CPu /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 9
EA /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 10
EP /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 11
f /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 12
Fu /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 13
GP /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 14
HDB /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 15
ic /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 16
ICjM /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 17
IPAC /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 18
LAcbSh /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 19
LDB /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 20
LH /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 21
LPO /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 22
LSS /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 23
LV /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 24
mfb /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 25
MS /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 26
ns /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 27
opt /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 28
SIB /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 29
st /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 30
ST /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 31
Tu /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 32
VDB /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 33
VP /atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz 34
The path to the label file referenced in label_mapping is with respect to the container. In this example, the file should be located on the host
/host/path/to/atlases/labels/AMBMC-c57bl6-basalganglia-labels-15um.nii.gz
Then in the singularity command we map this host atlas directory to
/atlases
in the container using the option
-B /path/to/atlases/on/host/:/atlases/
Therefore, the container should look for the label file in /atlases/labels/
as can be seen in the example label_mapping.txt
Other useful tools included:
tar2bids.py - create bids directory from a tarball (works correctly with bruker data)
fix_mouse_bids.py - fix iquadruped orientation, include slice timing in bids json
create_template.py - create a mouse template using antsTemplate
brain_extraction.py - extract the mouse brain using BrainSuite or a template and mask
downsample_atlas.py - downsample atlas and labels. Instead of nearest neighbour, downsample labels using most frequent neighbour (the high resolution label that occurs most often within the boundaries of the low resolution voxel)
anat2atlas.py - first registers all anatomicals to the atlas so that multiple functional runs can use a single anat bids derivative for registration instead of recalculating
Automated brain extraction steps:
- extract a group of mouse brains using brain_extraction.py with BrainSuite option
- manually touch up the brain masks to correct mistakes
- use create_template.py to create a template and brain probability mask (using masks from step 2)
- use the custom template and mask to extract future mouse brains using template option