Micapipe on Biowulf

Micapipe is a workflow for processing multiple types of brain MRI data, including structural, diffusion, resting-state functional, and microstructure-sensitive imaging. It takes data organized in BIDS format and produces standardized maps and connectivity measures that researchers can use to study brain structure and function across different regions and spatial scales.

Documentation
Important Notes

Interactive job
Interactive jobs should be used for debugging, graphics, or applications that cannot be run as ba tch jobs.
Below we use datalad on Helix to download a sample dataset, then test micapipe on an sinteractive session (user input in bold):

[user@biowulf ~]$ ssh helix.nih.gov

[user@helix ~] cd /data/$USER
[user@helix ~] mkdir -pv MICAPIPE_TEST
[user@helix ~] cd MICAPIPE_TEST

[user@helix ~]$ module load datalad
[+] Loading datalad  1.1.4  on helix.nih.gov 

[user@helix ~]$ datalad install https://github.com/conpdatasets/mica-mics.git
install(ok): MICAPIPE_TEST/mica-mics (dataset)

[user@helix ~]$ cd mica-mics

[user@helix ~]$ datalad get \
    MICs_release/rawdata/dataset_description.json \
    MICs_release/rawdata/sub-HC001/ses-01/anat/sub-HC001_ses-01_run-1_T1w.json \
    MICs_release/rawdata/sub-HC001/ses-01/anat/sub-HC001_ses-01_run-1_T1w.nii.gz

get(ok): MICs_release/rawdata/sub-HC001/ses-01/anat/sub-HC001_ses-01_run-1_T1w.json (file) [from web...]           
get(ok): MICs_release/rawdata/sub-HC001/ses-01/anat/sub-HC001_ses-01_run-1_T1w.nii.gz (file) [from web...]         
get(ok): MICs_release/rawdata/dataset_description.json (file) [from web...]
action summary: get (ok: 3)

[user@helix ~]$ exit

[user@biowulf ~] sinteractive --mem=32g --cpus-per-task=16 --gres=lscratch:50
salloc: Pending job allocation 28020319
salloc: job 28020319 queued and waiting for resources
salloc: job 28020319 has been allocated resources
salloc: Granted job allocation 28020319
salloc: Waiting for resource configuration
salloc: Nodes cn1234 are ready for job

[user@cn1234 ~] cd /data/$USER/MICAPIPE_TEST

[user@cn1234 ~] module load micapipe      

[user@cn1234 ~] micapipe \
    -bids mica-mics/MICs_release/rawdata \
    -out output \
    -sub HC001 \
    -ses 01 \
    -proc_structural \
    -T1wStr run-1_T1w \
    -threads 16 \
    -tmpDir /lscratch/${SLURM_JOB_ID} \
    -fs_licence /usr/local/apps/freesurfer/license.txt

Some packages in this Docker container are non-free
If you are considering commercial use of this container, please consult the relevant license:
https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Licence

micapipe -bids mica-mics/MICs_release/rawdata -out output -sub HC001 -ses 01 -proc_structural -T1wStr run-1_T1w -threads 16 -tmpDir /lscratch/28177916 -fs_licence /usr/local/apps/freesurfer/license.txt

-------------------------------------------------------------
	MICA pipeline - (Version v0.2.3 'Northern flicker') 
		Subject: HC001 Session: ses-01
-------------------------------------------------------------
		Freesurfer licence:	/usr/local/apps/freesurfer/license.txt

-------------------------------------------------------------
	Structural processing
		micapipe v0.2.3 'Northern flicker', container_micapipe-v0.2.3
-------------------------------------------------------------

[ INFO ]..... MICA pipe - Software versions 
		MRtrix3.....	3.0.1
		            	/opt/miniconda-22.11.1/envs/micapipe/bin/mrinfo
		FSL.........	6.0
		            	/opt/fsl-6.0.2
		ANFI........	 Jun 23 2023 (Version AFNI_23.1.09 'Publius Helvius Pertinax')
		            	/opt/afni-latest/3dresample
		ANTS........	 2.3.3.dev168-g29bdf
		            	/opt/ants-2.3.4/
		WorkBench...	1.3.2
		            	/usr/bin/wb_command
		FreeSurfer..	freesurfer-linux-ubuntu18_x86_64-7.3.2-20220804-6354275
		            	/opt/freesurfer-7.3.2
		fix.........	/opt/fix1.068/fix
		            	/opt/fix1.068
		python......	3.9.18
		            	/opt/miniconda-22.11.1/envs/micapipe/bin/python
		R...........	3.6.3
		            	/usr/bin/R
		conda.......	conda 22.11.1
		            	/opt/miniconda-22.11.1/condabin/conda

[...]
      
-------------------------------------------------------------
	proc_structural processing ended in 30.067 minutes:
	logs:
    	Steps completed : 09/09
    	Status          : COMPLETED
    	Check logs      : MICAPIPE_TEST/output/micapipe_v0.2.0/sub-HC001/ses-01/logs/proc_structural_2026-08-24_15.02.13.txt
-------------------------------------------------------------


-------------------------------------------------------------
	GLOBAL micapipe running time with container_micapipe-v0.2.3 processing: 30.117 minutes 
-------------------------------------------------------------

Batch job
Most jobs should be run as batch jobs.

Create a batch input file (e.g. micapipe.sh). For example:

#!/bin/bash

module load micapipe

cd /data/${USER}/MICAPIPE_TEST

micapipe \
    -bids mica-mics/MICs_release/rawdata \
    -out output \
    -sub HC001 \
    -ses 01 \
    -proc_structural \
    -T1wStr run-1_T1w \
    -threads 16 \
    -tmpDir /lscratch/${SLURM_JOB_ID} \
    -fs_licence /usr/local/apps/freesurfer/license.txt

Submit this job using the Slurm sbatch command.

sbatch --cpus-per-task=16 --mem=32g --gres=lscratch:50 micapipe.sh
Swarm of Jobs
A swarm of jobs is an easy way to submit a set of independent commands requiring identical resources.

Create a swarmfile (e.g. micapipe.swarm). For example:

micapipe \
  -bids MICAPIPE_TEST/mica-mics/MICs_release/rawdata \
  -out MICAPIPE_TEST/output \
  -sub HC001 \
  -ses 01 \
  -proc_structural \
  -T1wStr run-1_T1w \
  -fs_licence /path/to/license.txt \
  -threads 16 \
  -tmpDir /lscratch/${SLURM_JOB_ID}
micapipe \
  -bids MICAPIPE_TEST/mica-mics/MICs_release/rawdata \
  -out MICAPIPE_TEST/output \
  -sub HC002 \
  -ses 01 \
  -proc_structural \
  -T1wStr run-1_T1w \
  -fs_licence /path/to/license.txt \
  -threads 16 \
  -tmpDir /lscratch/${SLURM_JOB_ID} \
micapipe \
  -bids MICAPIPE_TEST/mica-mics/MICs_release/rawdata \
  -out MICAPIPE_TEST/output \
  -sub HC003 \
  -ses 01 \
  -proc_structural \
  -T1wStr run-1_T1w \
  -fs_licence /path/to/license.txt \
  -threads 16 \
  -tmpDir /lscratch/${SLURM_JOB_ID}

Submit this job using the swarm command.

swarm --gres=lscratch:50 -g 32 -t 16 --module micapipe micapipe.swarm
where
-gres=lscratch:# Number of Gigabytes of local disk space allocated per process (1 line in the swarm command file)
-g # Number of Gigabytes of memory required for each process (1 line in the swarm command file)
-t # Number of threads/CPUs required for each process (1 line in the swarm command file).
--module micapipe Loads the micapipe module for each subjob in the swarm