Skip to content

Commit

Permalink
Changed fsl version to 5.0.11 and switched from eddy_correct to eddy_…
Browse files Browse the repository at this point in the history
…openmp
  • Loading branch information
slimnsour authored and oesteban committed Feb 6, 2021
1 parent c769a5d commit 10639df
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 13 deletions.
30 changes: 30 additions & 0 deletions Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions dmriprep/workflows/dwi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 56 additions & 11 deletions dmriprep/workflows/dwi/eddy.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 10639df

Please sign in to comment.