Skip to content

Commit 0420e3d

Browse files
authored
Merge branch 'master' into enh/3dvolreg
2 parents add3e00 + 26e0f44 commit 0420e3d

File tree

16 files changed

+338
-133
lines changed

16 files changed

+338
-133
lines changed

.circleci/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ jobs:
252252
name: Run fMRIPrep tests
253253
no_output_timeout: 2h
254254
command: |
255+
mkdir /tmp/data/reports && \
255256
docker run -ti --rm=false \
256257
-v /tmp/data:/tmp/data \
257258
-e FMRIPREP_REGRESSION_SOURCE=/tmp/data/fmriprep_bold_truncated \
258259
-e FMRIPREP_REGRESSION_TARGETS=/tmp/data/fmriprep_bold_mask \
260+
-e FMRIPREP_REGRESSION_REPORTS=/tmp/data/reports \
259261
--entrypoint="py.test" poldracklab/fmriprep:latest \
260262
/root/src/fmriprep/ \
261263
--doctest-modules --ignore=/root/src/fmriprep/docs --ignore=setup.py
@@ -284,7 +286,7 @@ jobs:
284286
fmriprep-docker -i poldracklab/fmriprep:latest --help
285287
fmriprep-docker -i poldracklab/fmriprep:latest --version
286288
- store_artifacts:
287-
path: /home/circleci/out/tests
289+
path: /tmp/data/reports
288290

289291

290292
build_docs:

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@
8383
"affiliation": "Department of Psychology, Stanford University",
8484
"orcid": "0000-0001-6755-0259"
8585
},
86+
{
87+
"name": "Valabregue, Romain",
88+
"affiliation": "Cenir, ICM, Paris",
89+
"orcid": "0000-0002-1814-9570"
90+
},
8691
{
8792
"name": "Gorgolewski, Krzysztof J.",
8893
"affiliation": "Department of Psychology, Stanford University",

CHANGES.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
1.1.7 (September 25, 2018)
2+
==========================
3+
4+
Several bug fixes. With thanks to Elizabeth Dupre and Romain Vala for
5+
contributions.
6+
7+
* [FIX] Revert FreeSurfer download URL (#1280) @chrisfilo
8+
* [FIX] Default to 6 DoF for BOLD-T1w registration (#1286) @effigies
9+
* [FIX] Only grab sbref images, not metadata (#1285) @effigies
10+
* [FIX] QwarpPlusMinus renamed source_file to in_file (#1289) @effigies
11+
* [FIX] Remove long paths from all LTA output files (#1274) @romainVala
12+
* [ENH] Use single-band reference images when available (#1270) @effigies
13+
* [DOC] Note GIFTI surface alignment (#1288) @effigies
14+
* [REF] Split BOLD-T1w registration into calculation/application workflows (#1278) @emdupre
15+
* [MAINT] Pin pybids and grabbit in Docker build (#1281) @chrisfilo
16+
117
1.1.6 (September 10, 2018)
218
==========================
319

@@ -8,6 +24,9 @@ Hotfix release.
824
1.1.5 (September 06, 2018)
925
==========================
1026

27+
Improved documentation and minor bug fixes. With thanks to Jarod Roland and
28+
Taylor Salo for contributions.
29+
1130
* [DOC] Replace ``--clearenv`` with correct ``--cleanenv`` flag (#1237) @jarodroland
1231
* [DOC] De-indent to remove text from code block (#1238) @effigies
1332
* [TST] Add enhance-and-skullstrip regression tests (#1074) @effigies
@@ -27,13 +46,21 @@ Hotfix release.
2746
1.1.4 (August 06, 2018)
2847
=======================
2948

49+
A hotfix release for `#1235
50+
<https://github.com/poldracklab/fmriprep/issues/1235>`_. Additionally,
51+
notebooks have been synced with the latest version of that repository.
52+
3053
* [FIX] Verify first word of ``_cmd`` in dependency check (#1236)
3154
* [DOC] Add two missing references (#1234)
3255
* [ENH] Allow turning off random seeding for ANTs brain extraction (#919)
3356

3457
1.1.3 (July 30, 2018)
3558
=====================
3659

60+
This release comes with many updates to the documentation, a more lightweight
61+
``SignalExtraction``, a new dynamic boilerplate and some new features from
62+
Nipype.
63+
3764
* [ENH] Use upstream ``afni.TShift`` improvements (#1160)
3865
* [PIN] Nipype 1.1.1 (65078c9)
3966
* [ENH] Dynamic citation boilerplate (#1024)

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ RUN conda install -y mkl=2018.0.3 mkl-service; sync &&\
114114
pandas=0.23.0 \
115115
libxml2=2.9.4 \
116116
libxslt=1.1.29 \
117+
graphviz=2.40.1 \
117118
traits=4.6.0; sync && \
118119
chmod -R a+rX /usr/local/miniconda; sync && \
119120
chmod +x /usr/local/miniconda/bin/*; sync && \
@@ -127,8 +128,7 @@ RUN python -c "from matplotlib import font_manager" && \
127128
# Installing Ubuntu packages and cleaning up
128129
RUN apt-get update && \
129130
apt-get install -y --no-install-recommends \
130-
git=1:2.7.4-0ubuntu1 \
131-
graphviz=2.38.0-12ubuntu2 && \
131+
git=1:2.7.4-0ubuntu1 && \
132132
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
133133

134134
# Install latest pandoc
@@ -183,4 +183,3 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
183183
org.label-schema.vcs-url="https://github.com/poldracklab/fmriprep" \
184184
org.label-schema.version=$VERSION \
185185
org.label-schema.schema-version="1.0"
186-

docs/workflows.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ to be run through ``fmriprep``.
128128

129129
Longitudinal processing
130130
~~~~~~~~~~~~~~~~~~~~~~~
131-
In the case of multiple T1w images (across sessions and/or runs), T1w images are
131+
In the case of multiple T1w images (across sessions and/or runs), T1w images are
132132
merged into a single template image using FreeSurfer's `mri_robust_template`_.
133133
This template may be *unbiased*, or equidistant from all source images, or
134134
aligned to the first image (determined lexicographically by session label).
@@ -219,6 +219,12 @@ The ``smoothwm``, ``midthickness``, ``pial`` and ``inflated`` surfaces are also
219219
converted to GIFTI_ format and adjusted to be compatible with multiple software
220220
packages, including FreeSurfer and the `Connectome Workbench`_.
221221

222+
.. note::
223+
GIFTI surface outputs are aligned to the FreeSurfer T1.mgz image, which
224+
may differ from the T1w space in some cases, to maintain compatibility
225+
with the FreeSurfer directory.
226+
Any measures sampled to the surface take into account any difference in
227+
these images.
222228

223229
Refinement of the brain mask
224230
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -376,7 +382,7 @@ T2* Driven Coregistration
376382
:mod:`fmriprep.workflows.bold.t2s.init_bold_t2s_wf`
377383

378384
.. workflow::
379-
:graph2use: colored
385+
:graph2use: orig
380386
:simple_form: yes
381387

382388
from fmriprep.workflows.bold import init_bold_t2s_wf
@@ -389,7 +395,7 @@ T2* Driven Coregistration
389395
If the ``--t2s-coreg`` command line argument is supplied with multi-echo
390396
:abbr:`BOLD (blood-oxygen level-dependent)` data, a T2* map is generated.
391397
This T2* map is then used in place of the :ref:`BOLD reference image <bold_ref>`
392-
to ref:`register the BOLD series to the T1w image of the same subject <bold_reg>`.
398+
to :ref:`register the BOLD series to the T1w image <bold_reg>` of the same subject.
393399

394400
Susceptibility Distortion Correction (SDC)
395401
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -448,9 +454,9 @@ EPI to T1w registration
448454
use_bbr=True,
449455
bold2t1w_dof=9)
450456

451-
The reference :abbr:`EPI (echo-planar imaging)` image of each run is aligned
452-
by the ``bbregister`` routine to the reconstructed subject using the gray/white
453-
matter boundary (FreeSurfer's ``?h.white`` surfaces).
457+
The alignment between the reference :abbr:`EPI (echo-planar imaging)` image
458+
of each run and the reconstructed subject using the gray/white matter boundary
459+
(FreeSurfer's ``?h.white`` surfaces) is calculated by the ``bbregister`` routine.
454460

455461
.. figure:: _static/EPIT1Normalization.svg
456462
:scale: 100%
@@ -459,7 +465,9 @@ matter boundary (FreeSurfer's ``?h.white`` surfaces).
459465

460466
If FreeSurfer processing is disabled, FSL ``flirt`` is run with the
461467
:abbr:`BBR (boundary-based registration)` cost function, using the
462-
``fast`` segmentation to establish the gray/white matter boundary. After :abbr:`BBR (boundary-based registration)` is run, the resulting affine transform will be compared to the initial transform found by FLIRT. Excessive deviation will result in rejecting the BBR refinement and accepting the original, affine registration.
468+
``fast`` segmentation to establish the gray/white matter boundary.
469+
After :abbr:`BBR (boundary-based registration)` is run, the resulting affine transform will be compared to the initial transform found by FLIRT.
470+
Excessive deviation will result in rejecting the BBR refinement and accepting the original, affine registration.
463471

464472
EPI to MNI transformation
465473
~~~~~~~~~~~~~~~~~~~~~~~~~

fmriprep/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'grabbit',
9898
'pybids>=0.6.3',
9999
'nitime',
100-
'nipype>=1.1.1',
100+
'nipype>=1.1.3',
101101
'niworkflows>=0.4.3',
102102
'statsmodels',
103103
'seaborn',

fmriprep/cli/run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ def get_parser():
119119
'T2*-driven coregistration. When multi-echo data is provided and this '
120120
'option is not enabled, standard EPI-T1 coregistration is performed '
121121
'using the middle echo.')
122-
g_conf.add_argument('--bold2t1w-dof', action='store', default=9, choices=[6, 9, 12], type=int,
122+
g_conf.add_argument('--bold2t1w-dof', action='store', default=6, choices=[6, 9, 12], type=int,
123123
help='Degrees of freedom when registering BOLD to T1w images. '
124-
'9 (rotation, translation, and scaling) is used by '
125-
'default to compensate for field inhomogeneities.')
124+
'6 degrees (rotation and translation) are used by default.')
126125
g_conf.add_argument(
127126
'--output-space', required=False, action='store',
128127
choices=['T1w', 'template', 'fsnative', 'fsaverage', 'fsaverage6', 'fsaverage5'],

fmriprep/interfaces/freesurfer.py

Lines changed: 73 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
)
3535
from nipype.interfaces import freesurfer as fs
3636
from nipype.interfaces.base import SimpleInterface
37-
from nipype.interfaces.freesurfer.preprocess import ConcatenateLTA
37+
from nipype.interfaces.freesurfer.preprocess import ConcatenateLTA, RobustRegister
38+
from nipype.interfaces.freesurfer.utils import LTAConvert
39+
from niworkflows.interfaces.registration import BBRegisterRPT, MRICoregRPT
3840

3941

4042
class StructuralReference(fs.RobustTemplate):
@@ -190,7 +192,54 @@ def _run_interface(self, runtime):
190192
return runtime
191193

192194

193-
class PatchedConcatenateLTA(ConcatenateLTA):
195+
class TruncateLTA(object):
196+
"""Mixin to ensure that LTA files do not store overly long paths,
197+
which lead to segmentation faults when read by FreeSurfer tools.
198+
199+
See the following issues for discussion:
200+
201+
* https://github.com/freesurfer/freesurfer/pull/180
202+
* https://github.com/poldracklab/fmriprep/issues/768
203+
* https://github.com/poldracklab/fmriprep/pull/778
204+
* https://github.com/poldracklab/fmriprep/issues/1268
205+
* https://github.com/poldracklab/fmriprep/pull/1274
206+
"""
207+
208+
# Use a tuple in case some object produces multiple transforms
209+
lta_outputs = ('out_lta_file',)
210+
211+
def _post_run_hook(self, runtime):
212+
213+
outputs = self._list_outputs()
214+
215+
for lta_name in self.lta_outputs:
216+
lta_file = outputs[lta_name]
217+
if not isdefined(lta_file):
218+
continue
219+
220+
with open(lta_file, 'r') as f:
221+
lines = f.readlines()
222+
223+
fixed = False
224+
newfile = []
225+
226+
for line in lines:
227+
if line.startswith('filename = ') and len(line.strip("\n")) >= 255:
228+
fixed = True
229+
newfile.append('filename = path_too_long\n')
230+
else:
231+
newfile.append(line)
232+
233+
if fixed:
234+
with open(lta_file, 'w') as f:
235+
f.write(''.join(newfile))
236+
237+
runtime = super(TruncateLTA, self)._post_run_hook(runtime)
238+
239+
return runtime
240+
241+
242+
class PatchedConcatenateLTA(TruncateLTA, ConcatenateLTA):
194243
"""
195244
A temporarily patched version of ``fs.ConcatenateLTA`` to recover from
196245
`this bug <https://www.mail-archive.com/[email protected]/msg55520.html>`_
@@ -199,27 +248,30 @@ class PatchedConcatenateLTA(ConcatenateLTA):
199248
200249
The original FMRIPREP's issue is found
201250
`here <https://github.com/poldracklab/fmriprep/issues/768>`__.
251+
252+
the fix is now done through mixin with TruncateLTA
202253
"""
254+
lta_outputs = ['out_file']
203255

204-
def _list_outputs(self):
205-
outputs = super(PatchedConcatenateLTA, self)._list_outputs()
206-
207-
with open(outputs['out_file'], 'r') as f:
208-
lines = f.readlines()
209-
210-
fixed = False
211-
newfile = []
212-
for line in lines:
213-
if line.startswith('filename = ') and len(line.strip("\n")) >= 255:
214-
fixed = True
215-
newfile.append('filename = path_too_long\n')
216-
else:
217-
newfile.append(line)
218-
219-
if fixed:
220-
with open(outputs['out_file'], 'w') as f:
221-
f.write(''.join(newfile))
222-
return outputs
256+
257+
class PatchedLTAConvert(TruncateLTA, LTAConvert):
258+
"""
259+
LTAconvert is producing a lta file refer as out_lta
260+
truncate filename through mixin TruncateLTA
261+
"""
262+
lta_outputs = ('out_lta',)
263+
264+
265+
class PatchedBBRegisterRPT(TruncateLTA, BBRegisterRPT):
266+
pass
267+
268+
269+
class PatchedMRICoregRPT(TruncateLTA, MRICoregRPT):
270+
pass
271+
272+
273+
class PatchedRobustRegister(TruncateLTA, RobustRegister):
274+
lta_outputs = ('out_reg_file', 'half_source_xfm', 'half_targ_xfm')
223275

224276

225277
class RefineBrainMaskInputSpec(BaseInterfaceInputSpec):

fmriprep/workflows/anatomical.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
ConcatAffines, RefineBrainMask,
5050
)
5151
from ..utils.misc import fix_multi_T1w_source_name, add_suffix
52+
from ..interfaces.freesurfer import (
53+
PatchedLTAConvert as LTAConvert,
54+
PatchedRobustRegister as RobustRegister)
5255

5356
TEMPLATE_MAP = {
5457
'MNI152NLin2009cAsym': 'mni_icbm152_nlin_asym_09c',
@@ -533,7 +536,7 @@ def _get_first(in_list):
533536
# 2. Reorient template to RAS, if needed (mri_robust_template may set to LIA)
534537
t1_reorient = pe.Node(image.Reorient(), name='t1_reorient')
535538

536-
lta_to_fsl = pe.MapNode(fs.utils.LTAConvert(out_fsl=True), iterfield=['in_lta'],
539+
lta_to_fsl = pe.MapNode(LTAConvert(out_fsl=True), iterfield=['in_lta'],
537540
name='lta_to_fsl')
538541

539542
concat_affines = pe.MapNode(
@@ -813,9 +816,9 @@ def init_surface_recon_wf(omp_nthreads, hires, name='surface_recon_wf'):
813816

814817
skull_strip_extern = pe.Node(FSInjectBrainExtracted(), name='skull_strip_extern')
815818

816-
fsnative_2_t1_xfm = pe.Node(fs.RobustRegister(auto_sens=True, est_int_scale=True),
819+
fsnative_2_t1_xfm = pe.Node(RobustRegister(auto_sens=True, est_int_scale=True),
817820
name='fsnative_2_t1_xfm')
818-
t1_2_fsnative_xfm = pe.Node(fs.utils.LTAConvert(out_lta=True, invert=True),
821+
t1_2_fsnative_xfm = pe.Node(LTAConvert(out_lta=True, invert=True),
819822
name='t1_2_fsnative_xfm')
820823

821824
autorecon_resume_wf = init_autorecon_resume_wf(omp_nthreads=omp_nthreads)
@@ -1279,7 +1282,7 @@ def init_anat_derivatives_wf(output_dir, output_spaces, template, freesurfer,
12791282
DerivativesDataSink(base_directory=output_dir, suffix=suffix_fmt(template, 'warp')),
12801283
name='ds_t1_mni_warp', run_without_submitting=True)
12811284

1282-
lta_2_itk = pe.Node(fs.utils.LTAConvert(out_itk=True), name='lta_2_itk')
1285+
lta_2_itk = pe.Node(LTAConvert(out_itk=True), name='lta_2_itk')
12831286

12841287
ds_t1_fsnative = pe.Node(
12851288
DerivativesDataSink(base_directory=output_dir, suffix=suffix_fmt('fsnative', 'affine')),

fmriprep/workflows/bold/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
from .hmc import init_bold_hmc_wf
2525
from .stc import init_bold_stc_wf
2626
from .t2s import init_bold_t2s_wf
27-
from .registration import init_bold_reg_wf
27+
from .registration import (
28+
init_bold_t1_trans_wf,
29+
init_bold_reg_wf,
30+
)
2831
from .resampling import (
2932
init_bold_mni_trans_wf,
3033
init_bold_surf_wf,

0 commit comments

Comments
 (0)