dbdicom 0.3.9__tar.gz → 0.3.11__tar.gz
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.
Potentially problematic release.
This version of dbdicom might be problematic. Click here for more details.
- {dbdicom-0.3.9/src/dbdicom.egg-info → dbdicom-0.3.11}/PKG-INFO +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.11}/pyproject.toml +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/api.py +60 -46
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/dataset.py +2 -2
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/dbd.py +272 -135
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/register.py +21 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/enhanced_mr_image.py +1 -1
- dbdicom-0.3.11/src/dbdicom/utils/arrays.py +128 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11/src/dbdicom.egg-info}/PKG-INFO +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom.egg-info/SOURCES.txt +2 -1
- {dbdicom-0.3.9 → dbdicom-0.3.11}/tests/test_api.py +101 -11
- dbdicom-0.3.11/tests/test_utils.py +101 -0
- dbdicom-0.3.9/src/dbdicom/utils/arrays.py +0 -40
- {dbdicom-0.3.9 → dbdicom-0.3.11}/LICENSE +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/MANIFEST.in +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/README.rst +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/setup.cfg +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/const.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/database.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/README.md +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/deidentify +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/deidentify.bat +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/emf2sf +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/bin/emf2sf.bat +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/etc/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/etc/emf2sf/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/etc/emf2sf/log4j.properties +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/commons-cli-1.4.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/dcm4che-core-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/dcm4che-emf-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/dcm4che-tool-common-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/dcm4che-tool-emf2sf-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/log4j-1.2.17.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/macosx-x86-64/libopencv_java.jnilib +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/slf4j-api-1.7.30.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/slf4j-log4j12-1.7.30.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio_sse2.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio_util.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/windows-x86/opencv_java.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/external/dcm4che/lib/windows-x86-64/opencv_java.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/ct_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/mr_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/parametric_map.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/secondary_capture.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/segmentation.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/ultrasound_multiframe_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/sop_classes/xray_angiographic_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/utils/dcm4che.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/utils/files.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/utils/image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom/utils/pydicom_dataset.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom.egg-info/dependency_links.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom.egg-info/requires.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/src/dbdicom.egg-info/top_level.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/tests/test_dcm4che.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.11}/tests/test_sop_classes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbdicom
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.11
|
|
4
4
|
Summary: A pythonic interface for reading and writing DICOM databases
|
|
5
5
|
Author-email: Steven Sourbron <s.sourbron@sheffield.ac.uk>, Ebony Gunwhy <e.gunwhy@sheffield.ac.uk>
|
|
6
6
|
Project-URL: Homepage, https://openmiblab.github.io/dbdicom/
|
|
@@ -4,8 +4,7 @@ import zipfile
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Union
|
|
6
6
|
from tqdm import tqdm
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import numpy as np
|
|
9
8
|
import vreg
|
|
10
9
|
|
|
11
10
|
from dbdicom.dbd import DataBaseDicom
|
|
@@ -164,26 +163,34 @@ def series(entity:str | list, desc:str=None, contains:str=None, isin:list=None)-
|
|
|
164
163
|
"To retrieve a series, the entity must be a database, patient or study."
|
|
165
164
|
)
|
|
166
165
|
|
|
167
|
-
def copy(from_entity:list, to_entity
|
|
168
|
-
"""Copy a DICOM
|
|
166
|
+
def copy(from_entity:list, to_entity=None):
|
|
167
|
+
"""Copy a DICOM entity (patient, study or series)
|
|
169
168
|
|
|
170
169
|
Args:
|
|
171
170
|
from_entity (list): entity to copy
|
|
172
|
-
to_entity (list): entity after copying.
|
|
171
|
+
to_entity (list, optional): entity after copying. If this is not
|
|
172
|
+
provided, a copy will be made in the same study and returned.
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
entity: the copied entity. If th to_entity is provided, this is
|
|
176
|
+
returned.
|
|
173
177
|
"""
|
|
174
178
|
dbd = open(from_entity[0])
|
|
175
|
-
dbd.copy(from_entity, to_entity)
|
|
179
|
+
from_entity_copy = dbd.copy(from_entity, to_entity)
|
|
176
180
|
dbd.close()
|
|
181
|
+
return from_entity_copy
|
|
177
182
|
|
|
178
183
|
|
|
179
|
-
def delete(entity:list):
|
|
184
|
+
def delete(entity:list, not_exists_ok=False):
|
|
180
185
|
"""Delete a DICOM entity
|
|
181
186
|
|
|
182
187
|
Args:
|
|
183
188
|
entity (list): entity to delete
|
|
189
|
+
not_exists_ok (bool): By default, an exception is raised when attempting
|
|
190
|
+
to delete an entity that does not exist. Set this to True to pass over this silently.
|
|
184
191
|
"""
|
|
185
192
|
dbd = open(entity[0])
|
|
186
|
-
dbd.delete(entity)
|
|
193
|
+
dbd.delete(entity, not_exists_ok)
|
|
187
194
|
dbd.close()
|
|
188
195
|
|
|
189
196
|
|
|
@@ -216,25 +223,42 @@ def split_series(series:list, attr:Union[str, tuple], key=None)->list:
|
|
|
216
223
|
return split_series
|
|
217
224
|
|
|
218
225
|
|
|
219
|
-
def volume(
|
|
220
|
-
"""Read volume
|
|
226
|
+
def volume(series:list, dims:list=None, verbose=1) -> vreg.Volume3D:
|
|
227
|
+
"""Read volume from a series.
|
|
221
228
|
|
|
222
229
|
Args:
|
|
223
|
-
|
|
230
|
+
series (list, str): DICOM entity to read
|
|
224
231
|
dims (list, optional): Non-spatial dimensions of the volume. Defaults to None.
|
|
225
232
|
verbose (bool, optional): If set to 1, shows progress bar. Defaults to 1.
|
|
226
233
|
|
|
227
234
|
Returns:
|
|
228
|
-
vreg.Volume3D
|
|
229
|
-
a volume, else a list of volumes.
|
|
235
|
+
vreg.Volume3D.
|
|
230
236
|
"""
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
dbd = open(entity[0])
|
|
234
|
-
vol = dbd.volume(entity, dims, verbose)
|
|
237
|
+
dbd = open(series[0])
|
|
238
|
+
vol = dbd.volume(series, dims, verbose)
|
|
235
239
|
dbd.close()
|
|
236
240
|
return vol
|
|
237
241
|
|
|
242
|
+
|
|
243
|
+
def values(series:list, *attr, dims:list=None, verbose=1) -> Union[np.ndarray, list]:
|
|
244
|
+
"""Read the values of some attributes from a DICOM series
|
|
245
|
+
|
|
246
|
+
Args:
|
|
247
|
+
series (list): DICOM series to read.
|
|
248
|
+
attr (tuple, optional): DICOM attributes to read.
|
|
249
|
+
dims (list, optional): Dimensions to sort the values.
|
|
250
|
+
If dims is not provided, values are sorted by
|
|
251
|
+
InstanceNumber.
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
tuple: arrays with values for the attributes.
|
|
255
|
+
"""
|
|
256
|
+
dbd = open(series[0])
|
|
257
|
+
values = dbd.values(series, *attr, dims=dims, verbose=verbose)
|
|
258
|
+
dbd.close()
|
|
259
|
+
return values
|
|
260
|
+
|
|
261
|
+
|
|
238
262
|
def write_volume(vol:Union[vreg.Volume3D, tuple], series:list, ref:list=None):
|
|
239
263
|
"""Write a vreg.Volume3D to a DICOM series
|
|
240
264
|
|
|
@@ -247,6 +271,25 @@ def write_volume(vol:Union[vreg.Volume3D, tuple], series:list, ref:list=None):
|
|
|
247
271
|
dbd.write_volume(vol, series, ref)
|
|
248
272
|
dbd.close()
|
|
249
273
|
|
|
274
|
+
|
|
275
|
+
def edit(series:list, new_values:dict, dims:list=None, verbose=1):
|
|
276
|
+
"""Edit attribute values in a DICOM series
|
|
277
|
+
|
|
278
|
+
Warning: this function edits all values as requested. Please take care
|
|
279
|
+
when editing attributes that affect the DICOM file organisation, such as
|
|
280
|
+
UIDs, as this could corrupt the database.
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
series (list): DICOM series to edit
|
|
284
|
+
new_values (dict): dictionary with attribute: value pairs to write to the series
|
|
285
|
+
dims (list, optional): Non-spatial dimensions of the volume. Defaults to None.
|
|
286
|
+
verbose (bool, optional): If set to 1, shows progress bar. Defaults to 1.
|
|
287
|
+
|
|
288
|
+
"""
|
|
289
|
+
dbd = open(series[0])
|
|
290
|
+
dbd.edit(series, new_values, dims=dims, verbose=verbose)
|
|
291
|
+
dbd.close()
|
|
292
|
+
|
|
250
293
|
def to_nifti(series:list, file:str, dims:list=None, verbose=1):
|
|
251
294
|
"""Save a DICOM series in nifti format.
|
|
252
295
|
|
|
@@ -274,35 +317,6 @@ def from_nifti(file:str, series:list, ref:list=None):
|
|
|
274
317
|
dbd.close()
|
|
275
318
|
|
|
276
319
|
|
|
277
|
-
def values(series:list, attr=None, dims:list=None, coords=False) -> Union[dict, tuple]:
|
|
278
|
-
"""Read the values of some or all attributes from a DICOM series
|
|
279
|
-
|
|
280
|
-
Args:
|
|
281
|
-
series (list or str): DICOM series to read. This can also
|
|
282
|
-
be a path to a folder containing DICOM files, or a
|
|
283
|
-
patient or study to read all series in that patient or
|
|
284
|
-
study. In those cases a list is returned.
|
|
285
|
-
attr (list, optional): list of DICOM attributes to read.
|
|
286
|
-
dims (list, optional): Dimensions to sort the attributes.
|
|
287
|
-
If dims is not provided, values are sorted by
|
|
288
|
-
InstanceNumber.
|
|
289
|
-
coords (bool): If set to True, the coordinates of the
|
|
290
|
-
attributes are returned alongside the values
|
|
291
|
-
|
|
292
|
-
Returns:
|
|
293
|
-
dict or tuple: values as a dictionary in the last
|
|
294
|
-
return value, where each value is a numpy array with
|
|
295
|
-
the required dimensions. If coords is set to True,
|
|
296
|
-
these are returned too.
|
|
297
|
-
"""
|
|
298
|
-
if isinstance(series, str):
|
|
299
|
-
series = [series]
|
|
300
|
-
dbd = open(series[0])
|
|
301
|
-
array = dbd.values(series, attr, dims, coords)
|
|
302
|
-
dbd.close()
|
|
303
|
-
return array
|
|
304
|
-
|
|
305
|
-
|
|
306
320
|
def files(entity:list) -> list:
|
|
307
321
|
"""Read the files in a DICOM entity
|
|
308
322
|
|
|
@@ -370,7 +370,7 @@ def set_volume(ds, volume:vreg.Volume3D):
|
|
|
370
370
|
set_affine(ds, volume.affine)
|
|
371
371
|
if volume.coords is not None:
|
|
372
372
|
# All other dimensions should have size 1
|
|
373
|
-
coords =
|
|
373
|
+
coords = [c.reshape(-1) for c in volume.coords]
|
|
374
374
|
for i, d in enumerate(volume.dims):
|
|
375
375
|
if not is_valid_dicom_tag(d):
|
|
376
376
|
raise ValueError(
|
|
@@ -380,7 +380,7 @@ def set_volume(ds, volume:vreg.Volume3D):
|
|
|
380
380
|
"tags to change the dimensions."
|
|
381
381
|
)
|
|
382
382
|
else:
|
|
383
|
-
set_values(ds, d, coords[i
|
|
383
|
+
set_values(ds, d, coords[i][0])
|
|
384
384
|
|
|
385
385
|
|
|
386
386
|
|