<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20190208//EN" "http://jats.nlm.nih.gov/publishing/1.2/JATS-journalpublishing1.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="other" dtd-version="1.2" xml:lang="en">
    <front>
        <journal-meta>
            <journal-id journal-id-type="pmc">F1000Research</journal-id>
            <journal-title-group>
                <journal-title>F1000Research</journal-title>
            </journal-title-group>
            <issn pub-type="epub">2046-1402</issn>
            <publisher>
                <publisher-name>F1000 Research Limited</publisher-name>
                <publisher-loc>London, UK</publisher-loc>
            </publisher>
        </journal-meta>
        <article-meta>
            <article-id pub-id-type="doi">10.12688/f1000research.14361.1</article-id>
            <article-categories>
                <subj-group subj-group-type="heading">
                    <subject>Software Tool Article</subject>
                </subj-group>
                <subj-group>
                    <subject>Articles</subject>
                </subj-group>
            </article-categories>
            <title-group>
                <article-title>
                    <italic>freesurfer</italic>: Connecting the Freesurfer software with R</article-title>
                <fn-group content-type="pub-status">
                    <fn>
                        <p>[version 1; peer review: 2 approved]</p>
                    </fn>
                </fn-group>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author" corresp="yes">
                    <name>
                        <surname>Muschelli</surname>
                        <given-names>John</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Formal Analysis</role>
                    <role content-type="http://credit.niso.org/">Software</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Original Draft Preparation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <uri content-type="orcid">https://orcid.org/0000-0001-6469-1750</uri>
                    <xref ref-type="corresp" rid="c1">a</xref>
                    <xref ref-type="aff" rid="a1">1</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Sweeney</surname>
                        <given-names>Elizabeth</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Validation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a2">2</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Crainiceanu</surname>
                        <given-names>Ciprian M.</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Supervision</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a1">1</xref>
                </contrib>
                <aff id="a1">
                    <label>1</label>Department of Biostatistics, Johns Hopkins Bloomberg School of Public Health, Baltimore, MD, 21205, USA</aff>
                <aff id="a2">
                    <label>2</label>Flatiron Health, New York, NY, 10010, USA</aff>
            </contrib-group>
            <author-notes>
                <corresp id="c1">
                    <label>a</label>
                    <email xlink:href="mailto:muschellij2@gmail.com">muschellij2@gmail.com</email>
                </corresp>
                <fn fn-type="conflict">
                    <p>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>16</day>
                <month>5</month>
                <year>2018</year>
            </pub-date>
            <pub-date pub-type="collection">
                <year>2018</year>
            </pub-date>
            <volume>7</volume>
            <elocation-id>599</elocation-id>
            <history>
                <date date-type="accepted">
                    <day>11</day>
                    <month>5</month>
                    <year>2018</year>
                </date>
            </history>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Muschelli J et al.</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <self-uri content-type="pdf" xlink:href="https://f1000research.com/articles/7-599/pdf"/>
            <abstract>
                <p>We present the package 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/freesurfer/index.html">
                        <bold>freesurfer</bold>
                    </ext-link>, a set of R functions that interface with Freesurfer, a commonly-used open-source software package for processing and analyzing structural neuroimaging data, specifically T1-weighted images. The 
                    <bold>freesurfer</bold> package performs operations on 
                    <monospace>nifti</monospace> image objects in R using command-line functions from Freesurfer, and returns R objects back to the user. 
                    <bold>freesurfer</bold> allows users to process neuroanatomical images and provides functionality to convert and read the output of the Freesurfer pipelines more easily, including brain images, brain surfaces, and Freesurfer output tables.</p>
            </abstract>
            <kwd-group kwd-group-type="author">
                <kwd>freesurfer</kwd>
                <kwd>r</kwd>
                <kwd>neuroconductor</kwd>
                <kwd>neuroimaging</kwd>
            </kwd-group>
            <funding-group>
                <award-group id="fund-1" xlink:href="http://dx.doi.org/10.13039/100000002">
                    <funding-source>National Institutes of Health</funding-source>
                    <award-id>R01HL123407</award-id>
                    <award-id>R01NS060910</award-id>
                </award-group>
                <funding-statement>These efforts were supported by NIH grants R01HL123407 and R01NS060910.</funding-statement>
                <funding-statement>
                    <italic>The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.</italic>
                </funding-statement>
            </funding-group>
        </article-meta>
    </front>
    <body>
        <sec sec-type="intro">
            <title>Introduction</title>
            <p>Freesurfer is a commonly-used software for processing and analyzing anatomical neuroimaging data
                <sup>
                    <xref ref-type="bibr" rid="ref-1">1</xref>
                </sup>, developed by the Laboratory for Computational Neuroimaging at the Athinoula A. Martinos Center for Biomedical Imaging. This software provides open-source, command-line tools for image processing tasks such as brain extraction/skull-stripping
                <sup>
                    <xref ref-type="bibr" rid="ref-2">2</xref>
                </sup>, bias-field correction
                <sup>
                    <xref ref-type="bibr" rid="ref-3">3</xref>
                </sup>, segmentation of structures within the brain
                <sup>
                    <xref ref-type="bibr" rid="ref-4">4</xref>,
                    <xref ref-type="bibr" rid="ref-5">5</xref>
                </sup>, and image registration
                <sup>
                    <xref ref-type="bibr" rid="ref-6">6</xref>,
                    <xref ref-type="bibr" rid="ref-7">7</xref>
                </sup>. In addition to these functions, Freesurfer has functions that perform fully-automated pipelines for the user.</p>
            <p>There exist a number of R packages for reading and manipulating image data, including 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/AnalyzeFMRI/index.html">
                    <bold>AnalyzeFMRI</bold>
                </ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-8">8</xref>
                </sup> and 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/fmri/index.html">
                    <bold>fmri</bold>
                </ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-9">9</xref>
                </sup>, which analyze functional magnetic resonance images (MRI) and perform spatial smoothing, 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/RNiftyReg/index.html">
                    <bold>RNiftyReg</bold>
                </ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-10">10</xref>
                </sup>, which performs image registration, and 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/dpmixsim/index.html">
                    <bold>dpmixsim</bold>
                </ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-11">11</xref>
                </sup> and 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/mritc/index.html">
                    <bold>mritc</bold>
                </ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-12">12</xref>
                </sup>, which perform image clustering and segmentation (see the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/views/MedicalImaging.html">Medical Imaging CRAN task view</ext-link> for more information). These packages provide powerful tools for performing image analysis, but the neuroimaging community has additional tools that may perform better on a specific data set or provide more information than these R packages. Freesurfer provides methods that are not currently implemented in R, including surface-based registration and completely automated image segmentation pipelines. The 
                <ext-link ext-link-type="uri" xlink:href="https://github.com/ANTsX/ANTsR">
                    <bold>ANTsR</bold>
                </ext-link> package is a currently unpublished R package where additional image analysis functionality has been implemented, but does not include all the functionality Freesurfer has. Moreover, having multiple options for image processing through R enables users to compare methods and provides the flexibility of using multiple packages to achieve a working data processing pipeline.</p>
            <p>We provide an interface to users for the state-of-the-art anatomical processing implemented in Freesurfer, as well as a suite of tools that simplify analyzing the output of Freesurfer. The 
                <bold>freesurfer</bold> package allows R users to perform a complete anatomical imaging analyses without necessarily learning Freesurfer-specific syntax, while keeping both the image processing and analysis within R.</p>
        </sec>
        <sec sec-type="methods">
            <title>Methods</title>
            <sec>
                <title>R function setup</title>
                <p>To use 
                    <bold>freesurfer</bold>, a working installation of Freesurfer is required (downloads available: 
                    <ext-link ext-link-type="uri" xlink:href="http://freesurfer.net/fswiki/DownloadAndInstall">http://freesurfer.net/fswiki/DownloadAndInstall</ext-link>). The following code was run using Freesurfer version &#x201c;freesurfer-Darwin-lion-stable-pub-v5.3.0&#x201d;. The Freesurfer version can be accessed using the 
                    <bold>freesurfer</bold> 
                    <monospace>fs_version</monospace> function. The path of Freesurfer must also be set. When using R from a shell environment, after the 
                    <monospace>FREESURFER_HOME</monospace> environment variable is set (which is done when installing Freesurfer), 
                    <bold>freesurfer</bold> will use this as the path to Freesurfer. If using R through a graphical user interface (GUI) such as RStudio (RStudio, Boston, MA), environmental variables and paths are not explicitly exported. Therefore, 
                    <monospace>FREESURFER_HOME</monospace> is not set and 
                    <bold>freesurfer</bold> will try the default directories of Mac OSX and Linux. Freesurfer is only available on Windows via a virtual machine. If the user did not perform a standard installation of Freesurfer, the path to Freesurfer can be specified using 
                    <monospace>options(freesurfer.path="/path/to/freesurfer")</monospace>. The 
                    <monospace>have_fs</monospace> function tests whether a user has a Freesurfer installation, returning a logical, which is useful for 
                    <monospace>if</monospace> statements within examples. If 
                    <monospace>have_fs</monospace> function returns is TRUE, the 
                    <monospace>fs_dir</monospace> function will return the directory of the Freesurfer installation.</p>
            </sec>
            <sec>
                <title>Operation</title>
                <p>As per the 
                    <ext-link ext-link-type="uri" xlink:href="https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall">https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall</ext-link>, Freesurfer only works on Linux or Mac operating systems. The work station should have at least a 2GHz processor, over 8GB of RAM, over 10GB hard drive space, and FSL
                    <sup>
                        <xref ref-type="bibr" rid="ref-13">13</xref>
                    </sup> installed for certain functions.</p>
            </sec>
            <sec>
                <title>Structure of Freesurfer analyses</title>
                <p>During the installation of Freesurfer, environment variables in addition to 
                    <monospace>FREESURFER_HOME</monospace> are set. One of these variables is 
                    <monospace>SUBJECTS_DIR</monospace>, which refers to a directory of the output of analysis from all subjects. The 
                    <monospace>fs_subj_dir</monospace> function will return the path to the Freesurfer subjects directory if it is set. This default setup of a subjects directory in Freesurfer allows users to simply specify a subject identifier to analyze, rather than a specific path or multiple intermediate files.</p>
                <p>This setup may not be desirable if the user prefers to structure his or her data differently. For example, if data from multiple studies are present, these may be organized into different folders in different locations. Some functions in Freesurfer rely on the 
                    <monospace>SUBJECTS_DIR</monospace> variable to run. These functions take the subject name as the main argument rather than a file, which is more common. To provide flexibility to the user, 
                    <bold>freesurfer</bold> allows most functions to specify a file or different directory rather than specifying the subject.</p>
                <p>One example is the 
                    <monospace>asegstats2table</monospace> Freesurfer function. Freesurfer performs segmentations of the anatomical image into different structures and has associated statistics for each region such as volume and mean intensity. The 
                    <monospace>asegstats2table</monospace> function transforms 
                    <bold>a</bold>natomical 
                    <bold>seg</bold>mentation 
                    <bold>stat</bold>istics from images into to a table. The default argument for 
                    <monospace>asegstats2table</monospace> is to pass in a subject name rather than a file. The 
                    <bold>freesurfer</bold> 
                    <monospace>asegstats2table</monospace> function allows the R user to specify the subject name, but also allows the user to alternatively specify a file name instead. This function will temporarily set 
                    <monospace>SUBJECTS_DIR</monospace> to a temporary directory, copy the file to that directory, execute the command, then reset the 
                    <monospace>SUBJECTS_DIR</monospace> variable. This provides a more flexible workflow, while not overriding the default directory set in 
                    <monospace>SUBJECTS_DIR</monospace>. This functionality allows users to have separate folders with subjects and read in the data by simply switching the 
                    <monospace>subj_dir</monospace> argument in the R function.</p>
            </sec>
            <sec>
                <title>Reconstruction pipeline in Freesurfer</title>
                <p>The Freesurfer pipeline and analysis workflow for neuroanatomical images is designed to work with T1-weighted structural MRI of the brain. The full pipeline is implemented in the Freesurfer 
                    <monospace>recon-all</monospace> function, where the &#x201c;recon&#x201d; stands for reconstruction (
                    <ext-link ext-link-type="uri" xlink:href="https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all">https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all</ext-link>). The 
                    <monospace>recon-all</monospace> function is the main workhorse of Freesurfer and is the most commonly used. Using the 
                    <monospace>-all</monospace> flag in the the 
                    <monospace>recon-all</monospace> function performs over 30 different steps and takes 20&#x2013;40 hours to fully process a subject (
                    <ext-link ext-link-type="uri" xlink:href="https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all">https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all</ext-link>). This process is the recommended way of fully processing a T1-weighted image in Freesurfer, and is implemented in the 
                    <monospace>recon_all</monospace> 
                    <bold>freesurfer</bold> function.</p>
                <p>In the 
                    <monospace>recon_all</monospace> function, users must specify the input file (a T1-weighted image), the output directory (if different than 
                    <monospace>SUBJECTS_DIR</monospace>), and the subject identifier. The results will be written in the individual subject directory, a sub-directory of 
                    <monospace>SUBJECTS_DIR</monospace>. The syntax is:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">recon_all(infile, outdir, subjid)</styled-content>
                    </preformat>
                </p>
                <p>If there are problems with the result of this processing, there are multiple steps where users can edit certain parts of the processing, such as brain extraction, where non-brain tissues are removed from the image. The remainder of the pipeline can be run after these steps are corrected. The full pipeline is broken down into 3 separate sets of steps, referred to as 
                    <monospace>autorecon1</monospace>, 
                    <monospace>autorecon2</monospace>, and 
                    <monospace>autorecon3</monospace>, which correspond to the same-named flags in 
                    <monospace>recon-all</monospace> used to initiate these steps. We have written wrapper functions 
                    <monospace>autorecon1</monospace>, 
                    <monospace>autorecon2</monospace>, and 
                    <monospace>autorecon3</monospace>, respectively, so users can run pieces of the pipeline if desired or restart a failed process after correction to the data.</p>
            </sec>
            <sec>
                <title>Imaging formats in 
                    <bold>freesurfer</bold> and R</title>
                <p>The 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/freesurfer/index.html">
                        <bold>freesurfer</bold>
                    </ext-link> package relies on the 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/oro.nifti/index.html">
                        <bold>oro.nifti</bold>
                    </ext-link>
                    <sup>
                        <xref ref-type="bibr" rid="ref-14">14</xref>
                    </sup> package implementation of images (referred to as 
                    <monospace>nifti</monospace> objects) that are in the Neuroimaging Informatics Technology Initiative (NIfTI) format. For Freesurfer functions that require an image, the R 
                    <bold>freesurfer</bold> functions that call those Freesurfer functions will take in a file name or a 
                    <monospace>nifti</monospace> object. The R code will convert the 
                    <monospace>nifti</monospace> to the corresponding input required for Freesurfer. From the user&#x2019;s perspective, the input/output process is all within R, with one object format (
                    <monospace>nifti</monospace>). The advantage of this approach is that the user can read in an image, do manipulations of the nifti object using standard syntax for arrays, and pass this object into the 
                    <bold>freesurfer</bold> R function. Thus, users can use R functionality to manipulate objects while seamlessly passing these object to Freesurfer through 
                    <bold>freesurfer</bold>.</p>
                <p>Other Freesurfer functions require imaging formats other than NIfTI, such as the 
                    <ext-link ext-link-type="uri" xlink:href="http://www.bic.mni.mcgill.ca/ServicesSoftware/MINC">Medical Imaging NetCDF (MINC) format</ext-link>. The Freesurfer installation provides functions to convert from MINC to NIfTI formats and these are implemented in functions such as 
                    <monospace>nii2mnc</monospace> and 
                    <monospace>mnc2nii</monospace> in R. Moreover, the 
                    <monospace>mri_convert</monospace> Freesurfer function has been interfaced in 
                    <bold>freesurfer</bold> (same function name), which allows for a more general conversion tool of imaging types for R users than currently implemented in native R. Thus, many formats can be converted to NIfTI and then read into R using the 
                    <monospace>readNIfTI</monospace> function from 
                    <bold>oro.nifti</bold>.</p>
            </sec>
        </sec>
        <sec>
            <title>Example analyses and use of functions</title>
            <sec>
                <title>Reconstruction</title>
                <p>For this paper, we will not run the analysis on a subject, but rather explore the output results for a subject included in the Freesurfer installation for reproducibility for the user. In particular, in the default Freesurfer subjects directory, there is a subject named &#x201c;bert&#x201d;. If we were to run all the analyses, we would use the 
                    <monospace>recon_all</monospace> code (described below):</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">recon_all(infile = "/path/to/T1.nii", subjid = "bert")</styled-content>
                    </preformat>
                </p>
                <p>We see the result of this output in the &#x201c;bert&#x201d; directory, which includes a series of sub-directories:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">list.files(path  = file.path(fs_subj_dir(),  "bert"))

 [1] "bem"     "label"   "mri"     "scripts"  "src"    "stats"  "surf"
 [8] "tmp"     "touch"   "trash"</styled-content>
                    </preformat>
                </p>
                <p>We will explore the results in &#x201c;mri&#x201d;, which contain imaging data, &#x201c;stats&#x201d;, which containing statistics based on structures of the brain, and &#x201c;surf&#x201d;, which contain the surface and curvature output from the Freesurfer processing.</p>
            </sec>
            <sec>
                <title>MRI conversion: The 
                    <monospace>mri convert</monospace> function</title>
                <p>The typical output format of brain volumes from Freesurfer is MGH/MGZ format, which is explained here: 
                    <ext-link ext-link-type="uri" xlink:href="https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat">https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat</ext-link>. As NIfTI formats are one of the most common formats and has been the common format for analysis in the 
                    <bold>oro.nifti</bold> and 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/neurobase/index.html">
                        <bold>neurobase</bold>
                    </ext-link> packages, it is useful to convert these files to a NIfTI format to read into R. The 
                    <monospace>mri_convert</monospace> Freesurfer function will be used for that conversion. Here we will use the T1-weighted image from the &#x201c;bert&#x201d; subject and convert it to NIfTI, and read it into R:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">library(freesurfer)

                            <styled-content style="font-size:15px;">bert_dir = file.path(fs_subj_dir(), "bert") # subject directory
t1_mgz = file.path(bert_dir, "mri", "T1.mgz") # mgz file
t1_nii_fname = tempfile(fileext = ".nii.gz") # temporary NIfTI file
freesurfer::mri_convert(t1_mgz, t1_nii_fname) # conversion
img = neurobase::readnii(t1_nii_fname) # read in outputs</styled-content>
                        </styled-content>
                    </preformat>
                </p>
                <p>As this is a commonly-used process, we have wrapped these two steps into the 
                    <monospace>readmgz</monospace> and 
                    <monospace>readmgh</monospace> functions, which combine the 
                    <monospace>mri_convert</monospace> and 
                    <monospace>readnii</monospace> functions. Here we show that these steps are equivalent to the 
                    <monospace>readmgz</monospace> function:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">img_mgz = readmgz(t1_mgz)
identical(img, img_mgz)

[1] TRUE</styled-content>
                    </preformat>
                </p>
                <p>Now that we have the image in R, we can plot it using the standard plotting tools for 
                    <monospace>nifti</monospace> objects:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">neurobase::ortho2(img, add.orient = FALSE, mask = img &gt; 40)</styled-content>
                    </preformat>
                </p>
                <p>The result is in 
                    <xref ref-type="fig" rid="f1">Figure 1</xref>, which contains 3 slices of the head: axially, viewing the brain from the top of the head (top left), sagittally, viewing the brain from the right side (top right) and coronally, viewing the brain from the back of the head (bottom left).</p>
                <fig fig-type="figure" id="f1" orientation="portrait" position="float">
                    <label>Figure 1. </label>
                    <caption>
                        <title>Plot of T1-weighted image from bert subject in Freesurfer.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure1.gif"/>
                </fig>
                <p>Note, the image is not stored in the right/posterior/inferior (RPI) orientation which is assumed when displaying using the 
                    <ext-link ext-link-type="uri" xlink:href="http://www.grahamwideman.com/gw/brain/orientation/orientterms.htm">
                        <bold>neurobase</bold> 
                        <monospace>ortho2</monospace> function</ext-link>. We can use the 
                    <monospace>rpi_orient</monospace> function in 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/fslr/index.html">
                        <bold>fslr</bold>
                    </ext-link> (version &#x2265; 2.4.0)
                    <sup>
                        <xref ref-type="bibr" rid="ref-15">15</xref>
                    </sup> or 
                    <monospace>fslswapdim</monospace> to reorient the image to the assumed orientation.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">L = fslr::rpi_orient(img)
reoriented_img = L[["img"]]</styled-content>
                    </preformat>
                </p>
                <p>We see that this function puts this image in the RPI orientation, which matches the assumed orientation for 
                    <monospace>ortho2</monospace>:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">neurobase::ortho2(reoriented_img, mask = reoriented_img  &gt;  40)</styled-content>
                    </preformat>
                </p>
                <p>The result is in 
                    <xref ref-type="fig" rid="f2">Figure 2</xref>, which changes the views in reference to which panel they are located and matches the orientation markers assumed by 
                    <monospace>ortho2</monospace>.</p>
                <fig fig-type="figure" id="f2" orientation="portrait" position="float">
                    <label>Figure 2. </label>
                    <caption>
                        <title>Plot of T1-weighted image from bert subject in Freesurfer after re-orientation to RPI orientation.</title>
                        <p>Note, the letters denote the orientation of right/left (R/L), posterior/anterior (P/A), inferior/superior (I/S).</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure2.gif"/>
                </fig>
            </sec>
            <sec>
                <title>Bias-field correction: The 
                    <monospace>nu correct</monospace> function</title>
                <p>MRI images typically exhibit good contrast between soft tissue classes, but intensity inhomogeneities in the radio frequency field can cause differences in the ranges of tissue types at different spatial locations (e.g. top versus bottom of the brain). These inhomogeneities/non-uniformities can cause problems with algorithms based on histograms, quantiles, or raw intensities
                    <sup>
                        <xref ref-type="bibr" rid="ref-16">16</xref>
                    </sup>. Therefore, correction for image inhomogeneities is a crucial step in many analyses. The Freesurfer function 
                    <monospace>nu_correct</monospace> performs the non-uniformity correction by Sled 
                    <italic toggle="yes">et al</italic>.
                    <sup>
                        <xref ref-type="bibr" rid="ref-3">3</xref>
                    </sup>, and the 
                    <bold>freesurfer</bold> function of the same name will run the correction and return an image. The Freesurfer 
                    <monospace>nu_correct</monospace> function requires a MINC format (
                    <ext-link ext-link-type="uri" xlink:href="http://www.bic.mni.mcgill.ca/ServicesSoftware/MINC">http://www.bic.mni.mcgill.ca/ServicesSoftware/MINC</ext-link>). For this to work, you can convert the 
                    <monospace>nifti</monospace> object to a MINC file using 
                    <monospace>nii2mnc</monospace>:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">mnc = nii2mnc(reoriented_img)
print(mnc)

[1] "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpHsAnD0/filec0c96f7f779e.mnc"</styled-content>
                    </preformat>
                </p>
                <p>We can pass this MINC file into the 
                    <bold>freesurfer</bold> 
                    <monospace>nu_correct</monospace> function, which will run the correction and then convert the output MNC to a NIfTI object.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">nu_from_mnc = nu_correct(file = mnc)
class(nu_from_mnc)

[1] "nifti"
attr(,"package")
[1] "oro.nifti"</styled-content>
                    </preformat>
                </p>
                <p>We see that the results are indeed 
                    <monospace>nifti</monospace> objects. We can plot the estimated bias field (log-transformed for display purposes) side-by-side with the image to view which areas had been differentially corrected (
                    <xref ref-type="fig" rid="f3">Figure 3</xref>).</p>
                <fig fig-type="figure" id="f3" orientation="portrait" position="float">
                    <label>Figure 3. </label>
                    <caption>
                        <title>Inhomogeneity-corrected image output from Freesurfer 
                            <monospace>nu_correct</monospace> command and the estimated log bias-field.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure3.gif"/>
                </fig>
                <p>In addition to the 
                    <monospace>readmgz</monospace> and 
                    <monospace>readmgh</monospace> functions above, we have a 
                    <monospace>readmnc</monospace> wrapper function for reading in MINC files, after conversion to NIfTI files. If you pass in a 
                    <monospace>nifti</monospace> object in directly into 
                    <monospace>nu_correct</monospace>, the function will automatically convert any NIfTI input files, and then run the correction (shown below). We can also pass in a mask of the brain (see next section) to run the correction only the areas of the brain.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">nu_masked = nu_correct(file = reoriented_img, mask = mask)
class(nu_masked)

[1] "nifti"
attr(,"package")
[1] "oro.nifti"</styled-content>
                    </preformat>
                </p>
                <p>Overall, this correction is a way to make the intensities of the brain more homogeneous spatially. This method is different from that implemented in FSL
                    <sup>
                        <xref ref-type="bibr" rid="ref-13">13</xref>
                    </sup> (and therefore 
                    <bold>fslr</bold>), so it provides an alternative method to the R user than currently available.</p>
            </sec>
            <sec>
                <title>Brain extraction: The 
                    <monospace>mri watershed</monospace> function</title>
                <p>The 
                    <monospace>mri_watershed</monospace> function will segment the brain from the remainder of the image, such as extra-cranial tissues. Other imaging software in R have implemented the watershed algorithm, such as 
                    <ext-link ext-link-type="uri" xlink:href="http://www.bioconductor.org/packages/release/bioc/html/EBImage.html">
                        <bold>EBImage</bold>
                    </ext-link>
                    <sup>
                        <xref ref-type="bibr" rid="ref-17">17</xref>
                    </sup>. These methods have not been directly adapted for MRI nor specifically for brain extraction. In 
                    <bold>freesurfer</bold>, we can pass in the 
                    <monospace>nifti</monospace> object and the output is a brain-extracted 
                    <monospace>nifti</monospace> object.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">ss = mri_watershed(img)
ortho2(ss, mask = ss)</styled-content>
                    </preformat>
                </p>
                <p>The result is in 
                    <xref ref-type="fig" rid="f4">Figure 4</xref>, where we see areas of the skull, eyes, face, and other areas of the image are removed. We do see some areas remain that may be part of some of the membranes between the brain and the skull, but this looks like an adequate brain extraction for most analyses.</p>
                <fig fig-type="figure" id="f4" orientation="portrait" position="float">
                    <label>Figure 4. </label>
                    <caption>
                        <title>Brain-extracted image after using Freesurfer 
                            <monospace>mri_watershed</monospace> algorithm.</title>
                        <p>We see that the areas outside of the brain have been removed from the image.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure4.gif"/>
                </fig>
                <p>As the result is a 
                    <monospace>nifti</monospace> object, we can create a mask by standard logical operations for arrays. As MRI scans are typically positive-valued, the positive areas of the image are the &#x201c;brain&#x201d;:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">mask = ss &gt; 0</styled-content>
                    </preformat>
                </p>
                <p>We can then use this mask to perform operations on the image, such as subsetting.</p>
            </sec>
            <sec>
                <title>Segmentations of brain structures</title>
                <p>Freesurfer is commonly used to segment cortical and subcortical structures of the brain. We can visualize images of these segmentations, which are located in the &#x201c;mri&#x201d; folder. We will choose the colors based on the Freesurfer look up table (LUT), which values can be explored at 
                    <ext-link ext-link-type="uri" xlink:href="https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT">https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT</ext-link>. This look up table provides a label for each structure and the color associated with it:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">head(freesurfer::fs_lut, 3)

  index                       label    R    G    B  A
1     0                     Unknown    0    0    0  0
2     1      Left-Cerebral-Exterior   70  130  180  0
3     2  Left-Cerebral-White-Matter  245  245  245  0</styled-content>
                    </preformat>
                </p>
                <p>This object is included in 
                    <bold>freesurfer</bold> and denotes the indices, labels, and color representation of the structure. We note that the alpha channel is set to 0 for all regions of interest, so we will not use it in the calculation of the colors from RGB space. This LUT allows visualizations produced in R to be consistent with those from Freesurfer.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">seg_file = file = file.path(fs_subj_dir(), "bert", "mri", "aseg.mgz")
seg = readmgz(seg_file)
breaks = c(-1, fs_lut$index)
colors = rgb(fs_lut$R, fs_lut$G, fs_lut$B, alpha = 255/2, maxColorValue = 255)
ortho2(ss, seg, col.y = colors, ybreaks = breaks)</styled-content>
                    </preformat>
                </p>
                <p>Note above that the number of breaks must be one larger than the number of colors and the indices start at zero, so we add an additional element to the indices. The result in 
                    <xref ref-type="fig" rid="f5">Figure 5</xref> shows the image with colors overlaid.</p>
                <fig fig-type="figure" id="f5" orientation="portrait" position="float">
                    <label>Figure 5. </label>
                    <caption>
                        <title>Overlay of segmentation from Freesurfer 
                            <monospace>recon-all</monospace> command.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure5.gif"/>
                </fig>
            </sec>
            <sec>
                <title>Reading in anatomical statistics for brain structures</title>
                <p>We have explored the spatial results in the brain images, but not the quantitative information about the brain and sub-structures that are available from Freesurfer output. The &#x201c;aseg.stats&#x201d; in the &#x201c;stats&#x201d; folder for subject bert corresponds to measures and statistics from the anatomical segmentation. The 
                    <monospace>read_aseg_stats</monospace> function reads this corresponding file and creates a list of two different 
                    <monospace>data.frames</monospace>:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">file = file.path(fs_subj_dir(), "bert", "stats", "aseg.stats")
out = read_aseg_stats(file)
names(out)

[1] "measures"  "structures"</styled-content>
                    </preformat>
                </p>
                <p>The 
                    <monospace>measures</monospace> element corresponds to global measurements of the brain (e.g. volume of the brain) as well as measures of gross anatomical structures (e.g. gray matter).</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">head(out$measures[, c("meaning", "value", "units")], n = 3)

                                                 meaning	  value
1                              brain segmentation volume 1193318.000000
2           brain segmentation volume without ventricles 1174082.000000
3 brain segmentation volume without ventricles from surf 1173867.217735 
  units
1  mm^3
2  mm^3
3  mm^3</styled-content>
                    </preformat>
                </p>
                <p>In some imaging analyses, comparing at these large measures of brain volume over time or across groups are of interest. Alternatively, the 
                    <monospace>structures</monospace> element corresponds to a set of measures and statistics for a set of fixed anatomical structures.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">head(out$structures, n = 3)

 Index SegId NVoxels Volume_mm3                  StructName normMean
1    1     4    6563     6562.6       Left-Lateral-Ventricle 36.0959
2    2     5     228      228.3            Left-Inf-Lat-Vent 54.8842
3    3     7   15708    15708.2 Left-Cerebellum-White-Matter 92.7562
 normStdDev normMin normMax normRange
1   12.2771      16      91        75
2   10.7839      22      87        65
3    5.5123      40     107        67</styled-content>
                    </preformat>
                </p>
                <p>Similarly with global measures, these structure-specific measures are used in analysis. For example, measuring differences in hippocampus volumes across patients with Alzheimer&#x2019;s disease and those without. Moreover, a large deviation in volume, globally or locally, for a specific subject may indicate atrophy of a structure or an indication of a segmentation error.</p>
            </sec>
            <sec>
                <title>Converting surfaces using 
                    <monospace>mris convert</monospace>
                </title>
                <p>Freesurfer includes segmentations of different surfaces of the brain alongside the volumetric segmentations above. As the 
                    <monospace>mri_convert</monospace> function provides a tool to convert image volumes to a series of output formats, the 
                    <monospace>mris_convert</monospace> (note the &#x201c;s&#x201d;) allows users to convert between image surface formats. These surfaces usually store sets of vertices and faces to be plotted in 3 dimensions. 
                    <bold>freesurfer</bold> has implemented 
                    <monospace>mris_convert</monospace> (with a function of the same name) as well as functions to convert surfaces from Freesurfer to a set of triangles in R, such as 
                    <monospace>surface_to_triangles</monospace>. We will read in the left and right side of the pial surface of the brain and display the surface using 
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/rgl/index.html">rgl</ext-link>
                    <sup>
                        <xref ref-type="bibr" rid="ref-18">18</xref>
                    </sup> (
                    <xref ref-type="fig" rid="f6">Figure 6</xref>).</p>
                <fig fig-type="figure" id="f6" orientation="portrait" position="float">
                    <label>Figure 6. </label>
                    <caption>
                        <title>Pial surface from bert subject in Freesurfer rendered using rgl.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/15624/5d31a41c-a96b-4e9c-9e7a-0a6f689a0678_figure6.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">right_file = file.path(fs_subj_dir(),
                   "bert", "surf", "rh.pial")
right_triangles = surface_to_triangles(infile = right_file)
left_file = file.path(fs_subj_dir(),
                   "bert", "surf", "lh.pial")
left_triangles = surface_to_triangles(infile = left_file)
rgl::rgl.open()
rgl::rgl.triangles(right_triangles,
                   color = rainbow(nrow(right_triangles)))
rgl::rgl.triangles(left_triangles,
                   color = rainbow(nrow(left_triangles)))</styled-content>
                    </preformat>
                </p>
                <p>Thus, we can read in the output images, surfaces, and the tables of output metrics from Freesurfer.</p>
            </sec>
            <sec>
                <title>Additional features</title>
                <p>For the initial release, we did not implement a method to read the annotation files and other surface-based files that Freesurfer uses. Reading in these files are planned for a future release and may work with the functions described above. Freesurfer can also analyze diffusion tensor imaging data and some of the functions have been adapted for 
                    <bold>freesurfer</bold> but have not been thoroughly tested.</p>
            </sec>
        </sec>
        <sec sec-type="conclusions">
            <title>Conclusion</title>
            <p>The neuroimaging community has developed a large collection of tools for image processing and analysis. These tools have additional functionality that is not present in R, such as the surface-based registration and processing Freesurfer provides. We have provided a similar incorporation of tools from FSL to R in the 
                <bold>fslr</bold> package and have repeated the effort for Freesurfer with the 
                <bold>freesurfer</bold> package to bridge this gap and provide R users functions from Freesurfer.</p>
            <p>There has been an increasing popularity of similar interfacing of tools within the Python community such as 
                <ext-link ext-link-type="uri" xlink:href="https://qa.debian.org/popcon.php?package=nipype">Nipype</ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-19">19</xref>
                </sup>. As many users of R may not have experience with Python or bash scripting, we believe 
                <bold>freesurfer</bold> provides a lower threshold for use in the R community.</p>
            <p>Lowering this threshold is important because it allows more R users to control all aspects of image analysis from raw image processing to final statistical analysis. Interfacing R with existing, powerful software provides R users more functionality and a additional support community, which would not be available if the functions were rewritten in R. Although having an external software dependency may be disadvantage to R users, the software used benefits from the years of previous testing. Most importantly, as 
                <bold>freesurfer</bold> is based on the R framework, all the benefits of using R are available, such as dynamic documents, Shiny applications, customized figures, and state-of-the-art statistical methods. This added functionality affords the neuroimaging and R communities the ability to have analysis in one framework while borrowing the strengths of both.</p>
        </sec>
        <sec>
            <title>Experimental features</title>
            <sec>
                <title>Label files</title>
                <p>Although we have not thoroughly tested reading in a label file from Freesurfer, we have provided the 
                    <monospace>read_fs_label</monospace> function. Here we will read a label file for the left hemisphere cortex:</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;">file = file.path(fs_subj_dir(), "bert", "label", "lh.cortex.label")
out = read_fs_label(file)
head(out)

 vertex_num r_coord  a_coord  s_coord        value
1         0 -12.882 -102.449   -9.782 0.0000000000
2         1 -13.331 -102.518   -9.829 0.0000000000
3         2 -13.637 -102.514  -10.077 0.0000000000
4         3 -13.031 -102.596  -10.024 0.0000000000
5         4 -13.331 -102.510  -10.254 0.0000000000
6         5 -13.610 -102.483  -10.295 0.0000000000</styled-content>
                    </preformat>
                </p>
            </sec>
        </sec>
        <sec>
            <title>Software availability</title>
            <p>
                <bold>freesurfer</bold> is available at: 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/freesurfer/index.html">https://cran.r-project.org/package=freesurfer</ext-link>
            </p>
            <p>Source code is available at: 
                <ext-link ext-link-type="uri" xlink:href="https://github.com/muschellij2/freesurfer">https://github.com/muschellij2/freesurfer</ext-link>
            </p>
            <p>Archived source code as at time of publication: 
                <ext-link ext-link-type="uri" xlink:href="http://doi.org/10.5281/zenodo.1213308">http://doi.org/10.5281/zenodo.1213308</ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-20">20</xref>
                </sup>
            </p>
            <p>Software license: GPL-2</p>
            <p>All necessary code to generate this report is located at: 
                <ext-link ext-link-type="uri" xlink:href="https://github.com/muschellij2/fs_paper">https://github.com/muschellij2/fs_paper</ext-link>.</p>
        </sec>
    </body>
    <back>
        <ack>
            <title>Acknowledgements</title>
            <p>This paper was generated using the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/web/packages/rticles/index.html">rticles</ext-link> package
                <sup>
                    <xref ref-type="bibr" rid="ref-21">21</xref>
                </sup>.</p>
        </ack>
        <ref-list>
            <ref id="ref-1">
                <label>1</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Fischl</surname>
                            <given-names>B</given-names>
                        </name>
					</person-group>:
                    <article-title>FreeSurfer.</article-title>
                    <source>
						
                        <italic toggle="yes">NeuroImage.</italic>
					</source>
                    <year>2012</year>;<volume>62</volume>(<issue>2</issue>):<fpage>774</fpage>&#x2013;<lpage>781</lpage>.
                    <pub-id pub-id-type="pmid">22248573</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2012.01.021</pub-id>
                    <pub-id pub-id-type="pmcid">3685476</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-2">
                <label>2</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>S&#x00e9;gonne</surname>
                            <given-names>F</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Dale</surname>
                            <given-names>AM</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Busa</surname>
                            <given-names>E</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>A hybrid approach to the skull stripping problem in MRI.</article-title>
                    <source>
						
                        <italic toggle="yes">NeuroImage.</italic>
					</source>
                    <year>2004</year>;<volume>22</volume>(<issue>3</issue>):<fpage>1060</fpage>&#x2013;<lpage>1075</lpage>.
                    <pub-id pub-id-type="pmid">15219578</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2004.03.032</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-3">
                <label>3</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Sled</surname>
                            <given-names>JG</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Zijdenbos</surname>
                            <given-names>AP</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Evans</surname>
                            <given-names>AC</given-names>
                        </name>
					</person-group>:
                    <article-title>A nonparametric method for automatic correction of intensity nonuniformity in MRI data.</article-title>
                    <source>
						
                        <italic toggle="yes">IEEE Trans Med Imaging.</italic>
					</source>
                    <year>1998</year>;<volume>17</volume>(<issue>1</issue>):<fpage>87</fpage>&#x2013;<lpage>97</lpage>.
                    <pub-id pub-id-type="pmid">9617910</pub-id>
                    <pub-id pub-id-type="doi">10.1109/42.668698</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-4">
                <label>4</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Fischl</surname>
                            <given-names>B</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Salat</surname>
                            <given-names>DH</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Busa</surname>
                            <given-names>E</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Whole brain segmentation: automated labeling of neuroanatomical structures in the human brain.</article-title>
                    <source>
						
                        <italic toggle="yes">Neuron.</italic>
					</source>
                    <year>2002</year>;<volume>33</volume>(<issue>3</issue>):<fpage>341</fpage>&#x2013;<lpage>355</lpage>.
                    <pub-id pub-id-type="pmid">11832223</pub-id>
                    <pub-id pub-id-type="doi">10.1016/S0896-6273(02)00569-X</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-5">
                <label>5</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Fischl</surname>
                            <given-names>B</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Salat</surname>
                            <given-names>DH</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>van der Kouwe</surname>
                            <given-names>AJ</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Sequence-independent segmentation of magnetic resonance images.</article-title>
                    <source>
						
                        <italic toggle="yes">NeuroImage.</italic>
					</source>
                    <year>2004</year>;<volume>23 Suppl 1</volume>:<fpage>S69</fpage>&#x2013;<lpage>S84</lpage>.
                    <pub-id pub-id-type="pmid">15501102</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2004.07.016</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-6">
                <label>6</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Fischl</surname>
                            <given-names>B</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sereno</surname>
                            <given-names>MI</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Tootell</surname>
                            <given-names>RB</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>High-resolution intersubject averaging and a coordinate system for the cortical surface.</article-title>
                    <source>
						
                        <italic toggle="yes">Hum Brain Mapp.</italic>
					</source>
                    <year>1999</year>;<volume>8</volume>(<issue>4</issue>):<fpage>272</fpage>&#x2013;<lpage>284</lpage>.
                    <pub-id pub-id-type="pmid">10619420</pub-id>
                    <pub-id pub-id-type="doi">10.1002/(SICI)1097-0193(1999)8:4&lt;272::AID-HBM10&gt;3.0.CO;2-4</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-7">
                <label>7</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Reuter</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Rosas</surname>
                            <given-names>HD</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Fischl</surname>
                            <given-names>B</given-names>
                        </name>
					</person-group>:
                    <article-title>Highly accurate inverse consistent registration: a robust approach.</article-title>
                    <source>
						
                        <italic toggle="yes">NeuroImage.</italic>
					</source>
                    <year>2010</year>;<volume>53</volume>(<issue>4</issue>):<fpage>1181</fpage>&#x2013;<lpage>1196</lpage>.
                    <pub-id pub-id-type="pmid">20637289</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2010.07.020</pub-id>
                    <pub-id pub-id-type="pmcid">2946852</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-8">
                <label>8</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Bordier</surname>
                            <given-names>C</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Dojat</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Lafaye de Micheaux</surname>
                            <given-names>P</given-names>
                        </name>
					</person-group>:
                    <article-title>Temporal and spatial independent component analysis for fMRI data sets embedded in the AnalyzeFMRI R package.</article-title>
                    <source>
						
                        <italic toggle="yes">J Stat Softw.</italic>
					</source>
                    <year>2011</year>;<volume>44</volume>(<issue>9</issue>):<fpage>1</fpage>&#x2013;<lpage>24</lpage>.
                    <pub-id pub-id-type="doi">10.18637/jss.v044.i09</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-9">
                <label>9</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Tabelow</surname>
                            <given-names>K</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Polzehl</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>Statistical parametric maps for functional MRI experiments in R: The package fmri.</article-title>
                    <source>
						
                        <italic toggle="yes">J Stat Softw.</italic>
					</source>
                    <year>2011</year>;<volume>44</volume>(<issue>11</issue>):<fpage>1</fpage>&#x2013;<lpage>21</lpage>.
                    <pub-id pub-id-type="doi">10.18637/jss.v044.i11</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-10">
                <label>10</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Clayden</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>RNiftyReg: Medical Image Registration Using the NiftyReg Library</article-title>. Jon Clayden and based on original code by Marc Modat and Pankaj Daga. R package version 1.1.3.<year>2015</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://mran.microsoft.com/snapshot/2015-08-12/web/packages/RNiftyReg/RNiftyReg.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-11">
                <label>11</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Ferreira da Silva</surname>
                            <given-names>A</given-names>
                        </name>
					</person-group>:
                    <article-title>dpmixsim: Dirichlet Process Mixture model simulation for clustering and image segmentation</article-title>. R package version 0.0-8.<year>2012</year>.
                    <ext-link ext-link-type="uri" xlink:href="ftp://cran.r-project.org/pub/R/web/packages/dpmixsim/dpmixsim.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-12">
                <label>12</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Feng</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Tierney</surname>
                            <given-names>L</given-names>
                        </name>
					</person-group>:
                    <article-title>mritc: A package for MRI tissue classification.</article-title>
                    <source>
						
                        <italic toggle="yes">J Stat Softw.</italic>
					</source>
                    <year>2011</year>;<volume>44</volume>(<issue>7</issue>):<fpage>1</fpage>&#x2013;<lpage>20</lpage>.
                    <pub-id pub-id-type="doi">10.18637/jss.v044.i07</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-13">
                <label>13</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Jenkinson</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Beckmann</surname>
                            <given-names>CF</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Behrens</surname>
                            <given-names>TE</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>FSL.</article-title>
                    <source>
						
                        <italic toggle="yes">NeuroImage.</italic>
					</source>
                    <year>2012</year>;<volume>62</volume>(<issue>2</issue>):<fpage>782</fpage>&#x2013;<lpage>790</lpage>.
                    <pub-id pub-id-type="pmid">21979382</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2011.09.015</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-14">
                <label>14</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Whitcher</surname>
                            <given-names>B</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Schmid</surname>
                            <given-names>VJ</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Thornton</surname>
                            <given-names>A</given-names>
                        </name>
					</person-group>:
                    <article-title>Working with the DICOM and NIfTI Data Standards in R.</article-title>
                    <source>
						
                        <italic toggle="yes">J Stat Softw.</italic>
					</source>
                    <year>2011</year>;<volume>44</volume>(<issue>6</issue>):<fpage>1</fpage>&#x2013;<lpage>28</lpage>.
                    <pub-id pub-id-type="doi">10.18637/jss.v044.i06</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-15">
                <label>15</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Muschelli</surname>
                            <given-names>J</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sweeney</surname>
                            <given-names>E</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Lindquist</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>fslr: Connecting the FSL Software with R.</article-title>
                    <source>
						
                        <italic toggle="yes">R J.</italic>
					</source>
                    <year>2015</year>;<volume>7</volume>(<issue>1</issue>):<fpage>163</fpage>&#x2013;<lpage>175</lpage>.
                    <pub-id pub-id-type="pmid">27330830</pub-id>
                    <pub-id pub-id-type="pmcid">4911193</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-16">
                <label>16</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Zhang</surname>
                            <given-names>Y</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Brady</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Smith</surname>
                            <given-names>S</given-names>
                        </name>
					</person-group>:
                    <article-title>Segmentation of brain MR images through a hidden Markov random field model and the expectation-maximization algorithm.</article-title>
                    <source>
						
                        <italic toggle="yes">IEEE Trans Med Imaging.</italic>
					</source>
                    <year>2001</year>;<volume>20</volume>(<issue>1</issue>):<fpage>45</fpage>&#x2013;<lpage>57</lpage>.
                    <pub-id pub-id-type="pmid">11293691</pub-id>
                    <pub-id pub-id-type="doi">10.1109/42.906424</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-17">
                <label>17</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Pau</surname>
                            <given-names>G</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Fuchs</surname>
                            <given-names>F</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sklyar</surname>
                            <given-names>O</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>EBImage--an R package for image processing with applications to cellular phenotypes.</article-title>
                    <source>
						
                        <italic toggle="yes">Bioinformatics.</italic>
					</source>
                    <year>2010</year>;<volume>26</volume>(<issue>7</issue>):<fpage>979</fpage>&#x2013;<lpage>981</lpage>.
                    <pub-id pub-id-type="pmid">20338898</pub-id>
                    <pub-id pub-id-type="doi">10.1093/bioinformatics/btq046</pub-id>
                    <pub-id pub-id-type="pmcid">2844988</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-18">
                <label>18</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Adler</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Murdoch</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>rgl: 3D Visualization Using OpenGL.</article-title>R package version 0.96.0.<year>2016</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://mran.revolutionanalytics.com/snapshot/2016-10-13/web/packages/rgl/rgl.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-19">
                <label>19</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gorgolewski</surname>
                            <given-names>K</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Burns</surname>
                            <given-names>CD</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Madison</surname>
                            <given-names>C</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Nipype: a flexible, lightweight and extensible neuroimaging data processing framework in python.</article-title>
                    <source>
					      
                        <italic toggle="yes">Front Neuroinform.</italic>
					</source>
                    <year>2011</year>;<volume>5</volume>:<fpage>13</fpage>.
                    <pub-id pub-id-type="pmid">21897815</pub-id>
                    <pub-id pub-id-type="doi">10.3389/fninf.2011.00013</pub-id>
                    <pub-id pub-id-type="pmcid">3159964</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-20">
                <label>20</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Muschelli</surname>
                            <given-names>J</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sweeney</surname>
                            <given-names>E</given-names>
                        </name>
					</person-group>:
                    <article-title>muschellij2/freesurfer v1.6.2.9002 (Version v1.6.2.9002).</article-title>
                    <source>
					   
                        <italic toggle="yes">Zenodo.</italic>
					   </source>
                    <year>2018</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://dx.doi.org/10.5281/zenodo.1213308">Data Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-21">
                <label>21</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Allaire</surname>
                            <given-names>JJ</given-names>
                        </name>
						
                        <collab>R Foundation, </collab>
						
                        <name name-style="western">
                            <surname>Wickham</surname>
                            <given-names>H</given-names>
                        </name>
							
                        <etal/>
			       </person-group>:
                    <article-title>rticles: Article Formats for R Markdown</article-title>. R package version 0.2.<year>2016</year>.</mixed-citation>
            </ref>
        </ref-list>
    </back>
    <sub-article article-type="reviewer-report" id="report35180">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.15624.r35180</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Lafaye de Micheaux</surname>
                        <given-names>Pierre</given-names>
                    </name>
                    <xref ref-type="aff" rid="r35180a1">1</xref>
                    <role>Referee</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-0247-5136</uri>
                </contrib>
                <aff id="r35180a1">
                    <label>1</label>School of Mathematics and Statistics, University of New South Wales, Sydney, Australia</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>16</day>
                <month>7</month>
                <year>2018</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Lafaye de Micheaux P</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport35180" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.14361.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>This article describes a very interesting R package that enables R users to have access, directly from within R, to several functions from the great neuroimaging open source software Freesurfer. The paper is well written, and their package useful.</p>
            <p> </p>
            <p> I only have minor comments to improve the readability of the paper.</p>
            <p> </p>
            <p> First, I would&#x00a0;suggest to use brackets () to indicate freesurfer R functions and avoid confusion with Freesurfer command line functions. For example recon_all() for freesurfer and recon_all fro Freesurfer.</p>
            <p> </p>
            <p> Next, I tried to replicate all the results presented in the paper. My OS is Linux Debian 9.3 Stretch on a DELL laptop.</p>
            <p> </p>
            <p> First, I tried to install Freesurfer, following the link given in the paper. Two commands&#x00a0;I had to use&#x00a0;to make things work are:</p>
            <p> sudo apt-get install tcsh</p>
            <p> sudo ln -s /usr/lib/x86_64-linux-gnu/libpng16.so /usr/lib/x86_64-linux-gnu/libpng12.so.0</p>
            <p> </p>
            <p> Then I wanted to install FSL. I think the authors of the current paper should give a URL (e.g., https://fsl.fmrib.ox.ac.uk/fsldownloads_registration) to indicate where to download FSL. Unfortunately, FSL binaries are not available (yet) for Debian 9. I tried to install from the sources with no success. I then went back to the same URL and chose Debian 8, to download the&#x00a0;fslinstaller.py file, then run the following command:</p>
            <p> python fslinstaller.py</p>
            <p> </p>
            <p> This finally worked as expected. The authors of the current paper might want to indicate that these installation can take quite some time.</p>
            <p> </p>
            <p> I then launched an R session directly from the console, and typed the instructions given in the paper to check if they all work fine.</p>
            <p> </p>
            <p> I would suggest to give the following instructions before the user have to type all the instructions given in the paper. It was obvious for me, but might not be so for less experienced R users:</p>
            <p> </p>
            <p> install.packages("fslr")</p>
            <p> install.packages("freesurfer")</p>
            <p> install.packages("rgl")</p>
            <p> install.packages("neurobase")</p>
            <p> </p>
            <p> I suggest that close to this sentence "&#x00a0;If we were to run all the analyses, we would use the&#x00a0;recon_all&#x00a0;code (described below):", the authors indicate that this is not done since it would take more than 20 hours (if this is indeed the case).&#x00a0;</p>
            <p> </p>
            <p> I goth this first error:</p>
            <p> &gt; L = fslr::rpi_orient(img)</p>
            <p> Error in get.fsl() : Can't find FSL</p>
            <p> In addition: Warning message:</p>
            <p> In get.fsloutput() : Can't find FSLOUTPUTTYPE, setting to NIFTI_GZ</p>
            <p> </p>
            <p> I then typed:</p>
            <p> &gt; fslr::have.fsl()</p>
            <p> [1] FALSE</p>
            <p> </p>
            <p> I solved this error with:</p>
            <p> &gt; options(fsl.path="/home/lafaye/fslbuild/fsl")</p>
            <p> &gt; fslr::have.fsl()</p>
            <p> [1] TRUE</p>
            <p> </p>
            <p> Of course, this is because, due to hard-disk space constraints, I installed FSL (and also Freesurfer) in my home directory instead of the standard location. Maybe this could be mentioned.</p>
            <p> </p>
            <p> When I typed this instruction:</p>
            <p> &gt; nu_from_mnc = nu_correct(file = mnc)</p>
            <p> it worked but I got this warning:</p>
            <p> Malformed NIfTI - not reading NIfTI extension, use at own risk!</p>
            <p> </p>
            <p> When I typed this instruction:</p>
            <p> &gt; nu_masked = nu_correct(file = reoriented_img, mask = mask)</p>
            <p> I got this error:</p>
            <p> Error in nu_correct(file = reoriented_img, mask = mask) :&#x00a0;</p>
            <p> &#x00a0; object 'mask' not found</p>
            <p> </p>
            <p> Indeed, the object 'mask' is defined later on. I suggest to create this 'mask' object first, or otherwise to type the above&#x00a0;instruction later.</p>
            <p> </p>
            <p> This instruction also failed:</p>
            <p> &gt; ortho2(ss, mask = ss)</p>
            <p> Error: could not find function "ortho2"</p>
            <p> </p>
            <p> One should use (if the package neurobase is not loaded):</p>
            <p> &gt; neurobase::ortho2(ss, mask = ss)</p>
            <p> &gt; mask = ss &gt;0</p>
            <p> </p>
            <p> I then retried the previous&#x00a0;instruction now we have the mask:</p>
            <p> &gt; nu_masked = nu_correct(file = reoriented_img, mask = mask)</p>
            <p> </p>
            <p> but I got this error:</p>
            <p> Direction cosines of /tmp/RtmpxVKjYw/file29ad28e1ded7.mnc and /var/tmp/nu_correct_11320/file29ad516b90fd.mnc do not match</p>
            <p> Failed to shrink mask volume.</p>
            <p> nu_correct: crashed while running nu_estimate_np_and_em (termination status=65280)</p>
            <p> mnc2nii -float "/tmp/RtmpxVKjYw/file29ada6796e2.mnc" &#x00a0; "/tmp/RtmpxVKjYw/file29ad2a6e70b2.nii";</p>
            <p> </p>
            <p> Can't find input file '/tmp/RtmpxVKjYw/file29ada6796e2.mnc'</p>
            <p> Error in mnc2nii(tmpfile, outfile = outfile) :&#x00a0;</p>
            <p> &#x00a0; mnc2nii did not produce outfile specified</p>
            <p> </p>
            <p> Not sure what to do here ...</p>
            <p> </p>
            <p> Apart form that, everything was fine!</p>
            <p>Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>Is the rationale for developing the new software tool clearly explained?</p>
            <p>Yes</p>
            <p>Is the description of the software tool technically sound?</p>
            <p>Yes</p>
            <p>Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?</p>
            <p>Partly</p>
            <p>Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?</p>
            <p>Yes</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard.</p>
        </body>
    </sub-article>
    <sub-article article-type="reviewer-report" id="report35181">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.15624.r35181</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Lirette</surname>
                        <given-names>Seth T.</given-names>
                    </name>
                    <xref ref-type="aff" rid="r35181a1">1</xref>
                    <role>Referee</role>
                </contrib>
                <aff id="r35181a1">
                    <label>1</label>Department of Data Science, University of Mississippi Medical Center, Jackson, MS, USA</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>6</day>
                <month>7</month>
                <year>2018</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2018 Lirette ST</copyright-statement>
                <copyright-year>2018</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport35181" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.14361.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>Muschelli, Sweeney, and Crainiceanu have provided researchers (and particularly statisticians) with a useful new tool for analyzing structural neuroimaging data. They cite a number of packages for analyzing and manipulating imaging data, but lack the functionality of Freesurfer. They well document the processes for reading and converting file formats to obtain usable R objects. The examples for plotting, bias-field correction, surface mapping, and brain extraction are clear, concise, and provide readers with enough information to recreate these with their own data. A very minor addition I would like to see would be an example of how to extract the volumetric and segmented volumetric data from a sample of subjects (or from multiple studies on the same subject). These could then be stored in other R objects (vectors, data frames, etc.) to be further analyzed using statistical methodologies. Overall, this is a very nice tool, and I personally am excited to use 
                <bold>freesurfer </bold>very soon.</p>
            <p>Are the conclusions about the tool and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>Is the rationale for developing the new software tool clearly explained?</p>
            <p>Yes</p>
            <p>Is the description of the software tool technically sound?</p>
            <p>Yes</p>
            <p>Are sufficient details of the code, methods and analysis (if applicable) provided to allow replication of the software development and its use by others?</p>
            <p>Yes</p>
            <p>Is sufficient information provided to allow interpretation of the expected output datasets and any results generated using the tool?</p>
            <p>Yes</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>I confirm that I have read this submission and believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard.</p>
        </body>
    </sub-article>
</article>
