/
diffusion.py
635 lines (565 loc) · 28.4 KB
/
diffusion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# -*- coding: utf-8 -*-
# -*- coding: utf8 -*-
"""Autogenerated file - DO NOT EDIT
If you spot a bug, please report it on the mailing list and/or change the generator."""
import os
from ...base import (
CommandLine,
CommandLineInputSpec,
SEMLikeCommandLine,
TraitedSpec,
File,
Directory,
traits,
isdefined,
InputMultiPath,
OutputMultiPath,
)
class dtiaverageInputSpec(CommandLineInputSpec):
inputs = InputMultiPath(
File(exists=True),
desc="List of all the tensor fields to be averaged",
argstr="--inputs %s...",
)
tensor_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Averaged tensor volume",
argstr="--tensor_output %s",
)
DTI_double = traits.Bool(
desc="Tensor components are saved as doubles (cannot be visualized in Slicer)",
argstr="--DTI_double ",
)
verbose = traits.Bool(desc="produce verbose output", argstr="--verbose ")
class dtiaverageOutputSpec(TraitedSpec):
tensor_output = File(desc="Averaged tensor volume", exists=True)
class dtiaverage(SEMLikeCommandLine):
"""title: DTIAverage (DTIProcess)
category: Diffusion.Diffusion Tensor Images.CommandLineOnly
description: dtiaverage is a program that allows to compute the average of an arbitrary number of tensor fields (listed after the --inputs option) This program is used in our pipeline as the last step of the atlas building processing. When all the tensor fields have been deformed in the same space, to create the average tensor field (--tensor_output) we use dtiaverage.
Several average method can be used (specified by the --method option): euclidian, log-euclidian and pga. The default being euclidian.
version: 1.0.0
documentation-url: http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/DTIProcess
license: Copyright (c) Casey Goodlett. All rights reserved.
See http://www.ia.unc.edu/dev/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
contributor: Casey Goodlett
"""
input_spec = dtiaverageInputSpec
output_spec = dtiaverageOutputSpec
_cmd = " dtiaverage "
_outputs_filenames = {"tensor_output": "tensor_output.nii"}
_redirect_x = False
class dtiestimInputSpec(CommandLineInputSpec):
dwi_image = File(
desc="DWI image volume (required)", exists=True, argstr="--dwi_image %s"
)
tensor_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Tensor OutputImage",
argstr="--tensor_output %s",
)
B0 = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Baseline image, average of all baseline images",
argstr="--B0 %s",
)
idwi = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="idwi output image. Image with isotropic diffusion-weighted information = geometric mean of diffusion images",
argstr="--idwi %s",
)
B0_mask_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="B0 mask used for the estimation. B0 thresholded either with the -t option value or the automatic OTSU value",
argstr="--B0_mask_output %s",
)
brain_mask = File(
desc="Brain mask. Image where for every voxel == 0 the tensors are not estimated. Be aware that in addition a threshold based masking will be performed by default. If such an additional threshold masking is NOT desired, then use option -t 0.",
exists=True,
argstr="--brain_mask %s",
)
bad_region_mask = File(
desc="Bad region mask. Image where for every voxel > 0 the tensors are not estimated",
exists=True,
argstr="--bad_region_mask %s",
)
method = traits.Enum(
"lls",
"wls",
"nls",
"ml",
desc="Esitmation method (lls:linear least squares, wls:weighted least squares, nls:non-linear least squares, ml:maximum likelihood)",
argstr="--method %s",
)
correction = traits.Enum(
"none",
"zero",
"abs",
"nearest",
desc="Correct the tensors if computed tensor is not semi-definite positive",
argstr="--correction %s",
)
threshold = traits.Int(
desc="Baseline threshold for estimation. If not specified calculated using an OTSU threshold on the baseline image.",
argstr="--threshold %d",
)
weight_iterations = traits.Int(
desc="Number of iterations to recaluate weightings from tensor estimate",
argstr="--weight_iterations %d",
)
step = traits.Float(
desc="Gradient descent step size (for nls and ml methods)", argstr="--step %f"
)
sigma = traits.Float(argstr="--sigma %f")
DTI_double = traits.Bool(
desc="Tensor components are saved as doubles (cannot be visualized in Slicer)",
argstr="--DTI_double ",
)
verbose = traits.Bool(desc="produce verbose output", argstr="--verbose ")
defaultTensor = InputMultiPath(
traits.Float,
desc="Default tensor used if estimated tensor is below a given threshold",
sep=",",
argstr="--defaultTensor %s",
)
shiftNeg = traits.Bool(
desc="Shift eigenvalues so all are positive (accounts for bad tensors related to noise or acquisition error). This is the same option as the one available in DWIToDTIEstimation in Slicer (but instead of just adding the minimum eigenvalue to all the eigenvalues if it is smaller than 0, we use a coefficient to have stictly positive eigenvalues",
argstr="--shiftNeg ",
)
shiftNegCoeff = traits.Float(
desc="Shift eigenvalues so all are positive (accounts for bad tensors related to noise or acquisition error). Instead of just adding the minimum eigenvalue to all the eigenvalues if it is smaller than 0, we use a coefficient to have stictly positive eigenvalues. Coefficient must be between 1.0 and 1.001 (included).",
argstr="--shiftNegCoeff %f",
)
class dtiestimOutputSpec(TraitedSpec):
tensor_output = File(desc="Tensor OutputImage", exists=True)
B0 = File(desc="Baseline image, average of all baseline images", exists=True)
idwi = File(
desc="idwi output image. Image with isotropic diffusion-weighted information = geometric mean of diffusion images",
exists=True,
)
B0_mask_output = File(
desc="B0 mask used for the estimation. B0 thresholded either with the -t option value or the automatic OTSU value",
exists=True,
)
class dtiestim(SEMLikeCommandLine):
"""title: DTIEstim (DTIProcess)
category: Diffusion.Diffusion Weighted Images
description: dtiestim is a tool that takes in a set of DWIs (with --dwi_image option) in nrrd format and estimates a tensor field out of it. The output tensor file name is specified with the --tensor_output option
There are several methods to estimate the tensors which you can specify with the option --method lls|wls|nls|ml . Here is a short description of the different methods:
lls
Linear least squares. Standard estimation technique that recovers the tensor parameters by multiplying the log of the normalized signal intensities by the pseudo-inverse of the gradient matrix. Default option.
wls
Weighted least squares. This method is similar to the linear least squares method except that the gradient matrix is weighted by the original lls estimate. (See Salvador, R., Pena, A., Menon, D. K., Carpenter, T. A., Pickard, J. D., and Bullmore, E. T. Formal characterization and extension of the linearized diffusion tensor model. Human Brain Mapping 24, 2 (Feb. 2005), 144-155. for more information on this method). This method is recommended for most applications. The weight for each iteration can be specified with the --weight_iterations. It is not currently the default due to occasional matrix singularities.
nls
Non-linear least squares. This method does not take the log of the signal and requires an optimization based on levenberg-marquadt to optimize the parameters of the signal. The lls estimate is used as an initialization. For this method the step size can be specified with the --step option.
ml
Maximum likelihood estimation. This method is experimental and is not currently recommended. For this ml method the sigma can be specified with the option --sigma and the step size can be specified with the --step option.
You can set a threshold (--threshold) to have the tensor estimated to only a subset of voxels. All the baseline voxel value higher than the threshold define the voxels where the tensors are computed. If not specified the threshold is calculated using an OTSU threshold on the baseline image.The masked generated by the -t option or by the otsu value can be saved with the --B0_mask_output option.
dtiestim also can extract a few scalar images out of the DWI set of images:
- the average baseline image (--B0) which is the average of all the B0s.
- the IDWI (--idwi)which is the geometric mean of the diffusion images.
You can also load a mask if you want to compute the tensors only where the voxels are non-zero (--brain_mask) or a negative mask and the tensors will be estimated where the negative mask has zero values (--bad_region_mask)
version: 1.2.0
documentation-url: http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/DTIProcess
license: Copyright (c) Casey Goodlett. All rights reserved.
See http://www.ia.unc.edu/dev/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
contributor: Casey Goodlett, Francois Budin
acknowledgements: Hans Johnson(1,3,4); Kent Williams(1); (1=University of Iowa Department of Psychiatry, 3=University of Iowa Department of Biomedical Engineering, 4=University of Iowa Department of Electrical and Computer Engineering) provided conversions to make DTIProcess compatible with Slicer execution, and simplified the stand-alone build requirements by removing the dependancies on boost and a fortran compiler.
"""
input_spec = dtiestimInputSpec
output_spec = dtiestimOutputSpec
_cmd = " dtiestim "
_outputs_filenames = {
"B0": "B0.nii",
"idwi": "idwi.nii",
"tensor_output": "tensor_output.nii",
"B0_mask_output": "B0_mask_output.nii",
}
_redirect_x = False
class dtiprocessInputSpec(CommandLineInputSpec):
dti_image = File(desc="DTI tensor volume", exists=True, argstr="--dti_image %s")
fa_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Fractional Anisotropy output file",
argstr="--fa_output %s",
)
md_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Mean Diffusivity output file",
argstr="--md_output %s",
)
sigma = traits.Float(desc="Scale of gradients", argstr="--sigma %f")
fa_gradient_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Fractional Anisotropy Gradient output file",
argstr="--fa_gradient_output %s",
)
fa_gradmag_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Fractional Anisotropy Gradient Magnitude output file",
argstr="--fa_gradmag_output %s",
)
color_fa_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Color Fractional Anisotropy output file",
argstr="--color_fa_output %s",
)
principal_eigenvector_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Principal Eigenvectors Output",
argstr="--principal_eigenvector_output %s",
)
negative_eigenvector_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Negative Eigenvectors Output: create a binary image where if any of the eigen value is below zero, the voxel is set to 1, otherwise 0.",
argstr="--negative_eigenvector_output %s",
)
frobenius_norm_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Frobenius Norm Output",
argstr="--frobenius_norm_output %s",
)
lambda1_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Axial Diffusivity - Lambda 1 (largest eigenvalue) output",
argstr="--lambda1_output %s",
)
lambda2_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Lambda 2 (middle eigenvalue) output",
argstr="--lambda2_output %s",
)
lambda3_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Lambda 3 (smallest eigenvalue) output",
argstr="--lambda3_output %s",
)
RD_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="RD (Radial Diffusivity 1/2*(lambda2+lambda3)) output",
argstr="--RD_output %s",
)
rot_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Rotated tensor output file. Must also specify the dof file.",
argstr="--rot_output %s",
)
affineitk_file = File(
desc="Transformation file for affine transformation. ITK format.",
exists=True,
argstr="--affineitk_file %s",
)
dof_file = File(
desc="Transformation file for affine transformation. This can be ITK format (or the outdated RView).",
exists=True,
argstr="--dof_file %s",
)
newdof_file = File(
desc="Transformation file for affine transformation. RView NEW format. (txt file output of dof2mat)",
exists=True,
argstr="--newdof_file %s",
)
mask = File(
desc="Mask tensors. Specify --outmask if you want to save the masked tensor field, otherwise the mask is applied just for the current processing ",
exists=True,
argstr="--mask %s",
)
outmask = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Name of the masked tensor field.",
argstr="--outmask %s",
)
hField = traits.Bool(
desc="forward and inverse transformations are h-fields instead of displacement fields",
argstr="--hField ",
)
forward = File(
desc="Forward transformation. Assumed to be a deformation field in world coordinates, unless the --h-field option is specified.",
exists=True,
argstr="--forward %s",
)
deformation_output = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Warped tensor field based on a deformation field. This option requires the --forward,-F transformation to be specified.",
argstr="--deformation_output %s",
)
interpolation = traits.Enum(
"nearestneighbor",
"linear",
"cubic",
desc="Interpolation type (nearestneighbor, linear, cubic)",
argstr="--interpolation %s",
)
reorientation = traits.Enum(
"fs", "ppd", desc="Reorientation type (fs, ppd)", argstr="--reorientation %s"
)
correction = traits.Enum(
"none",
"zero",
"abs",
"nearest",
desc="Correct the tensors if computed tensor is not semi-definite positive",
argstr="--correction %s",
)
scalar_float = traits.Bool(
desc="Write scalar [FA,MD] as unscaled float (with their actual values, otherwise scaled by 10 000). Also causes FA to be unscaled [0..1].",
argstr="--scalar_float ",
)
DTI_double = traits.Bool(
desc="Tensor components are saved as doubles (cannot be visualized in Slicer)",
argstr="--DTI_double ",
)
verbose = traits.Bool(desc="produce verbose output", argstr="--verbose ")
class dtiprocessOutputSpec(TraitedSpec):
fa_output = File(desc="Fractional Anisotropy output file", exists=True)
md_output = File(desc="Mean Diffusivity output file", exists=True)
fa_gradient_output = File(
desc="Fractional Anisotropy Gradient output file", exists=True
)
fa_gradmag_output = File(
desc="Fractional Anisotropy Gradient Magnitude output file", exists=True
)
color_fa_output = File(desc="Color Fractional Anisotropy output file", exists=True)
principal_eigenvector_output = File(
desc="Principal Eigenvectors Output", exists=True
)
negative_eigenvector_output = File(
desc="Negative Eigenvectors Output: create a binary image where if any of the eigen value is below zero, the voxel is set to 1, otherwise 0.",
exists=True,
)
frobenius_norm_output = File(desc="Frobenius Norm Output", exists=True)
lambda1_output = File(
desc="Axial Diffusivity - Lambda 1 (largest eigenvalue) output", exists=True
)
lambda2_output = File(desc="Lambda 2 (middle eigenvalue) output", exists=True)
lambda3_output = File(desc="Lambda 3 (smallest eigenvalue) output", exists=True)
RD_output = File(
desc="RD (Radial Diffusivity 1/2*(lambda2+lambda3)) output", exists=True
)
rot_output = File(
desc="Rotated tensor output file. Must also specify the dof file.", exists=True
)
outmask = File(desc="Name of the masked tensor field.", exists=True)
deformation_output = File(
desc="Warped tensor field based on a deformation field. This option requires the --forward,-F transformation to be specified.",
exists=True,
)
class dtiprocess(SEMLikeCommandLine):
"""title: DTIProcess (DTIProcess)
category: Diffusion.Diffusion Tensor Images
description: dtiprocess is a tool that handles tensor fields. It takes as an input a tensor field in nrrd format.
It can generate diffusion scalar properties out of the tensor field such as : FA (--fa_output), Gradient FA image (--fa_gradient_output), color FA (--color_fa_output), MD (--md_output), Frobenius norm (--frobenius_norm_output), lbd1, lbd2, lbd3 (--lambda{1,2,3}_output), binary map of voxel where if any of the eigenvalue is negative, the voxel is set to 1 (--negative_eigenvector_output)
It also creates 4D images out of the tensor field such as: Highest eigenvector map (highest eigenvector at each voxel) (--principal_eigenvector_output)
Masking capabilities: For any of the processing done with dtiprocess, it's possible to apply it on a masked region of the tensor field. You need to use the --mask option for any of the option to be applied on that tensor field sub-region only. If you want to save the masked tensor field use the option --outmask and specify the new masked tensor field file name.
dtiprocess also allows a range of transformations on the tensor fields. The transformed tensor field file name is specified with the option --deformation_output. There are 3 resampling interpolation methods specified with the tag --interpolation followed by the type to use (nearestneighbor, linear, cubic) Then you have several transformations possible to apply:
- Affine transformations using as an input
- itk affine transformation file (based on the itkAffineTransform class)
- Affine transformations using rview (details and download at http://www.doc.ic.ac.uk/~dr/software/). There are 2 versions of rview both creating transformation files called dof files. The old version of rview outputs text files containing the transformation parameters. It can be read in with the --dof_file option. The new version outputs binary dof files. These dof files can be transformed into human readable file with the dof2mat tool which is part of the rview package. So you need to save the output of dof2mat into a text file which can then be used with the -- newdof_file option. Usage example: dof2mat mynewdoffile.dof >> mynewdoffile.txt dtiprocess --dti_image mytensorfield.nhdr --newdof_file mynewdoffile.txt --rot_output myaffinetensorfield.nhdr
Non linear transformations as an input: The default transformation file type is d-field (displacement field) in nrrd format. The option to use is --forward with the name of the file. If the transformation file is a h-field you have to add the option --hField.
version: 1.0.1
documentation-url: http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/DTIProcess
license: Copyright (c) Casey Goodlett. All rights reserved.
See http://www.ia.unc.edu/dev/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
contributor: Casey Goodlett
"""
input_spec = dtiprocessInputSpec
output_spec = dtiprocessOutputSpec
_cmd = " dtiprocess "
_outputs_filenames = {
"fa_gradmag_output": "fa_gradmag_output.nii",
"fa_gradient_output": "fa_gradient_output.nii",
"lambda1_output": "lambda1_output.nii",
"lambda2_output": "lambda2_output.nii",
"color_fa_output": "color_fa_output.nii",
"fa_output": "fa_output.nii",
"frobenius_norm_output": "frobenius_norm_output.nii",
"principal_eigenvector_output": "principal_eigenvector_output.nii",
"outmask": "outmask.nii",
"lambda3_output": "lambda3_output.nii",
"negative_eigenvector_output": "negative_eigenvector_output.nii",
"md_output": "md_output.nii",
"RD_output": "RD_output.nii",
"deformation_output": "deformation_output.nii",
"rot_output": "rot_output.nii",
}
_redirect_x = False
class DWIConvertInputSpec(CommandLineInputSpec):
conversionMode = traits.Enum(
"DicomToNrrd",
"DicomToFSL",
"NrrdToFSL",
"FSLToNrrd",
desc="Determine which conversion to perform. DicomToNrrd (default): Convert DICOM series to NRRD DicomToFSL: Convert DICOM series to NIfTI File + gradient/bvalue text files NrrdToFSL: Convert DWI NRRD file to NIfTI File + gradient/bvalue text files FSLToNrrd: Convert NIfTI File + gradient/bvalue text files to NRRD file.",
argstr="--conversionMode %s",
)
inputVolume = File(
desc="Input DWI volume -- not used for DicomToNrrd mode.",
exists=True,
argstr="--inputVolume %s",
)
outputVolume = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Output filename (.nhdr or .nrrd)",
argstr="--outputVolume %s",
)
inputDicomDirectory = Directory(
desc="Directory holding Dicom series",
exists=True,
argstr="--inputDicomDirectory %s",
)
fslNIFTIFile = File(
desc="4D NIfTI file containing gradient volumes",
exists=True,
argstr="--fslNIFTIFile %s",
)
inputBValues = File(
desc="The B Values are stored in FSL .bval text file format",
exists=True,
argstr="--inputBValues %s",
)
inputBVectors = File(
desc="The Gradient Vectors are stored in FSL .bvec text file format",
exists=True,
argstr="--inputBVectors %s",
)
outputBValues = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The B Values are stored in FSL .bval text file format (defaults to <outputVolume>.bval)",
argstr="--outputBValues %s",
)
outputBVectors = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="The Gradient Vectors are stored in FSL .bvec text file format (defaults to <outputVolume>.bvec)",
argstr="--outputBVectors %s",
)
fMRI = traits.Bool(
desc="Output a NRRD file, but without gradients", argstr="--fMRI "
)
writeProtocolGradientsFile = traits.Bool(
desc="Write the protocol gradients to a file suffixed by '.txt' as they were specified in the procol by multiplying each diffusion gradient direction by the measurement frame. This file is for debugging purposes only, the format is not fixed, and will likely change as debugging of new dicom formats is necessary.",
argstr="--writeProtocolGradientsFile ",
)
useIdentityMeaseurementFrame = traits.Bool(
desc="Adjust all the gradients so that the measurement frame is an identity matrix.",
argstr="--useIdentityMeaseurementFrame ",
)
useBMatrixGradientDirections = traits.Bool(
desc="Fill the nhdr header with the gradient directions and bvalues computed out of the BMatrix. Only changes behavior for Siemens data. In some cases the standard public gradients are not properly computed. The gradients can emperically computed from the private BMatrix fields. In some cases the private BMatrix is consistent with the public grandients, but not in all cases, when it exists BMatrix is usually most robust.",
argstr="--useBMatrixGradientDirections ",
)
outputDirectory = traits.Either(
traits.Bool,
Directory(),
hash_files=False,
desc="Directory holding the output NRRD file",
argstr="--outputDirectory %s",
)
gradientVectorFile = traits.Either(
traits.Bool,
File(),
hash_files=False,
desc="Text file giving gradient vectors",
argstr="--gradientVectorFile %s",
)
smallGradientThreshold = traits.Float(
desc="If a gradient magnitude is greater than 0 and less than smallGradientThreshold, then DWIConvert will display an error message and quit, unless the useBMatrixGradientDirections option is set.",
argstr="--smallGradientThreshold %f",
)
allowLossyConversion = traits.Bool(
desc="The only supported output type is 'short'. Conversion from images of a different type may cause data loss due to rounding or truncation. Use with caution!",
argstr="--allowLossyConversion ",
)
transposeInputBVectors = traits.Bool(
desc="FSL input BVectors are expected to be encoded in the input file as one vector per line. If it is not the case, use this option to transpose the file as it is read.",
argstr="--transposeInputBVectors ",
)
class DWIConvertOutputSpec(TraitedSpec):
outputVolume = File(desc="Output filename (.nhdr or .nrrd)", exists=True)
outputBValues = File(
desc="The B Values are stored in FSL .bval text file format (defaults to <outputVolume>.bval)",
exists=True,
)
outputBVectors = File(
desc="The Gradient Vectors are stored in FSL .bvec text file format (defaults to <outputVolume>.bvec)",
exists=True,
)
outputDirectory = Directory(
desc="Directory holding the output NRRD file", exists=True
)
gradientVectorFile = File(desc="Text file giving gradient vectors", exists=True)
class DWIConvert(SEMLikeCommandLine):
"""title: DWIConverter
category: Diffusion.Diffusion Data Conversion
description: Converts diffusion weighted MR images in dicom series into Nrrd format for analysis in Slicer. This program has been tested on only a limited subset of DTI dicom formats available from Siemens, GE, and Phillips scanners. Work in progress to support dicom multi-frame data. The program parses dicom header to extract necessary information about measurement frame, diffusion weighting directions, b-values, etc, and write out a nrrd image. For non-diffusion weighted dicom images, it loads in an entire dicom series and writes out a single dicom volume in a .nhdr/.raw pair.
version: Version 1.0
documentation-url: http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/DWIConverter
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: Vince Magnotta (UIowa), Hans Johnson (UIowa), Joy Matsui (UIowa), Kent Williams (UIowa), Mark Scully (Uiowa), Xiaodong Tao (GE)
acknowledgements: This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149. Additional support for DTI data produced on Philips scanners was contributed by Vincent Magnotta and Hans Johnson at the University of Iowa.
"""
input_spec = DWIConvertInputSpec
output_spec = DWIConvertOutputSpec
_cmd = " DWIConvert "
_outputs_filenames = {
"outputVolume": "outputVolume.nii",
"outputDirectory": "outputDirectory",
"outputBValues": "outputBValues.bval",
"gradientVectorFile": "gradientVectorFile",
"outputBVectors": "outputBVectors.bvec",
}
_redirect_x = False