Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ dependencies:
- svgutils
- nitime
- nilearn
- git+https://github.com/nipy/nipype.git@c13f967506aa426c63ad4131cf29b655f742649c#egg=nipype
- git+https://github.com/poldracklab/niworkflows.git@0.0.7#egg=niworkflows
- git+https://github.com/nipy/nipype.git@603f424a379767abffa055283b799d69b840a58d#egg=nipype
- git+https://github.com/poldracklab/niworkflows.git@70a85b98e6161620af1763c050212e348cd20388#egg=niworkflows
- git+https://github.com/INCF/pybids.git@7205ae01fbdca8e8bfd26ac773b1134b84c8af0c#egg=pybids
2 changes: 1 addition & 1 deletion fmriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def init_anat_preproc_wf(skull_strip_ants, output_spaces, template, debug, frees
RobustMNINormalizationRPT(
generate_report=True,
num_threads=omp_nthreads,
testing=debug,
flavor='testing' if debug else 'precise',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oesteban I believe this is the 0.0.7+ equivalent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

),
name='t1_2_mni'
)
Expand Down
10 changes: 5 additions & 5 deletions fmriprep/workflows/fieldmap/fmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu

from nipype.interfaces import fsl
from nipype.interfaces import fsl, ants
from niworkflows.interfaces.masks import BETRPT
from nipype.workflows.dmri.fsl.utils import demean_image, cleanup_edge_pipeline
from fmriprep.workflows.util import init_n4bias_wf
from fmriprep.interfaces import IntraModalMerge
from fmriprep.interfaces.bids import DerivativesDataSink
from fmriprep.interfaces.fmap import FieldEnhance
Expand Down Expand Up @@ -60,7 +59,8 @@ def init_fmap_wf(reportlets_dir, omp_nthreads, fmap_bspline, name='fmap_wf'):
name='fmapmrg')

# de-gradient the fields ("bias/illumination artifact")
n4bias_wf = init_n4bias_wf()
n4_correct = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True),
name='n4_correct')
bet = pe.Node(BETRPT(generate_report=True, frac=0.6, mask=True),
name='bet')
ds_fmap_mask = pe.Node(
Expand All @@ -70,8 +70,8 @@ def init_fmap_wf(reportlets_dir, omp_nthreads, fmap_bspline, name='fmap_wf'):
workflow.connect([
(inputnode, magmrg, [('magnitude', 'in_files')]),
(inputnode, fmapmrg, [('fieldmap', 'in_files')]),
(magmrg, n4bias_wf, [('out_file', 'inputnode.in_file')]),
(n4bias_wf, bet, [('outputnode.out_file', 'in_file')]),
(magmrg, n4_correct, [('out_file', 'input_image')]),
(n4_correct, bet, [('output_image', 'in_file')]),
(bet, outputnode, [('mask_file', 'fmap_mask'),
('out_file', 'fmap_ref')]),
(inputnode, ds_fmap_mask, [('fieldmap', 'source_file')]),
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/fieldmap/phdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _pick1st(inlist):
magmrg = pe.Node(IntraModalMerge(), name='magmrg')

# de-gradient the fields ("bias/illumination artifact")
n4 = pe.Node(ants.N4BiasFieldCorrection(dimension=3), name='n4')
n4 = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True), name='n4')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this wasn't using init_n4bias_wf already. If there's a good reason for not copying the header, let me know and I'll revert this.

bet = pe.Node(BETRPT(generate_report=True, frac=0.6, mask=True),
name='bet')
ds_fmap_mask = pe.Node(
Expand Down
30 changes: 6 additions & 24 deletions fmriprep/workflows/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import nipype.interfaces.fsl as fsl
import nipype.interfaces.afni as afni
from niworkflows.interfaces import CopyHeader
from niworkflows.interfaces.masks import SimpleShowMaskRPT


Expand All @@ -26,7 +25,8 @@ def init_enhance_and_skullstrip_epi_wf(name='enhance_and_skullstrip_epi_wf'):
'bias_corrected_file',
'out_report']),
name='outputnode')
n4bias_wf = init_n4bias_wf()
n4_correct = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True),
name='n4_correct')
skullstrip_first_pass = pe.Node(fsl.BET(frac=0.2, mask=True),
name='skullstrip_first_pass')
unifize = pe.Node(afni.Unifize(t2=True, outputtype='NIFTI_GZ',
Expand All @@ -42,38 +42,20 @@ def init_enhance_and_skullstrip_epi_wf(name='enhance_and_skullstrip_epi_wf'):
mask_reportlet = pe.Node(SimpleShowMaskRPT(), name='mask_reportlet')

workflow.connect([
(inputnode, n4bias_wf, [('in_file', 'inputnode.in_file')]),
(n4bias_wf, skullstrip_first_pass, [('outputnode.out_file', 'in_file')]),
(inputnode, n4_correct, [('in_file', 'input_image')]),
(n4_correct, skullstrip_first_pass, [('output_image', 'in_file')]),
(skullstrip_first_pass, unifize, [('out_file', 'in_file')]),
(unifize, skullstrip_second_pass, [('out_file', 'in_file')]),
(skullstrip_first_pass, combine_masks, [('mask_file', 'in_file')]),
(skullstrip_second_pass, combine_masks, [('out_file', 'operand_file')]),
(unifize, apply_mask, [('out_file', 'in_file')]),
(combine_masks, apply_mask, [('out_file', 'mask_file')]),
(n4bias_wf, mask_reportlet, [('outputnode.out_file', 'background_file')]),
(n4_correct, mask_reportlet, [('output_image', 'background_file')]),
(combine_masks, mask_reportlet, [('out_file', 'mask_file')]),
(combine_masks, outputnode, [('out_file', 'mask_file')]),
(mask_reportlet, outputnode, [('out_report', 'out_report')]),
(apply_mask, outputnode, [('out_file', 'skull_stripped_file')]),
(n4bias_wf, outputnode, [('outputnode.out_file', 'bias_corrected_file')]),
])

return workflow


def init_n4bias_wf(name='n4bias_wf'):
workflow = pe.Workflow(name=name)
inputnode = pe.Node(niu.IdentityInterface(fields=['in_file']), name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(fields=['out_file']), name='outputnode')

n4_correct = pe.Node(ants.N4BiasFieldCorrection(dimension=3), name='n4_correct')
orig_hdr = pe.Node(CopyHeader(), name='orig_hdr')

workflow.connect([
(inputnode, n4_correct, [('in_file', 'input_image')]),
(inputnode, orig_hdr, [('in_file', 'hdr_file')]),
(n4_correct, orig_hdr, [('output_image', 'in_file')]),
(orig_hdr, outputnode, [('out_file', 'out_file')]),
(n4_correct, outputnode, [('output_image', 'bias_corrected_file')]),
])

return workflow
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
git+https://github.com/nipy/nipype.git@c13f967506aa426c63ad4131cf29b655f742649c#egg=nipype
git+https://github.com/poldracklab/niworkflows.git@0.0.7#egg=niworkflows
git+https://github.com/nipy/nipype.git@603f424a379767abffa055283b799d69b840a58d#egg=nipype
git+https://github.com/poldracklab/niworkflows.git@70a85b98e6161620af1763c050212e348cd20388#egg=niworkflows
git+https://github.com/INCF/pybids.git@7205ae01fbdca8e8bfd26ac773b1134b84c8af0c#egg=pybids