Package that provides tools for brain MRI Deep Learning pre-processing.
Note
Go to the end to download the full example code.
fmriprep pre-processing use caseΒΆ
Credit: A Grigis
Example on how to run thefmriprep pre-processing using the brainprep Singularity container.
# sphinx_gallery_thumbnail_path = '_static/carousel/fmriprep.png'
import os
import subprocess
from brainrise.datasets import MRIToyDataset
Please tune these parameters.
DATADIR = "/tmp/brainprep-data"
OUTDIR = "/tmp/brainprep-out"
WORKDIR = "/tmp/brainprep-out/work"
HOMEDIR = "/tmp/brainprep-home"
SCRIPT = "fmriprep"
SIMG = "/volatile/nsap/brainprep/fmriprep/brainprep-fmriprep-latest.simg"
for path in (DATADIR, OUTDIR, HOMEDIR, WORKDIR):
if not os.path.isdir(path):
os.mkdir(path)
dataset = MRIToyDataset(root=DATADIR)
t1w_file = os.path.join(DATADIR, os.path.basename(MRIToyDataset.t1w_url))
func_file = t1w_file
desc_file = t1w_file
cmd = ["singularity", "run", "--bind", "{0}:/data".format(DATADIR),
"--bind", "{0}:/out".format(OUTDIR), "--home", HOMEDIR, "--cleanenv",
SIMG,
"brainprep", SCRIPT,
t1w_file.replace(DATADIR, "/data"),
func_file.replace(DATADIR, "/data"),
desc_file.replace(DATADIR, "/data"),
"sub-error",
"--outdir", "/out",
"--workdir", "/out/work"]
You can now execute this command.
print(" ".join(cmd))
singularity run --bind /tmp/brainprep-data:/data --bind /tmp/brainprep-out:/out --home /tmp/brainprep-home --cleanenv /volatile/nsap/brainprep/fmriprep/brainprep-fmriprep-latest.simg brainprep fmriprep /data/T1W.nii.gz /data/T1W.nii.gz /data/T1W.nii.gz sub-error --outdir /out --workdir /out/work
Total running time of the script: (0 minutes 0.284 seconds)
Estimated memory usage: 68 MB
Follow us