34
34
)
35
35
from nipype .interfaces import freesurfer as fs
36
36
from nipype .interfaces .base import SimpleInterface
37
- from nipype .interfaces .freesurfer .preprocess import ConcatenateLTA
37
+ from nipype .interfaces .freesurfer .preprocess import ConcatenateLTA , RobustRegister
38
38
from nipype .interfaces .freesurfer .utils import LTAConvert
39
39
from niworkflows .interfaces .registration import BBRegisterRPT , MRICoregRPT
40
40
@@ -193,15 +193,23 @@ def _run_interface(self, runtime):
193
193
194
194
195
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
+
196
208
# Use a tuple in case some object produces multiple transforms
197
209
lta_outputs = ('out_lta_file' ,)
198
210
199
211
def _post_run_hook (self , runtime ):
200
212
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
205
213
outputs = self ._list_outputs ()
206
214
207
215
for lta_name in self .lta_outputs :
@@ -231,23 +239,26 @@ def _post_run_hook(self, runtime):
231
239
return runtime
232
240
233
241
234
- class PatchedConcatenateLTA (ConcatenateLTA ):
242
+ class PatchedConcatenateLTA (TruncateLTA , ConcatenateLTA ):
235
243
"""
236
244
A temporarily patched version of ``fs.ConcatenateLTA`` to recover from
237
245
`this bug <https://www.mail-archive.com/[email protected] /msg55520.html>`_
238
246
in FreeSurfer, that was
239
247
`fixed here <https://github.com/freesurfer/freesurfer/pull/180>`__.
248
+
240
249
The original FMRIPREP's issue is found
241
250
`here <https://github.com/poldracklab/fmriprep/issues/768>`__.
242
251
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
246
253
"""
247
- pass
254
+ lta_outputs = [ 'out_file' ]
248
255
249
256
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
+ """
251
262
lta_outputs = ('out_lta' ,)
252
263
253
264
@@ -259,6 +270,10 @@ class PatchedMRICoregRPT(TruncateLTA, MRICoregRPT):
259
270
pass
260
271
261
272
273
+ class PatchedRobustRegister (TruncateLTA , RobustRegister ):
274
+ lta_outputs = ('out_reg_file' , 'half_source_xfm' , 'half_targ_xfm' )
275
+
276
+
262
277
class RefineBrainMaskInputSpec (BaseInterfaceInputSpec ):
263
278
in_anat = File (exists = True , mandatory = True ,
264
279
desc = 'input anatomical reference (INU corrected)' )
0 commit comments