fmriprep-docker

Menu

Loading wiki pages...

View
Wiki Version:
<h2>fmriprep-docker</h2> <hr> <p>fmriprep-docker is a light weight python wrapper for the BIDS app, fmriprep, allowing fmriprep to be run from within a Docker environment. It requires Docker and python to be installed, as well as an active internet connection. Additionally, as fmriprep is a BIDS app, the input image files must have BIDS-format filenames and be stored in a BIDS-format directory that passes the BIDS validator.</p> <p>@[toc]</p> <h2>General Installation Instructions</h2> <ol> <li>Follow the instructions <a href="https://osf.io/k89fh/wiki/Docker" rel="nofollow">here</a> for installing Docker on your system.</li> <li>Ensure that you have python (python 3.7 preferred) installed on your system. If not, probably easiest to install the python 3.7 <a href="https://www.anaconda.com/distribution/" rel="nofollow">Anaconda Distribution</a>.</li> <li>You will need a Freesurfer license file, even if you are planning on running the fmriprep pipeline without Freesurfer. A Freesurfer license can be obtained by registering for free at the following website: <a href="https://surfer.nmr.mgh.harvard.edu/registration.html" rel="nofollow">https://surfer.nmr.mgh.harvard.edu/registration.html</a></li> </ol> <p><strong>N.B.</strong>: If Freesurfer does not include a license.txt file as an attachment to the email with your Freesurfer license information, copy the four lines beginning with your email address into an empty Matlab .m file and save out as a .txt file. Do NOT use any other text editor to save out these four lines.</p> <hr> <h3>Mac OS</h3> <ol> <li>Launch Docker. (It may take a few minutes for it to start up.)</li> <li> <p>Open the Preferences menu for Docker and make sure that all of the needed parent directories are listed under the File Sharing tab. If not, add the needed parent directories. Click Apply and Restart to adopt the changes. ![MacFileSharing](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1650dc8a17d5001804f277?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1650dc8a17d5001804f277?mode=render</a> =50%x)</p> </li> <li> <p>From the Disk tab, you can change the amount of storage allocated to the Docker Engine. ![MacDisk](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d16512c1385c10017538c1d?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d16512c1385c10017538c1d?mode=render</a> =50%x)</p> </li> <li> <p>Still in the Preferences menu, use the Advanced tab to set the parameters for the Docker Engine. Again click on Apply and Restart to adopt the changes.<strong>N.B.: The Docker Engine is configured to access 2GM RAM by default. It is recommended to assign at least 8GB of RAM to the Docker Engine.</strong> ![MacAdvanced](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1651d58a17d5001804f3ad?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1651d58a17d5001804f3ad?mode=render</a> =50%x)</p> </li> <li> <p>Open a Terminal window and follow the fmriprep <a href="https://fmriprep.readthedocs.io/en/stable/installation.html" rel="nofollow">documentation</a> for installing the fmriprep-docker function. From your home directory, type the following at the Terminal command prompt:</p> </li> </ol> <pre class="highlight"><code>pip install --user --upgrade fmriprep-docker</code></pre> <ol> <li>Make note of the directory in which fmriprep-docker is installed. For the above command with <code>--user</code> specified, the location should be:</li> </ol> <pre class="highlight"><code>/Users/&lt;username&gt;/.local/bin</code></pre> <ol> <li>Make sure that the fmriprep-docker directory is in your PATH. In your .bashrc file (<code>~/.bashrc</code>), add the following lines to add the fmriprep-docker path to PATH and create an alias for the fmriprep-docker command:</li> </ol> <pre class="highlight"><code>export PATH=$PATH:/Users/&lt;username&gt;/.local/bin alias fmriprep-docker='/Users/&lt;username&gt;/.local/bin/fmriprep-docker'</code></pre> <ol> <li>Save out the changes to .bashrc, and from the Terminal command prompt type the following from your home directory (<code>~/</code>) to have the new changes take effect. <strong>N.B.: When launching Docker and Terminal each time, you may need to re-execute this command for Docker to find fmriprep-docker again.</strong> </li> </ol> <pre class="highlight"><code>source .bashrc </code></pre> <ol> <li>With Docker running, from a Terminal command prompt, type:</li> </ol> <pre class="highlight"><code>fmriprep-docker -h</code></pre> <p>to check the installation and get the usage statement. If prompted to install the latest fmriprep image, accept. <strong>N.B.: Once an image of fmriprep has been installed, users should refrain (if prompted) from installing the latest version to ensure that all data are being run through the same version of the fmriprep pipeline.</strong></p> <ol> <li>At this point fmriprep-docker should be ready to use.</li> </ol> <hr> <h3>Windows</h3> <ol> <li>Launch Docker.</li> <li> <p>If you get the following pop-up error message when launching Docker, you most likely do not have <a href="https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/hyper-v-technology-overview" rel="nofollow">Hyper-V</a> or virtualization enabled on your system. ![DockersWindowErrorPopUp](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5cd6719dae001934b83a?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5cd6719dae001934b83a?mode=render</a> =50%x)</p> </li> <li> <p>You can check whether virtualization is enabled from the Performance tab of the Task Manager menu. ![WindowsTaskManager](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5de7719dae0017340e9a?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5de7719dae0017340e9a?mode=render</a> =50%x)</p> </li> <li> <p>First follow the Visualization section on the <a href="https://docs.docker.com/docker-for-windows/troubleshoot/" rel="nofollow">Docker for Windows troubleshooting guide</a> for enabling (or installing if necessary) Hyper-V. During this process, make sure that the following Windows Features are enabled: Containers, Hyper-V, and Virtualization. ![WindowsFeatures](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5d5efe43a100162285bb?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e5d5efe43a100162285bb?mode=render</a> =50%x)</p> </li> <li> <p>In order to enable virtualization, access PC BIOS. The following <a href="https://support.bluestacks.com/hc/en-us/articles/115003910391-How-can-I-enable-virtualization-VT-on-my-PC-" rel="nofollow">website</a> outlines several ways of accessing the PC BIOS menu depending on Windows version and PC brand. (Scroll down part way to: <em>2. How can I enable virtualization, if available but disabled on my PC?</em>) Users located in BMI/WIRB should contact Haitao Yang (htyang AT uwo DOT ca) if they have any questions about and/or experience any difficulties enabling virtualization.</p> </li> <li> <p>Once Hyper-V and Virtualization have been enabled, the Docker Desktop for Windows menu can be opened by right-clicking on the Docker icon in the Notifications area or System tray. ![DockerDesktopforWindows](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a051385c10018531955?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a051385c10018531955?mode=render</a> =50%x) </p> </li> <li> <p>Select Settings to access the settings for the Docker Engine.</p> </li> <li> <p>Under Shared Drives, it is vital that you make sure that all relevant local drives are shared with Docker. <strong>N.B.: Per the Docker for Windows <a href="https://docs.docker.com/docker-for-windows/" rel="nofollow">website</a>, shared drives are tied to specific Windows user credentials. So a user logged into another account on the same computer will also need to complete this step.</strong> ![WindowsSharedDrives](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a4e7c9eb700172c2251?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a4e7c9eb700172c2251?mode=render</a> =50%x)</p> </li> <li> <p>Under Advanced, set at least 8GB RAM (Memory) for the Docker Engine (See note above in Step 4 of Mac OS instructions). ![WindowsAdvanced](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a868a17d5001904d2b2?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d165a868a17d5001904d2b2?mode=render</a> =50%x)</p> </li> <li> <p>With Docker running, open a Anaconda Prompt window and type the following to install fmriprep-docker:</p> </li> </ol> <pre class="highlight"><code>pip install --user --upgrade fmriprep-docker</code></pre> <ol> <li>Once fmriprep-docker is succesfully installed, make note of the installation directory (listed in the yellow text following the installation log). It will most likely be:</li> </ol> <pre class="highlight"><code>C:\Users\&lt;username&gt;\AppData\Roaming\Python\Python37\Scripts</code></pre> <p>![fmriprepInstallationLocation](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e6305719dae0016340eb5?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e6305719dae0016340eb5?mode=render</a> =100%x)</p> <ol> <li>In order to be able to run fmriprep-docker, its location needs to be added to the Windows Environmental Path variable. The following <a href="https://www.datacamp.com/community/tutorials/installing-anaconda-windows" rel="nofollow">website</a> includes instructions for editing the Windows Environmental Path variable. In this case, you will want to replace the anaconda path location with the path location of fmriprep-docker. (Scroll down to: <em>Add Anaconda to Path (Optional)</em>.) </li> <li> <p><strong>For older versions of Windows:</strong> Open the Windows Environmental Variables menu, select Path from the User variables, and click Edit. From there, append the existing list of paths with the location of <code>fmriprep-docker.exe</code>, using a semi-colon (<code>;</code>) to separate the fmriprep-docker path from the previous path in the list. Quit and restart Anaconda Prompt. ![WindowsEnvironmentalVariables](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e65f462a17300173857ec?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d1e65f462a17300173857ec?mode=render</a> =50%x) <strong>For newer versions of Windows:</strong> Open the Windows Environmental Variables menu, select Path from the User variables, and click Edit. Click 'New' to create a new entry to the Path variable and enter the fmriprep-docker path in the blank. Quit and restart Anaconda Prompt. ![WindowsPathDialog](<a href="https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d3f6eba532261001cda3e68?mode=render" rel="nofollow">https://files.osf.io/v1/resources/k89fh/providers/osfstorage/5d3f6eba532261001cda3e68?mode=render</a> =50%x)</p> </li> <li> <p>Back in the Anaconda Prompt window, you can test whether <code>fmriprep-docker.exe</code> has been successfully added to your Path variable by typing the following command to get the usage statement:</p> </li> </ol> <pre class="highlight"><code>fmriprep-docker -h</code></pre> <ol> <li>If the usage statement appears and this is a new installation of fmriprep-docker, go ahead and type 'Y' to accept the installation of the latest fmriprep container. If the you still get the message about fmriprep-docker not being in your PATH, restart your computer to force the changes you made in step 12 to take affect. Then try again with steps 13 and 14. <strong>N.B.: As with the Mac OS installation, once you have begun to preprocess data using fmriprep, you do NOT want to update the fmriprep container unless you intend to re-preprocess all of the data for a given study with the new version of the container.</strong></li> </ol> <hr> <h2>Examples of common fmriprep-docker usage statements</h2> <p>Below are several examples of usage statements for fmriprep-docker covering some of the more common options. This list is by no means exhaustive, and users are encouraged to consult the fmriprep <a href="https://fmriprep.readthedocs.io/en/stable/usage.html" rel="nofollow">usage documentation</a> for information on all options.</p> <p><strong>N.B.: When specifying an output (or working) directory for fmriprep-docker to write to, make sure the output (or working) directory is not located inside the BIDS directory.</strong></p> <h3>Basic usage</h3> <p>The following will run the basic fmriprep pipeline including Freesurfer. No intermediate output will be saved. The pipeline will be run on <strong>all</strong> subjects in <code>&lt;bidsDir&gt;</code>.</p> <pre class="highlight"><code>fmriprep-docker &lt;bidsDir&gt; &lt;outputDir&gt; participant --fs-license-file &lt;full path to Freesurfer license.txt&gt;</code></pre> <p>On a Mac, the above command will look something like this:</p> <pre class="highlight"><code>fmriprep-docker /Users/JaneDoe/Documents/fMRIStudy/bids /Users/JaneDoe/Documents/fMRIStudy/fmriprep_output participant --fs-license-file /Users/JaneDoe/Documents/freesurfer/license.txt</code></pre> <p>On a Windows machine, the above command will look something like this:</p> <pre class="highlight"><code>fmriprep-docker C:\Users\JaneDoe\Documents\fMRIStudy\bids C:\Users\JaneDoe\Documents\fMRIStudy\fmriprep_output participant --fs-license-file C:\Users\JaneDoe\Documents\freesurfer\license.txt</code></pre> <h3>Single subject</h3> <p>To run fmriprep on a specific subject, rather than all subjects contained in a BIDS directory, you can specify a single subject ID (omitting the <code>sub-</code> prefix).</p> <pre class="highlight"><code>fmriprep-docker &lt;bidsDir&gt; &lt;outputDir&gt; participant --fs-license-file &lt;full path to Freesurfer license.txt&gt; --participant-label &lt;bidsSubjectID&gt;</code></pre> <p><strong>N.B.: The fmriprep-docker people recommend running the docker version of the fmriprep pipeline on a single subject at a time. If you are based at Western and need a more efficient way to run fmriprep (e.g., submitting multiple subjects at a time), please see the documentation for getting started with Compute Canada <a href="https://osf.io/k89fh/wiki/Compute%20Canada/" rel="nofollow">here</a> and the documentation for running BIDS apps on Compute Canada <a href="https://osf.io/k89fh/wiki/neuroglia-helpers/" rel="nofollow">here</a>.</strong></p> <h3>Omitting Freesurfer</h3> <p>If processing time or memory constraints may be an issue, Freesurfer can be omitted.</p> <pre class="highlight"><code>fmriprep-docker &lt;bidsDir&gt; &lt;outputDir&gt; participant --fs-license-file &lt;full path to Freesurfer license.txt&gt; --fs-no-reconall</code></pre> <h3>Saving out intermediate output</h3> <p>To save the intermediate output, specify the location of a working directory. Using this option requires more disk storage. This option, though, can save time if fmriprep exits with an error, as re-executing the exact same fmriprep-docker command again will skip over any modules that have already been run without error. (The working directory can be safely deleted after successful completion of fmriprep pipeline on all subjects in a given BIDS directory.)</p> <pre class="highlight"><code>fmriprep-docker &lt;bidsDir&gt; &lt;outputDir&gt; participant --fs-license-file &lt;full path to Freesurfer license.txt&gt; -w &lt;workingDir&gt;</code></pre> <h3>General procedure for including options</h3> <p>The fmriprep-docker command will take multiple options. Options can be specified in any order <strong>but must be specified after the mandatory inputs of</strong> <code>&lt;bidsDir&gt;</code>, <code>&lt;outputDir&gt;</code>, <code>participant</code>. For example, to run fmriprep on a single subject, omitting Freesurfer, the following commmand can be used:</p> <pre class="highlight"><code>fmriprep-docker &lt;bidsDir&gt; &lt;outputDir&gt; participant --fs-license-file &lt;full path to Freesurfer license.txt&gt; --participant-label &lt;bidsSubjectID&gt; --fs-no-reconall</code></pre> <hr> <h2>Additional Resources</h2> <ol> <li>Stanford Center for Reproducible Neuroscience fmriprep-docker <a href="http://reproducibility.stanford.edu/fmriprep-tutorial-running-the-docker-image/" rel="nofollow">tutorial</a> </li> <li>Help forum: <a href="https://neurostars.org/" rel="nofollow">https://neurostars.org/</a></li> </ol> <hr> <h2>Appendix</h2> <h3>Unix commands and Windows CMD equivalents</h3> <p>|Description |Unix Command | CMD Command | |------------|-------------|-------------| |Current directory | . | . | |One directory up from current directory | .. | ..| |Print current directory | pwd | cd | |List directory contents, list details, list hidden items |ls, ls -l, ls -a | dir, dir /N, dir /H | |Clear terminal screen |clear | cls | |Remove file, directory |rm &lt;filename&gt;, rm -r &lt;dirname&gt; | erase &lt;filename&gt;, rmdir &lt;dirname&gt;| |Copy file, directory |cp &lt;filename&gt;, cp -r &lt;dirname&gt;| copy &lt;filename&gt; or &lt;dirname&gt; | |Move file, directory |mv | move | |Rename file, directory |mv | rename | |Display text file contents |cat | type | |Change directory |cd &lt;dirpath&gt; | cd &lt;dirpath&gt; | |Make new directory |mkdir &lt;dirname&gt; | md &lt;dirname&gt; | |Temporarily save path |pushd | pushd | |Return to path saved in pushd |popd | popd | |Find path of command | which &lt;commandname&gt; | where &lt;commandname&gt; | |Display full path of file | realpath &lt;dirname&gt; or &lt;filename&gt; | dir /S /B &lt;dirname&gt; or &lt;filename&gt; | |Make symbolic link of directory | ln -s &lt;dirpath&gt; &lt;linkpath&gt; | mklink /d &lt;dirpath&gt; &lt;linkpath&gt;&lt;/linkpath&gt;&lt;/dirpath&gt;&lt;/linkpath&gt;&lt;/dirpath&gt;&lt;/filename&gt;&lt;/dirname&gt;&lt;/filename&gt;&lt;/dirname&gt;&lt;/commandname&gt;&lt;/commandname&gt;&lt;/dirname&gt;&lt;/dirname&gt;&lt;/dirpath&gt;&lt;/dirpath&gt;&lt;/dirname&gt;&lt;/filename&gt;&lt;/dirname&gt;&lt;/filename&gt;&lt;/dirname&gt;&lt;/filename&gt;&lt;/dirname&gt;&lt;/filename&gt;</p> <p>Adapted from <a href="https://docs.microsoft.com/en-us/powershell/scripting/samples/appendix-1---compatibility-aliases?view=powershell-6" rel="nofollow">here</a>.</p> <h2>Acknowledgements</h2> <p>A big thank you to Lien Peters, Aysha Motala, and Cassie Lowe for their help in correcting and clarifying the Windows instructions and usage statements.</p>
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.