2
2
# vi: set ft=python sts=4 ts=4 sw=4 et:
3
3
4
4
import os
5
+ from warnings import warn
6
+
5
7
import nipype .pipeline .engine as pe
6
8
import nipype .interfaces .utility as util
7
9
import nipype .interfaces .fsl as fsl
@@ -99,7 +101,7 @@ def create_tbss_2_reg(name="tbss_2_reg"):
99
101
100
102
>>> from nipype.workflows.dmri.fsl import tbss
101
103
>>> tbss2 = create_tbss_2_reg(name="tbss2")
102
- >>> tbss2.inputs.inputnode.target = fsl.Info.standard_image("FMRIB58_FA_1mm.nii.gz")
104
+ >>> tbss2.inputs.inputnode.target = fsl.Info.standard_image("FMRIB58_FA_1mm.nii.gz") # doctest: +SKIP
103
105
>>> tbss2.inputs.inputnode.fa_list = ['s1_FA.nii', 's2_FA.nii', 's3_FA.nii']
104
106
>>> tbss2.inputs.inputnode.mask_list = ['s1_mask.nii', 's2_mask.nii', 's3_mask.nii']
105
107
@@ -126,13 +128,16 @@ def create_tbss_2_reg(name="tbss_2_reg"):
126
128
iterfield = ['in_file' , 'in_weight' ],
127
129
name = "flirt" )
128
130
131
+ fnirt = pe .MapNode (interface = fsl .FNIRT (fieldcoeff_file = True ),
132
+ iterfield = ['in_file' , 'inmask_file' , 'affine_file' ],
133
+ name = "fnirt" )
129
134
# Fnirt the FA image to the target
130
- config_file = os . path . join ( os . environ [ "FSLDIR" ],
131
- "etc/flirtsch/FA_2_FMRIB58_1mm.cnf" )
132
- fnirt = pe . MapNode ( interface = fsl . FNIRT ( config_file = config_file ,
133
- fieldcoeff_file = True ) ,
134
- iterfield = [ 'in_file' , 'inmask_file' , 'affine_file' ],
135
- name = " fnirt" )
135
+ if fsl . no_fsl ():
136
+ warn ( 'NO FSL found' )
137
+ else :
138
+ config_file = os . path . join ( os . environ [ "FSLDIR" ] ,
139
+ "etc/flirtsch/FA_2_FMRIB58_1mm.cnf" )
140
+ fnirt . inputs . config_file = config_file
136
141
137
142
# Define the registration workflow
138
143
tbss2 = pe .Workflow (name = name )
@@ -195,7 +200,10 @@ def create_tbss_3_postreg(name='tbss_3_postreg', estimate_skeleton=True):
195
200
applywarp = pe .MapNode (interface = fsl .ApplyWarp (),
196
201
iterfield = ['in_file' , 'field_file' ],
197
202
name = "applywarp" )
198
- applywarp .inputs .ref_file = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
203
+ if fsl .no_fsl ():
204
+ warn ('NO FSL found' )
205
+ else :
206
+ applywarp .inputs .ref_file = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
199
207
200
208
# Merge the FA files into a 4D file
201
209
mergefa = pe .Node (fsl .Merge (dimension = "t" ),
@@ -402,7 +410,10 @@ def create_tbss_all(name='tbss_all', estimate_skeleton=True):
402
410
403
411
tbss1 = create_tbss_1_preproc (name = 'tbss1' )
404
412
tbss2 = create_tbss_2_reg (name = 'tbss2' )
405
- tbss2 .inputs .inputnode .target = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
413
+ if fsl .no_fsl ():
414
+ warn ('NO FSL found' )
415
+ else :
416
+ tbss2 .inputs .inputnode .target = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
406
417
tbss3 = create_tbss_3_postreg (name = 'tbss3' , estimate_skeleton = estimate_skeleton )
407
418
tbss4 = create_tbss_4_prestats (name = 'tbss4' )
408
419
@@ -522,7 +533,10 @@ def create_tbss_non_FA(name='tbss_non_FA'):
522
533
applywarp = pe .MapNode (interface = fsl .ApplyWarp (),
523
534
iterfield = ['in_file' , 'field_file' ],
524
535
name = "applywarp" )
525
- applywarp .inputs .ref_file = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
536
+ if fsl .no_fsl ():
537
+ warn ('NO FSL found' )
538
+ else :
539
+ applywarp .inputs .ref_file = fsl .Info .standard_image ("FMRIB58_FA_1mm.nii.gz" )
526
540
# Merge the non FA files into a 4D file
527
541
merge = pe .Node (fsl .Merge (dimension = "t" ), name = "merge" )
528
542
#merged_file="all_FA.nii.gz"
0 commit comments