dbdicom 0.3.9__tar.gz → 0.3.10__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.10}/PKG-INFO +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.10}/pyproject.toml +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/api.py +56 -44
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/dataset.py +2 -2
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/dbd.py +259 -133
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/register.py +21 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/enhanced_mr_image.py +1 -1
- dbdicom-0.3.10/src/dbdicom/utils/arrays.py +128 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10/src/dbdicom.egg-info}/PKG-INFO +1 -1
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom.egg-info/SOURCES.txt +2 -1
- {dbdicom-0.3.9 → dbdicom-0.3.10}/tests/test_api.py +101 -11
- dbdicom-0.3.10/tests/test_utils.py +101 -0
- dbdicom-0.3.9/src/dbdicom/utils/arrays.py +0 -40
- {dbdicom-0.3.9 → dbdicom-0.3.10}/LICENSE +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/MANIFEST.in +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/README.rst +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/setup.cfg +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/const.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/database.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/README.md +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-311.pyc +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/deidentify +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/deidentify.bat +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/emf2sf +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/bin/emf2sf.bat +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/etc/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/etc/emf2sf/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/etc/emf2sf/log4j.properties +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/__init__.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/commons-cli-1.4.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/dcm4che-core-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/dcm4che-emf-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/dcm4che-tool-common-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/dcm4che-tool-emf2sf-5.23.1.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/log4j-1.2.17.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/macosx-x86-64/libopencv_java.jnilib +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/slf4j-api-1.7.30.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/slf4j-log4j12-1.7.30.jar +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio_sse2.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/windows-x86/clib_jiio_util.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/windows-x86/opencv_java.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/external/dcm4che/lib/windows-x86-64/opencv_java.dll +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/ct_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/mr_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/parametric_map.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/secondary_capture.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/segmentation.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/ultrasound_multiframe_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/sop_classes/xray_angiographic_image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/utils/dcm4che.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/utils/files.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/utils/image.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom/utils/pydicom_dataset.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom.egg-info/dependency_links.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom.egg-info/requires.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/src/dbdicom.egg-info/top_level.txt +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/tests/test_dcm4che.py +0 -0
- {dbdicom-0.3.9 → dbdicom-0.3.10}/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.10
|
|
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,16 +163,22 @@ 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
184
|
def delete(entity:list):
|
|
@@ -216,25 +221,42 @@ def split_series(series:list, attr:Union[str, tuple], key=None)->list:
|
|
|
216
221
|
return split_series
|
|
217
222
|
|
|
218
223
|
|
|
219
|
-
def volume(
|
|
220
|
-
"""Read volume
|
|
224
|
+
def volume(series:list, dims:list=None, verbose=1) -> vreg.Volume3D:
|
|
225
|
+
"""Read volume from a series.
|
|
221
226
|
|
|
222
227
|
Args:
|
|
223
|
-
|
|
228
|
+
series (list, str): DICOM entity to read
|
|
224
229
|
dims (list, optional): Non-spatial dimensions of the volume. Defaults to None.
|
|
225
230
|
verbose (bool, optional): If set to 1, shows progress bar. Defaults to 1.
|
|
226
231
|
|
|
227
232
|
Returns:
|
|
228
|
-
vreg.Volume3D
|
|
229
|
-
a volume, else a list of volumes.
|
|
233
|
+
vreg.Volume3D.
|
|
230
234
|
"""
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
dbd = open(entity[0])
|
|
234
|
-
vol = dbd.volume(entity, dims, verbose)
|
|
235
|
+
dbd = open(series[0])
|
|
236
|
+
vol = dbd.volume(series, dims, verbose)
|
|
235
237
|
dbd.close()
|
|
236
238
|
return vol
|
|
237
239
|
|
|
240
|
+
|
|
241
|
+
def values(series:list, *attr, dims:list=None, verbose=1) -> Union[np.ndarray, list]:
|
|
242
|
+
"""Read the values of some attributes from a DICOM series
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
series (list): DICOM series to read.
|
|
246
|
+
attr (tuple, optional): DICOM attributes to read.
|
|
247
|
+
dims (list, optional): Dimensions to sort the values.
|
|
248
|
+
If dims is not provided, values are sorted by
|
|
249
|
+
InstanceNumber.
|
|
250
|
+
|
|
251
|
+
Returns:
|
|
252
|
+
tuple: arrays with values for the attributes.
|
|
253
|
+
"""
|
|
254
|
+
dbd = open(series[0])
|
|
255
|
+
values = dbd.values(series, *attr, dims=dims, verbose=verbose)
|
|
256
|
+
dbd.close()
|
|
257
|
+
return values
|
|
258
|
+
|
|
259
|
+
|
|
238
260
|
def write_volume(vol:Union[vreg.Volume3D, tuple], series:list, ref:list=None):
|
|
239
261
|
"""Write a vreg.Volume3D to a DICOM series
|
|
240
262
|
|
|
@@ -247,6 +269,25 @@ def write_volume(vol:Union[vreg.Volume3D, tuple], series:list, ref:list=None):
|
|
|
247
269
|
dbd.write_volume(vol, series, ref)
|
|
248
270
|
dbd.close()
|
|
249
271
|
|
|
272
|
+
|
|
273
|
+
def edit(series:list, new_values:dict, dims:list=None, verbose=1):
|
|
274
|
+
"""Edit attribute values in a DICOM series
|
|
275
|
+
|
|
276
|
+
Warning: this function edits all values as requested. Please take care
|
|
277
|
+
when editing attributes that affect the DICOM file organisation, such as
|
|
278
|
+
UIDs, as this could corrupt the database.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
series (list): DICOM series to edit
|
|
282
|
+
new_values (dict): dictionary with attribute: value pairs to write to the series
|
|
283
|
+
dims (list, optional): Non-spatial dimensions of the volume. Defaults to None.
|
|
284
|
+
verbose (bool, optional): If set to 1, shows progress bar. Defaults to 1.
|
|
285
|
+
|
|
286
|
+
"""
|
|
287
|
+
dbd = open(series[0])
|
|
288
|
+
dbd.edit(series, new_values, dims=dims, verbose=verbose)
|
|
289
|
+
dbd.close()
|
|
290
|
+
|
|
250
291
|
def to_nifti(series:list, file:str, dims:list=None, verbose=1):
|
|
251
292
|
"""Save a DICOM series in nifti format.
|
|
252
293
|
|
|
@@ -274,35 +315,6 @@ def from_nifti(file:str, series:list, ref:list=None):
|
|
|
274
315
|
dbd.close()
|
|
275
316
|
|
|
276
317
|
|
|
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
318
|
def files(entity:list) -> list:
|
|
307
319
|
"""Read the files in a DICOM entity
|
|
308
320
|
|
|
@@ -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
|
|