<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://ortiztudela.github.io//feed.xml" rel="self" type="application/atom+xml" /><link href="https://ortiztudela.github.io//" rel="alternate" type="text/html" /><updated>2026-08-12T02:05:21+02:00</updated><id>https://ortiztudela.github.io//feed.xml</id><title type="html">Javier Ortiz-Tudela, PhD</title><subtitle>personal description</subtitle><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><entry><title type="html">A heuristic for LMM model selection</title><link href="https://ortiztudela.github.io//blog/lmm-heuristic/" rel="alternate" type="text/html" title="A heuristic for LMM model selection" /><published>2022-02-10T00:00:00+01:00</published><updated>2022-02-10T00:00:00+01:00</updated><id>https://ortiztudela.github.io//blog/lmm-heuristic</id><content type="html" xml:base="https://ortiztudela.github.io//blog/lmm-heuristic/"><![CDATA[<p>Heuristic for using LMMs as a two-step process. This helps me conceptualise the process.</p>

<h1 id="how-to">How to?</h1>

<p>The two steps are: 1) determine whether the slopes of your effects differ, 2) test your main effects.</p>

<p><strong>In order to do 1):</strong></p>

<ul>
  <li>Build the more complex (maximal) model.</li>
  <li>Check convergence with a large number of iterations.</li>
  <li>Build a reduced model by removing 1 element.</li>
  <li>Compare models in descending order: if there is a significant reduction in fit, accept the more complex model; if there is no decrease, continue descending.</li>
  <li>If further descending is needed, remove 1 element from the previously reduced model and repeat the process.</li>
  <li>Continue until a significant reduction in fit is found.</li>
  <li>Pro tip: the suggested reduction order is interactions &gt; main effects.</li>
</ul>

<p><strong>In order to do 2)</strong>, you can use a Chi-square likelihood ratio test. In R, this is what <code class="language-plaintext highlighter-rouge">anova(reduced_model, full_model)</code> does (not <code class="language-plaintext highlighter-rouge">summary()</code>, which only prints the coefficient estimates).</p>

<p>Pro tip: if you’re running a logistic (binomial) mixed model, you can get the effect size as an odds ratio by exponentiating the beta estimate — in R, <code class="language-plaintext highlighter-rouge">exp()</code> will do it for you. This only applies to logistic/binomial models; for a standard linear mixed model with a continuous outcome, the beta is already on the outcome’s scale and there’s no odds ratio to compute.</p>]]></content><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><category term="Statistics" /><category term="LMM" /><category term="R" /><category term="tutorial" /><summary type="html"><![CDATA[Hopefully, this will help as a guide for your thinking through the process.]]></summary></entry><entry><title type="html">Estimating sample size</title><link href="https://ortiztudela.github.io//blog/estimating-sample-size/" rel="alternate" type="text/html" title="Estimating sample size" /><published>2021-10-15T00:00:00+02:00</published><updated>2021-10-15T00:00:00+02:00</updated><id>https://ortiztudela.github.io//blog/estimating-sample-size</id><content type="html" xml:base="https://ortiztudela.github.io//blog/estimating-sample-size/"><![CDATA[<p>We have all been there: you want to fill in your pre-data-collection registration for your new study and you need to input a number for the targeted sample size. Plus, you need to specify how you came to that number. You turn to your favourite software (most likely G*Power) and, unless the design of the study is identical to ones you have used before, a thousand questions come to your head.</p>

<p>What does “number of groups” mean? The number of actual groups of participants? The number of levels in your variables? Also, what does “number of measurements” mean? The number of variables? The levels in them? Should I sum the levels of all variables? Should I multiply them? And, what is even worse, which measure of effect size should I use? d, eta, eta squared, F, the other weird Greek letter… Should I leave the one set by default in the software? I guess that must be the correct one, but then… how do I decide how much is a medium effect size?</p>

<p>If you want to dive deep and learn about all of that, you can go <a href="https://osf.io/9bt5s/">here</a> and <a href="https://www.frontiersin.org/articles/10.3389/fpsyg.2013.00863/full">here</a>. But if you only want to know which numbers to use, rest assured, I got you covered. You just need to know the size of the effect you would care about and which one is your key analysis. You can use the table below as an orientation on effect sizes.</p>

<p><strong>Cohen’s d</strong> (<a href="https://www.statisticshowto.com/cohens-d/">definition and calculation</a>)</p>
<ul>
  <li>0.2 = Small effect size</li>
  <li>0.5 = Medium effect size</li>
  <li>0.8 = Large effect size</li>
</ul>

<p><strong>Cohen’s f</strong> (<a href="https://www.statisticshowto.com/cohens-f-statistic-definition-formulas/">definition and calculation</a>)</p>
<ul>
  <li>.10 = Small effect size</li>
  <li>.25 = Medium effect size</li>
  <li>.40 = Large effect size</li>
</ul>

<p><em>From: Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale, NJ: Erlbaum.</em></p>

<h2 id="quick-calculators-by-design">Quick calculators by design</h2>

<p>The original version of this post had interactive calculators embedded for each design below. Those widgets were tied to my old Google Sites page and didn’t survive the move, but the designs they covered — and where to get the numbers instead — are still useful:</p>

<ul>
  <li><strong>One-tailed t-test (matched samples)</strong></li>
  <li><strong>Two-tailed t-test (matched samples)</strong></li>
  <li><strong>One-way repeated-measures ANOVA (3 levels)</strong></li>
  <li><strong>Mixed design: 3 (within) by 3 (between)</strong></li>
</ul>

<p>For any of these, <a href="https://www.psychologie.hhu.de/arbeitsgruppen/allgemeine-psychologie-und-arbeitspsychologie/gpower">G*Power</a> remains the standard free tool — pick the matching test family and design under “Test family → t tests / F tests” and plug in the effect size from the table above; for the mixed design specifically, use G*Power’s dedicated “ANOVA: Repeated measures, within-between interaction” test. If you prefer to stay in R, the <a href="https://cran.r-project.org/web/packages/pwr/index.html"><code class="language-plaintext highlighter-rouge">pwr</code> package</a> covers the t-tests and the one-way ANOVA (<code class="language-plaintext highlighter-rouge">pwr.t.test()</code>, <code class="language-plaintext highlighter-rouge">pwr.anova.test()</code>), but doesn’t have a repeated-measures/mixed-design function — for that, use <code class="language-plaintext highlighter-rouge">wp.rmanova()</code> from the <a href="https://webpower.psychstat.org/wiki/"><code class="language-plaintext highlighter-rouge">WebPower</code></a> R package (or its free <a href="https://webpower.psychstat.org/wiki/">online calculators</a> if you’d rather not install anything).</p>]]></content><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><category term="Statistics" /><category term="power analysis" /><category term="tutorial" /><summary type="html"><![CDATA[We have all been there: you want to fill in your pre-data-collection registration for your new study and you need to input a number for the targeted sample size.]]></summary></entry><entry><title type="html">How to run fmriprep on an HPC cluster (Singularity)</title><link href="https://ortiztudela.github.io//blog/how-to-fmriprep-singularity/" rel="alternate" type="text/html" title="How to run fmriprep on an HPC cluster (Singularity)" /><published>2021-02-01T00:00:00+01:00</published><updated>2021-02-01T00:00:00+01:00</updated><id>https://ortiztudela.github.io//blog/how-to-fmriprep-singularity</id><content type="html" xml:base="https://ortiztudela.github.io//blog/how-to-fmriprep-singularity/"><![CDATA[<p>This is a very short tutorial on how to run fMRIPrep on a shared cluster where you do not have access to Docker. This usually happens because Docker requires sudo access to run, so on shared machines administrators usually would rather install Singularity, which also uses containers but without sudo.</p>

<h2 id="why">Why?</h2>

<p>If you are here, you have probably tried to run fmriprep through Docker and have realized that you do not have admin rights in the system that you want to use. <strong>If you have not tried that, I suggest you do it</strong> (see <a href="/blog/how-to-fmriprep/">here how to</a>) and only use Singularity as a plan B.</p>

<p>Since I cannot find a reason why you might want to run Singularity locally (other than debugging your scripts), I will describe here how to run it on a <strong>High-Performance Cluster (HPC)</strong>. The first thing to do is to take a deep breath, get a cup of your favorite drink, and equip yourself with a lot of patience: this can get messy.</p>

<p>Every HPC can be different and you will probably have to tweak things here and there to get it running the first time. The examples I give here are for an HPC using SLURM and with a rather closed setup, so you can think about this procedure as a brute-force approach: the bright side is that if you try all this, you will probably succeed on every system.</p>

<p>Also check the <a href="/blog/tips-for-singularity/">Tips for Singularity</a> post, gathered after too many trial-and-error attempts of my own.</p>

<h2 id="how">How?</h2>

<p>Make sure Singularity is (or can be) installed on your HPC. This part might require some time and <em>mano izquierda</em> to talk your support people into doing it.</p>

<p>Once Singularity is up and running, you need to make sure that you have enough writing space for your user on the HPC. Usually some temporary storage drive is allowed for this — make sure you know where it is and how to access it. NOTE: storage limits can come in size or number of files (inodes), or both; try to discover your limits.</p>

<p>The next step is to download fmriprep’s image. While this is a rather trivial step in Docker, in Singularity it can be tricky. First, identify which version of fmriprep you would like to use; I recommend you always start with the latest one. Singularity does not like the “latest” tag when building, so you need to specify the exact version (e.g., <code class="language-plaintext highlighter-rouge">poldracklab/fmriprep:20.1.1</code>). You might want to build the image locally and transfer it to the HPC:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>singularity build /my_images/fmriprep-&lt;version&gt;.simg docker://poldracklab/fmriprep:&lt;version&gt;

scp /my_images/fmriprep-&lt;version&gt; user@address:/path/to/writable/location/
</code></pre></div></div>

<p>Replacing <code class="language-plaintext highlighter-rouge">&lt;version&gt;</code> with the exact version name as in the example above, and <code class="language-plaintext highlighter-rouge">user</code> and <code class="language-plaintext highlighter-rouge">address</code> with your HPC login details.</p>

<ol>
  <li>
    <p>Some HPC nodes do not have <strong>internet access</strong>, and fmriprep will try to go online to pull brain templates from <a href="https://www.templateflow.org/"><em>TemplateFlow</em></a>. My recommendation is that you download the templates you are going to need (or all of them, if you want to go with the <em>sledgehammer</em> approach) and transfer them to the HPC. Templates can be downloaded with the Python API using the syntax below (choose the templates that you need):</p>

    <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">templateflow</span> <span class="kn">import</span> <span class="n">api</span> <span class="k">as</span> <span class="n">tflow</span>

<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNI152NLin2009cAsym'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'OASIS30ANTs'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNI152NLin6Asym'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'fsaverage'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'NKI'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNI152NLin2009cSym'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'WHS'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'fsLR'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNIPediatricAsym'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNI152Lin'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNIInfant'</span><span class="p">)</span>
<span class="n">tflow</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'MNI152NLin6Sym'</span><span class="p">)</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Rather obvious step: you need to put your BIDS dataset on the HPC (duh!).</p>
  </li>
  <li>
    <p>Once you have all the files needed on the HPC, you can start… preparing your call script. Singularity and fmriprep will try to write a bunch of temporary files in your home directory, so if you have limited space in home, you need to redirect them to your larger writable locations. See the lines after <em>“Re-direct some (…)”</em> in the script below.</p>
  </li>
  <li>
    <p>You also need to overwrite fmriprep’s <code class="language-plaintext highlighter-rouge">TEMPLATEFLOW_HOME</code> with the path inside the container where you are going to mount your templates. See the lines after <em>“Pass some variables into the container”</em>.</p>
  </li>
  <li>
    <p>Now you are ready to call fmriprep through Singularity. After the <code class="language-plaintext highlighter-rouge">run</code> command, you need to mount the BIDS folder, the output folder, the templates folder, and a writable folder for the home and working directory. Use the <code class="language-plaintext highlighter-rouge">-B</code> flag for that (see script below). Do not forget to also mount the path to your FreeSurfer license.</p>
  </li>
  <li>
    <p>Remember about the nodes not having internet access? You need to tell fmriprep not to attempt it, since it will fail anyway. That is what the <code class="language-plaintext highlighter-rouge">--notrack</code> flag does.</p>
  </li>
  <li>
    <p>Finally, it is important to pass the <code class="language-plaintext highlighter-rouge">--home</code> flag to Singularity so that it overwrites the default <code class="language-plaintext highlighter-rouge">home</code> directory. This one needs to be followed by <code class="language-plaintext highlighter-rouge">/home/fmriprep</code>.</p>
  </li>
  <li>
    <p>And you are set!</p>
  </li>
</ol>

<p>Just a few more notes on the script below:</p>

<ul>
  <li>I am passing a variable into the container named <code class="language-plaintext highlighter-rouge">subject</code> so I can pass it to the <code class="language-plaintext highlighter-rouge">--participant-label</code> flag for fmriprep. This is pretty useful if you want to create different temporary folders for different subjects, or if you want to use your job ID to index several subjects.</li>
  <li>
    <p>Sometimes, after crashing, FreeSurfer does not delete all of its intermediate files, and that might cause problems when trying to re-run fmriprep on the same subjects. You might want to include a line at the beginning to search for those corrupted files and delete them if found; something like this will do:</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>find <span class="k">${</span><span class="nv">FREESURFER_HOST_CACHE</span><span class="k">}</span>/<span class="nv">$subject</span>/ <span class="nt">-name</span> <span class="s2">"*IsRunning*"</span> <span class="nt">-type</span> f <span class="nt">-delete</span>
</code></pre></div>    </div>
  </li>
  <li>Everything prior to the line <em>“Which subject do you want to run?”</em> is set for our HPC at Goethe University in Frankfurt. Yours might be different in terms of available resources or requirements; adjust it accordingly.</li>
</ul>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>
<span class="c">#SBATCH --array 01</span>
<span class="c">#SBATCH --partition=general1</span>
<span class="c">#SBATCH --nodes=1</span>
<span class="c">#SBATCH --ntasks=1</span>
<span class="c">#SBATCH --cpus-per-task=80</span>
<span class="c">#SBATCH --mem-per-cpu=1024</span>
<span class="c">#SBATCH --time=02:30:00</span>
<span class="c">#SBATCH --no-requeue</span>
<span class="c">#SBATCH --mail-type=ALL</span>
<span class="c"># ------------------------------------------</span>

<span class="c">##########################################################################</span>
<span class="c"># fmriprep</span>
<span class="c">##########################################################################</span>
<span class="c"># This script runs a singularity image of fmriPrep on files on BIDS format.</span>
<span class="c"># This script is optimized for Frankfurt's HLR cluster.</span>
<span class="c">#</span>
<span class="c"># Javier Ortiz-Tudela (ortiz-tudela@psych.uni-frankfurt.de)</span>
<span class="c">##########################################################################</span>

<span class="nb">echo</span> <span class="s2">"Loading singularity..."</span>
spack load singularity@3.5.2

<span class="c"># Which subject do you want to run?</span>
<span class="nv">subject</span><span class="o">=</span>01  <span class="c"># swap for $SLURM_ARRAY_TASK_ID if you want each array task to run a different subject</span>

<span class="c"># Re-direct some environmental variables to writable locations</span>
<span class="nb">export </span><span class="nv">SINGULARITY_TMPDIR</span><span class="o">=</span>/path/to/writable/location/fmriprep_temp/<span class="nv">$subject</span>
<span class="nb">export </span><span class="nv">SINGULARITY_CACHEDIR</span><span class="o">=</span>/path/to/writable/location/.cache
<span class="nb">export </span><span class="nv">TEMP_DIR</span><span class="o">=</span>/path/to/writable/location/fmriprep_temp/<span class="nv">$subject</span>
<span class="nb">echo</span> <span class="s2">"creating temp directory in"</span>
<span class="nb">echo</span> <span class="nv">$TEMP_DIR</span>
<span class="nb">mkdir</span> <span class="nt">-p</span> <span class="nv">$TEMP_DIR</span>

<span class="c"># Pass some variables into the container</span>
<span class="nb">export </span><span class="nv">SINGULARITYENV_subject</span><span class="o">=</span><span class="nv">$subject</span>
<span class="nb">export </span><span class="nv">SINGULARITYENV_TEMPLATEFLOW_HOME</span><span class="o">=</span>/templateflow

<span class="c"># Setup done, print a message and run the fmriprep call</span>
<span class="nb">echo</span> <span class="nt">-e</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span>
<span class="nb">echo</span> <span class="s2">"Starting fmriprep."</span>
<span class="nb">echo</span> <span class="s2">"subject: </span><span class="nv">$subject</span><span class="s2">"</span>
<span class="nb">echo</span> <span class="nt">-e</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span>

singularity run <span class="se">\</span>
    <span class="nt">-B</span> /path/to/writable/location:/home/fmriprep <span class="se">\</span>
    <span class="nt">-B</span> /path/to/data/BIDS:/data:ro <span class="se">\</span>
    <span class="nt">-B</span> /path/to/templates/templateflow:/templateflow <span class="se">\</span>
    <span class="nt">-B</span> /path/to/output/folder:/output <span class="se">\</span>
    <span class="nt">-B</span> /path/to/license:/lic <span class="se">\</span>
    <span class="nt">-B</span> <span class="nv">$TEMP_DIR</span>:/working_dir <span class="se">\</span>
    <span class="nt">--home</span> /home/fmriprep <span class="nt">--cleanenv</span> <span class="se">\</span>
    /path/to/image/fmriprep-20.1.0.simg <span class="se">\</span>
    /data /output participant <span class="se">\</span>
    <span class="nt">--notrack</span> <span class="se">\</span>
    <span class="nt">--fs-license-file</span> /lic/license.txt <span class="se">\</span>
    <span class="nt">--participant-label</span> <span class="nv">$subject</span> <span class="se">\</span>
    <span class="nt">--work-dir</span> /working_dir
</code></pre></div></div>]]></content><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><category term="fMRI" /><category term="fMRIPrep" /><category term="Singularity" /><category term="HPC" /><category term="tutorial" /><summary type="html"><![CDATA[This is a very short tutorial on how to run fMRIPrep on a shared cluster where you do not have access to Docker. This usually happens because Docker requires sudo access to run, so on shared machines administrators usually would rather install Singularity, which also uses containers but without sudo.]]></summary></entry><entry><title type="html">Tips for Singularity</title><link href="https://ortiztudela.github.io//blog/tips-for-singularity/" rel="alternate" type="text/html" title="Tips for Singularity" /><published>2021-02-01T00:00:00+01:00</published><updated>2021-02-01T00:00:00+01:00</updated><id>https://ortiztudela.github.io//blog/tips-for-singularity</id><content type="html" xml:base="https://ortiztudela.github.io//blog/tips-for-singularity/"><![CDATA[<p>Tips gathered after too-many trial-and-error attempts. Note: Singularity was renamed to <a href="https://apptainer.org/">Apptainer</a> in 2021, so if you’re setting this up today look for the equivalent config under that name too.</p>

<h2 id="failed-to-set-effective-uid-to-0">Failed to set effective UID to 0</h2>

<p>From <a href="https://github.com/hpcng/singularity/issues/1258">this GitHub issue</a> I got that the easiest way is to look for a <code class="language-plaintext highlighter-rouge">singularity.conf</code> file and change <code class="language-plaintext highlighter-rouge">allow setuid=yes</code> to <code class="language-plaintext highlighter-rouge">allow setuid=no</code>. That file should be located in your Singularity installation directory. If you used spack for the installation, the path would look something like this:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/path/to/spack/opt/spack/linux-scientific7-haswell/gcc-4.8.5/singularity-3.5.2-k2cgya4v4mjzvfay2n4jfmy7wbda5ucq/etc/singularity/singularity.conf
</code></pre></div></div>

<p>See also: <a href="/blog/how-to-fmriprep-singularity/">how to run fmriprep on an HPC cluster with Singularity</a>.</p>]]></content><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><category term="Singularity" /><category term="HPC" /><category term="tutorial" /><summary type="html"><![CDATA[Tips gathered after too-many trial-and-error attempts.]]></summary></entry><entry><title type="html">How to run fmriprep (and not die trying)</title><link href="https://ortiztudela.github.io//blog/how-to-fmriprep/" rel="alternate" type="text/html" title="How to run fmriprep (and not die trying)" /><published>2021-01-15T00:00:00+01:00</published><updated>2021-01-15T00:00:00+01:00</updated><id>https://ortiztudela.github.io//blog/how-to-fmriprep</id><content type="html" xml:base="https://ortiztudela.github.io//blog/how-to-fmriprep/"><![CDATA[<p>If you are here you probably already know about <a href="https://fmriprep.org/en/stable/usage.html">fmriprep</a> and <a href="https://bids.neuroimaging.io/">BIDS</a>, so no need to get into that. Let’s get started.</p>

<p>The easiest way to use fmriprep is through a Docker container (learn more about them <a href="https://opensource.com/resources/what-docker">here</a>). You need to install it in your system in case it is not there yet (click <a href="https://docs.docker.com/get-docker/">here</a> to learn how to). Bear in mind that, in order to use Docker, you need admin rights in your system. In case you cannot get those, <a href="/blog/how-to-fmriprep-singularity/">you can use Singularity instead</a>.</p>

<p>Below you will find an example shell script that I use to make the fmriprep call using Docker (original source <a href="https://gitlab.com/ortizTud/neuroim-methods/-/blob/master/resources/example-fmriprep_local.sh">here</a>).</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">##########################################################################</span>
<span class="c"># fmriprep</span>
<span class="c">##########################################################################</span>
<span class="c"># This script runs a docker image of fmriPrep on files on BIDS format.</span>
<span class="c">#</span>
<span class="c"># Javier Ortiz-Tudela (ortiz-tudela@psych.uni-frankfurt.de)</span>
<span class="c">##########################################################################</span>

<span class="c">### Input in the study info here #####</span>

<span class="c"># Which subject are you preprocessing?</span>
<span class="nv">which_sub</span><span class="o">=</span>999

<span class="c"># Where is your project located?</span>
<span class="nv">project_path</span><span class="o">=</span>~/path/to/project/

<span class="c">### Now I will build some names for you ####</span>

<span class="c"># Build BIDS and output folders paths</span>
<span class="nv">bids_path</span><span class="o">=</span><span class="nv">$project_path</span>/BIDS
<span class="nv">out_path</span><span class="o">=</span><span class="nv">$project_path</span>/BIDS/derivatives

<span class="c"># Build license folder path</span>
<span class="nv">lic_path</span><span class="o">=</span><span class="nv">$project_path</span>/

<span class="c">#----START PREPROCESSING ------#</span>
<span class="nb">sudo </span>docker run <span class="nt">-ti</span> <span class="nt">--rm</span> <span class="se">\</span>
  <span class="nt">-v</span> <span class="nv">$bids_path</span>/:/data:ro <span class="se">\</span>
  <span class="nt">-v</span> <span class="nv">$out_path</span>/:/output <span class="se">\</span>
  <span class="nt">-v</span> <span class="nv">$lic_path</span>/:/lic <span class="se">\</span>
  nipreps/fmriprep:latest <span class="se">\</span>
  /data /output <span class="se">\</span>
  participant <span class="se">\</span>
  <span class="nt">--participant_label</span> <span class="nv">$which_sub</span> <span class="se">\</span>
  <span class="nt">--fs-license-file</span> /lic/license.txt
</code></pre></div></div>

<p>Just place this snippet of code on your machine, adapt the paths to match yours, and select which options you want to turn on or off for fmriprep (check the full list <a href="https://fmriprep.org/en/stable/usage.html">here</a>). Most of the things can be set to default, but there are a few options that you will probably want to fiddle with:</p>

<ul>
  <li><strong>Options for handling performance</strong>: fmriprep runs some heavy stuff on your images, so you might want to restrict how much of your machine’s power it can harvest. Find <a href="https://fmriprep.org/en/stable/faq.html#how-much-cpu-time-and-ram-should-i-allocate-for-a-typical-fmriprep-run">here the recommendations from their site</a>. I would not recommend less than 10-12 GB of RAM for one subject. Use the number-of-threads argument to restrict the number of subprocesses run in parallel (too many things in parallel will max out your RAM and crash the entire thing!).</li>
  <li><strong><code class="language-plaintext highlighter-rouge">--output-spaces</code></strong>: your preprocessed data will be resampled into whichever space you put here. You can specify the space and the resolution (this last option is only available for standard spaces). See <a href="https://fmriprep.org/en/stable/spaces.html">here</a> a more detailed guide on spaces. NOTE: If you want to use AROMA in fmriprep to clean your data, you can only use <code class="language-plaintext highlighter-rouge">MNI152NLin6Asym</code>; if you want to preprocess your data with fmriprep and then run AROMA manually, that is also possible.</li>
</ul>

<p>Getting the whole thing running for the first time might sound daunting, but after you have done it once for one dataset (and computer), it will be super easy to run more people and to transfer that knowledge to new projects.</p>]]></content><author><name>Javier Ortiz-Tudela</name><email>ortiztudela@ugr.es</email></author><category term="fMRI" /><category term="fMRIPrep" /><category term="Docker" /><category term="tutorial" /><summary type="html"><![CDATA[If you are here you probably already know about fmriprep and BIDS, so no need to get into that. Let’s get started.]]></summary></entry></feed>