dbdicom 0.2.0__py3-none-any.whl → 0.3.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dbdicom/__init__.py +3 -25
- dbdicom/api.py +496 -0
- dbdicom/const.py +144 -0
- dbdicom/database.py +133 -0
- dbdicom/dataset.py +471 -0
- dbdicom/dbd.py +1290 -0
- dbdicom/external/__pycache__/__init__.cpython-311.pyc +0 -0
- dbdicom/external/dcm4che/__pycache__/__init__.cpython-311.pyc +0 -0
- dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-311.pyc +0 -0
- dbdicom/external/dcm4che/bin/emf2sf +57 -57
- dbdicom/register.py +402 -0
- dbdicom/{ds/types → sop_classes}/ct_image.py +2 -16
- dbdicom/{ds/types → sop_classes}/enhanced_mr_image.py +206 -160
- dbdicom/sop_classes/mr_image.py +338 -0
- dbdicom/sop_classes/parametric_map.py +381 -0
- dbdicom/sop_classes/secondary_capture.py +140 -0
- dbdicom/sop_classes/segmentation.py +311 -0
- dbdicom/{ds/types → sop_classes}/ultrasound_multiframe_image.py +1 -15
- dbdicom/{ds/types → sop_classes}/xray_angiographic_image.py +2 -17
- dbdicom/utils/arrays.py +142 -0
- dbdicom/utils/files.py +0 -20
- dbdicom/utils/image.py +43 -466
- dbdicom/utils/pydicom_dataset.py +386 -0
- dbdicom-0.3.16.dist-info/METADATA +26 -0
- dbdicom-0.3.16.dist-info/RECORD +54 -0
- {dbdicom-0.2.0.dist-info → dbdicom-0.3.16.dist-info}/WHEEL +1 -1
- dbdicom/create.py +0 -450
- dbdicom/ds/__init__.py +0 -10
- dbdicom/ds/create.py +0 -63
- dbdicom/ds/dataset.py +0 -841
- dbdicom/ds/dictionaries.py +0 -620
- dbdicom/ds/types/mr_image.py +0 -267
- dbdicom/ds/types/parametric_map.py +0 -226
- dbdicom/external/__pycache__/__init__.cpython-310.pyc +0 -0
- dbdicom/external/__pycache__/__init__.cpython-37.pyc +0 -0
- dbdicom/external/dcm4che/__pycache__/__init__.cpython-310.pyc +0 -0
- dbdicom/external/dcm4che/__pycache__/__init__.cpython-37.pyc +0 -0
- dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-310.pyc +0 -0
- dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-37.pyc +0 -0
- dbdicom/external/dcm4che/lib/linux-x86/libclib_jiio.so +0 -0
- dbdicom/external/dcm4che/lib/linux-x86-64/libclib_jiio.so +0 -0
- dbdicom/external/dcm4che/lib/linux-x86-64/libopencv_java.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio_vis.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio_vis2.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio_vis.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio_vis2.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-x86/libclib_jiio.so +0 -0
- dbdicom/external/dcm4che/lib/solaris-x86-64/libclib_jiio.so +0 -0
- dbdicom/manager.py +0 -2077
- dbdicom/message.py +0 -119
- dbdicom/record.py +0 -1526
- dbdicom/types/database.py +0 -107
- dbdicom/types/instance.py +0 -184
- dbdicom/types/patient.py +0 -40
- dbdicom/types/series.py +0 -816
- dbdicom/types/study.py +0 -58
- dbdicom/utils/variables.py +0 -155
- dbdicom/utils/vreg.py +0 -2626
- dbdicom/wrappers/__init__.py +0 -7
- dbdicom/wrappers/dipy.py +0 -462
- dbdicom/wrappers/elastix.py +0 -855
- dbdicom/wrappers/numpy.py +0 -119
- dbdicom/wrappers/scipy.py +0 -1413
- dbdicom/wrappers/skimage.py +0 -1030
- dbdicom/wrappers/sklearn.py +0 -151
- dbdicom/wrappers/vreg.py +0 -273
- dbdicom-0.2.0.dist-info/METADATA +0 -276
- dbdicom-0.2.0.dist-info/RECORD +0 -81
- {dbdicom-0.2.0.dist-info → dbdicom-0.3.16.dist-info/licenses}/LICENSE +0 -0
- {dbdicom-0.2.0.dist-info → dbdicom-0.3.16.dist-info}/top_level.txt +0 -0
dbdicom/types/study.py
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Importing annotations to handle or sign in import type hints
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
import numpy as np
|
|
6
|
-
from dbdicom.record import Record
|
|
7
|
-
|
|
8
|
-
class Study(Record):
|
|
9
|
-
|
|
10
|
-
name = 'StudyInstanceUID'
|
|
11
|
-
|
|
12
|
-
def remove(self):
|
|
13
|
-
self.manager.delete_studies([self.uid])
|
|
14
|
-
|
|
15
|
-
def new_series(self, **kwargs):
|
|
16
|
-
attr = {**kwargs, **self.attributes}
|
|
17
|
-
uid, key = self.manager.new_series(parent=self.uid, key=self.key(), **attr)
|
|
18
|
-
return self.record('Series', uid, key, **attr)
|
|
19
|
-
|
|
20
|
-
def parent(self):
|
|
21
|
-
#uid = self.manager.register.at[self.key(), 'PatientID']
|
|
22
|
-
key = self.key()
|
|
23
|
-
uid = self.manager._at(key, 'PatientID')
|
|
24
|
-
return self.record('Patient', uid, key=key)
|
|
25
|
-
|
|
26
|
-
def children(self, **kwargs):
|
|
27
|
-
return self.series(**kwargs)
|
|
28
|
-
|
|
29
|
-
def new_child(self, dataset=None, **kwargs):
|
|
30
|
-
attr = {**kwargs, **self.attributes}
|
|
31
|
-
return self.new_series(**attr)
|
|
32
|
-
|
|
33
|
-
def new_sibling(self, suffix=None, **kwargs):
|
|
34
|
-
if suffix is not None:
|
|
35
|
-
desc = self.manager._at(self.key(), 'StudyDescription')
|
|
36
|
-
kwargs['StudyDescription'] = desc + ' [' + suffix + ']'
|
|
37
|
-
return self.parent().new_child(**kwargs)
|
|
38
|
-
|
|
39
|
-
def _copy_from(self, record, **kwargs):
|
|
40
|
-
attr = {**kwargs, **self.attributes}
|
|
41
|
-
uids = self.manager.copy_to_study(record.uid, self.uid, **attr)
|
|
42
|
-
if isinstance(uids, list):
|
|
43
|
-
return [self.record('Series', uid, **attr) for uid in uids]
|
|
44
|
-
else:
|
|
45
|
-
return self.record('Series', uids, **attr)
|
|
46
|
-
|
|
47
|
-
def zeros(*args, **kwargs): # OBSOLETE - remove
|
|
48
|
-
return zeros(*args, **kwargs)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def zeros(study, shape, dtype='mri'): # OBSOLETE - remove
|
|
52
|
-
series = study.new_series()
|
|
53
|
-
array = np.zeros(shape, dtype=np.float32)
|
|
54
|
-
if dtype not in ['mri', 'MRImage']:
|
|
55
|
-
message = 'dbdicom can only create images of type MRImage at this stage'
|
|
56
|
-
raise ValueError(message)
|
|
57
|
-
series.set_pixel_array(array)
|
|
58
|
-
return series
|
dbdicom/utils/variables.py
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import math
|
|
2
|
-
import datetime
|
|
3
|
-
|
|
4
|
-
def str_to_seconds(dicom_tm):
|
|
5
|
-
if dicom_tm is None:
|
|
6
|
-
return None
|
|
7
|
-
if dicom_tm == '':
|
|
8
|
-
return None
|
|
9
|
-
# dicom_tm is of the form 'HHMMSS.FFFFFF'
|
|
10
|
-
# Split the seconds into seconds and fractional seconds
|
|
11
|
-
seconds, fractional_seconds = dicom_tm.split('.')
|
|
12
|
-
# Convert the hours, minutes, and seconds to integers
|
|
13
|
-
hours = int(seconds[:2])
|
|
14
|
-
minutes = int(seconds[2:4])
|
|
15
|
-
seconds = int(seconds[4:])
|
|
16
|
-
# Convert the fractional seconds to a decimal
|
|
17
|
-
fractional_seconds = float('.' + fractional_seconds)
|
|
18
|
-
# Create a datetime object representing the time
|
|
19
|
-
seconds_since_midnight = (hours * 3600) + (minutes * 60) + seconds + fractional_seconds
|
|
20
|
-
return seconds_since_midnight
|
|
21
|
-
|
|
22
|
-
def seconds_to_str(seconds_since_midnight):
|
|
23
|
-
if not isinstance(seconds_since_midnight, float):
|
|
24
|
-
return None
|
|
25
|
-
hours = math.floor(seconds_since_midnight/3600)
|
|
26
|
-
minutes = math.floor((seconds_since_midnight-hours*3600)/60)
|
|
27
|
-
seconds = math.floor(seconds_since_midnight-hours*3600-minutes*60)
|
|
28
|
-
fractional_seconds = round(seconds_since_midnight-hours*3600-minutes*60-seconds, 6)
|
|
29
|
-
hours = str(hours).zfill(2)
|
|
30
|
-
minutes = str(minutes).zfill(2)
|
|
31
|
-
seconds = str(seconds).zfill(2)
|
|
32
|
-
fractional_seconds = str(fractional_seconds)
|
|
33
|
-
fractional_seconds = fractional_seconds.split('.')
|
|
34
|
-
if len(fractional_seconds) == 2:
|
|
35
|
-
fractional_seconds = fractional_seconds[1].ljust(6,'0')
|
|
36
|
-
else:
|
|
37
|
-
fractional_seconds = '0'.ljust(6,'0')
|
|
38
|
-
return hours + minutes + seconds + '.' + fractional_seconds
|
|
39
|
-
|
|
40
|
-
def time_to_seconds(tm):
|
|
41
|
-
if tm is None:
|
|
42
|
-
return None
|
|
43
|
-
hours = tm.hour
|
|
44
|
-
minutes = tm.minute
|
|
45
|
-
seconds = tm.second
|
|
46
|
-
fractional_seconds = tm.microsecond / 1000000.0
|
|
47
|
-
seconds_since_midnight = (hours * 3600) + (minutes * 60) + seconds + fractional_seconds
|
|
48
|
-
return seconds_since_midnight
|
|
49
|
-
|
|
50
|
-
def seconds_to_time(seconds_since_midnight):
|
|
51
|
-
if not isinstance(seconds_since_midnight, float):
|
|
52
|
-
return None
|
|
53
|
-
hours = math.floor(seconds_since_midnight/3600)
|
|
54
|
-
minutes = math.floor((seconds_since_midnight-hours*3600)/60)
|
|
55
|
-
seconds = math.floor(seconds_since_midnight-hours*3600-minutes*60)
|
|
56
|
-
fractional_seconds = round(seconds_since_midnight-hours*3600-minutes*60-seconds, 6)
|
|
57
|
-
microseconds = fractional_seconds*1000000.0
|
|
58
|
-
return datetime.time(int(hours), int(minutes), int(seconds), int(microseconds))
|
|
59
|
-
|
|
60
|
-
def time_to_str(tm):
|
|
61
|
-
if tm is None:
|
|
62
|
-
return None
|
|
63
|
-
hours = tm.hour
|
|
64
|
-
minutes = tm.minute
|
|
65
|
-
seconds = tm.second
|
|
66
|
-
fractional_seconds = tm.microsecond / 1000000.0
|
|
67
|
-
hours = str(hours).zfill(2)
|
|
68
|
-
minutes = str(minutes).zfill(2)
|
|
69
|
-
seconds = str(seconds).zfill(2)
|
|
70
|
-
fractional_seconds = str(fractional_seconds)
|
|
71
|
-
_, fractional_seconds = fractional_seconds.split('.')
|
|
72
|
-
fractional_seconds = fractional_seconds.ljust(6,'0')
|
|
73
|
-
return hours + minutes + seconds + '.' + fractional_seconds
|
|
74
|
-
|
|
75
|
-
def date_to_str(tm):
|
|
76
|
-
if tm is None:
|
|
77
|
-
return None
|
|
78
|
-
year = str(tm.year).rjust(4, '0')
|
|
79
|
-
month = str(tm.month).rjust(2, '0')
|
|
80
|
-
day = str(tm.day).rjust(2, '0')
|
|
81
|
-
return year + month + day
|
|
82
|
-
|
|
83
|
-
def datetime_to_str(dt):
|
|
84
|
-
if dt is None:
|
|
85
|
-
return None
|
|
86
|
-
date = date_to_str(dt.date())
|
|
87
|
-
time = time_to_str(dt.time())
|
|
88
|
-
return date + time
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def test_all_conversions(sec, dcm, tim, date, date_str, dt, dt_str):
|
|
92
|
-
|
|
93
|
-
assert seconds_to_str(None) is None
|
|
94
|
-
assert str_to_seconds(dcm) == sec
|
|
95
|
-
assert seconds_to_str(sec) == dcm
|
|
96
|
-
assert str_to_seconds(seconds_to_str(sec)) == sec
|
|
97
|
-
assert seconds_to_str(str_to_seconds(dcm)) == dcm
|
|
98
|
-
assert time_to_seconds(tim) == sec
|
|
99
|
-
assert seconds_to_time(sec) == tim
|
|
100
|
-
assert time_to_seconds(seconds_to_time(sec)) == sec
|
|
101
|
-
assert seconds_to_time(time_to_seconds(tim)) == tim
|
|
102
|
-
assert date_to_str(date) == date_str
|
|
103
|
-
assert time_to_str(tim) == dcm
|
|
104
|
-
assert datetime_to_str(dt) == dt_str
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def test_module():
|
|
108
|
-
|
|
109
|
-
sec = 13*60*60 + 12*60 + 40 + 0.03
|
|
110
|
-
dcm = '131240.030000'
|
|
111
|
-
tim = datetime.time(13, 12, 40, 30000)
|
|
112
|
-
date = datetime.date(2023, 3, 1)
|
|
113
|
-
date_str = '20230301'
|
|
114
|
-
dt = datetime.datetime(2023, 3, 1, 13, 12, 40, 30000)
|
|
115
|
-
dt_str = '20230301131240.030000'
|
|
116
|
-
|
|
117
|
-
test_all_conversions(sec, dcm, tim, date, date_str, dt, dt_str)
|
|
118
|
-
|
|
119
|
-
sec = 7*60*60 + 12*60 + 40 + 0.03
|
|
120
|
-
dcm = '071240.030000'
|
|
121
|
-
tim = datetime.time(7, 12, 40, 30000)
|
|
122
|
-
date = datetime.date(2023, 3, 1)
|
|
123
|
-
date_str = '20230301'
|
|
124
|
-
dt = datetime.datetime(2023, 3, 1, 7, 12, 40, 30000)
|
|
125
|
-
dt_str = '20230301071240.030000'
|
|
126
|
-
|
|
127
|
-
test_all_conversions(sec, dcm, tim, date, date_str, dt, dt_str)
|
|
128
|
-
|
|
129
|
-
sec = 7*60*60 + 3*60 + 40 + 0.03
|
|
130
|
-
dcm = '070340.030000'
|
|
131
|
-
tim = datetime.time(7, 3, 40, 30000)
|
|
132
|
-
date = datetime.date(2023, 3, 1)
|
|
133
|
-
date_str = '20230301'
|
|
134
|
-
dt = datetime.datetime(2023, 3, 1, 7, 3, 40, 30000)
|
|
135
|
-
dt_str = '20230301070340.030000'
|
|
136
|
-
|
|
137
|
-
test_all_conversions(sec, dcm, tim, date, date_str, dt, dt_str)
|
|
138
|
-
|
|
139
|
-
sec = 7*60*60 + 3*60 + 4 + 0.03
|
|
140
|
-
dcm = '070304.030000'
|
|
141
|
-
tim = datetime.time(7, 3, 4, 30000)
|
|
142
|
-
date = datetime.date(2023, 3, 1)
|
|
143
|
-
date_str = '20230301'
|
|
144
|
-
dt = datetime.datetime(2023, 3, 1, 7, 3, 4, 30000)
|
|
145
|
-
dt_str = '20230301070304.030000'
|
|
146
|
-
|
|
147
|
-
test_all_conversions(sec, dcm, tim, date, date_str, dt, dt_str)
|
|
148
|
-
|
|
149
|
-
print('dbdicom.utils.variables passed all tests')
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if __name__ == "__main__":
|
|
153
|
-
|
|
154
|
-
test_module()
|
|
155
|
-
|