mirp 2.2.3__tar.gz → 2.3.0__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.
Files changed (147) hide show
  1. {mirp-2.2.3 → mirp-2.3.0}/NEWS.md +32 -1
  2. {mirp-2.2.3 → mirp-2.3.0}/PKG-INFO +37 -14
  3. {mirp-2.2.3 → mirp-2.3.0}/README.md +34 -12
  4. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file.py +254 -60
  5. mirp-2.3.0/mirp/_data_import/dicom_file_cr.py +6 -0
  6. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_ct.py +32 -62
  7. mirp-2.3.0/mirp/_data_import/dicom_file_dx.py +6 -0
  8. mirp-2.3.0/mirp/_data_import/dicom_file_mg.py +6 -0
  9. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_mr.py +98 -57
  10. mirp-2.3.0/mirp/_data_import/dicom_file_mr_adc.py +38 -0
  11. mirp-2.3.0/mirp/_data_import/dicom_file_mr_dce.py +15 -0
  12. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_pet.py +45 -102
  13. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_rtdose.py +4 -33
  14. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_rtstruct.py +3 -3
  15. mirp-2.3.0/mirp/_data_import/dicom_file_seg.py +326 -0
  16. mirp-2.3.0/mirp/_data_import/dicom_multi_frame.py +221 -0
  17. mirp-2.3.0/mirp/_data_import/dicom_planar_image.py +131 -0
  18. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/directory.py +16 -2
  19. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/generic_file.py +6 -6
  20. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/generic_file_stack.py +3 -3
  21. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/itk_file.py +5 -35
  22. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/mask_contour.py +3 -3
  23. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/numpy_file.py +5 -35
  24. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/utilities.py +100 -11
  25. mirp-2.3.0/mirp/_features/base_feature.py +40 -0
  26. mirp-2.3.0/mirp/_features/cm_features.py +602 -0
  27. mirp-2.3.0/mirp/_features/cm_matrix.py +150 -0
  28. mirp-2.3.0/mirp/_features/dzm_features.py +415 -0
  29. mirp-2.3.0/mirp/_features/dzm_matrix.py +106 -0
  30. mirp-2.3.0/mirp/_features/feature_generator.py +67 -0
  31. mirp-2.3.0/mirp/_features/histogram.py +106 -0
  32. mirp-2.3.0/mirp/_features/ih_features.py +556 -0
  33. mirp-2.3.0/mirp/_features/ivh_features.py +456 -0
  34. mirp-2.3.0/mirp/_features/local_intensity_features.py +260 -0
  35. mirp-2.3.0/mirp/_features/morph_3d_data.py +743 -0
  36. mirp-2.3.0/mirp/_features/morph_3d_features.py +836 -0
  37. mirp-2.3.0/mirp/_features/ngldm_features.py +462 -0
  38. mirp-2.3.0/mirp/_features/ngldm_matrix.py +147 -0
  39. mirp-2.3.0/mirp/_features/ngtdm_features.py +262 -0
  40. mirp-2.3.0/mirp/_features/ngtdm_matrix.py +173 -0
  41. mirp-2.3.0/mirp/_features/rlm_features.py +413 -0
  42. mirp-2.3.0/mirp/_features/rlm_matrix.py +159 -0
  43. mirp-2.3.0/mirp/_features/stat_features.py +415 -0
  44. mirp-2.3.0/mirp/_features/szm_features.py +407 -0
  45. mirp-2.3.0/mirp/_features/szm_matrix.py +105 -0
  46. mirp-2.3.0/mirp/_features/texture_features.py +28 -0
  47. mirp-2.3.0/mirp/_features/texture_matrix.py +343 -0
  48. mirp-2.3.0/mirp/_features/utilities.py +15 -0
  49. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/alter_mask.py +1 -8
  50. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/anti_aliasing.py +2 -2
  51. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/cropping.py +2 -3
  52. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/discretise_image.py +3 -0
  53. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/randomise_mask.py +3 -6
  54. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/split_mask.py +4 -4
  55. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/exponential_transform.py +6 -5
  56. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/gabor.py +9 -6
  57. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/gaussian.py +11 -7
  58. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/generic.py +7 -2
  59. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/laplacian_of_gaussian.py +11 -7
  60. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/laws.py +7 -6
  61. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/log_transform.py +6 -5
  62. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/mean.py +7 -6
  63. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/nonseparable_wavelet.py +12 -8
  64. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/separable_wavelet.py +6 -5
  65. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/square_root_transform.py +6 -5
  66. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/square_transform.py +6 -5
  67. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/base_image.py +6 -2
  68. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/ct_image.py +8 -0
  69. mirp-2.3.0/mirp/_images/digital_xray_image.py +21 -0
  70. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/generic_image.py +41 -28
  71. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/mask_image.py +10 -27
  72. mirp-2.3.0/mirp/_images/mr_adc_image.py +67 -0
  73. mirp-2.3.0/mirp/_images/mr_dce_image.py +58 -0
  74. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/pet_image.py +8 -0
  75. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/rtdose_image.py +8 -0
  76. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/transformed_image.py +4 -0
  77. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/utilities.py +34 -15
  78. {mirp-2.2.3 → mirp-2.3.0}/mirp/_masks/base_mask.py +11 -12
  79. {mirp-2.2.3 → mirp-2.3.0}/mirp/_workflows/standardWorkflow.py +50 -222
  80. {mirp-2.2.3 → mirp-2.3.0}/mirp.egg-info/PKG-INFO +37 -14
  81. {mirp-2.2.3 → mirp-2.3.0}/mirp.egg-info/SOURCES.txt +35 -13
  82. {mirp-2.2.3 → mirp-2.3.0}/mirp.egg-info/requires.txt +1 -3
  83. {mirp-2.2.3 → mirp-2.3.0}/pyproject.toml +7 -6
  84. mirp-2.2.3/mirp/_data_import/dicom_file_seg.py +0 -518
  85. mirp-2.2.3/mirp/_featuresets/cm.py +0 -558
  86. mirp-2.2.3/mirp/_featuresets/dzm.py +0 -326
  87. mirp-2.2.3/mirp/_featuresets/intensity_histogram.py +0 -193
  88. mirp-2.2.3/mirp/_featuresets/intensity_volume_histogram.py +0 -314
  89. mirp-2.2.3/mirp/_featuresets/local_intensity.py +0 -181
  90. mirp-2.2.3/mirp/_featuresets/morphology_3d.py +0 -814
  91. mirp-2.2.3/mirp/_featuresets/ngldm.py +0 -382
  92. mirp-2.2.3/mirp/_featuresets/ngtdm.py +0 -352
  93. mirp-2.2.3/mirp/_featuresets/rlm.py +0 -502
  94. mirp-2.2.3/mirp/_featuresets/statistics.py +0 -129
  95. mirp-2.2.3/mirp/_featuresets/szm.py +0 -314
  96. mirp-2.2.3/mirp/_featuresets/utilities.py +0 -94
  97. {mirp-2.2.3 → mirp-2.3.0}/CONTRIBUTING.md +0 -0
  98. {mirp-2.2.3 → mirp-2.3.0}/LICENSE.txt +0 -0
  99. {mirp-2.2.3 → mirp-2.3.0}/MANIFEST.in +0 -0
  100. {mirp-2.2.3 → mirp-2.3.0}/mirp/__init__.py +0 -0
  101. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/__init__.py +0 -0
  102. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/dicom_file_stack.py +0 -0
  103. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/itk_file_stack.py +0 -0
  104. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/numpy_file_stack.py +0 -0
  105. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/read_data.py +0 -0
  106. {mirp-2.2.3 → mirp-2.3.0}/mirp/_data_import/suv.py +0 -0
  107. {mirp-2.2.3/mirp/_featuresets → mirp-2.3.0/mirp/_features}/__init__.py +0 -0
  108. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/__init__.py +0 -0
  109. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/tissue_mask.py +0 -0
  110. {mirp-2.2.3 → mirp-2.3.0}/mirp/_image_processing/utilities.py +0 -0
  111. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/__init__.py +0 -0
  112. {mirp-2.2.3 → mirp-2.3.0}/mirp/_imagefilters/utilities.py +0 -0
  113. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/__init__.py +0 -0
  114. {mirp-2.2.3 → mirp-2.3.0}/mirp/_images/mr_image.py +0 -0
  115. {mirp-2.2.3 → mirp-2.3.0}/mirp/_masks/__init__.py +0 -0
  116. {mirp-2.2.3 → mirp-2.3.0}/mirp/_workflows/__init__.py +0 -0
  117. {mirp-2.2.3 → mirp-2.3.0}/mirp/_workflows/baseWorkflow.py +0 -0
  118. {mirp-2.2.3 → mirp-2.3.0}/mirp/config_data.xml +0 -0
  119. {mirp-2.2.3 → mirp-2.3.0}/mirp/config_settings.xml +0 -0
  120. {mirp-2.2.3 → mirp-2.3.0}/mirp/data_import/__init__.py +0 -0
  121. {mirp-2.2.3 → mirp-2.3.0}/mirp/data_import/import_image.py +0 -0
  122. {mirp-2.2.3 → mirp-2.3.0}/mirp/data_import/import_image_and_mask.py +0 -0
  123. {mirp-2.2.3 → mirp-2.3.0}/mirp/data_import/import_mask.py +0 -0
  124. {mirp-2.2.3 → mirp-2.3.0}/mirp/deep_learning_preprocessing.py +0 -0
  125. {mirp-2.2.3 → mirp-2.3.0}/mirp/deprecated.py +0 -0
  126. {mirp-2.2.3 → mirp-2.3.0}/mirp/extract_features_and_images.py +0 -0
  127. {mirp-2.2.3 → mirp-2.3.0}/mirp/extract_image_parameters.py +0 -0
  128. {mirp-2.2.3 → mirp-2.3.0}/mirp/extract_mask_labels.py +0 -0
  129. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/__init__.py +0 -0
  130. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/feature_parameters.py +0 -0
  131. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/general_parameters.py +0 -0
  132. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/generic.py +0 -0
  133. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/image_processing_parameters.py +0 -0
  134. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/import_config_parameters.py +0 -0
  135. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/import_data_parameters.py +0 -0
  136. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/interpolation_parameters.py +0 -0
  137. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/perturbation_parameters.py +0 -0
  138. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/resegmentation_parameters.py +0 -0
  139. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/transformation_parameters.py +0 -0
  140. {mirp-2.2.3 → mirp-2.3.0}/mirp/settings/utilities.py +0 -0
  141. {mirp-2.2.3 → mirp-2.3.0}/mirp/utilities/__init__.py +0 -0
  142. {mirp-2.2.3 → mirp-2.3.0}/mirp/utilities/config_utilities.py +0 -0
  143. {mirp-2.2.3 → mirp-2.3.0}/mirp/utilities/parallel.py +0 -0
  144. {mirp-2.2.3 → mirp-2.3.0}/mirp/utilities/utilities.py +0 -0
  145. {mirp-2.2.3 → mirp-2.3.0}/mirp.egg-info/dependency_links.txt +0 -0
  146. {mirp-2.2.3 → mirp-2.3.0}/mirp.egg-info/top_level.txt +0 -0
  147. {mirp-2.2.3 → mirp-2.3.0}/setup.cfg +0 -0
@@ -1,3 +1,34 @@
1
+ # Version 2.3.0
2
+
3
+ ## Major changes
4
+
5
+ - The proper ancient feature computation code running in the background of MIRP has been completely refactored. We
6
+ moved from a functional backend where all features were computed per feature family to a more flexible
7
+ object-oriented approach. Although this change is not visible at the user-end, it offers several new possibilities:
8
+ - Single features can now be computed. In addition, for some features (e.g. percentile statistics), a flexible
9
+ percentile value could be passed.
10
+ - Creation of feature maps.
11
+ - Output of features and their metadata to machine-readable formats, instead of just tabular data.
12
+
13
+ **Important**: Though the *name* of features in the tabular exports has not changed, their *ordering* may have.
14
+ Avoid using column position when processing or analysing feature data.
15
+
16
+ - Apparent diffusion coefficient (ADC) maps, diffusion contrast-enhanced (DCE) MRI and multi-frame DICOM objects in
17
+ general are now supported.
18
+ - Planar imaging, i.e. computed radiography, digital X-ray and digital mammography DICOM files are now supported.
19
+ - Python version 3.12 is now supported thanks to recent updates by the maintainers of `ray` and `itk`.
20
+ This means that `mirp` now supports Python version 3.10 and later.
21
+
22
+ ## Fixes
23
+
24
+ - Internal use of `numpy.cross` no longer produces deprecation warnings.
25
+
26
+ # Version 2.2.4
27
+
28
+ ## Fixes
29
+
30
+ - Masks can now be plotted in images without causing an error when using `matplotlib` version 3.9.0 or later.
31
+
1
32
  # Version 2.2.3
2
33
 
3
34
  ## Minor changes
@@ -7,7 +38,7 @@
7
38
 
8
39
  - MIRP now checks whether there are potential problems between the frames of reference of image and mask files.
9
40
 
10
- # Fixes
41
+ ## Fixes
11
42
 
12
43
  - Fixed an error that occurs when attempting to create a deep copy `ImageITKFile` objects.
13
44
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mirp
3
- Version: 2.2.3
3
+ Version: 2.3.0
4
4
  Summary: A package for standardised processing of medical imaging and computation of quantitative features.
5
5
  Author-email: Alex Zwanenburg <alexander.zwanenburg@nct-dresden.de>
6
6
  License: European Union Public Licence
@@ -284,6 +284,7 @@ Project-URL: Changelog, https://github.com/oncoray/mirp/blob/master/NEWS.md
284
284
  Classifier: Programming Language :: Python :: 3
285
285
  Classifier: Programming Language :: Python :: 3.10
286
286
  Classifier: Programming Language :: Python :: 3.11
287
+ Classifier: Programming Language :: Python :: 3.12
287
288
  Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
288
289
  Classifier: Operating System :: OS Independent
289
290
  Classifier: Topic :: Scientific/Engineering :: Image Processing
@@ -299,8 +300,8 @@ Requires-Dist: pydicom>=2.4.0
299
300
  Requires-Dist: pywavelets>=1.4.0
300
301
  Requires-Dist: scikit-image>=0.20.0
301
302
  Requires-Dist: scipy>=1.11
303
+ Requires-Dist: ray>=2.34.0
302
304
  Requires-Dist: typing-extensions>=4.10; python_version < "3.11"
303
- Requires-Dist: ray>=2.10.0; python_version <= "3.11"
304
305
  Provides-Extra: test
305
306
  Requires-Dist: pytest>=7.4.0; extra == "test"
306
307
  Provides-Extra: docs
@@ -310,15 +311,36 @@ Requires-Dist: nbsphinx; extra == "docs"
310
311
 
311
312
  <img src="https://raw.githubusercontent.com/oncoray/mirp/master/icon/mirp.svg" align="right" width="120"/>
312
313
 
314
+ ![GitHub License](https://img.shields.io/github/license/oncoray/mirp)
315
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mirp)
316
+ [![PyPI - Version](https://img.shields.io/pypi/v/mirp)](https://pypi.org/project/mirp/)
317
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/oncoray/mirp/auto-test-dependencies_timed.yml)
318
+ [![JOSS](https://joss.theoj.org/papers/165c85b1ecad891550a21b12c8b2e577/status.svg)](https://joss.theoj.org/papers/165c85b1ecad891550a21b12c8b2e577)
319
+
313
320
  # Medical Image Radiomics Processor
314
321
 
315
- Medical Image Radiomics Processor (MIRP) is a python package for medical image analysis that is compliant with the
316
- reference standards of the Image Biomarker Standardisation Initiative (IBSI). MIRP focuses on radiomics applications
317
- and supports computation of features for conventional radiomics and image processing for deep-learning applications.
322
+ MIRP is a python package for quantitative analysis of medical images. It focuses on processing images for integration
323
+ with radiomics workflows. These workflows either use quantitative features computed using MIRP, or directly use MIRP
324
+ to process images as input for neural networks and other deep learning models.
325
+
326
+ MIRP offers the following main functionality:
327
+
328
+ - [Extract and collect metadata](https://oncoray.github.io/mirp/image_metadata.html) from medical images.
329
+ - [Find and collect labels or names](https://oncoray.github.io/mirp/mask_labels.html) of regions of interest from image
330
+ segmentations.
331
+ - [Compute quantitative features](https://oncoray.github.io/mirp/quantitative_image_analysis.html) from regions of interest in medical images.
332
+ - [Process images for deep learning](https://oncoray.github.io/mirp/deep_learning.html).
333
+
334
+ ## Tutorials
335
+
336
+ We currently offer the following tutorials:
337
+
338
+ - [Computing quantitative features from MR images](https://oncoray.github.io/mirp/tutorial_compute_radiomics_features_mr.html)
339
+ - [Applying filters to images](https://oncoray.github.io/mirp/tutorial_apply_image_filter.html)
318
340
 
319
- ## Documentation and tutorials
341
+ ## Documentation
320
342
 
321
- Documentation and tutorials can be found here: https://oncoray.github.io/mirp/
343
+ Documentation can be found here: https://oncoray.github.io/mirp/
322
344
 
323
345
  ## Supported Python and OS
324
346
 
@@ -328,18 +350,19 @@ MIRP currently supports the following Python versions and operating systems:
328
350
  |--------|-----------|-----------|-----------|
329
351
  | 3.10 | Supported | Supported | Supported |
330
352
  | 3.11 | Supported | Supported | Supported |
353
+ | 3.12 | Supported | Supported | Supported |
331
354
 
332
355
  ## Supported imaging and mask modalities
333
356
 
334
357
  MIRP currently supports the following image modalities:
335
358
 
336
- | File format | File type | Supported modality |
337
- |-------------|-----------|--------------------|
338
- | DICOM | image | CT, MR, PT, RTDOSE |
339
- | DICOM | mask | RTSTRUCT, SEG |
340
- | NIfTI | any | any |
341
- | NRRD | any | any |
342
- | numpy | any | any |
359
+ | File format | File type | Supported modality |
360
+ |-------------|-----------|-------------------------------------------------|
361
+ | DICOM | image | CT, MR (incl. ADC, DCE), PT, RTDOSE, CR, DX, MG |
362
+ | DICOM | mask | RTSTRUCT, SEG |
363
+ | NIfTI | any | any |
364
+ | NRRD | any | any |
365
+ | numpy | any | any |
343
366
 
344
367
  NIfTI, NRRD, and numpy files support any kind of (single-channel) image. MIRP cannot process RGB or 4D images.
345
368
 
@@ -1,14 +1,35 @@
1
1
  <img src="https://raw.githubusercontent.com/oncoray/mirp/master/icon/mirp.svg" align="right" width="120"/>
2
2
 
3
+ ![GitHub License](https://img.shields.io/github/license/oncoray/mirp)
4
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mirp)
5
+ [![PyPI - Version](https://img.shields.io/pypi/v/mirp)](https://pypi.org/project/mirp/)
6
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/oncoray/mirp/auto-test-dependencies_timed.yml)
7
+ [![JOSS](https://joss.theoj.org/papers/165c85b1ecad891550a21b12c8b2e577/status.svg)](https://joss.theoj.org/papers/165c85b1ecad891550a21b12c8b2e577)
8
+
3
9
  # Medical Image Radiomics Processor
4
10
 
5
- Medical Image Radiomics Processor (MIRP) is a python package for medical image analysis that is compliant with the
6
- reference standards of the Image Biomarker Standardisation Initiative (IBSI). MIRP focuses on radiomics applications
7
- and supports computation of features for conventional radiomics and image processing for deep-learning applications.
11
+ MIRP is a python package for quantitative analysis of medical images. It focuses on processing images for integration
12
+ with radiomics workflows. These workflows either use quantitative features computed using MIRP, or directly use MIRP
13
+ to process images as input for neural networks and other deep learning models.
14
+
15
+ MIRP offers the following main functionality:
16
+
17
+ - [Extract and collect metadata](https://oncoray.github.io/mirp/image_metadata.html) from medical images.
18
+ - [Find and collect labels or names](https://oncoray.github.io/mirp/mask_labels.html) of regions of interest from image
19
+ segmentations.
20
+ - [Compute quantitative features](https://oncoray.github.io/mirp/quantitative_image_analysis.html) from regions of interest in medical images.
21
+ - [Process images for deep learning](https://oncoray.github.io/mirp/deep_learning.html).
22
+
23
+ ## Tutorials
24
+
25
+ We currently offer the following tutorials:
26
+
27
+ - [Computing quantitative features from MR images](https://oncoray.github.io/mirp/tutorial_compute_radiomics_features_mr.html)
28
+ - [Applying filters to images](https://oncoray.github.io/mirp/tutorial_apply_image_filter.html)
8
29
 
9
- ## Documentation and tutorials
30
+ ## Documentation
10
31
 
11
- Documentation and tutorials can be found here: https://oncoray.github.io/mirp/
32
+ Documentation can be found here: https://oncoray.github.io/mirp/
12
33
 
13
34
  ## Supported Python and OS
14
35
 
@@ -18,18 +39,19 @@ MIRP currently supports the following Python versions and operating systems:
18
39
  |--------|-----------|-----------|-----------|
19
40
  | 3.10 | Supported | Supported | Supported |
20
41
  | 3.11 | Supported | Supported | Supported |
42
+ | 3.12 | Supported | Supported | Supported |
21
43
 
22
44
  ## Supported imaging and mask modalities
23
45
 
24
46
  MIRP currently supports the following image modalities:
25
47
 
26
- | File format | File type | Supported modality |
27
- |-------------|-----------|--------------------|
28
- | DICOM | image | CT, MR, PT, RTDOSE |
29
- | DICOM | mask | RTSTRUCT, SEG |
30
- | NIfTI | any | any |
31
- | NRRD | any | any |
32
- | numpy | any | any |
48
+ | File format | File type | Supported modality |
49
+ |-------------|-----------|-------------------------------------------------|
50
+ | DICOM | image | CT, MR (incl. ADC, DCE), PT, RTDOSE, CR, DX, MG |
51
+ | DICOM | mask | RTSTRUCT, SEG |
52
+ | NIfTI | any | any |
53
+ | NRRD | any | any |
54
+ | numpy | any | any |
33
55
 
34
56
  NIfTI, NRRD, and numpy files support any kind of (single-channel) image. MIRP cannot process RGB or 4D images.
35
57
 
@@ -1,51 +1,27 @@
1
+ import sys
1
2
  import datetime
2
3
  import os.path
3
4
  import hashlib
4
5
  import numpy as np
5
6
 
7
+ if sys.version_info >= (3, 11):
8
+ from typing import Self
9
+ else:
10
+ from typing_extensions import Self
6
11
  from typing import Any
7
12
 
8
13
  from pydicom import dcmread
9
14
  from warnings import warn
15
+ from copy import deepcopy
10
16
 
11
17
  from mirp._data_import.generic_file import ImageFile, MaskFile
12
18
  from mirp._data_import.utilities import supported_image_modalities, stacking_dicom_image_modalities, \
13
- supported_mask_modalities, get_pydicom_meta_tag, convert_dicom_time
19
+ supported_mask_modalities, get_pydicom_meta_tag, convert_dicom_time, has_pydicom_meta_tag
14
20
 
15
21
 
16
22
  class ImageDicomFile(ImageFile):
17
- def __init__(
18
- self,
19
- file_path: None | str = None,
20
- dir_path: None | str = None,
21
- sample_name: None | str | list[str] = None,
22
- file_name: None | str = None,
23
- image_name: None | str = None,
24
- image_modality: None | str = None,
25
- image_file_type: None | str = None,
26
- image_data: None | np.ndarray = None,
27
- image_origin: None | tuple[float, ...] = None,
28
- image_orientation: None | np.ndarray = None,
29
- image_spacing: None | tuple[float, ...] = None,
30
- image_dimensions: None | tuple[int, ...] = None,
31
- **kwargs
32
- ):
33
-
34
- super().__init__(
35
- file_path=file_path,
36
- dir_path=dir_path,
37
- sample_name=sample_name,
38
- file_name=file_name,
39
- image_name=image_name,
40
- image_modality=image_modality,
41
- image_file_type=image_file_type,
42
- image_data=image_data,
43
- image_origin=image_origin,
44
- image_orientation=image_orientation,
45
- image_spacing=image_spacing,
46
- image_dimensions=image_dimensions,
47
- **kwargs
48
- )
23
+ def __init__(self, **kwargs):
24
+ super().__init__(**kwargs)
49
25
 
50
26
  # These are set using the 'complete' method.
51
27
  self.series_instance_uid: None | str = None
@@ -103,6 +79,13 @@ class ImageDicomFile(ImageFile):
103
79
 
104
80
  def _check_modality(self, raise_error: bool) -> bool:
105
81
  dicom_modality = get_pydicom_meta_tag(dcm_seq=self.image_metadata, tag=(0x0008, 0x0060), tag_type="str")
82
+
83
+ # Check for ADC images
84
+ if self._check_is_mr_adc():
85
+ dicom_modality = "adc"
86
+ if self._check_is_mr_dce():
87
+ dicom_modality = "dce"
88
+
106
89
  support_modalities = supported_image_modalities(self.modality)
107
90
  if dicom_modality.lower() not in support_modalities:
108
91
  if raise_error:
@@ -164,8 +147,14 @@ class ImageDicomFile(ImageFile):
164
147
  # Import locally to prevent circular references.
165
148
  from mirp._data_import.dicom_file_ct import ImageDicomFileCT
166
149
  from mirp._data_import.dicom_file_mr import ImageDicomFileMR
150
+ from mirp._data_import.dicom_file_mr_adc import ImageDicomFileMRADC
151
+ from mirp._data_import.dicom_file_mr_dce import ImageDicomFileMRDCE
167
152
  from mirp._data_import.dicom_file_pet import ImageDicomFilePT
168
153
  from mirp._data_import.dicom_file_rtdose import ImageDicomFileRTDose
154
+ from mirp._data_import.dicom_file_cr import ImageDicomFileCR
155
+ from mirp._data_import.dicom_file_dx import ImageDicomFileDX
156
+ from mirp._data_import.dicom_file_mg import ImageDicomFileMG
157
+ from mirp._data_import.dicom_multi_frame import ImageDicomMultiFrame
169
158
 
170
159
  # Load metadata so that the modality tag can be read.
171
160
  self.load_metadata(limited=True)
@@ -174,39 +163,75 @@ class ImageDicomFile(ImageFile):
174
163
  if modality is None:
175
164
  raise TypeError(f"Modality attribute could not be obtained from DICOM file. [{self.describe_self()}]")
176
165
 
166
+ if modality == "mr" and self._check_is_mr_adc():
167
+ modality = "adc"
168
+ if modality == "mr" and self._check_is_mr_dce():
169
+ modality = "dce"
170
+
177
171
  if modality == "ct":
178
172
  file_class = ImageDicomFileCT
179
173
  elif modality == "pt":
180
174
  file_class = ImageDicomFilePT
181
175
  elif modality == "mr":
182
176
  file_class = ImageDicomFileMR
177
+ elif modality == "adc":
178
+ file_class = ImageDicomFileMRADC
179
+ elif modality == "dce":
180
+ file_class = ImageDicomFileMRDCE
183
181
  elif modality == "rtdose":
184
182
  file_class = ImageDicomFileRTDose
183
+ elif modality == "cr":
184
+ file_class = ImageDicomFileCR
185
+ elif modality == "dx":
186
+ file_class = ImageDicomFileDX
187
+ elif modality == "mg":
188
+ file_class = ImageDicomFileMG
185
189
  else:
186
190
  # This will return a base class, which will fail to pass the modality check.
187
191
  return None
188
192
 
189
- image = file_class(
190
- file_path=self.file_path,
191
- dir_path=self.dir_path,
192
- sample_name=self.sample_name,
193
- file_name=self.file_name,
194
- image_modality=self.modality,
195
- image_name=self.image_name,
196
- image_file_type=self.file_type,
197
- image_data=self.image_data,
198
- image_origin=self.image_origin,
199
- image_orientation=self.image_orientation,
200
- image_spacing=self.image_spacing,
201
- image_dimensions=self.image_dimension,
202
- )
193
+ if has_pydicom_meta_tag(dcm_seq=self.image_metadata, tag=(0x5200, 0x9299)) or \
194
+ has_pydicom_meta_tag(dcm_seq=self.image_metadata, tag=(0x5200, 0x9230)):
195
+ file_class = ImageDicomMultiFrame
196
+
197
+ # Instantiate subclass, and update using current object.
198
+ # Modality is updated here to reflect the choices made above.
199
+ image = file_class()
200
+ image.update_from_template(template=self)
201
+ image.modality = modality
203
202
 
204
- # Set metadata of image.
205
- image.image_metadata = self.image_metadata
206
- image.is_limited_metadata = self.is_limited_metadata
203
+ # Multi-frame images need additional work.
204
+ if isinstance(image, ImageDicomMultiFrame):
205
+ image = image.create()
207
206
 
208
207
  return image
209
208
 
209
+ def update_from_template(self, template: Self):
210
+ if not isinstance(template, ImageDicomFile):
211
+ raise TypeError(
212
+ f"The new class object should inherit from an ImageDicomFile object. Found: {type(template)}"
213
+ )
214
+
215
+ # Attributes from the template Image Dicom File. Note that image_data and image_metadata are shallow copies.
216
+ self.file_path = deepcopy(template.file_path)
217
+ self.dir_path = deepcopy(template.dir_path)
218
+ self.sample_name = deepcopy(template.sample_name)
219
+ self.file_name = deepcopy(template.file_name)
220
+ self.modality = deepcopy(template.modality)
221
+ self.image_name = deepcopy(template.image_name)
222
+ self.file_type = deepcopy(template.file_type)
223
+ self.image_data = template.image_data
224
+ self.image_origin = deepcopy(template.image_origin)
225
+ self.image_orientation = deepcopy(template.image_orientation)
226
+ self.image_spacing = deepcopy(template.image_spacing)
227
+ self.image_dimension = deepcopy(template.image_dimension)
228
+ self.frame_of_reference_uid = deepcopy(template.frame_of_reference_uid)
229
+ self.image_metadata = template.image_metadata
230
+ self.is_limited_metadata = deepcopy(template.is_limited_metadata)
231
+ self.series_instance_uid = deepcopy(template.series_instance_uid)
232
+ self.sop_instance_uid = deepcopy(template.sop_instance_uid)
233
+ self.associated_masks = template.associated_masks
234
+
210
235
  def complete(self, remove_metadata=False, force=False):
211
236
 
212
237
  # complete loads metadata.
@@ -283,7 +308,7 @@ class ImageDicomFile(ImageFile):
283
308
  else:
284
309
  self.sample_name = None
285
310
 
286
- def _complete_image_origin(self, force=False):
311
+ def _complete_image_origin(self, force=False, frame_id=None):
287
312
  if self.image_origin is None:
288
313
  # Origin needs to be determined at the stack-level for slice-based dicom, not for each slice.
289
314
  if self.modality in stacking_dicom_image_modalities() and not force:
@@ -292,10 +317,16 @@ class ImageDicomFile(ImageFile):
292
317
  # Load relevant metadata.
293
318
  self.load_metadata(limited=True)
294
319
 
295
- origin = get_pydicom_meta_tag(dcm_seq=self.image_metadata, tag=(0x0020, 0x0032), tag_type="mult_float")[::-1]
320
+ origin = get_pydicom_meta_tag(
321
+ dcm_seq=self.image_metadata,
322
+ tag=(0x0020, 0x0032),
323
+ tag_type="mult_float",
324
+ macro_dcm_seq=(0x0020, 0x9113),
325
+ frame_id=frame_id
326
+ )[::-1]
296
327
  self.image_origin = tuple(origin)
297
328
 
298
- def _complete_image_orientation(self, force=False):
329
+ def _complete_image_orientation(self, force=False, frame_id=None):
299
330
  if self.image_orientation is None:
300
331
  # Orientation needs to be determined at the stack-level for slice-based dicom, not for each slice.
301
332
  if self.modality in stacking_dicom_image_modalities() and not force:
@@ -307,14 +338,17 @@ class ImageDicomFile(ImageFile):
307
338
  orientation: list[float] = get_pydicom_meta_tag(
308
339
  dcm_seq=self.image_metadata,
309
340
  tag=(0x0020, 0x0037),
310
- tag_type="mult_float"
341
+ tag_type="mult_float",
342
+ macro_dcm_seq=(0x0020, 0x9116),
343
+ frame_id=frame_id
311
344
  )
312
345
 
313
346
  # First compute z-orientation.
347
+ # noinspection PyUnreachableCode
314
348
  orientation += list(np.cross(orientation[0:3], orientation[3:6]))
315
349
  self.image_orientation = np.reshape(orientation[::-1], [3, 3], order="F")
316
350
 
317
- def _complete_image_spacing(self, force=False):
351
+ def _complete_image_spacing(self, force=False, frame_id=None):
318
352
  if self.image_spacing is None:
319
353
  # Image spacing needs to be determined at the stack-level for slice-based dicom, not for each slice.
320
354
  if self.modality in stacking_dicom_image_modalities() and not force:
@@ -324,14 +358,36 @@ class ImageDicomFile(ImageFile):
324
358
  self.load_metadata(limited=True)
325
359
 
326
360
  # Get pixel-spacing.
327
- spacing = get_pydicom_meta_tag(dcm_seq=self.image_metadata, tag=(0x0028, 0x0030), tag_type="mult_float")
361
+ spacing = get_pydicom_meta_tag(
362
+ dcm_seq=self.image_metadata,
363
+ tag=(0x0028, 0x0030),
364
+ tag_type="mult_float",
365
+ macro_dcm_seq=(0x0028, 0x9110),
366
+ frame_id=frame_id
367
+ )
328
368
 
329
- # Get slice thickness.
369
+ # First try to get spacing between slices.
330
370
  z_spacing = get_pydicom_meta_tag(
331
371
  dcm_seq=self.image_metadata,
332
- tag=(0x0018, 0x0050),
372
+ tag=(0x0018, 0x0088),
333
373
  tag_type="float",
334
- default=1.0)
374
+ macro_dcm_seq=(0x0028, 0x9110),
375
+ frame_id=frame_id
376
+ )
377
+
378
+ # If spacing between slices is not set, get slice thickness.
379
+ if z_spacing is None:
380
+ z_spacing = get_pydicom_meta_tag(
381
+ dcm_seq=self.image_metadata,
382
+ tag=(0x0018, 0x0050),
383
+ tag_type="float",
384
+ macro_dcm_seq=(0x0028, 0x9110),
385
+ frame_id=frame_id
386
+ )
387
+
388
+ # If slice thickness is not set, use a default value.
389
+ if z_spacing is None:
390
+ z_spacing = 1.0
335
391
  spacing += [z_spacing]
336
392
 
337
393
  self.image_spacing = tuple(spacing[::-1])
@@ -496,10 +552,145 @@ class ImageDicomFile(ImageFile):
496
552
  # Update object_metadata
497
553
  self.object_metadata.update(dict(metadata))
498
554
 
555
+ def export_metadata(self, self_only=False, **kwargs) -> None | dict[str, Any]:
556
+ if not self_only:
557
+ metadata = super().export_metadata()
558
+ else:
559
+ metadata = {}
560
+
561
+ self.load_metadata()
562
+
563
+ dcm_meta_data = []
564
+
565
+ # Scanner type
566
+ scanner_type = get_pydicom_meta_tag(
567
+ dcm_seq=self.image_metadata,
568
+ tag=(0x0008, 0x1090),
569
+ tag_type="str"
570
+ )
571
+ if scanner_type is not None:
572
+ dcm_meta_data += [("scanner_type", scanner_type)]
573
+
574
+ # Scanner manufacturer
575
+ manufacturer = get_pydicom_meta_tag(
576
+ dcm_seq=self.image_metadata,
577
+ tag=(0x0008, 0x0070),
578
+ tag_type="str"
579
+ )
580
+ if manufacturer is not None:
581
+ dcm_meta_data += [("manufacturer", manufacturer)]
582
+
583
+ # Image type
584
+ image_type = get_pydicom_meta_tag(
585
+ dcm_seq=self.image_metadata,
586
+ tag=(0x0008, 0x0008),
587
+ tag_type="str"
588
+ )
589
+ if image_type is not None:
590
+ dcm_meta_data += [("image_type", image_type)]
591
+
592
+ # Patient orientation
593
+ patient_orientation = get_pydicom_meta_tag(
594
+ dcm_seq=self.image_metadata,
595
+ tag=(0x0020, 0x0020),
596
+ tag_type="str"
597
+ )
598
+ if patient_orientation is not None:
599
+ dcm_meta_data += [("patient_orientation", patient_orientation)]
600
+
601
+ metadata.update(dict(dcm_meta_data))
602
+
603
+ return metadata
604
+
605
+ def _check_is_mr_adc(self):
606
+ # Check for ADC images. ADC can sometimes by identified the ADC value in the Image Type (0008,0008) tag,
607
+ # the frame type tag (0008, 9007) or acquisition contrast (0008, 9209) [though this typically should be
608
+ # DIFFUSION].
609
+ image_type = get_pydicom_meta_tag(
610
+ dcm_seq=self.image_metadata,
611
+ tag=(0x0008, 0x0008),
612
+ tag_type="mult_str"
613
+ )
614
+ frame_type = get_pydicom_meta_tag(
615
+ dcm_seq=self.image_metadata,
616
+ tag=(0x0008, 0x9007),
617
+ tag_type="mult_str",
618
+ macro_dcm_seq=(0x0018, 0x9226),
619
+ frame_id=0
620
+ )
621
+ alt_frame_type = get_pydicom_meta_tag(
622
+ dcm_seq=self.image_metadata,
623
+ tag=(0x0008, 0x9007),
624
+ tag_type="mult_str",
625
+ macro_dcm_seq=(0x0040, 0x9092),
626
+ frame_id=0
627
+ )
628
+ acquisition_contrast = get_pydicom_meta_tag(
629
+ dcm_seq=self.image_metadata,
630
+ tag=(0x0008, 0x9209),
631
+ tag_type="str",
632
+ macro_dcm_seq=(0x0018, 0x9226),
633
+ frame_id=0
634
+ )
635
+
636
+ if image_type is not None and any(x.lower() == "adc" for x in image_type):
637
+ return True
638
+ elif frame_type is not None and any(x.lower() == "adc" for x in frame_type):
639
+ return True
640
+ elif alt_frame_type is not None and any(x.lower() == "adc" for x in alt_frame_type):
641
+ return True
642
+ elif acquisition_contrast is not None and acquisition_contrast.lower() == "adc":
643
+ return True
644
+
645
+ return False
646
+
647
+ def _check_is_mr_dce(self):
648
+ # Check for DCE images. DCE can sometimes by identified the DCE value in the Image Type (0008,0008) tag,
649
+ # the frame type tag (0008, 9007) or acquisition contrast (0008, 9209) [though this typically should be
650
+ # DIFFUSION].
651
+ image_type = get_pydicom_meta_tag(
652
+ dcm_seq=self.image_metadata,
653
+ tag=(0x0008, 0x0008),
654
+ tag_type="mult_str"
655
+ )
656
+ frame_type = get_pydicom_meta_tag(
657
+ dcm_seq=self.image_metadata,
658
+ tag=(0x0008, 0x9007),
659
+ tag_type="mult_str",
660
+ macro_dcm_seq=(0x0018, 0x9226),
661
+ frame_id=0
662
+ )
663
+ alt_frame_type = get_pydicom_meta_tag(
664
+ dcm_seq=self.image_metadata,
665
+ tag=(0x0008, 0x9007),
666
+ tag_type="mult_str",
667
+ macro_dcm_seq=(0x0040, 0x9092),
668
+ frame_id=0
669
+ )
670
+ acquisition_contrast = get_pydicom_meta_tag(
671
+ dcm_seq=self.image_metadata,
672
+ tag=(0x0008, 0x9209),
673
+ tag_type="str",
674
+ macro_dcm_seq=(0x0018, 0x9226),
675
+ frame_id=0
676
+ )
677
+
678
+ if image_type is not None and any(x.lower() == "dce" for x in image_type):
679
+ return True
680
+ elif frame_type is not None and any(x.lower() == "dce" for x in frame_type):
681
+ return True
682
+ elif alt_frame_type is not None and any(x.lower() == "dce" for x in alt_frame_type):
683
+ return True
684
+ elif acquisition_contrast is not None and acquisition_contrast.lower() == "dce":
685
+ return True
686
+
687
+ return False
688
+
499
689
  @staticmethod
500
690
  def _get_limited_metadata_tags():
501
691
  # Limited tags are read to populate basic
502
692
  return [
693
+ (0x0008, 0x0008), # image type
503
694
  (0x0008, 0x0018), # SOP instance UID
504
695
  (0x0008, 0x0060), # modality
505
696
  (0x0008, 0x1030), # study description
@@ -507,6 +698,7 @@ class ImageDicomFile(ImageFile):
507
698
  (0x0010, 0x0010), # patient name
508
699
  (0x0010, 0x0020), # patient id
509
700
  (0x0018, 0x0050), # slice thickness
701
+ (0x0018, 0x9087), # diffusion b-value
510
702
  (0x0020, 0x000E), # series instance UID
511
703
  (0x0020, 0x0010), # study id
512
704
  (0x0020, 0x0032), # origin
@@ -516,7 +708,9 @@ class ImageDicomFile(ImageFile):
516
708
  (0x0028, 0x0010), # pixel rows
517
709
  (0x0028, 0x0011), # pixel columns
518
710
  (0x0028, 0x0030), # pixel spacing
519
- (0x3004, 0x000C) # grid frame offset vector
711
+ (0x3004, 0x000C), # grid frame offset vector
712
+ (0x5200, 0x9229), # shared functional groups sequence
713
+ (0x5200, 0x9230) # per-frame functional groups sequence
520
714
  ]
521
715
 
522
716
  def _get_acquisition_start_time(self) -> datetime.datetime:
@@ -0,0 +1,6 @@
1
+ from mirp._data_import.dicom_planar_image import ImageDicomPlanarImage
2
+
3
+
4
+ class ImageDicomFileCR(ImageDicomPlanarImage):
5
+ def __init__(self, **kwargs):
6
+ super().__init__(**kwargs)