@brainpilot/skills 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/06_fMRI_Neuroimaging/fmriprep/SKILL.md +256 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/bids-filter.md +287 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/citation.md +284 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/cli-reference.md +260 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/confounds.md +344 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/installation.md +346 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/outputs.md +369 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/sdc-fieldmaps.md +306 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/spaces.md +334 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/troubleshooting-faq.md +419 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/usage-examples.md +465 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/versions-dependencies.md +228 -0
- package/skills/06_fMRI_Neuroimaging/fmriprep/references/workflows.md +392 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
# Confounds Reference
|
|
2
|
+
|
|
3
|
+
fMRIPrep does not smooth or denoise BOLD data. Instead it emits a **rich table
|
|
4
|
+
of nuisance regressors** per run — your downstream tool (Nilearn, FitLins, FSL
|
|
5
|
+
FEAT, SPM) is responsible for including them in a design matrix or regressing
|
|
6
|
+
them out.
|
|
7
|
+
|
|
8
|
+
File: `sub-<label>_[specifiers]_desc-confounds_timeseries.tsv` (+ `.json`).
|
|
9
|
+
|
|
10
|
+
Row = one BOLD timepoint (kept for every volume in the raw series; leading
|
|
11
|
+
non-steady-state rows typically have `n/a` in framewise-derivative columns).
|
|
12
|
+
|
|
13
|
+
⚠️ **Never dump every column into a design matrix**. Pick a strategy and
|
|
14
|
+
include only its subset. See [strategy recipes](#recommended-denoising-strategies) at the bottom.
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
1. [Column reference](#column-reference)
|
|
18
|
+
2. [aCompCor and tCompCor](#acompcor-and-tcompcor)
|
|
19
|
+
3. [DCT cosine regressors](#dct-cosine-regressors)
|
|
20
|
+
4. [Spike/outlier regressors](#spikeoutlier-regressors)
|
|
21
|
+
5. [Crown / brain-edge PCA](#crown--brain-edge-pca)
|
|
22
|
+
6. [JSON metadata schema](#json-metadata-schema)
|
|
23
|
+
7. [Recommended denoising strategies](#recommended-denoising-strategies)
|
|
24
|
+
8. [Programmatic loading](#programmatic-loading)
|
|
25
|
+
9. [Interpreting the report's carpetplot](#interpreting-the-reports-carpetplot)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Column reference
|
|
30
|
+
|
|
31
|
+
### Motion parameters (6 base + expansions → up to 24)
|
|
32
|
+
|
|
33
|
+
| Column | Meaning |
|
|
34
|
+
|--------|---------|
|
|
35
|
+
| `trans_x`, `trans_y`, `trans_z` | Rigid-body translations (mm) w.r.t. reference volume |
|
|
36
|
+
| `rot_x`, `rot_y`, `rot_z` | Rigid-body rotations (radians) |
|
|
37
|
+
| `trans_{x,y,z}_derivative1` | 1st temporal derivative of each translation |
|
|
38
|
+
| `rot_{x,y,z}_derivative1` | 1st temporal derivative of each rotation |
|
|
39
|
+
| `trans_{x,y,z}_power2` | Quadratic term of each translation |
|
|
40
|
+
| `rot_{x,y,z}_power2` | Quadratic term of each rotation |
|
|
41
|
+
| `trans_{x,y,z}_derivative1_power2` | Squared derivative |
|
|
42
|
+
| `rot_{x,y,z}_derivative1_power2` | Squared derivative |
|
|
43
|
+
|
|
44
|
+
Choose 6 = base, 12 = base + derivatives (Friston), 24 = base + derivatives +
|
|
45
|
+
squares (Satterthwaite).
|
|
46
|
+
|
|
47
|
+
### Global signals
|
|
48
|
+
|
|
49
|
+
| Column | Meaning |
|
|
50
|
+
|--------|---------|
|
|
51
|
+
| `csf` | Mean signal in eroded CSF mask (anatomical) |
|
|
52
|
+
| `white_matter` | Mean signal in eroded WM mask (anatomical) |
|
|
53
|
+
| `global_signal` | Mean signal in brain mask |
|
|
54
|
+
| `csf_derivative1`, `csf_power2`, `csf_derivative1_power2` | expansions |
|
|
55
|
+
| `white_matter_derivative1`, `white_matter_power2`, `white_matter_derivative1_power2` | expansions |
|
|
56
|
+
| `global_signal_derivative1`, `global_signal_power2`, `global_signal_derivative1_power2` | expansions |
|
|
57
|
+
|
|
58
|
+
Combined with the 24 motion params → **36-parameter Satterthwaite** strategy.
|
|
59
|
+
|
|
60
|
+
### Motion metrics
|
|
61
|
+
|
|
62
|
+
| Column | Meaning | Notes |
|
|
63
|
+
|--------|---------|-------|
|
|
64
|
+
| `framewise_displacement` | FD (mm) per Power 2012 | `n/a` for first volume |
|
|
65
|
+
| `rmsd` | Relative frame-to-frame head motion (Jenkinson 2002) | |
|
|
66
|
+
| `dvars` | Derivative of RMS voxel variance (Power 2012) | `n/a` for first volume |
|
|
67
|
+
| `std_dvars` | Standardized DVARS | For thresholding |
|
|
68
|
+
|
|
69
|
+
### Non-steady-state outliers
|
|
70
|
+
|
|
71
|
+
`non_steady_state_outlier00`, `non_steady_state_outlier01`, ... — one column
|
|
72
|
+
per detected dummy volume, with `1` at that timepoint and `0` elsewhere.
|
|
73
|
+
Detected automatically or set by `--dummy-scans N`.
|
|
74
|
+
|
|
75
|
+
### Motion spike regressors
|
|
76
|
+
|
|
77
|
+
`motion_outlier00`, `motion_outlier01`, ... — one column per timepoint flagged
|
|
78
|
+
by (FD > `--fd-spike-threshold`) OR (std_dvars > `--dvars-spike-threshold`).
|
|
79
|
+
Defaults: FD > 0.5 mm, std_dvars > 1.5.
|
|
80
|
+
|
|
81
|
+
These are **one-hot** regressors — including them censors those volumes when
|
|
82
|
+
regressed. Alternatively use them to build a scrub mask and drop volumes.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## aCompCor and tCompCor
|
|
87
|
+
|
|
88
|
+
**aCompCor** (anatomical, Behzadi 2007 / Muschelli 2014): PCA of BOLD signals
|
|
89
|
+
inside three noise ROIs derived from tissue segmentation. Each ROI's
|
|
90
|
+
components are written to a **distinct column prefix** — no need to consult
|
|
91
|
+
the JSON `Mask` field to disambiguate:
|
|
92
|
+
|
|
93
|
+
| ROI | Column prefix | JSON `Mask` |
|
|
94
|
+
|-----|---------------|-------------|
|
|
95
|
+
| Combined WM ∪ CSF (Behzadi original) | `a_comp_cor_00`, `a_comp_cor_01`, ... | `combined` |
|
|
96
|
+
| CSF alone (Muschelli) | `c_comp_cor_00`, `c_comp_cor_01`, ... | `CSF` |
|
|
97
|
+
| WM alone (Muschelli) | `w_comp_cor_00`, `w_comp_cor_01`, ... | `WM` |
|
|
98
|
+
|
|
99
|
+
All three sets carry `Method: aCompCor` in the JSON. Retained-vs-dropped
|
|
100
|
+
status, singular value, and cumulative variance explained are in the JSON
|
|
101
|
+
sidecar per component.
|
|
102
|
+
|
|
103
|
+
**tCompCor** (temporal, Behzadi 2007): PCA on top-variance voxels
|
|
104
|
+
(temporally). Columns: `t_comp_cor_00`, `t_comp_cor_01`, ...
|
|
105
|
+
JSON `Method: tCompCor`.
|
|
106
|
+
|
|
107
|
+
**Retention policy**: by default fMRIPrep keeps components that cumulatively
|
|
108
|
+
explain the top 50% variance of each ROI's decomposition. Dropped components
|
|
109
|
+
are kept in the JSON with the `dropped_XX` prefix. Use `--return-all-components`
|
|
110
|
+
to include every component in the TSV.
|
|
111
|
+
|
|
112
|
+
**Selection tips**:
|
|
113
|
+
- The three anatomical CompCor variants are now distinguishable by column
|
|
114
|
+
prefix (`a_`, `c_`, `w_`) — no need to filter the JSON `Mask` field to
|
|
115
|
+
separate combined / CSF-only / WM-only families.
|
|
116
|
+
- Common choices: first 5–6 components; first N to explain 50% / 70% / 90%
|
|
117
|
+
cumulative variance; number chosen by elbow / broken stick.
|
|
118
|
+
- Behzadi original: use `a_comp_cor_*` (combined-mask components).
|
|
119
|
+
- Muschelli refinement: use `w_comp_cor_*` and `c_comp_cor_*` separately.
|
|
120
|
+
- Do **not** combine WM/CSF CompCor with the plain `white_matter` / `csf`
|
|
121
|
+
global signal (redundant / collinear).
|
|
122
|
+
- Combining `global_signal` **with** CompCor is beneficial (Parkes 2018).
|
|
123
|
+
|
|
124
|
+
### High-pass filtering caveat
|
|
125
|
+
|
|
126
|
+
fMRIPrep applies a temporal high-pass filter *before* CompCor decomposition.
|
|
127
|
+
When you use CompCor regressors, you MUST include the corresponding
|
|
128
|
+
`cosine_XX` regressors in the same design matrix — otherwise you'll re-alias
|
|
129
|
+
low-frequency drift back into your model.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## DCT cosine regressors
|
|
134
|
+
|
|
135
|
+
`cosine_00`, `cosine_01`, ..., `cosine_NN` — DCT basis functions modeling
|
|
136
|
+
low-frequency drift.
|
|
137
|
+
|
|
138
|
+
- Number of regressors depends on effective series length (excluding detected
|
|
139
|
+
non-steady-state volumes) and TR.
|
|
140
|
+
- Cutoff is set internally to match the CompCor high-pass.
|
|
141
|
+
- Two datasets with the same TR and effective length produce identical cosine
|
|
142
|
+
regressors.
|
|
143
|
+
- **Do not combine with your own high-pass filter.**
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Spike/outlier regressors
|
|
148
|
+
|
|
149
|
+
Categories (each is a set of one-hot columns):
|
|
150
|
+
|
|
151
|
+
| Prefix | Trigger | Threshold flag |
|
|
152
|
+
|--------|---------|----------------|
|
|
153
|
+
| `non_steady_state_outlier` | Detected T1-saturation / dummy scans | `--dummy-scans` |
|
|
154
|
+
| `motion_outlier` | Frame with FD > threshold OR std_dvars > threshold | `--fd-spike-threshold`, `--dvars-spike-threshold` |
|
|
155
|
+
|
|
156
|
+
Common practice:
|
|
157
|
+
- **Regress-out**: include as regressors → those timepoints are effectively censored.
|
|
158
|
+
- **Scrub**: use as a mask to drop volumes prior to GLM (rebuilds series length).
|
|
159
|
+
- **Report**: track the fraction of flagged volumes per subject — a common
|
|
160
|
+
quality-control exclusion criterion (e.g. exclude subject if >20%).
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Crown / brain-edge PCA
|
|
165
|
+
|
|
166
|
+
24 PCA components extracted from voxels on the outer brain edge ("crown"):
|
|
167
|
+
signal here is dominated by motion / physiological artifacts, not neural
|
|
168
|
+
activity. Introduced in Patriat 2017 and formalized for fMRIPrep in
|
|
169
|
+
Provins 2022.
|
|
170
|
+
|
|
171
|
+
Columns: `edge_comp_00`, `edge_comp_01`, ..., `edge_comp_23` (24 components).
|
|
172
|
+
JSON `Method: EdgeRegressor` (not `aCompCor` or `tCompCor`, though the
|
|
173
|
+
implementation reuses aCompCor plumbing on the "crown" mask). Useful as an
|
|
174
|
+
aggressive nuisance model when a lot of motion is expected.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## JSON metadata schema
|
|
179
|
+
|
|
180
|
+
Each TSV has a paired JSON. Example entry for one component:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"a_comp_cor_00": {
|
|
185
|
+
"CumulativeVarianceExplained": 0.1082,
|
|
186
|
+
"Mask": "combined",
|
|
187
|
+
"Method": "aCompCor",
|
|
188
|
+
"Retained": true,
|
|
189
|
+
"SingularValue": 25.827,
|
|
190
|
+
"VarianceExplained": 0.1082
|
|
191
|
+
},
|
|
192
|
+
"dropped_0": {
|
|
193
|
+
"CumulativeVarianceExplained": 0.5966,
|
|
194
|
+
"Mask": "combined",
|
|
195
|
+
"Method": "aCompCor",
|
|
196
|
+
"Retained": false,
|
|
197
|
+
"SingularValue": 20.796,
|
|
198
|
+
"VarianceExplained": 0.0701
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Fields:
|
|
204
|
+
- `Method` — `aCompCor` or `tCompCor`.
|
|
205
|
+
- `Mask` — for aCompCor: `CSF`, `WM`, `combined`.
|
|
206
|
+
- `SingularValue` — component's singular value.
|
|
207
|
+
- `VarianceExplained` — this component's share of ROI variance.
|
|
208
|
+
- `CumulativeVarianceExplained` — running total up through this component.
|
|
209
|
+
- `Retained` — whether saved in the TSV (`true`) or listed only in JSON (`false`, i.e. `dropped_XX`).
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Recommended denoising strategies
|
|
214
|
+
|
|
215
|
+
Pick ONE (or a small orthogonal set) — don't mix redundant families.
|
|
216
|
+
|
|
217
|
+
### Minimal (6-parameter)
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
trans_x, trans_y, trans_z, rot_x, rot_y, rot_z
|
|
221
|
+
+ framewise_displacement (optional group-level covariate)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Simplest; only motion. Poor for high-motion cohorts.
|
|
225
|
+
|
|
226
|
+
### 24-parameter Friston-24 (aka Volterra)
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
Base 6 + 6 derivatives + 6 squares + 6 squared derivatives
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Column pattern: `(trans|rot)_[xyz](_derivative1)?(_power2)?`
|
|
233
|
+
|
|
234
|
+
### 36-parameter Satterthwaite (aka aCompCor+GSR expansion)
|
|
235
|
+
|
|
236
|
+
24-parameter motion + 12 tissue signals (csf, white_matter, global_signal,
|
|
237
|
+
each with derivative + squares).
|
|
238
|
+
|
|
239
|
+
### aCompCor (Behzadi original)
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
6 motion + first N aCompCor components with Mask=="combined" + cosine_XX
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### aCompCor (Muschelli refinement)
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
6 motion + first N w_comp_cor_* (WM mask) + first N c_comp_cor_* (CSF mask) + cosine_XX
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
(No need to filter by JSON `Mask` — the column prefixes already partition
|
|
252
|
+
combined/WM/CSF.)
|
|
253
|
+
|
|
254
|
+
### Scrubbing / censoring
|
|
255
|
+
|
|
256
|
+
Use `motion_outlier_XX` as a design regressor OR drop those volumes entirely
|
|
257
|
+
(rebuild series). Common threshold: FD>0.5 mm (default) or stricter (0.2 mm)
|
|
258
|
+
for resting-state connectivity.
|
|
259
|
+
|
|
260
|
+
### AROMA (via post-processor)
|
|
261
|
+
|
|
262
|
+
fMRIPrep 21+ dropped built-in AROMA. Use the community-maintained
|
|
263
|
+
`fmripost-aroma` BIDS-App downstream — it consumes fMRIPrep outputs.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Programmatic loading
|
|
268
|
+
|
|
269
|
+
Python (Nilearn / pandas):
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
from pathlib import Path
|
|
273
|
+
import pandas as pd
|
|
274
|
+
import json
|
|
275
|
+
|
|
276
|
+
conf = Path("derivatives/sub-01/func/"
|
|
277
|
+
"sub-01_task-rest_desc-confounds_timeseries.tsv")
|
|
278
|
+
|
|
279
|
+
df = pd.read_csv(conf, sep="\t")
|
|
280
|
+
|
|
281
|
+
# Metadata (used to pick components by variance / retention if desired)
|
|
282
|
+
with open(conf.with_suffix(".json")) as f:
|
|
283
|
+
meta = json.load(f)
|
|
284
|
+
|
|
285
|
+
# Extract aCompCor combined-mask, top 6 — columns are prefixed a_/c_/w_ to
|
|
286
|
+
# denote combined/CSF/WM masks respectively, so filtering by prefix suffices.
|
|
287
|
+
combined_cols = [c for c in df.columns if c.startswith("a_comp_cor_")][:6]
|
|
288
|
+
|
|
289
|
+
# Motion basic 6
|
|
290
|
+
motion6 = ["trans_x", "trans_y", "trans_z", "rot_x", "rot_y", "rot_z"]
|
|
291
|
+
|
|
292
|
+
# High-pass cosines
|
|
293
|
+
cosines = [c for c in df.columns if c.startswith("cosine")]
|
|
294
|
+
|
|
295
|
+
# Motion outliers
|
|
296
|
+
outliers = [c for c in df.columns if c.startswith("motion_outlier")]
|
|
297
|
+
|
|
298
|
+
design = df[motion6 + combined_cols + cosines + outliers].fillna(0.0)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Nilearn convenience:
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
from nilearn.interfaces.fmriprep import load_confounds
|
|
305
|
+
|
|
306
|
+
confounds, sample_mask = load_confounds(
|
|
307
|
+
"sub-01_task-rest_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz",
|
|
308
|
+
strategy=["motion", "high_pass", "wm_csf", "scrub"],
|
|
309
|
+
motion="basic",
|
|
310
|
+
wm_csf="basic",
|
|
311
|
+
scrub=5,
|
|
312
|
+
fd_threshold=0.5,
|
|
313
|
+
std_dvars_threshold=1.5,
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
`load_confounds` supports `strategy=[...]` values: `motion`, `high_pass`,
|
|
318
|
+
`wm_csf`, `global_signal`, `compcor`, `ica_aroma`, `scrub`, `non_steady_state`.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Interpreting the report's carpetplot
|
|
323
|
+
|
|
324
|
+
The visual report's per-run carpetplot (Power 2016; Provins 2022 extension)
|
|
325
|
+
plots BOLD time × voxels as a heatmap, with above-the-carpet:
|
|
326
|
+
- `GS`, `CSF`, `WM` — global / tissue signals
|
|
327
|
+
- `FD` — framewise displacement
|
|
328
|
+
- `DVARS` — derivative of variance
|
|
329
|
+
|
|
330
|
+
Rows are grouped: cortical GM, deep GM, WM, CSF, cerebellum, edge/crown.
|
|
331
|
+
|
|
332
|
+
Diagnostic patterns:
|
|
333
|
+
- **Vertical bright/dark stripes** — motion or physiological events;
|
|
334
|
+
correlates with FD/DVARS spikes.
|
|
335
|
+
- **Slow drift** — scanner drift; ensure cosine regressors or high-pass.
|
|
336
|
+
- **Correlated stripes across all rows** — global signal contamination;
|
|
337
|
+
consider including `global_signal` regressor.
|
|
338
|
+
- **Row-specific bright bands** — issue localized to that tissue class (e.g.,
|
|
339
|
+
vascular near-edge).
|
|
340
|
+
|
|
341
|
+
The report also shows:
|
|
342
|
+
- **CompCor cumulative-variance curves** — helps choose N components.
|
|
343
|
+
- **Confound correlation heatmap** — spot collinearity in your chosen model.
|
|
344
|
+
- **Confound-vs-global-signal bar plot** — flag partial-volume effects.
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Installation Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
1. [Container installations (recommended)](#container-installations-recommended)
|
|
5
|
+
- 1.1 [Docker](#11-docker)
|
|
6
|
+
- 1.2 [`fmriprep-docker` wrapper](#12-fmriprep-docker-wrapper)
|
|
7
|
+
- 1.3 [Apptainer / Singularity](#13-apptainer--singularity)
|
|
8
|
+
2. [Bare-metal (pip) installation](#bare-metal-pip-installation)
|
|
9
|
+
3. [External binary dependencies (bare-metal only)](#external-binary-dependencies-bare-metal-only)
|
|
10
|
+
4. [FreeSurfer license](#freesurfer-license)
|
|
11
|
+
5. [TemplateFlow setup](#templateflow-setup)
|
|
12
|
+
6. [Environment variables](#environment-variables)
|
|
13
|
+
7. [Verifying the installation](#verifying-the-installation)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Container installations (recommended)
|
|
18
|
+
|
|
19
|
+
fMRIPrep is a **BIDS-App**. Containers are the officially supported deployment
|
|
20
|
+
path — they package every neuroimaging binary (FreeSurfer, FSL, ANTs, AFNI,
|
|
21
|
+
Connectome-Workbench, MSM) at exact tested versions, avoiding the pain of a
|
|
22
|
+
manual environment.
|
|
23
|
+
|
|
24
|
+
### 1.1 Docker
|
|
25
|
+
|
|
26
|
+
Pull an official image from Docker Hub:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
docker pull nipreps/fmriprep:25.2.5 # replace with the desired version
|
|
30
|
+
docker pull nipreps/fmriprep:latest # bleeding edge (not recommended for research)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Image sizes are ~10 GB compressed / ~25 GB extracted.
|
|
34
|
+
|
|
35
|
+
Minimal bare-Docker invocation:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
docker run --rm -it \
|
|
39
|
+
-v /path/to/bids:/data:ro \
|
|
40
|
+
-v /path/to/derivatives:/out \
|
|
41
|
+
-v /path/to/work:/scratch \
|
|
42
|
+
-v /path/to/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
|
|
43
|
+
nipreps/fmriprep:25.2.5 \
|
|
44
|
+
/data /out participant \
|
|
45
|
+
-w /scratch
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Docker Hub tags: https://hub.docker.com/r/nipreps/fmriprep/tags/
|
|
49
|
+
|
|
50
|
+
### 1.2 `fmriprep-docker` wrapper
|
|
51
|
+
|
|
52
|
+
A Python wrapper that constructs the `docker run` command for you. It shares
|
|
53
|
+
the CLI of `fmriprep` (paths are automatically bind-mounted).
|
|
54
|
+
|
|
55
|
+
Install:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip install --user fmriprep-docker
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use exactly like `fmriprep`:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
fmriprep-docker /path/to/bids /path/to/derivatives participant \
|
|
65
|
+
--fs-license-file $HOME/.licenses/freesurfer/license.txt \
|
|
66
|
+
--output-spaces MNI152NLin2009cAsym:res-2 fsaverage \
|
|
67
|
+
-w /path/to/work
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Wrapper-specific options (translate to `docker run` flags):
|
|
71
|
+
|
|
72
|
+
| Wrapper flag | Purpose |
|
|
73
|
+
|--------------|---------|
|
|
74
|
+
| `-i / --image IMG` | Pick a specific image (default: `nipreps/fmriprep:<wrapper_version>`) |
|
|
75
|
+
| `-e / --env VAR val` | Inject an env var (repeatable) |
|
|
76
|
+
| `-u / --user UID[:GID]` | Run container as another user |
|
|
77
|
+
| `--network none` | Simulate offline mode |
|
|
78
|
+
| `--shell` | Drop into a bash shell inside the container |
|
|
79
|
+
| `--patch PACKAGE=PATH` | Bind-mount a dev checkout over the installed package |
|
|
80
|
+
| `--no-tty` | Omit `-it` (useful for CI / batch) |
|
|
81
|
+
| `--config PATH` | Custom `nipype.cfg` |
|
|
82
|
+
|
|
83
|
+
The wrapper auto-detects `$FS_LICENSE` and bind-mounts it. It also warns if
|
|
84
|
+
Docker has <8 GB of RAM available.
|
|
85
|
+
|
|
86
|
+
The wrapper source lives at `wrapper/src/fmriprep_docker/__main__.py`; expected
|
|
87
|
+
Docker image path convention: `/app/.pixi/envs/fmriprep/lib/python3.12/site-packages`.
|
|
88
|
+
|
|
89
|
+
### 1.3 Apptainer / Singularity
|
|
90
|
+
|
|
91
|
+
Build an image from Docker Hub (typical HPC workflow):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# On a machine with internet + apptainer/singularity
|
|
95
|
+
apptainer build fmriprep-25.2.5.sif docker://nipreps/fmriprep:25.2.5
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
apptainer run --cleanenv \
|
|
102
|
+
-B /path/to/bids:/data:ro \
|
|
103
|
+
-B /path/to/derivatives:/out \
|
|
104
|
+
-B /path/to/work:/work \
|
|
105
|
+
-B $FS_LICENSE:/opt/freesurfer/license.txt:ro \
|
|
106
|
+
-B $HOME/.cache/templateflow:/opt/templateflow \
|
|
107
|
+
--env TEMPLATEFLOW_HOME=/opt/templateflow \
|
|
108
|
+
fmriprep-25.2.5.sif \
|
|
109
|
+
/data /out participant \
|
|
110
|
+
--fs-license-file /opt/freesurfer/license.txt \
|
|
111
|
+
-w /work --nthreads 8 --omp-nthreads 4 --mem 16000
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Notes:
|
|
115
|
+
- `--cleanenv` prevents host env from leaking in (recommended). If `$FS_LICENSE`
|
|
116
|
+
is set on the host and you use `--cleanenv`, you must pass
|
|
117
|
+
`--fs-license-file` explicitly (as above).
|
|
118
|
+
- Recent Apptainer (≥1.0) is a drop-in replacement for Singularity 3.x.
|
|
119
|
+
- Under Singularity 2.x, use `singularity exec` and add `-w` explicitly.
|
|
120
|
+
|
|
121
|
+
Extended HPC / TemplateFlow docs:
|
|
122
|
+
https://www.nipreps.org/apps/singularity/
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Bare-metal (pip) installation
|
|
127
|
+
|
|
128
|
+
> ⚠️ **Not recommended** — the container is the tested reference; bare-metal
|
|
129
|
+
> installs commonly break when a system library version drifts. Use only when
|
|
130
|
+
> containers are impossible.
|
|
131
|
+
|
|
132
|
+
Requirements:
|
|
133
|
+
- Python **3.10+** (3.11–3.13 also supported)
|
|
134
|
+
- All [External Dependencies](#external-binary-dependencies-bare-metal-only) present on `$PATH`
|
|
135
|
+
|
|
136
|
+
Install fMRIPrep from PyPI:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
python -m pip install fmriprep
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
To pin a specific version:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -m pip install fmriprep==25.2.5
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Development install from GitHub:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
git clone https://github.com/nipreps/fmriprep.git
|
|
152
|
+
cd fmriprep
|
|
153
|
+
python -m pip install -e ".[all]"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Optional feature groups (via pip extras):
|
|
157
|
+
|
|
158
|
+
| Extra | Adds |
|
|
159
|
+
|-------|------|
|
|
160
|
+
| `[doc]` / `[docs]` | Sphinx + docs deps |
|
|
161
|
+
| `[dev]` | ruff, pre-commit |
|
|
162
|
+
| `[test]` / `[tests]` | pytest, coverage |
|
|
163
|
+
| `[telemetry]` | migas + sentry-sdk |
|
|
164
|
+
| `[container]` | Extras baked into container (datalad, git-annex) |
|
|
165
|
+
| `[duecredit]` | duecredit citation tracking |
|
|
166
|
+
| `[maint]` | maintenance tools |
|
|
167
|
+
| `[all]` | Everything |
|
|
168
|
+
|
|
169
|
+
Python dependencies (auto-installed):
|
|
170
|
+
`acres`, `looseversion`, `nibabel≥5.1.1`, `nipype≥1.9.0`, `nireports≥24.1.0`,
|
|
171
|
+
`nitime≥0.9`, `nitransforms≥25.0.1`, `niworkflows≥1.14.4`, `numpy≥2.0`,
|
|
172
|
+
`packaging≥24`, `pandas≥2.2`, `psutil≥5.4`, `pybids≥0.16`, `requests≥2.27`,
|
|
173
|
+
`sdcflows≥2.15.0`, `smriprep≥0.19.2`, `tedana≥25.1.0`, `templateflow≥24.2.2`,
|
|
174
|
+
`transforms3d≥0.4.2`, `toml≥0.10`, `codecarbon≥2`, `APScheduler≥3.10`.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## External binary dependencies (bare-metal only)
|
|
179
|
+
|
|
180
|
+
Containers include these. For bare-metal, install these versions (from fMRIPrep
|
|
181
|
+
25.2.x lockfiles / Dockerfile):
|
|
182
|
+
|
|
183
|
+
| Tool | Version (25.2.x) | Notes |
|
|
184
|
+
|------|------------------|-------|
|
|
185
|
+
| FreeSurfer | **7.3.2** | Get from Harvard, requires license.txt |
|
|
186
|
+
| FSL | **6.0.7.7** (via fsl-{bet2, flirt, fast4, fugue, mcflirt, miscmaths, topup} conda pkgs) | Only the components fMRIPrep uses |
|
|
187
|
+
| ANTs | **2.5.1** (2.6.* in pixi env) | `antsRegistration`, `N4BiasFieldCorrection`, `antsBrainExtraction.sh` |
|
|
188
|
+
| AFNI | **25.2.09** | Only `3dvolreg`, `3dTshift`, `3dUnifize`, `3dAutomask` are used |
|
|
189
|
+
| Connectome Workbench | **1.5.0+** (2.0.* in container, Qt6 build) | CIFTI + surface I/O |
|
|
190
|
+
| MSM | **HOCR (Nov 2019)** | Multimodal Surface Matching |
|
|
191
|
+
| bids-validator | **1.14.10** | Input dataset validation |
|
|
192
|
+
| NodeJS | **20.x** | For bids-validator, svgo |
|
|
193
|
+
| svgo | **^3.2.0** | Report SVG optimization |
|
|
194
|
+
| Python | **3.12** | Container uses 3.12 |
|
|
195
|
+
|
|
196
|
+
Use `references/versions-dependencies.md` for the exact pin table.
|
|
197
|
+
|
|
198
|
+
Verify each tool is on PATH:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
which recon-all antsRegistration flirt 3dvolreg wb_command
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## FreeSurfer license
|
|
207
|
+
|
|
208
|
+
fMRIPrep uses FreeSurfer tools even when `--fs-no-reconall` is set (some
|
|
209
|
+
utilities need it). **You must supply a license file.**
|
|
210
|
+
|
|
211
|
+
Register (free): https://surfer.nmr.mgh.harvard.edu/registration.html
|
|
212
|
+
|
|
213
|
+
You receive a `license.txt` (small text file with 4 lines). Recommended location:
|
|
214
|
+
`$HOME/.licenses/freesurfer/license.txt`.
|
|
215
|
+
|
|
216
|
+
fMRIPrep resolves the license path in this order:
|
|
217
|
+
1. `--fs-license-file /path/to/license.txt` argument
|
|
218
|
+
2. `$FS_LICENSE` environment variable (fMRIPrep sets this in-process)
|
|
219
|
+
3. `$FREESURFER_HOME/license.txt` (bare-metal fallback)
|
|
220
|
+
|
|
221
|
+
### Passing the license into containers
|
|
222
|
+
|
|
223
|
+
**Docker (raw):**
|
|
224
|
+
```bash
|
|
225
|
+
-v $FS_LICENSE:/opt/freesurfer/license.txt:ro
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Docker (wrapper) — auto-detected from `$FS_LICENSE`:**
|
|
229
|
+
```bash
|
|
230
|
+
export FS_LICENSE=$HOME/.licenses/freesurfer/license.txt
|
|
231
|
+
fmriprep-docker /data /out participant
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Apptainer with `--cleanenv`:** must pass `--fs-license-file` explicitly, e.g.:
|
|
235
|
+
```bash
|
|
236
|
+
apptainer run --cleanenv \
|
|
237
|
+
-B $HOME/.licenses/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
|
|
238
|
+
fmriprep-25.2.5.sif /data /out participant \
|
|
239
|
+
--fs-license-file /opt/freesurfer/license.txt
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## TemplateFlow setup
|
|
245
|
+
|
|
246
|
+
TemplateFlow is the registry that provides `MNI152NLin2009cAsym`, `fsLR`,
|
|
247
|
+
`OASIS30ANTs`, etc. Templates are downloaded on first use.
|
|
248
|
+
|
|
249
|
+
Default cache path: `$HOME/.cache/templateflow`. Override with:
|
|
250
|
+
```bash
|
|
251
|
+
export TEMPLATEFLOW_HOME=/path/to/templateflow
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Pre-fetch templates** (recommended for HPC, air-gapped or slow-network setups):
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
python -m pip install templateflow
|
|
258
|
+
python -c "from templateflow.api import get; \
|
|
259
|
+
get(['MNI152NLin2009cAsym', 'MNI152NLin6Asym', 'OASIS30ANTs', \
|
|
260
|
+
'MNIPediatricAsym', 'MNIInfant', 'fsaverage', 'fsLR'])"
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Templates that **must** be present for common workflows:
|
|
264
|
+
|
|
265
|
+
| Template | Needed when |
|
|
266
|
+
|----------|-------------|
|
|
267
|
+
| `MNI152NLin2009cAsym` | Always (default output space + internal reference) |
|
|
268
|
+
| `OASIS30ANTs` | Skull-stripping default (`--skull-strip-template`) |
|
|
269
|
+
| `MNI152NLin6Asym` | `--cifti-output` |
|
|
270
|
+
| `fsaverage` / `fsLR` | Surface / CIFTI output |
|
|
271
|
+
| `MNIPediatricAsym` / `MNIInfant` | Pediatric / infant cohorts |
|
|
272
|
+
|
|
273
|
+
The helper script bundled in the repo (`scripts/fetch_templates.py`) pulls all
|
|
274
|
+
common templates:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
wget https://raw.githubusercontent.com/nipreps/fmriprep/master/scripts/fetch_templates.py
|
|
278
|
+
python fetch_templates.py --tf-dir /path/to/templateflow
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
The container image includes a pre-populated TemplateFlow mirror in
|
|
282
|
+
`/home/fmriprep/.cache/templateflow` — you don't strictly need to bind-mount
|
|
283
|
+
your host cache when using Docker/Apptainer, but doing so avoids re-downloads
|
|
284
|
+
if you delete the container.
|
|
285
|
+
|
|
286
|
+
Apptainer + TemplateFlow guide:
|
|
287
|
+
https://www.nipreps.org/apps/singularity/#templateflow-and-singularity
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Environment variables
|
|
292
|
+
|
|
293
|
+
| Variable | Effect |
|
|
294
|
+
|----------|--------|
|
|
295
|
+
| `FS_LICENSE` | Path to FreeSurfer license (auto-picked up by fMRIPrep and the wrapper) |
|
|
296
|
+
| `FREESURFER_HOME` | FreeSurfer install root (bare-metal); used as fallback license search location |
|
|
297
|
+
| `SUBJECTS_DIR` | FreeSurfer subjects directory (bare-metal) |
|
|
298
|
+
| `TEMPLATEFLOW_HOME` | TemplateFlow cache root (default `~/.cache/templateflow`) |
|
|
299
|
+
| `FMRIPREP_DEV` | Set to `1` to enable dev warnings (normally suppressed) |
|
|
300
|
+
| `FMRIPREP_WARNINGS` | Force warnings even in production builds (dev use) |
|
|
301
|
+
| `NIPYPE_NO_ET` / `NO_ET` | Disable Nipype telemetry ping (fMRIPrep force-sets these) |
|
|
302
|
+
| `PYTHONHASHSEED` | Set to `0` for reproducible runs (container sets automatically) |
|
|
303
|
+
| `MKL_NUM_THREADS` / `OMP_NUM_THREADS` | Set to `1` in container so Nipype controls parallelism |
|
|
304
|
+
| `FSLDIR` | FSL install root (bare-metal); container sets to pixi env |
|
|
305
|
+
| `FSLOUTPUTTYPE` | `NIFTI_GZ` in container |
|
|
306
|
+
| `IS_DOCKER_8395080871` | Set inside the container; fMRIPrep uses it to detect containerized execution |
|
|
307
|
+
| `DOCKER_VERSION_8395080871` | Set by the Docker wrapper; distinguishes `docker` from `fmriprep-docker` runs |
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Verifying the installation
|
|
312
|
+
|
|
313
|
+
Print the version — every install path should respond:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# bare-metal
|
|
317
|
+
fmriprep --version
|
|
318
|
+
|
|
319
|
+
# Docker
|
|
320
|
+
docker run --rm nipreps/fmriprep:25.2.5 --version
|
|
321
|
+
|
|
322
|
+
# Docker wrapper
|
|
323
|
+
fmriprep-docker --version
|
|
324
|
+
|
|
325
|
+
# Apptainer
|
|
326
|
+
apptainer run fmriprep-25.2.5.sif --version
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Expected: `fMRIPrep v25.2.5` (or your installed release).
|
|
330
|
+
|
|
331
|
+
Dry-run to verify a BIDS dataset without doing work:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
fmriprep /path/to/bids /path/to/derivatives participant \
|
|
335
|
+
--participant-label 01 \
|
|
336
|
+
--boilerplate-only # emit only the methods paragraph and exit
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Or generate reports without redoing computation (uses cached working dir):
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
fmriprep /path/to/bids /path/to/derivatives participant \
|
|
343
|
+
--participant-label 01 \
|
|
344
|
+
--reports-only \
|
|
345
|
+
-w /path/to/work
|
|
346
|
+
```
|