# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [default]
#     language: python
#     name: python3
# ---

# ### Using fmriprep

# [fmriprep](https://fmriprep.readthedocs.io/en/stable/) is a package developed by the Poldrack lab to do the minimal preprocessing of fMRI data required. It covers brain extraction, motion correction, field unwarping, and registration. It uses a combination of well-known software packages (e.g., FSL, SPM, ANTS, AFNI) and selects the 'best' implementation of each preprocessing step.
#
# Once installed, `fmriprep` can be invoked from the command line. We can even run it inside this notebook! The following command should work after you remove the 'hashtag' `#`. 
#
# However, running fmriprep takes quite some time (we included the hashtag to prevent you from accidentally running it). You'll most likely want to run it in parallel on a computing cluster.

# +
# #!fmriprep \
# #  --ignore slicetiming \
# #  --ignore fieldmaps \
# #  --output-space template \
# #  --template MNI152NLin2009cAsym \
# #  --template-resampling-grid 2mm \
# #  --fs-no-reconall \
# #  --fs-license-file \
# #  ../license.txt \
# #  ../data/ds000030 ../data/ds000030/derivatives/fmriprep participant
# -

# The command above consists of the following parts:
# - \"fmriprep\" calls fmriprep
# - `--ignore slicetiming` tells fmriprep to _not_ perform slice timing correction
# - `--ignore fieldmaps` tells fmriprep to _not_ perform distortion correction (unfortunately, there are no field maps available in this data set)
# - `--output-space template` tells fmriprep to normalize (register) data to a template
# - `--template MNI152NLin2009cAsym` tells fmriprep that the template should be MNI152 version 6 (2009c)
# - `--template-resampling-grid 2mm` tells fmriprep to resample the output images to 2mm isotropic resolution
# - `--fs-license-file ../../license.txt` tells fmriprep where to find the license.txt-file for freesurfer - you can ignore this
# - `bids` is the name of the folder containing the data in bids format
# - `output_folder` is the name of the folder where we want the preprocessed data to be stored,
# - `participant` tells fmriprep to run only at the participant level (and not, for example, at the group level - you can forget about this)
#
# The [official documentation](http://fmriprep.readthedocs.io/) contains all possible arguments you can pass.

# ### Using nipype

# fmriprep makes use of [Nipype](https://nipype.readthedocs.io/en/latest/), a pipelining tool for preprocessing neuroimaging data. Nipype makes it easy to share and document pipelines and run them in parallel on a computing cluster. If you would like to build your own preprocessing pipelines, a good resource to get started is [this tutorial](https://miykael.github.io/nipype_tutorial/).

StarcoderdataJupyterScriptsDedupFiltered