diff --git a/Dockerfile b/Dockerfile old mode 100644 new mode 100755 index d66b05f08..f1d397c35 --- a/Dockerfile +++ b/Dockerfile @@ -96,6 +96,36 @@ COPY .docker/fsl-6.0/bin/topup /usr/share/fsl/5.0/bin/topup COPY .docker/fsl-6.0/bin/imglob /usr/share/fsl/5.0/bin/imglob COPY .docker/fsl-6.0/lib/* /usr/lib/fsl/5.0/ +ENV FSLDIR="/opt/fsl-5.0.11" \ + PATH="/opt/fsl-5.0.11/bin:$PATH" \ + FSLOUTPUTTYPE="NIFTI_GZ" + +RUN apt-get update -qq && \ + apt-get install -y -q --no-install-recommends \ + bc \ + dc \ + file \ + libfontconfig1 \ + libfreetype6 \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + libgomp1 \ + libice6 \ + libxcursor1 \ + libxft2 \ + libxinerama1 \ + libxrandr2 \ + libxrender1 \ + libxt6 \ + python \ + wget && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + echo "Downloading FSL ..." && \ + wget -q http://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py && \ + chmod 775 fslinstaller.py && \ + /usr/bin/python fslinstaller.py -d /opt/fsl-5.0.11 -V 5.0.11 -q + # Installing ANTs 2.3.3 (NeuroDocker build) # Note: the URL says 2.3.4 but it is actually 2.3.3 ENV ANTSPATH=/usr/lib/ants diff --git a/dmriprep/workflows/dwi/base.py b/dmriprep/workflows/dwi/base.py index f3017d6f0..babc0249b 100755 --- a/dmriprep/workflows/dwi/base.py +++ b/dmriprep/workflows/dwi/base.py @@ -203,12 +203,18 @@ def _bold_reg_suffix(fallback): # fmt: on # Eddy distortion correction - eddy_wf = init_eddy_wf() + eddy_wf = init_eddy_wf(debug=config.execution.debug) + eddy_wf.inputs.inputnode.metadata = layout.get_metadata(str(dwi_file)) # fmt:off workflow.connect([ (dwi_reference_wf, eddy_wf, [ ("outputnode.ref_image", "inputnode.dwi_file"), - ]) + ("outputnode.dwi_mask", "inputnode.dwi_mask"), + ]), + (inputnode, eddy_wf, [ + ("in_bvec", "inputnode.in_bvec"), + ("in_bval", "inputnode.in_bval") + ]), ]) # fmt:on diff --git a/dmriprep/workflows/dwi/eddy.py b/dmriprep/workflows/dwi/eddy.py old mode 100644 new mode 100755 index 32658eaf3..54e8abcca --- a/dmriprep/workflows/dwi/eddy.py +++ b/dmriprep/workflows/dwi/eddy.py @@ -52,7 +52,7 @@ def gen_eddy_textfiles(in_file, in_meta): return out_acqparams, out_index -def init_eddy_wf(name="eddy_wf"): +def init_eddy_wf(debug=False, name="eddy_wf"): """ Create a workflow for head-motion & Eddy currents distortion estimation with FSL. @@ -72,26 +72,71 @@ def init_eddy_wf(name="eddy_wf"): The eddy corrected diffusion image.. """ - from nipype.interfaces.fsl import EddyCorrect - - inputnode = pe.Node(niu.IdentityInterface(fields=["dwi_file"]), name="inputnode",) + from nipype.interfaces.fsl import Eddy + + inputnode = pe.Node( + niu.IdentityInterface( + fields=[ + "dwi_file", + "metadata", + "dwi_mask", + "in_bvec", + "in_bval" + ] + ), + name="inputnode", + ) - outputnode = pe.Node(niu.IdentityInterface(fields=["out_eddy"]), name="outputnode",) + outputnode = pe.Node( + niu.IdentityInterface( + fields=[ + "out_rotated_bvecs", + "out_eddy" + ] + ), + name="outputnode", + ) workflow = Workflow(name=name) workflow.__desc__ = f"""\ Geometrical distortions derived from the so-called Eddy-currents, and head-motion -realignment parameters were estimated with the joint modeling of ``eddy_correct``, -included in FSL {EddyCorrect().version} [@eddy]. +realignment parameters were estimated with the joint modeling of ``eddy_openmp``, +included in FSL {Eddy().version} [@eddy]. """ + eddy = pe.Node( + Eddy(repol=True, cnr_maps=True, residuals=True, method="jac"), + name="eddy", + ) - eddy_correct = pe.Node(EddyCorrect(), name="eddy_correct",) + if debug: + eddy.inputs.niter = 1 + + # Generate the acqp and index files for eddy + gen_eddy_files = pe.Node( + niu.Function( + input_names=["in_file", "in_meta"], + output_names=["out_acqparams", "out_index"], + function=gen_eddy_textfiles, + ), + name="gen_eddy_files", + ) - # Connect the workflow # fmt:off workflow.connect([ - (inputnode, eddy_correct, [("dwi_file", "in_file")]), - (eddy_correct, outputnode, [("eddy_corrected", "out_eddy")]), + (inputnode, eddy, [ + ("dwi_file", "in_file"), + ("dwi_mask", "in_mask"), + ("in_bvec", "in_bvec"), + ("in_bval", "in_bval"), + ]), + (inputnode, gen_eddy_files, [ + ("dwi_file", "in_file"), + ("metadata", "in_meta") + ]), + (eddy, outputnode, [ + ("out_corrected", "out_eddy"), + ("out_rotated_bvecs", "out_rotated_bvecs") + ]), ]) # fmt:on return workflow