Skip to content

Commit 30ffbc6

Browse files
Merge pull request #21 from marcobarilari/marco_add_mriqc
Add mriqc section
2 parents a034e85 + 1998cad commit 30ffbc6

File tree

5 files changed

+302
-24
lines changed

5 files changed

+302
-24
lines changed

doc/cpp_fmriprep.slurm

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
22

33
#SBATCH --job-name=fMRIprep
4-
#SBATCH --time=00:05:00 # hh:mm:ss
4+
#SBATCH --time=9:00:00 # hh:mm:ss
55

66
#SBATCH --ntasks=1
7-
#SBATCH --cpus-per-task=6
7+
#SBATCH --cpus-per-task=9
88
#SBATCH --mem-per-cpu=10000 # megabytes
99
#SBATCH --partition=batch,debug
1010

@@ -14,33 +14,40 @@
1414

1515
#SBATCH --comment=project-name
1616

17-
#export OMP_NUM_THREADS=1
18-
#export MKL_NUM_THREADS=1
17+
#export OMP_NUM_THREADS=9
18+
#export MKL_NUM_THREADS=9
1919

2020
## CPP frmiprep script for CECI cluster
2121
#
2222
# writtent by CPP people
2323
#
24-
# Submission script for Lemaitre3
25-
#
26-
# USAGE on cluster:
27-
#
28-
# sbatch cpp_fmriprep.sh <subjID> <TaskName>
29-
#
24+
# Submission command for Lemaitre3
25+
#
26+
# sbatch cpp_fmriprep.slurm <subjID> <TaskName>
27+
#
3028
# examples:
31-
#
3229
# - 1 subject 1 task
33-
# sbatch cpp_fmriprep.sh sub-01 visMotLocalizer
34-
#
30+
# sbatch cpp_fmriprep.slurm sub-01 visMotLocalizer
31+
#
32+
# - 1 subject all task
33+
# sbatch cpp_fmriprep.slurm sub-01 ''
34+
#
35+
# - all subjects 1 task
36+
# sbatch cpp_fmriprep.slurm '' visMotLocalizer
37+
#
3538
# - multiple subjects
36-
# sbatch cpp_fmriprep.sh 'sub-01 sub-02` visMotLocalizer
39+
# sbatch cpp_fmriprep.slurm 'sub-01 sub-02' visMotLocalizer
40+
#
41+
# - multiple tasks
42+
# sbatch cpp_fmriprep.slurm sub-01 'visMotLocalizer audMotLocalizer'
3743
#
38-
# - multipple tasks
39-
# sbatch cpp_fmriprep.sh sub-01 'visMotLocalizer audMotLocalizer'
44+
# - submit all the subjects (1 per job) all at once
45+
# read subj list to submit each to a job for all the tasks
46+
# !!! to run from within `raw` folder
47+
# ls -d sub* | xargs -n1 -I{} sbatch path/to/cpp_fmriprep.slurm {} ''
4048

41-
# create jobs_report and output folders in case they don't exist
49+
# create jobs_report folder in case they don't exist
4250
mkdir -p $HOME/jobs_report/
43-
mkdir -p "${output_dir}"
4451

4552
# fail whenever something is fishy
4653
# -e exit immediately
@@ -72,6 +79,9 @@ freesurfer_license_folder="$HOME/tools/freesurfer_license"
7279
# make the scratch folder, here there is no limit space and fmriprep can store stuff in case of crash and do not start from zero again
7380
mkdir -p "${scratch_dir}"/work-fmriprep
7481

82+
# create output folder in case it does not exists
83+
mkdir -p "${output_dir}"
84+
7585
singularity run --cleanenv \
7686
-B "${scratch_dir}":/scratch_dir \
7787
-B "${bids_dir}":/bids_dir \

doc/cpp_mriqc.slurm

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=MRIqc
4+
#SBATCH --time=4:00:00 # hh:mm:ss
5+
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=9
8+
#SBATCH --mem-per-cpu=10000 # megabytes
9+
#SBATCH --partition=batch,debug
10+
11+
#SBATCH --mail-user=marco.barilari@uclouvain.be
12+
#SBATCH --mail-type=ALL
13+
#SBATCH --output=/home/ucl/irsp/marcobar/jobs_report/mriqc_job-%j.txt
14+
15+
#SBATCH --comment=project-name
16+
17+
#export OMP_NUM_THREADS=9
18+
#export MKL_NUM_THREADS=9
19+
20+
## CPP MRIqc script for CECI cluster
21+
#
22+
# writtent by CPP people
23+
#
24+
# Submission command for Lemaitre3
25+
#
26+
# sbatch cpp_mriqc.slurm <subjID>
27+
#
28+
# examples:
29+
# - 1 subject
30+
# sbatch cpp_mriqc.slurm sub-01
31+
#
32+
# - all subjects
33+
# sbatch cpp_mriqc.slurm ''
34+
#
35+
# - multiple subjects
36+
# sbatch cpp_mriqc.slurm 'sub-01 sub-02'
37+
#
38+
# - submit all the subjects (1 per job) all at once
39+
# read subj list to submit each to a job
40+
# !!! to run from within `raw` folder
41+
# ls -d sub* | xargs -n1 -I{} sbatch path/to/cpp_mriqc.slurm {}
42+
43+
# create jobs_report folder in case they don't exist
44+
mkdir -p $HOME/jobs_report/
45+
46+
# fail whenever something is fishy
47+
# -e exit immediately
48+
# -x to get verbose logfiles
49+
# -u to fail when using undefined variables
50+
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
51+
set -e -x -u -o pipefail
52+
53+
module --force purge
54+
55+
subjID=$1
56+
57+
# "latest" or procide specific version number
58+
MRIQC_VERSION="23.1.0"
59+
60+
# set username to locate scratch folder
61+
ceci_username="marcobar"
62+
63+
path_to_singularity_image="$HOME/tools/containers/images/bids/bids-mriqc--${MRIQC_VERSION}.sing"
64+
bids_dir="$HOME/mriqc_trial/raw"
65+
output_dir="$HOME/mriqc_trial/derivatives/mriqc"
66+
67+
# create output folder in case it does not exists
68+
mkdir -p "${output_dir}"
69+
70+
singularity run --cleanenv \
71+
-B "${bids_dir}":/data \
72+
-B "${output_dir}":/out \
73+
"${path_to_singularity_image}" \
74+
/data \
75+
/out \
76+
participant --participant-label "${subjID}"

doc/cpp_mriqc_group.slurm

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=MRIqc
4+
#SBATCH --time=9:00:00 # hh:mm:ss
5+
6+
#SBATCH --ntasks=1
7+
#SBATCH --cpus-per-task=9
8+
#SBATCH --mem-per-cpu=10000 # megabytes
9+
#SBATCH --partition=batch,debug
10+
11+
#SBATCH --mail-user=marco.barilari@uclouvain.be
12+
#SBATCH --mail-type=ALL
13+
#SBATCH --output=/home/ucl/irsp/marcobar/jobs_report/mriqc_job-%j.txt
14+
15+
#SBATCH --comment=project-name
16+
17+
#export OMP_NUM_THREADS=9
18+
#export MKL_NUM_THREADS=9
19+
20+
## CPP MRIqc script for CECI cluster
21+
#
22+
# writtent by CPP people
23+
#
24+
# Submission command for Lemaitre3 after running mriqc for each participant
25+
#
26+
# sbatch cpp_mriqc_group.slurm
27+
28+
# create jobs_report folder in case they don't exist
29+
mkdir -p $HOME/jobs_report/
30+
31+
# fail whenever something is fishy
32+
# -e exit immediately
33+
# -x to get verbose logfiles
34+
# -u to fail when using undefined variables
35+
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
36+
set -e -x -u -o pipefail
37+
38+
module --force purge
39+
40+
# "latest" or procide specific version number
41+
MRIQC_VERSION="23.1.0"
42+
43+
# set username to locate scratch folder
44+
ceci_username="marcobar"
45+
46+
path_to_singularity_image="$HOME/tools/containers/images/bids/bids-mriqc--${MRIQC_VERSION}.sing"
47+
bids_dir="$HOME/mriqc_trial/raw"
48+
output_dir="$HOME/mriqc_trial/derivatives/mriqc"
49+
50+
# create mriqc output folder in case they don't exist
51+
mkdir -p "${output_dir}"
52+
53+
singularity run --cleanenv \
54+
-B "${bids_dir}":/data \
55+
-B "${output_dir}":/out \
56+
"${path_to_singularity_image}" \
57+
/data \
58+
/out \
59+
group

doc/run_fmriprep.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Run fmriprep and mriQC on the cluster
1+
# Run fmriprep on the cluster
22

33
Written by CPP lab people
44

@@ -24,9 +24,20 @@ here the example is with `fmriprp version 21.0.1` but check for newer version, l
2424
```bash
2525
datalad install https://github.com/ReproNim/containers.git
2626

27-
datalad get containers/images/bids/bids-fmriprep--21.0.1.sing
27+
cd containers
28+
29+
datalad get images/bids/bids-fmriprep--21.0.1.sing
2830
```
2931

32+
In case you have installe the repo a while a ago and you want to use a new version of fmriprep., update the `containers` repo via:
33+
34+
```bash
35+
# go to the repo folder
36+
cd path/to/containers
37+
38+
datald update --merge
39+
``````
40+
3041
Depending on the cluster “unlock” is needed or not. No need for `lemaitre3`.
3142

3243
```bash
@@ -144,9 +155,7 @@ should consider as `bold` as `T1w`.
144155
The one below corresponds to the fMRIprep default (also available inside this
145156
repo).
146157
147-
See this part of the FAQ for more info:
148-
149-
https://fmriprep.org/en/21.0.2/faq.html#how-do-I-select-only-certain-files-to-be-input-to-fMRIPrep
158+
See this part of the FAQ for more info [here](https://fmriprep.org/en/21.0.2/faq.html#how-do-I-select-only-certain-files-to-be-input-to-fMRIPrep)
150159
151160
```json
152161
{% include "bids_filter_file.json" %}

doc/run_mriqc.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,127 @@
1-
# WIP
1+
# WIP# Run MRIqc on the cluster
2+
3+
Written by CPP lab people
4+
5+
To contribute see [here](https://cpp-lln-lab.github.io/CPP_HPC/contributing/)
6+
7+
!!! Warning
8+
9+
Space problem since the `work` folder is not set in the script. Marco is working on it.
10+
11+
12+
## General tips
13+
14+
- The more resources required, the faster it can be but the more waiting time
15+
16+
- To try things, set `--time=00:05:00` and `--partition=debug` so it starts
17+
right away and you can check if it at least starts without problems (eg the
18+
singularity images is running, data are bids compatible or data folders are
19+
loaded proprerly). See below in the section [Submit a MRIqc job via sbatch command](#submit-a-MRIqc-job-via-sbatch-command-without-a-script-mainly-for-debug-purposes)
20+
21+
## Prepare to run MRIqc on the cluster
22+
23+
- have your data on the cluster
24+
- install datalad on your user (see [here](https://github.com/cpp-lln-lab/CPP_HPC/install_datalad))
25+
- get the fmriprep singularity image as follow:
26+
27+
here the example is with `MRIqc version 23.1.0` but check for newer version, list of fmriprep version available [here](https://hub.docker.com/r/nipreps/fmriprep/tags/)
28+
29+
```bash
30+
datalad install https://github.com/ReproNim/containers.git
31+
32+
cd containers
33+
34+
datalad get images/bids/bids-mriqc--23.1.0.sing
35+
```
36+
37+
In case you have installe the repo a while a ago and you want to use a new version of fmriprep., update the `containers` repo via:
38+
39+
```bash
40+
# go to the repo folder
41+
cd path/to/containers
42+
43+
datald update --merge
44+
``````
45+
46+
Depending on the cluster “unlock” is needed or not. No need for `lemaitre3`.
47+
48+
```bash
49+
datalad unlock containers/images/bids/bids-mriqc--23.1.0.sing
50+
```
51+
52+
## Submit a MRIqc job via a `slurm` script
53+
54+
- pros:
55+
- easy to run for multiple subject
56+
- cons:
57+
- the `slurm` script can be hard to edit from within the cluster in case of error or a change of mind with fmriprep
58+
options. You can edit via `vim` or locally and then
59+
uploading a newversion.
60+
61+
### Participants level
62+
63+
Content of the `cpp_mriqc.slurm` file (download and edit from [here](cpp_mriqc.slurm))
64+
65+
!!! Warning
66+
67+
1. Read the MRIqc documentation to know what you are doing and how the arguments of the run call effects the results
68+
2. All the paths and email are set afte Marco's users for demosntration.
69+
3. Edit the scripts with the info you need to make it run for your user from top to buttom of the script, do not over look the first "commented" chunk cause it is not a real commented section (check the email and job report path, data paths and the `username` etc.).
70+
71+
```bash
72+
{% include "cpp_mriqc.slurm" %}
73+
```
74+
75+
On the cluster prompt, submit the jobs as:
76+
77+
```bash
78+
# Submission command for Lemaitre3
79+
80+
# USAGE on cluster:
81+
82+
sbatch cpp_mriqc.slurm <subjID>
83+
84+
# examples:
85+
# - 1 subject
86+
87+
sbatch cpp_mriqc.slurm sub-01
88+
89+
# submit all the subjects (1 per job) all at once
90+
# read subj list to submit each to a job for all the tasks
91+
# !!! to run from within `raw` folder
92+
ls -d sub* | xargs -n1 -I{} sbatch path/to/cpp_mriqc.slurm {}
93+
```
94+
95+
### Group level
96+
97+
Content of the `cpp_mriqc_group.slurm` file (download and edit from [here](cpp_mriqc_group.slurm))
98+
99+
!!! Warning
100+
101+
1. Read the MRIqc documentation to know what you are doing and how the arguments of the run call effects the results
102+
2. All the paths and email are set afte Marco's users for demosntration.
103+
3. Edit the scripts with the info you need to make it run for your user from top to buttom of the script, do not over look the first "commented" chunk cause it is not a real commented section (check the email and job report path, data paths and the `username` etc.).
104+
105+
```bash
106+
{% include "cpp_mriqc_group.slurm" %}
107+
```
108+
109+
On the cluster prompt, submit the jobs as:
110+
111+
```bash
112+
# Submission command for Lemaitre3
113+
114+
# USAGE on cluster:
115+
116+
# no need to priovide any input
117+
118+
sbatch cpp_mriqc_group.slurm
119+
```
120+
121+
## TIPS
122+
123+
### check your job
124+
125+
see [here](https://github.com/cpp-lln-lab/CPP_HPC/cluster_code_snippets/#check-your-running-jobs)
2126

3127
To contribute see [here](https://cpp-lln-lab.github.io/CPP_HPC/contributing/)

0 commit comments

Comments
 (0)