16
16
import shutil
17
17
import warnings
18
18
19
+ from ... import LooseVersion
19
20
from nipype .interfaces .fsl .base import (FSLCommand , FSLCommandInputSpec , Info ,
20
21
FSLXCommand , FSLXCommandInputSpec ,
21
22
FSLXCommandOutputSpec )
@@ -100,14 +101,14 @@ def _list_outputs(self):
100
101
return outputs
101
102
102
103
103
- class BEDPOSTXInputSpec (FSLXCommandInputSpec ):
104
+ class BEDPOSTX5InputSpec (FSLXCommandInputSpec ):
104
105
out_dir = Directory ('.' , mandatory = True , desc = 'output directory' ,
105
106
usedefault = True , position = 1 , argstr = '%s' )
106
107
gradnonlin = traits .Bool (False , argstr = '-g' , desc = ('consider gradient '
107
108
'nonlinearities, default off' ))
108
109
109
110
110
- class BEDPOSTXOutputSpec (FSLXCommandOutputSpec ):
111
+ class BEDPOSTX5OutputSpec (FSLXCommandOutputSpec ):
111
112
mean_thsamples = OutputMultiPath (File (), desc = ('Mean of '
112
113
'distribution on theta' ))
113
114
mean_phsamples = OutputMultiPath (File (), desc = ('Mean of '
@@ -124,7 +125,7 @@ class BEDPOSTXOutputSpec(FSLXCommandOutputSpec):
124
125
' estimated fiber orientation' ))
125
126
126
127
127
- class BEDPOSTX (FSLXCommand ):
128
+ class BEDPOSTX5 (FSLXCommand ):
128
129
"""
129
130
BEDPOSTX stands for Bayesian Estimation of Diffusion Parameters Obtained
130
131
using Sampling Techniques. The X stands for modelling Crossing Fibres.
@@ -143,7 +144,7 @@ class BEDPOSTX(FSLXCommand):
143
144
-------
144
145
145
146
>>> from nipype.interfaces import fsl
146
- >>> bedp = fsl.BEDPOSTX (bvecs='bvecs', bvals='bvals', dwi='diffusion.nii',
147
+ >>> bedp = fsl.BEDPOSTX5 (bvecs='bvecs', bvals='bvals', dwi='diffusion.nii',
147
148
... mask='mask.nii', n_fibres=1)
148
149
>>> bedp.cmdline
149
150
'bedpostx . --bvals=bvals --bvecs=bvecs --data=diffusion.nii \
@@ -152,8 +153,8 @@ class BEDPOSTX(FSLXCommand):
152
153
"""
153
154
154
155
_cmd = 'bedpostx'
155
- input_spec = BEDPOSTXInputSpec
156
- output_spec = BEDPOSTXOutputSpec
156
+ input_spec = BEDPOSTX5InputSpec
157
+ output_spec = BEDPOSTX5OutputSpec
157
158
_can_resume = True
158
159
159
160
def _run_interface (self , runtime ):
@@ -179,7 +180,7 @@ def _run_interface(self, runtime):
179
180
copyfile (self .inputs .bvecs ,
180
181
os .path .join (subjectdir , 'bvecs' ))
181
182
182
- return super (BEDPOSTX , self )._run_interface (runtime )
183
+ return super (BEDPOSTX5 , self )._run_interface (runtime )
183
184
184
185
def _list_outputs (self ):
185
186
outputs = self .output_spec ().get ()
@@ -209,26 +210,30 @@ def _list_outputs(self):
209
210
outputs ['dyads_disp' ].append (self ._gen_fname (('dyads%d'
210
211
'_dispersion' ) % i , cwd = out_dir ))
211
212
212
- super_out = super (BEDPOSTX , self )._list_outputs ()
213
+ super_out = super (BEDPOSTX5 , self )._list_outputs ()
213
214
214
215
for k , v in super_out .iteritems ():
215
216
outputs [k ] = v
216
217
217
218
return outputs
218
219
219
220
220
- class XFibresInputSpec (FSLXCommandInputSpec ):
221
+ class BEDPOSTX5GPU (BEDPOSTX5 ):
222
+ _cmd = 'bedpostx_gpu'
223
+
224
+
225
+ class XFibres5InputSpec (FSLXCommandInputSpec ):
221
226
gradnonlin = File (exists = True , argstr = '--gradnonlin=%s' ,
222
227
desc = 'gradient file corresponding to slice' )
223
228
224
229
225
- class XFibres (FSLXCommand ):
230
+ class XFibres5 (FSLXCommand ):
226
231
"""
227
232
Perform model parameters estimation for local (voxelwise) diffusion
228
233
parameters
229
234
"""
230
235
_cmd = 'xfibres'
231
- input_spec = XFibresInputSpec
236
+ input_spec = XFibres5InputSpec
232
237
output_spec = FSLXCommandOutputSpec
233
238
234
239
@@ -902,7 +907,7 @@ def _list_outputs(self):
902
907
return outputs
903
908
904
909
905
- class OldXFibresInputSpec (FSLCommandInputSpec ):
910
+ class XFibres4InputSpec (FSLCommandInputSpec ):
906
911
dwi = File (exists = True , argstr = "--data=%s" , mandatory = True )
907
912
mask = File (exists = True , argstr = "--mask=%s" , mandatory = True )
908
913
gradnonlin = File (exists = True , argstr = "--gradnonlin=%s" )
@@ -941,7 +946,7 @@ class OldXFibresInputSpec(FSLCommandInputSpec):
941
946
argstr = '--forcedir' , usedefault = True )
942
947
943
948
944
- class OldXFibresOutputSpec (TraitedSpec ):
949
+ class XFibres4OutputSpec (TraitedSpec ):
945
950
dyads = OutputMultiPath (File (exists = True ), desc = "Mean of PDD distribution in vector form." )
946
951
fsamples = OutputMultiPath (File (exists = True ), desc = "Samples from the distribution on anisotropic volume fraction" )
947
952
mean_dsamples = File (exists = True , desc = "Mean of distribution on diffusivity d" )
@@ -951,22 +956,22 @@ class OldXFibresOutputSpec(TraitedSpec):
951
956
thsamples = OutputMultiPath (File (exists = True ), desc = "Samples from the distribution on theta" )
952
957
953
958
954
- class OldXFibres (FSLCommand ):
959
+ class XFibres4 (FSLCommand ):
955
960
"""
956
961
Perform model parameters estimation for local (voxelwise) diffusion
957
962
parameters
958
963
959
964
.. deprecated:: 0.9.2
960
- Use :class:`.XFibres ` instead.
965
+ Use :class:`.XFibres5 ` instead.
961
966
962
967
963
968
"""
964
969
_cmd = "xfibres"
965
- input_spec = OldXFibresInputSpec
966
- output_spec = OldXFibresOutputSpec
970
+ input_spec = XFibres4InputSpec
971
+ output_spec = XFibres4OutputSpec
967
972
968
973
def _run_interface (self , runtime ):
969
- runtime = super (OldXFibres , self )._run_interface (runtime )
974
+ runtime = super (XFibres4 , self )._run_interface (runtime )
970
975
if runtime .stderr :
971
976
self .raise_exception (runtime )
972
977
return runtime
@@ -992,7 +997,7 @@ def _list_outputs(self):
992
997
return outputs
993
998
994
999
995
- class OldBEDPOSTXInputSpec (FSLCommandInputSpec ):
1000
+ class BEDPOSTX4InputSpec (FSLCommandInputSpec ):
996
1001
dwi = File (exists = True , desc = 'diffusion weighted image data file' ,
997
1002
mandatory = True )
998
1003
mask = File (exists = True , desc = 'bet binary mask file' , mandatory = True )
@@ -1017,7 +1022,7 @@ class OldBEDPOSTXInputSpec(FSLCommandInputSpec):
1017
1022
'hardware/queue (if found)' ))
1018
1023
1019
1024
1020
- class OldBEDPOSTXOutputSpec (TraitedSpec ):
1025
+ class BEDPOSTX4OutputSpec (TraitedSpec ):
1021
1026
bpx_out_directory = Directory (exists = True ,
1022
1027
desc = 'path/name of directory with all ' +
1023
1028
'bedpostx output files for this subject' )
@@ -1044,7 +1049,7 @@ class OldBEDPOSTXOutputSpec(TraitedSpec):
1044
1049
dyads = traits .List (File (exists = True ), desc = 'a list of path/name of mean of PDD distribution in vector form' )
1045
1050
1046
1051
1047
- class OldBEDPOSTX (FSLCommand ):
1052
+ class BEDPOSTX4 (FSLCommand ):
1048
1053
"""
1049
1054
bedpostx has an old interface, implemented here
1050
1055
@@ -1061,21 +1066,22 @@ class OldBEDPOSTX(FSLCommand):
1061
1066
-------
1062
1067
1063
1068
>>> from nipype.interfaces import fsl
1064
- >>> bedp = fsl.OldBEDPOSTX (bpx_directory='subjdir', bvecs='bvecs', \
1069
+ >>> bedp = fsl.BEDPOSTX4 (bpx_directory='subjdir', bvecs='bvecs', \
1065
1070
bvals='bvals', dwi='diffusion.nii', mask='mask.nii', fibres=1)
1066
1071
>>> bedp.cmdline
1067
1072
'bedpostx subjdir -n 1'
1068
1073
1069
1074
"""
1070
1075
1071
1076
_cmd = 'bedpostx'
1072
- input_spec = OldBEDPOSTXInputSpec
1073
- output_spec = OldBEDPOSTXOutputSpec
1077
+ input_spec = BEDPOSTX4InputSpec
1078
+ output_spec = BEDPOSTX4OutputSpec
1074
1079
_can_resume = True
1075
1080
1076
1081
def __init__ (self , ** inputs ):
1077
- warnings .warn ("Deprecated: Please use create_bedpostx_pipeline instead" , DeprecationWarning )
1078
- return super (OldBEDPOSTX , self ).__init__ (** inputs )
1082
+ warnings .warn (('Deprecated: Please use BEDPOSTX5 or '
1083
+ 'create_bedpostx_pipeline instead' ), DeprecationWarning )
1084
+ return super (BEDPOSTX4 , self ).__init__ (** inputs )
1079
1085
1080
1086
def _run_interface (self , runtime ):
1081
1087
@@ -1097,7 +1103,7 @@ def _run_interface(self, runtime):
1097
1103
shutil .copyfile (self .inputs .bvecs ,
1098
1104
os .path .join (self .inputs .bpx_directory , 'bvecs' ))
1099
1105
1100
- runtime = super (BEDPOSTX , self )._run_interface (runtime )
1106
+ runtime = super (BEDPOSTX4 , self )._run_interface (runtime )
1101
1107
if runtime .stderr :
1102
1108
self .raise_exception (runtime )
1103
1109
return runtime
@@ -1138,3 +1144,33 @@ def _list_outputs(self):
1138
1144
suffix = '' ,
1139
1145
cwd = outputs ['bpx_out_directory' ]))
1140
1146
return outputs
1147
+
1148
+
1149
+ class BEDPOSTX4GPU (BEDPOSTX4 ):
1150
+ _cmd = 'bedpostx_gpu'
1151
+
1152
+
1153
+ if (Info .version () and
1154
+ LooseVersion (Info .version ()) >= LooseVersion ('5.0.0' )):
1155
+ CurrentXFibres = XFibres5
1156
+ CurrentBEDPOST = BEDPOSTX5
1157
+ CurrentBEDPOSTgpu = BEDPOSTX5GPU
1158
+ else :
1159
+ CurrentXFibres = XFibres4
1160
+ CurrentBEDPOST = BEDPOSTX4
1161
+ CurrentBEDPOSTgpu = BEDPOSTX4GPU
1162
+
1163
+
1164
+ class XFibres (CurrentXFibres ):
1165
+ def __init__ (self , ** inputs ):
1166
+ return super (XFibres , self ).__init__ (** inputs )
1167
+
1168
+
1169
+ class BEDPOSTX (CurrentBEDPOST ):
1170
+ def __init__ (self , ** inputs ):
1171
+ return super (BEDPOSTX , self ).__init__ (** inputs )
1172
+
1173
+
1174
+ class BEDPOSTXGPU (CurrentBEDPOSTgpu ):
1175
+ def __init__ (self , ** inputs ):
1176
+ return super (BEDPOSTXGPU , self ).__init__ (** inputs )
0 commit comments