/
converters.py
177 lines (147 loc) · 6.25 KB
/
converters.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
# -*- 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."""
from nipype.interfaces.base import (
CommandLine,
CommandLineInputSpec,
SEMLikeCommandLine,
TraitedSpec,
File,
Directory,
traits,
isdefined,
InputMultiPath,
OutputMultiPath,
)
import os
class DicomToNrrdConverterInputSpec(CommandLineInputSpec):
inputDicomDirectory = Directory(
desc="Directory holding Dicom series",
exists=True,
argstr="--inputDicomDirectory %s",
)
outputDirectory = traits.Either(
traits.Bool,
Directory(),
hash_files=False,
desc="Directory holding the output NRRD format",
argstr="--outputDirectory %s",
)
outputVolume = traits.Str(
desc="Output filename (.nhdr or .nrrd)", argstr="--outputVolume %s"
)
smallGradientThreshold = traits.Float(
desc="If a gradient magnitude is greater than 0 and less than smallGradientThreshold, then DicomToNrrdConverter will display an error message and quit, unless the useBMatrixGradientDirections option is set.",
argstr="--smallGradientThreshold %f",
)
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.",
argstr="--useBMatrixGradientDirections ",
)
class DicomToNrrdConverterOutputSpec(TraitedSpec):
outputDirectory = Directory(
desc="Directory holding the output NRRD format", exists=True
)
class DicomToNrrdConverter(SEMLikeCommandLine):
"""title: DICOM to NRRD Converter
category: Converters
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: 0.2.0.$Revision: 916 $(alpha)
documentation-url: http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/DicomToNrrdConverter
license: https://www.nitrc.org/svn/brains/BuildScripts/trunk/License.txt
contributor: Xiaodong Tao (GE), Vince Magnotta (UIowa), Hans Johnson (UIowa)
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 = DicomToNrrdConverterInputSpec
output_spec = DicomToNrrdConverterOutputSpec
_cmd = "DicomToNrrdConverter "
_outputs_filenames = {"outputDirectory": "outputDirectory"}
class OrientScalarVolumeInputSpec(CommandLineInputSpec):
inputVolume1 = File(position=-2, desc="Input volume 1", exists=True, argstr="%s")
outputVolume = traits.Either(
traits.Bool,
File(),
position=-1,
hash_files=False,
desc="The oriented volume",
argstr="%s",
)
orientation = traits.Enum(
"Axial",
"Coronal",
"Sagittal",
"RIP",
"LIP",
"RSP",
"LSP",
"RIA",
"LIA",
"RSA",
"LSA",
"IRP",
"ILP",
"SRP",
"SLP",
"IRA",
"ILA",
"SRA",
"SLA",
"RPI",
"LPI",
"RAI",
"LAI",
"RPS",
"LPS",
"RAS",
"LAS",
"PRI",
"PLI",
"ARI",
"ALI",
"PRS",
"PLS",
"ARS",
"ALS",
"IPR",
"SPR",
"IAR",
"SAR",
"IPL",
"SPL",
"IAL",
"SAL",
"PIR",
"PSR",
"AIR",
"ASR",
"PIL",
"PSL",
"AIL",
"ASL",
desc="Orientation choices",
argstr="--orientation %s",
)
class OrientScalarVolumeOutputSpec(TraitedSpec):
outputVolume = File(position=-1, desc="The oriented volume", exists=True)
class OrientScalarVolume(SEMLikeCommandLine):
"""title: Orient Scalar Volume
category: Converters
description: Orients an output volume. Rearranges the slices in a volume according to the selected orientation. The slices are not interpolated. They are just reordered and/or permuted. The resulting volume will cover the original volume. NOTE: since Slicer takes into account the orientation of a volume, the re-oriented volume will not show any difference from the original volume, To see the difference, save the volume and display it with a system that either ignores the orientation of the image (e.g. Paraview) or displays individual images.
version: 0.1.0.$Revision: 19608 $(alpha)
documentation-url: http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/OrientImage
contributor: Bill Lorensen (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.
"""
input_spec = OrientScalarVolumeInputSpec
output_spec = OrientScalarVolumeOutputSpec
_cmd = "OrientScalarVolume "
_outputs_filenames = {"outputVolume": "outputVolume.nii"}