Skip to content

Commit 8d779e2

Browse files
committed
improve
1 parent 53e2076 commit 8d779e2

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

fmriprep/interfaces/freesurfer.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
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
3838
from nipype.interfaces.freesurfer.utils import LTAConvert
3939
from niworkflows.interfaces.registration import BBRegisterRPT, MRICoregRPT
4040

@@ -193,15 +193,23 @@ def _run_interface(self, runtime):
193193

194194

195195
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+
196208
# Use a tuple in case some object produces multiple transforms
197209
lta_outputs = ('out_lta_file',)
198210

199211
def _post_run_hook(self, runtime):
200212

201-
outputs = self.aggregate_outputs(runtime)
202-
print(outputs)
203-
print(type(outputs))
204-
# I will modify this as soon as I understand what is the right syntax to use it
205213
outputs = self._list_outputs()
206214

207215
for lta_name in self.lta_outputs:
@@ -231,23 +239,26 @@ def _post_run_hook(self, runtime):
231239
return runtime
232240

233241

234-
class PatchedConcatenateLTA(ConcatenateLTA):
242+
class PatchedConcatenateLTA(TruncateLTA, ConcatenateLTA):
235243
"""
236244
A temporarily patched version of ``fs.ConcatenateLTA`` to recover from
237245
`this bug <https://www.mail-archive.com/[email protected]/msg55520.html>`_
238246
in FreeSurfer, that was
239247
`fixed here <https://github.com/freesurfer/freesurfer/pull/180>`__.
248+
240249
The original FMRIPREP's issue is found
241250
`here <https://github.com/poldracklab/fmriprep/issues/768>`__.
242251
243-
this is no more useful, since we now change the lta file after their creation by
244-
patching LTAconvert directly
245-
we can remove it and the reference to it
252+
the fix is now done through mixin with TruncateLTA
246253
"""
247-
pass
254+
lta_outputs = ['out_file']
248255

249256

250-
class PatchedLTAconvert(TruncateLTA, LTAConvert):
257+
class PatchedLTAConvert(TruncateLTA, LTAConvert):
258+
"""
259+
LTAconvert is producing a lta file refer as out_lta
260+
truncate filename through mixin TruncateLTA
261+
"""
251262
lta_outputs = ('out_lta',)
252263

253264

@@ -259,6 +270,10 @@ class PatchedMRICoregRPT(TruncateLTA, MRICoregRPT):
259270
pass
260271

261272

273+
class PatchedRobustRegister(TruncateLTA, RobustRegister):
274+
lta_outputs = ('out_reg_file', 'half_source_xfm', 'half_targ_xfm')
275+
276+
262277
class RefineBrainMaskInputSpec(BaseInterfaceInputSpec):
263278
in_anat = File(exists=True, mandatory=True,
264279
desc='input anatomical reference (INU corrected)')

0 commit comments

Comments
 (0)