-
Notifications
You must be signed in to change notification settings - Fork 0
/
dicompatient.py
291 lines (243 loc) · 12.2 KB
/
dicompatient.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import date, time
from enum import Enum
class PatientSex(Enum):
"""Class wrapping enumerated values describing patient sex. Accessible
values are:
na: indicating that patient sex information is not available
other: indicating that patient is nor a female or a male
female: indicating that patient is a female
male: indicating that patient is a male
"""
na = 0
other = 1
female = 2
male = 3
class QualityControlSubject(Enum):
"""Class wrapping enumerated values describing if patient is a quality
control subject (phantom) or not. Accessible values are:
no: indicating that patient is not quality control subject
yes: indicating that patient is a quality control subject
"""
no = 0
yes = 1
class DicomPatient(object):
"""Class representing DICOM Patient IE (information entity) objects.
The Patient IE defines the characteristics of a patient who is subject of
one or more medical studies.
The Patient IE is modality independent.
"""
def __init__(self):
# Patient's full name
self.name = str()
# Primary hospital identification number or code for the patient.
# In the Serbia it is "LBO"
self.id = int()
# Birthdate of the patient
self.birthdate = date()
# Sex of the named patient
self.sex = PatientSex.na
# Indicates whether or not the subject is a quality control phantom
self.qcs = QualityControlSubject.no
# List of studies for the named patient
self.studies = list()
class DicomGeneralStudy(object):
"""Class representing DICOM General Study objects. General Study objects
represent attributes that describe and identify the Study performed upon
the Patient.
"""
def __init__(self):
# Unique identifier for the Study
self.studyinstanceuid = int()
# Date the Study started
self.studydate = date()
# Time the Study started
self.studytime = time()
# User or equipment generated Study identifier
self.studyid = int()
# Institution-generated description or classification of the Study
# (component) performed
self.studydesc = str()
class DicomPatientStudy(object):
"""Class representing DICOM Patient Study objects. Patient Study objects
represent attributes that provide information about the Patient at the time
the Study started.
"""
def __init__(self):
# Age of the Patient
self.age = int()
# Length or size of the Patient, in meters
self.size = int()
# Weight of the Patient, in kilograms
self.weight = int()
# Description of the admitting diagnosis (diagnoses)
self.admtdgsdesc = str()
class DicomStudy(object):
"""Class representing DICOM Study IE (information entity) objects.
The Study IE defines the characteristics of a medical study performed on
a patient. A study is a collection of one or more series of medical images,
presentation states, and/or SR documents that are logically related for
the purpose of diagnosing a patient. Each study is associated with exactly
one patient.
A study may include composite instances that are created by a single
modality, multiple modalities or by multiple devices of the same modality.
The Study IE is modality independent.
"""
def __init__(self):
self.series = list()
class DicomSeries(object):
"""Class representing DICOM Series IE (information entity) objects.
The Series IE defines the Attributes that are used to group composite
instances into distinct logical sets. Each series is associated with
exactly one Study.
The following criteria group composite instances into a specific series:
a. All composite instances within a series must be of the same modality
b. Each series may be associated with exactly one Frame of Reference
IE, and if so associated all composite instances within the series
shall be spatially or temporally related to each other
c. All composite instances within the series shall be created by the
same equipment; therefore, each series is associated with exactly
one Equipment IE
d. All composite instances within a series shall have the same
series information
Presentation States shall be grouped into Series without Images (i.e., in a
different Series from the Series containing the Images to which
they refer).
Note that the Series containing Grayscale, Color and Pseudo-Color Softcopy
Presentation States and the Series containing the Images to which they
refer are both contained within the same Study, except for Blended
Presentation States, which may refer to images from different Studies.
Waveforms shall be grouped into Series without Images. A Frame of Reference
IE may apply to both Waveform Series and Image Series.
SR Documents shall be grouped into Series without Images. The Frame of
Reference IE may apply to SR Document Series, for SR Documents that
contain 3D spatial coordinates relative to one or more spatial Frames of
Reference, or temporal coordinates that require a temporal
Frame of Reference.
"""
def __init__(self):
# Indicates equipment used to acquire given series
self.equipment = DicomEquipment()
self.frameofreference = DicomFrameOfReference()
self.modalitylut = DicomModalityLUT()
self.images = list()
class DicomEquipment(object):
"""Class representing DICOM Equipment IE (information entity) objects. The
Equipment IE describes the particular device that produced the series of
composite instances. A device may produce one or more series within
a study. The Equipment IE does not describe the data acquisition or image
creation Attributes used to generate the composite instances within
a series. These Attributes are described in the composite instance specific
IEs (e.g., the Image IE).
"""
def __init__(self):
# Manufacturer of the equipment that produced the composite instances.
# Attribute requirement type 2
self.manufacturer = str()
# Institution where the equipment that produced the composite instances
# is located. Attribute requirement type 3
self.institutionname = str()
# Mailing address of the institution where the equipment that produced
# the composite instances is located. Attribute requirement type 3
self.institutionaddress = str()
# User defined name identifying the machine that produced the composite
# instances. Attribute requirement type 3
self.stationname = str()
# Department in the institution where the equipment that produced the
# composite instances is located. Attribute requirement type 3
self.deptname = str()
# Manufacturer's model name of the equipment that produced the
# composite instances. Attribute requirement type 3
self.modelname = str()
# Manufacturer's serial number of the equipment that produced the
# composite instances. Attribute requirement type 3
self.devicesno = str()
# Manufacturer's designation of software version of the equipment that
# produced the composite instances. Attribute requirement type 3
self.softwarever = str()
# Identifier of the gantry or positioner. Attribute requirement type 3
self.gantryid = str()
# The inherent limiting resolution in mm of the acquisition equipment
# for high contrast objects for the data gathering and reconstruction
# technique chosen. Attribute requirement type 3
self.spatialresolution = float()
# Date and time when the image acquisition device calibration was last
# changed in any way. Multiple entries may be used. Attribute
# requirement type 3
self.calibrationtime = list()
# Single pixel value or one limit (inclusive) of a range of pixel
# values used in an image to pad to rectangular format or to signal
# background that may be suppressed. Attribute requirement type 1C
self.pixelpaddingval = int()
class CalibrationTime(object):
"""Class representing date and time when the image acquisition device
calibration was last changed in any way. The Attribute Date of Last
Calibration may be supported alone, however, Time of Last Calibration
Attribute has no meaning unless Attribute Date of Last Calibration is also
supported. The order for each Attribute shall be from the oldest
date/time to the most recent date/time. When the Attributes are both
supported they shall be provided as pairs.
"""
def __init__(self):
# Date when the image acquisition device calibration was last changed
# in any way. Attribute requirement type 3
self.date = date()
# Time when the image acquisition device calibration was last changed
# in any way. Attribute requirement type 3
self.time = time()
class DicomFrameOfReference(object):
"""Class representing DICOM Frame of Reference IE (information entity)
objects. The Frame of Reference IE identifies the coordinate system that
conveys spatial and/or temporal information of composite instances in
a series.
When present, a Frame of Reference IE may be related to one or more series.
In this case, it provides the ability to spatially or temporally relate
multiple series to each other. In such cases, the series may share the UID
of the Frame of Reference, or alternatively, a Registration SOP Instance
may specify the spatial relationship explicitly, as a spatial
transformation. A Frame of Reference IE may also spatially register a Frame
of Reference to an atlas.
"""
def __init__(self):
# Uniquely identifies the frame of reference for a Series. Attribute
# requirement type 3
self.foruid = str()
# Part of the imaging target used as a reference. Attribute
# requirement type 3
self.prindicator = str()
class DicomImage(object):
"""Class representing DICOM Image IE (information entity) objects.
The Image IE defines the Attributes that describe the pixel data of
an image. The pixel data may be generated as a direct result of patient
scanning (termed an Original Image) or the pixel data may be derived from
the pixel data of one or more other images (termed a Derived Image). An
image is defined by its image plane, pixel data characteristics, gray scale
and/or color mapping characteristics, overlay planes and modality specific
characteristics (acquisition parameters and image creation information).
An image is related to a single series within a single study.
The pixel data within an Image IE may be represented as a single frame of
pixels or as multiple frames of pixel data. The frames of a Multi-frame
image (a cine run or the slices of a volume) are sequentially ordered and
share a number of common properties. A few Attributes may vary between
frames (e.g., Time, Angular Displacement, Slice Increment). All common
Image IE Attributes refer to the first frame of a multiple frame image.
Overlay and Lookup Table data may be included within an Image IE only if
this information is directly associated with the image.
"""
def __init__(self):
pass
class DicomModalityLUT(object):
"""Class representing DICOM Modality LUT IE (information entity) objects.
The Modality LUT IE defines the Attributes that describe the transformation
of manufacturer dependent pixel values into pixel values that are
manufacturer independent (e.g., Hounsfield units for CT, Optical Density
for film digitizers, etc.). The Modality LUT may be contained within an
image, or a presentation state that references an image. When the
transformation is linear, the Modality LUT is described by Rescale
Slope (0028,1053) and Rescale Intercept (0028,1052). When the
transformation is non-linear, the Modality LUT is described by Modality LUT
Sequence (0028,3000).
"""
def __init__(self):
pass