Skip to content

[WIP] ENH: Apply 9 DOF alignment in T1 merge #473

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

Closed
wants to merge 2 commits into from
Closed
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 fmriprep/interfaces/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _run_interface(self, runtime):
magmrg = fsl.Merge(dimension='t', in_files=self.inputs.in_files)
in_files = magmrg.run().outputs.merged_file
mcflirt = fsl.MCFLIRT(cost='normcorr', save_mats=True, save_plots=True,
ref_vol=0, in_file=in_files)
ref_vol=0, dof=9, in_file=in_files)
mcres = mcflirt.run()
self._results['out_mats'] = mcres.outputs.mat_file
self._results['out_movpar'] = mcres.outputs.par_file
Expand Down
21 changes: 7 additions & 14 deletions fmriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ def init_anat_preproc_wf(skull_strip_ants, debug, freesurfer, ants_nthreads,
if freesurfer:
workflow.connect([
(inputnode, surface_recon_wf, [
('t1w', 'inputnode.t1w'),
('t2w', 'inputnode.t2w'),
('subjects_dir', 'inputnode.subjects_dir')]),
(arw, surface_recon_wf, [('out', 'inputnode.reoriented_t1')]),
(arw, surface_recon_wf, [('out', 'inputnode.t1w')]),
(skullstrip_wf, surface_recon_wf, [
('outputnode.out_file', 'inputnode.skullstripped_t1')]),
(surface_recon_wf, outputnode, [
Expand Down Expand Up @@ -285,7 +284,7 @@ def init_surface_recon_wf(nthreads, hires, reportlets_dir, output_dir,

inputnode = pe.Node(
niu.IdentityInterface(
fields=['t1w', 't2w', 'reoriented_t1', 'skullstripped_t1', 'subjects_dir']),
fields=['t1w', 't2w', 'skullstripped_t1', 'subjects_dir']),
name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(
fields=['subjects_dir', 'subject_id', 'fs_2_t1_transform']), name='outputnode')
Expand All @@ -301,25 +300,19 @@ def detect_inputs(t1w_list, t2w_list=[], hires_enabled=True):
# Use high resolution preprocessing if voxel size < 1.0mm
# Tolerance of 0.05mm requires that rounds down to 0.9mm or lower
hires = hires_enabled and max(t1w_ref.header.get_zooms()) < 1 - 0.05
t1w_outs = [t1w_list.pop(0)]
for t1w in t1w_list:
img = nib.load(t1w)
if all((img.shape == t1w_ref.shape,
img.header.get_zooms() == t1w_ref.header.get_zooms())):
t1w_outs.append(t1w)

t2w = Undefined
if t2w_list and max(nib.load(t2w_list[0]).header.get_zooms()) < 1.2:
t2w = t2w_list[0]

# https://surfer.nmr.mgh.harvard.edu/fswiki/SubmillimeterRecon
mris_inflate = '-n 50' if hires else Undefined
return (t1w_outs, t2w, isdefined(t2w), hires, mris_inflate)
return (t2w, isdefined(t2w), hires, mris_inflate)

recon_config = pe.Node(
niu.Function(
function=detect_inputs,
output_names=['t1w', 't2w', 'use_T2', 'hires', 'mris_inflate']),
output_names=['t2w', 'use_T2', 'hires', 'mris_inflate']),
name='recon_config',
run_without_submitting=True)
recon_config.inputs.hires_enabled = hires
Expand Down Expand Up @@ -495,8 +488,8 @@ def normalize_surfs(in_file):
(reconall, outputnode, [('subjects_dir', 'subjects_dir'),
('subject_id', 'subject_id')]),
# Reconstruction phases
(recon_config, autorecon1, [('t1w', 'T1_files'),
('t2w', 'T2_file'),
(inputnode, autorecon1, [('t1w', 'T1_files')]),
(recon_config, autorecon1, [('t2w', 'T2_file'),
('hires', 'hires'),
# First run only (recon-all saves expert options)
('mris_inflate', 'mris_inflate')]),
Expand All @@ -508,7 +501,7 @@ def normalize_surfs(in_file):
(reconall, recon_report, [('out_report', 'in_file')]),
# Construct transform from FreeSurfer conformed image to FMRIPREP
# reoriented image
(inputnode, fs_transform, [('reoriented_t1', 'target_image')]),
(inputnode, fs_transform, [('t1w', 'target_image')]),
(autorecon1, fs_transform, [('T1', 'moving_image')]),
(fs_transform, outputnode, [('fsl_file', 'fs_2_t1_transform')]),
# Generate midthickness surfaces and save to FreeSurfer derivatives
Expand Down