Skip to content

FIX: Immediately fix headers of AFNI outputs #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2017
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
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Next release
============

* [FIX] Adopt new FreeSurfer license mechanism (#787)

* [FIX] Correct headers in AFNI-generated NIfTI files (#818)

1.0.0-rc9 (2nd of November 2017)
================================
Expand Down
7 changes: 6 additions & 1 deletion fmriprep/workflows/bold/stc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from niworkflows.nipype import logging
from niworkflows.nipype.pipeline import engine as pe
from niworkflows.nipype.interfaces import utility as niu, afni
from niworkflows.interfaces.utils import CopyXForm

DEFAULT_MEMORY_MIN_GB = 0.01
LOGGER = logging.getLogger('workflow')
Expand Down Expand Up @@ -79,6 +80,8 @@ def create_custom_slice_timing_file_func(metadata):
afni.TShift(outputtype='NIFTI_GZ', tr='{}s'.format(metadata["RepetitionTime"])),
name='slice_timing_correction')

copy_xform = pe.Node(CopyXForm(), name='copy_xform', mem_gb=0.1, run_without_submitting=True)

def _prefix_at(x):
return "@" + x

Expand All @@ -87,7 +90,9 @@ def _prefix_at(x):
('skip_vols', 'ignore')]),
(create_custom_slice_timing_file, slice_timing_correction, [
(('out', _prefix_at), 'tpattern')]),
(slice_timing_correction, outputnode, [('out_file', 'stc_file')]),
(slice_timing_correction, copy_xform, [('out_file', 'in_file')]),
(inputnode, copy_xform, [('out_file', 'hdr_file')]),
(copy_xform, outputnode, [('out_file', 'stc_file')]),
])

return workflow
20 changes: 12 additions & 8 deletions fmriprep/workflows/bold/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,33 +162,37 @@ def init_enhance_and_skullstrip_bold_wf(name='enhance_and_skullstrip_bold_wf',
unifize = pe.Node(afni.Unifize(t2=True, outputtype='NIFTI_GZ',
args='-clfrac 0.4',
out_file="uni.nii.gz"), name='unifize')
fixhdr_unifize = pe.Node(CopyXForm(), name='fixhdr_unifize',
mem_gb=0.1, run_without_submitting=True)
skullstrip_second_pass = pe.Node(afni.Automask(dilate=1,
outputtype='NIFTI_GZ'),
name='skullstrip_second_pass')
fixhdr_skullstrip2 = pe.Node(CopyXForm(), name='fixhdr_skullstrip2',
mem_gb=0.1, run_without_submitting=True)
combine_masks = pe.Node(fsl.BinaryMaths(operation='mul'),
name='combine_masks')
apply_mask = pe.Node(fsl.ApplyMask(),
name='apply_mask')
copy_xform = pe.Node(CopyXForm(), name='copy_xform',
mem_gb=0.1, run_without_submitting=True)
mask_reportlet = pe.Node(SimpleShowMaskRPT(), name='mask_reportlet')

workflow.connect([
(inputnode, n4_correct, [('in_file', 'input_image')]),
(inputnode, copy_xform, [('in_file', 'hdr_file')]),
(inputnode, fixhdr_unifize, [('in_file', 'hdr_file')]),
(inputnode, fixhdr_skullstrip2, [('in_file', 'hdr_file')]),
(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')]),
(unifize, fixhdr_unifize, [('out_file', 'in_file')]),
(fixhdr_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')]),
(skullstrip_second_pass, fixhdr_skullstrip2, [('out_file', 'in_file')]),
(fixhdr_skullstrip2, combine_masks, [('out_file', 'operand_file')]),
(fixhdr_unifize, apply_mask, [('out_file', 'in_file')]),
(combine_masks, apply_mask, [('out_file', 'mask_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, copy_xform, [('out_file', 'in_file')]),
(copy_xform, outputnode, [('out_file', 'skull_stripped_file')]),
(apply_mask, outputnode, [('out_file', 'skull_stripped_file')]),
(n4_correct, outputnode, [('output_image', 'bias_corrected_file')]),
])

Expand Down