Skip to content

Commit ab686c9

Browse files
authored
Merge pull request #1353 from poldracklab/revert-1283-enh/3dvolreg
Revert #1283 enh/3dvolreg
2 parents b9576a5 + c31f25c commit ab686c9

File tree

16 files changed

+43
-174
lines changed

16 files changed

+43
-174
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ jobs:
537537
-e FMRIPREP_DEV 1 \
538538
--config $PWD/nipype.cfg -w /tmp/ds054/work \
539539
/tmp/data/ds054 /tmp/ds054/derivatives participant \
540-
--fs-no-reconall --sloppy --hmc-use-mcflirt \
540+
--fs-no-reconall --sloppy \
541541
--output-space T1w template \
542542
--template-resampling-grid 2mm \
543543
--mem_mb 4096 --nthreads 2 -vv

docs/citing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ we recommend to include in your paper.
100100

101101
<p style="font-style: italic;">
102102
Functional data was <span class="slicetime_text_true">slice time corrected using
103-
<code>3dTshift</code> (AFNI v16.2.07 [11, RRID:SCR_005927]) and </span>
104-
motion-corrected using <code>3dVolreg</code> (AFNI v16.2.07 [11, RRID:SCR_005927]).
103+
<code>3dTshift</code> from AFNI v16.2.07 [11, RRID:SCR_005927]
104+
and </span>motion corrected using <code>mcflirt</code> (FSL v5.0.9 [9]).
105105
<span class="SDC_text_TOPUP" style="display: none">Distortion correction was performed
106106
using an implementation of the TOPUP technique [10] using <code>3dQwarp</code> (AFNI v16.2.07 [11]).</span>
107107
<span class="SDC_text_FUGUE" style="display: none">Distortion correction was performed using fieldmaps

docs/outputs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Derivatives related to EPI files are in the ``func`` subfolder.
7777
Volumetric output spaces include ``T1w`` and ``MNI152NLin2009cAsym`` (default).
7878

7979
- ``*bold_space-<space>_brainmask.nii.gz`` Brain mask for EPI files, calculated by nilearn on the average EPI volume, post-motion correction
80-
- ``*bold_space-<space>_preproc.nii.gz`` Head-motion corrected EPI file
81-
- (optional) ``*bold_space-<space>_variant-smoothAROMAnonaggr_preproc.nii.gz`` Head-motion corrected,
80+
- ``*bold_space-<space>_preproc.nii.gz`` Motion-corrected (using MCFLIRT for estimation and ANTs for interpolation) EPI file
81+
- (optional) ``*bold_space-<space>_variant-smoothAROMAnonaggr_preproc.nii.gz`` Motion-corrected (using MCFLIRT for estimation and ANTs for interpolation),
8282
smoothed (6mm), and non-aggressively denoised (using AROMA) EPI file - currently produced only for the ``MNI152NLin2009cAsym`` space
8383

8484
Surface output spaces include ``fsnative`` (full density subject-specific mesh),

docs/workflows.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ is presented below:
5151
use_aroma=False,
5252
aroma_melodic_dim=None,
5353
ignore_aroma_err=False,
54-
use_mcflirt=False,
5554
)
5655

5756

@@ -274,7 +273,6 @@ BOLD preprocessing
274273
use_aroma=False,
275274
aroma_melodic_dim=None,
276275
ignore_aroma_err=False,
277-
use_mcflirt=False,
278276
)
279277

280278
Preprocessing of :abbr:`BOLD (blood-oxygen level-dependent)` files is
@@ -336,12 +334,11 @@ Head-motion estimation
336334

337335
from fmriprep.workflows.bold import init_bold_hmc_wf
338336
wf = init_bold_hmc_wf(
339-
use_mcflirt=False,
340337
mem_gb=1,
341338
omp_nthreads=1)
342339

343340
Using the previously :ref:`estimated reference scan <bold_ref>`,
344-
AFNI's ``3dVolreg`` is used to estimate head-motion.
341+
FSL ``mcflirt`` is used to estimate head-motion.
345342
As a result, one rigid-body transform with respect to
346343
the reference image is written for each :abbr:`BOLD (blood-oxygen level-dependent)`
347344
time-step.
@@ -551,7 +548,7 @@ Confounds estimation
551548
metadata={"RepetitionTime": 2.0,
552549
"SliceTiming": [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]})
553550

554-
Given a motion-corrected fMRI, a brain mask, head-motion parameters and a
551+
Given a motion-corrected fMRI, a brain mask, ``mcflirt`` movement parameters and a
555552
segmentation, the `discover_wf` sub-workflow calculates potential
556553
confounds per volume.
557554

fmriprep/__about__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
'scikit-image',
106106
'versioneer',
107107
'pyyaml',
108-
'transforms3d',
109108
]
110109

111110
LINKS_REQUIRES = [

fmriprep/cli/run.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ def get_parser():
160160
'--medial-surface-nan', required=False, action='store_true', default=False,
161161
help='Replace medial wall values with NaNs on functional GIFTI files. Only '
162162
'performed for GIFTI files mapped to a freesurfer subject (fsaverage or fsnative).')
163-
g_conf.add_argument(
164-
'--hmc-use-mcflirt', required=False, action='store_true', default=False,
165-
help='Head-Motion Correction (HMC) - use FSL\'s ``mcflirt`` instead '
166-
'of AFNI\'s ``3dVolreg``.')
167163

168164
# ICA_AROMA options
169165
g_aroma = parser.add_argument_group('Specific options for running ICA_AROMA')
@@ -558,7 +554,6 @@ def build_workflow(opts, retval):
558554
use_aroma=opts.use_aroma,
559555
aroma_melodic_dim=opts.aroma_melodic_dimensionality,
560556
ignore_aroma_err=opts.ignore_aroma_denoising_errors,
561-
use_mcflirt=opts.hmc_use_mcflirt,
562557
)
563558
retval['return_code'] = 0
564559

fmriprep/interfaces/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
from .utils import TPM2ROI, AddTPMs, AddTSVHeader, ConcatAffines, JoinTSVColumns
1717
from .fmap import FieldEnhance, FieldToRadS, FieldToHz, Phasediff2Fieldmap
1818
from .confounds import GatherConfounds, ICAConfounds, FMRISummary
19-
from .itk import MCFLIRT2ITK, Volreg2ITK, MultiApplyTransforms
19+
from .itk import MCFLIRT2ITK, MultiApplyTransforms
2020
from .multiecho import FirstEcho

fmriprep/interfaces/images.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
traits, TraitedSpec, BaseInterfaceInputSpec, SimpleInterface,
2222
File, InputMultiPath, OutputMultiPath)
2323
from nipype.interfaces import fsl
24-
from fmriprep.utils.misc import remove_rotation_and_shear
2524

2625
LOGGER = logging.getLogger('nipype.interface')
2726

@@ -294,7 +293,6 @@ def _run_interface(self, runtime):
294293

295294
class ValidateImageInputSpec(BaseInterfaceInputSpec):
296295
in_file = File(exists=True, mandatory=True, desc='input image')
297-
remove_rotation_and_shear = traits.Bool(False, usedefault=True)
298296

299297

300298
class ValidateImageOutputSpec(TraitedSpec):
@@ -344,7 +342,6 @@ class ValidateImage(SimpleInterface):
344342
output_spec = ValidateImageOutputSpec
345343

346344
def _run_interface(self, runtime):
347-
348345
img = nb.load(self.inputs.in_file)
349346
out_report = os.path.join(runtime.cwd, 'report.html')
350347

@@ -373,14 +370,7 @@ def _run_interface(self, runtime):
373370

374371
# Both match, qform valid (implicit with match), codes okay -> do nothing, empty report
375372
if matching_affines and qform_code > 0 and sform_code > 0:
376-
if self.inputs.remove_rotation_and_shear:
377-
out_fname = fname_presuffix(self.inputs.in_file, suffix='_valid',
378-
newpath=runtime.cwd)
379-
img = remove_rotation_and_shear(img)
380-
img.to_filename(out_fname)
381-
self._results['out_file'] = out_fname
382-
else:
383-
self._results['out_file'] = self.inputs.in_file
373+
self._results['out_file'] = self.inputs.in_file
384374
open(out_report, 'w').close()
385375
self._results['out_report'] = out_report
386376
return runtime
@@ -428,9 +418,6 @@ def _run_interface(self, runtime):
428418
</p>
429419
"""
430420
snippet = '<h3 class="elem-title">%s</h3>\n%s\n' % (warning_txt, description)
431-
432-
if self.inputs.remove_rotation_and_shear:
433-
img = remove_rotation_and_shear(img)
434421
# Store new file and report
435422
img.to_filename(out_fname)
436423
with open(out_report, 'w') as fobj:

fmriprep/interfaces/itk.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
1010
"""
1111
import os
12-
from pathlib import Path
1312
from mimetypes import guess_type
1413
from tempfile import TemporaryDirectory
1514
import numpy as np
@@ -79,49 +78,6 @@ def _run_interface(self, runtime):
7978
return runtime
8079

8180

82-
class Volreg2ITKInputSpec(BaseInterfaceInputSpec):
83-
in_file = File(exists=True, mandatory=True,
84-
desc='mat file generated by AFNI\'s 3dVolreg')
85-
86-
87-
class Volreg2ITKOutputSpec(TraitedSpec):
88-
out_file = File(desc='the output ITKTransform file')
89-
90-
91-
class Volreg2ITK(SimpleInterface):
92-
93-
"""
94-
Convert an AFNI's mat file into an ITK Transform file.
95-
"""
96-
input_spec = Volreg2ITKInputSpec
97-
output_spec = Volreg2ITKOutputSpec
98-
99-
def _run_interface(self, runtime):
100-
# Load AFNI mat entries and reshape appropriately
101-
orig_afni_mat = np.loadtxt(self.inputs.in_file)
102-
afni_affines = [mat.reshape(3, 4, order='C') for mat in orig_afni_mat]
103-
104-
out_file = Path(fname_presuffix(self.inputs.in_file, use_ext=False,
105-
suffix='_mc4d_itk.txt', newpath=runtime.cwd))
106-
107-
fixed_params = 'FixedParameters: 0 0 0' # Center of rotation does not change
108-
lines = ["#Insight Transform File V1.0"]
109-
for i, affine in enumerate(afni_affines):
110-
lines.append("#Transform %d" % i)
111-
lines.append("Transform: AffineTransform_double_3_3")
112-
113-
ants_affine_2d = np.hstack((affine[:3, :3].reshape(1, -1),
114-
affine[:3, 3].reshape(1, -1)))
115-
params = ants_affine_2d.reshape(-1).astype('float64')
116-
params_list = ["%g" % i for i in params.tolist()]
117-
lines.append("Parameters: %s" % ' '.join(params_list))
118-
lines.append(fixed_params)
119-
120-
out_file.write_text('\n'.join(lines))
121-
self._results['out_file'] = str(out_file)
122-
return runtime
123-
124-
12581
class MultiApplyTransformsInputSpec(ApplyTransformsInputSpec):
12682
input_image = InputMultiPath(File(exists=True), mandatory=True,
12783
desc='input time-series as a list of volumes after splitting'

fmriprep/utils/misc.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,6 @@
77
"""
88

99

10-
def remove_rotation_and_shear(img):
11-
from transforms3d.affines import decompose, compose
12-
import numpy as np
13-
14-
T, _, Z, _ = decompose(img.affine)
15-
affine = compose(T=T, R=np.diag([1, 1, 1]), Z=Z)
16-
return img.__class__(np.asanyarray(img.dataobj), affine, img.header)
17-
18-
19-
def split_and_rm_rotshear_func(in_file):
20-
import os
21-
import nibabel as nb
22-
from fmriprep.utils.misc import remove_rotation_and_shear
23-
out_files = []
24-
imgs = nb.four_to_three(nb.load(in_file))
25-
for i, img in enumerate(imgs):
26-
out_file = os.path.abspath('vol%04d.nii.gz' % i)
27-
img = remove_rotation_and_shear(
28-
nb.as_closest_canonical(img))
29-
img.to_filename(out_file)
30-
out_files.append(out_file)
31-
return out_files
32-
33-
3410
def fix_multi_T1w_source_name(in_files):
3511
"""
3612
Make up a generic source name when there are multiple T1s

0 commit comments

Comments
 (0)