mirp 2.3.2__tar.gz → 2.3.3__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.
- {mirp-2.3.2 → mirp-2.3.3}/NEWS.md +16 -0
- mirp-2.3.3/PKG-INFO +252 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/cm_features.py +80 -3
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ivh_features.py +1 -1
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_workflows/standardWorkflow.py +1 -1
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/feature_parameters.py +3 -3
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/interpolation_parameters.py +3 -3
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/transformation_parameters.py +3 -3
- mirp-2.3.3/mirp.egg-info/PKG-INFO +252 -0
- {mirp-2.3.2 → mirp-2.3.3}/pyproject.toml +2 -3
- mirp-2.3.2/PKG-INFO +0 -527
- mirp-2.3.2/mirp.egg-info/PKG-INFO +0 -527
- {mirp-2.3.2 → mirp-2.3.3}/CONTRIBUTING.md +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/LICENSE.txt +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/MANIFEST.in +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/README.md +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_cr.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_ct.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_dx.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_mg.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_mr.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_mr_adc.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_mr_dce.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_pet.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_rtdose.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_rtstruct.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_seg.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_file_stack.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_multi_frame.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/dicom_planar_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/directory.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/generic_file.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/generic_file_stack.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/itk_file.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/itk_file_stack.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/mask_contour.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/numpy_file.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/numpy_file_stack.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/read_data.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/suv.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_data_import/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/base_feature.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/cm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/dzm_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/dzm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/feature_generator.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/histogram.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ih_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/local_intensity_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/morph_3d_data.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/morph_3d_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ngldm_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ngldm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ngtdm_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/ngtdm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/rlm_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/rlm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/stat_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/szm_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/szm_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/texture_features.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/texture_matrix.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_features/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/alter_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/anti_aliasing.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/cropping.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/discretise_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/randomise_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/split_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/tissue_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_image_processing/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/exponential_transform.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/gabor.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/gaussian.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/generic.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/laplacian_of_gaussian.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/laws.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/log_transform.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/mean.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/nonseparable_wavelet.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/separable_wavelet.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/square_root_transform.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/square_transform.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_imagefilters/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/base_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/ct_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/digital_xray_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/generic_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/mask_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/mr_adc_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/mr_dce_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/mr_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/pet_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/rtdose_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/transformed_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_images/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_masks/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_masks/base_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_workflows/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/_workflows/baseWorkflow.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/config_data.xml +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/config_settings.xml +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/data_import/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/data_import/import_image.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/data_import/import_image_and_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/data_import/import_mask.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/deep_learning_preprocessing.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/deprecated.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/extract_features_and_images.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/extract_image_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/extract_mask_labels.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/general_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/generic.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/image_processing_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/import_config_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/import_data_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/perturbation_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/resegmentation_parameters.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/settings/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/utilities/__init__.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/utilities/config_utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/utilities/parallel.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp/utilities/utilities.py +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp.egg-info/SOURCES.txt +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp.egg-info/dependency_links.txt +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp.egg-info/requires.txt +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/mirp.egg-info/top_level.txt +0 -0
- {mirp-2.3.2 → mirp-2.3.3}/setup.cfg +0 -0
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# Version 2.3.3
|
|
2
|
+
|
|
3
|
+
## Minor changes
|
|
4
|
+
|
|
5
|
+
- Added the co-occurrence matrix-based maximum correlation coefficient feature. Since no reference standards for this
|
|
6
|
+
feature exist, you need to specify `ibsi_compliant = False` to compute it.
|
|
7
|
+
|
|
8
|
+
## Fixes
|
|
9
|
+
|
|
10
|
+
- `numpy.trapz` was deprecated and is now replaced by `numpy.trapezoid`.
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
- The documentation erroneously mentioned that the `by_slice` parameter could take `"largest"` as an option. This
|
|
15
|
+
was no longer possible since the introduction of the `mask_select_largest_slice` parameter in version 2.1.0.
|
|
16
|
+
|
|
1
17
|
# Version 2.3.2
|
|
2
18
|
|
|
3
19
|
## Minor changes
|
mirp-2.3.3/PKG-INFO
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mirp
|
|
3
|
+
Version: 2.3.3
|
|
4
|
+
Summary: A package for standardised processing of medical imaging and computation of quantitative features.
|
|
5
|
+
Author-email: Alex Zwanenburg <alexander.zwanenburg@nct-dresden.de>
|
|
6
|
+
License-Expression: EUPL-1.2
|
|
7
|
+
Project-URL: Repository, https://github.com/oncoray/mirp
|
|
8
|
+
Project-URL: Documentation, https://oncoray.github.io/mirp/
|
|
9
|
+
Project-URL: Changelog, https://github.com/oncoray/mirp/blob/master/NEWS.md
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.txt
|
|
20
|
+
Requires-Dist: itk>=5.3.0
|
|
21
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
22
|
+
Requires-Dist: numpy>=1.25
|
|
23
|
+
Requires-Dist: pandas>=2.0.0
|
|
24
|
+
Requires-Dist: pydicom>=2.4.0
|
|
25
|
+
Requires-Dist: pywavelets>=1.4.0
|
|
26
|
+
Requires-Dist: scikit-image>=0.20.0
|
|
27
|
+
Requires-Dist: scipy>=1.11
|
|
28
|
+
Requires-Dist: ray>=2.34.0
|
|
29
|
+
Requires-Dist: typing-extensions>=4.10; python_version < "3.11"
|
|
30
|
+
Provides-Extra: test
|
|
31
|
+
Requires-Dist: pytest>=7.4.0; extra == "test"
|
|
32
|
+
Provides-Extra: docs
|
|
33
|
+
Requires-Dist: sphinx>=5.0.0; extra == "docs"
|
|
34
|
+
Requires-Dist: sphinx_rtd_theme>=2.0.0; extra == "docs"
|
|
35
|
+
Requires-Dist: nbsphinx; extra == "docs"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<img src="https://raw.githubusercontent.com/oncoray/mirp/master/icon/mirp.svg" align="right" width="120"/>
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+

|
|
42
|
+
[](https://pypi.org/project/mirp/)
|
|
43
|
+

|
|
44
|
+
[](https://joss.theoj.org/papers/165c85b1ecad891550a21b12c8b2e577)
|
|
45
|
+
|
|
46
|
+
# Medical Image Radiomics Processor
|
|
47
|
+
|
|
48
|
+
MIRP is a python package for quantitative analysis of medical images. It focuses on processing images for integration
|
|
49
|
+
with radiomics workflows. These workflows either use quantitative features computed using MIRP, or directly use MIRP
|
|
50
|
+
to process images as input for neural networks and other deep learning models.
|
|
51
|
+
|
|
52
|
+
MIRP offers the following main functionality:
|
|
53
|
+
|
|
54
|
+
- [Extract and collect metadata](https://oncoray.github.io/mirp/image_metadata.html) from medical images.
|
|
55
|
+
- [Find and collect labels or names](https://oncoray.github.io/mirp/mask_labels.html) of regions of interest from image
|
|
56
|
+
segmentations.
|
|
57
|
+
- [Compute quantitative features](https://oncoray.github.io/mirp/quantitative_image_analysis.html) from regions of interest in medical images.
|
|
58
|
+
- [Process images for deep learning](https://oncoray.github.io/mirp/deep_learning.html).
|
|
59
|
+
|
|
60
|
+
## Tutorials
|
|
61
|
+
|
|
62
|
+
We currently offer the following tutorials:
|
|
63
|
+
|
|
64
|
+
- [Computing quantitative features from MR images](https://oncoray.github.io/mirp/tutorial_compute_radiomics_features_mr.html)
|
|
65
|
+
- [Applying filters to images](https://oncoray.github.io/mirp/tutorial_apply_image_filter.html)
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
Documentation can be found here: https://oncoray.github.io/mirp/
|
|
70
|
+
|
|
71
|
+
## Supported Python and OS
|
|
72
|
+
|
|
73
|
+
MIRP currently supports the following Python versions and operating systems:
|
|
74
|
+
|
|
75
|
+
| Python | Linux | Win | OSX |
|
|
76
|
+
|--------|-----------|-----------|-----------|
|
|
77
|
+
| 3.10 | Supported | Supported | Supported |
|
|
78
|
+
| 3.11 | Supported | Supported | Supported |
|
|
79
|
+
| 3.12 | Supported | Supported | Supported |
|
|
80
|
+
|
|
81
|
+
## Supported imaging and mask modalities
|
|
82
|
+
|
|
83
|
+
MIRP currently supports the following image modalities:
|
|
84
|
+
|
|
85
|
+
| File format | File type | Supported modality |
|
|
86
|
+
|-------------|-----------|-------------------------------------------------|
|
|
87
|
+
| DICOM | image | CT, MR (incl. ADC, DCE), PT, RTDOSE, CR, DX, MG |
|
|
88
|
+
| DICOM | mask | RTSTRUCT, SEG |
|
|
89
|
+
| NIfTI | any | any |
|
|
90
|
+
| NRRD | any | any |
|
|
91
|
+
| numpy | any | any |
|
|
92
|
+
|
|
93
|
+
NIfTI, NRRD, and numpy files support any kind of (single-channel) image. MIRP cannot process RGB or 4D images.
|
|
94
|
+
|
|
95
|
+
## Installing MIRP
|
|
96
|
+
MIRP is available from PyPI and can be installed using `pip`, or other installer tools:
|
|
97
|
+
|
|
98
|
+
```commandline
|
|
99
|
+
pip install mirp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Examples - Computing Radiomics Features
|
|
103
|
+
|
|
104
|
+
MIRP can be used to compute quantitative features from regions of interest in images in an IBSI-compliant manner
|
|
105
|
+
using a standardized workflow This requires both images and masks. MIRP can process DICOM, NIfTI, NRRD and numpy
|
|
106
|
+
images. Masks are DICOM radiotherapy structure sets (RTSTRUCT), DICOM segmentation (SEG) or volumetric data with
|
|
107
|
+
integer labels (e.g. 1, 2, etc.).
|
|
108
|
+
|
|
109
|
+
Below is a minimal working example for extracting features from a single image file and its mask.
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from mirp import extract_features
|
|
113
|
+
|
|
114
|
+
feature_data = extract_features(
|
|
115
|
+
image="path to image",
|
|
116
|
+
mask="path to mask",
|
|
117
|
+
base_discretisation_method="fixed_bin_number",
|
|
118
|
+
base_discretisation_n_bins=32
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
Instead of providing the path to the image (`"path_to_image"`), a numpy image can be provided, and the same goes for
|
|
122
|
+
`"path to mask"`. The disadvantage of doing so is that voxel spacing cannot be determined.
|
|
123
|
+
|
|
124
|
+
MIRP also supports processing images and masks for multiple samples (e.g., patients). The syntax is much the same,
|
|
125
|
+
but depending on the file type and directory structure, additional arguments need to be specified. For example,
|
|
126
|
+
assume that files are organised in subfolders for each sample, i.e. `main_folder / sample_name / subfolder`. The
|
|
127
|
+
minimal working example is then:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from mirp import extract_features
|
|
131
|
+
|
|
132
|
+
feature_data = extract_features(
|
|
133
|
+
image="path to main image directory",
|
|
134
|
+
mask="path to main mask directory",
|
|
135
|
+
image_sub_folder="image subdirectory structure relative to main image directory",
|
|
136
|
+
mask_sub_folder="mask subdirectory structure relative to main mask directory",
|
|
137
|
+
base_discretisation_method="fixed_bin_number",
|
|
138
|
+
base_discretisation_n_bins=32
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
The above example will compute features sequentially. MIRP supports parallel processing using the `ray` package.
|
|
142
|
+
Feature computation can be parallelized by specifying the `num_cpus` argument, e.g. `num_cpus=2` for two CPU threads.
|
|
143
|
+
|
|
144
|
+
## Examples - Image Preprocessing for Deep Learning
|
|
145
|
+
Deep learning-based radiomics is an alternative to using predefined quantitative features. MIRP supports
|
|
146
|
+
preprocessing of images and masks using the same standardized workflow that is used for computing features.
|
|
147
|
+
|
|
148
|
+
Below is a minimal working example for preprocessing deep learning images. Note that MIRP uses the numpy notation
|
|
149
|
+
for indexing, i.e. indices are ordered [*z*, *y*, *x*].
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from mirp import deep_learning_preprocessing
|
|
153
|
+
|
|
154
|
+
processed_images = deep_learning_preprocessing(
|
|
155
|
+
image="path to image",
|
|
156
|
+
mask="path to mask",
|
|
157
|
+
crop_size=[50, 224, 224]
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Examples - Summarising Image Metadata
|
|
162
|
+
|
|
163
|
+
MIRP can also summarise image metadata. This is particularly relevant for DICOM files that have considerable
|
|
164
|
+
metadata. Other files, e.g. NIfTI, only have metadata related to position and spacing of the image.
|
|
165
|
+
|
|
166
|
+
Below is a minimal working example for extracting metadata from a single image file.
|
|
167
|
+
```python
|
|
168
|
+
from mirp import extract_image_parameters
|
|
169
|
+
|
|
170
|
+
image_parameters = extract_image_parameters(
|
|
171
|
+
image="path to image"
|
|
172
|
+
)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
MIRP also supports extracting metadata from multiple files. For example, assume that files are organised in
|
|
176
|
+
subfolders for each sample, i.e. `main_folder / sample_name / subfolder`. The minimal working example is then:
|
|
177
|
+
```python
|
|
178
|
+
from mirp import extract_image_parameters
|
|
179
|
+
|
|
180
|
+
image_parameters = extract_image_parameters(
|
|
181
|
+
image="path to main image directory",
|
|
182
|
+
image_sub_folder="image subdirectory structure relative to main image directory"
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Examples - Finding labels
|
|
187
|
+
|
|
188
|
+
MIRP can identify which labels are present in masks. For a single mask file, labels can be retrieved as follows:
|
|
189
|
+
```python
|
|
190
|
+
from mirp import extract_mask_labels
|
|
191
|
+
|
|
192
|
+
mask_labels = extract_mask_labels(
|
|
193
|
+
mask="path to mask"
|
|
194
|
+
)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
MIRP supports extracting labels from multiple masks. For example, assume that files are organised in subfolders for
|
|
198
|
+
each sample, i.e. `main_folder / sample_name / subfolder`. The minimal working example is then:
|
|
199
|
+
```python
|
|
200
|
+
from mirp import extract_mask_labels
|
|
201
|
+
mask_labels = extract_mask_labels(
|
|
202
|
+
mask="path to main mask directory",
|
|
203
|
+
mask_sub_folder="mask subdirectory structure relative to main mask directory"
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Transitioning to version 2
|
|
208
|
+
|
|
209
|
+
Version 2 is a major refactoring of the previous code base. For users this brings the following noticeable changes:
|
|
210
|
+
|
|
211
|
+
- MIRP was previously configured using two `xml` files: [`config_data.xml`](mirp/config_data.xml) for configuring
|
|
212
|
+
directories, data to be read, etc., and [`config_settings.xml`](mirp/config_settings.xml) for configuring experiments.
|
|
213
|
+
While these two files can still be used, MIRP can now be configured directly, without using these files.
|
|
214
|
+
- The main functions of MIRP (`mainFunctions.py`) have all been re-implemented.
|
|
215
|
+
- `mainFunctions.extract_features` is now `extract_features` (functional form) or
|
|
216
|
+
`extract_features_generator` (generator). The replacements allow for both writing
|
|
217
|
+
feature values to a directory and returning them as function output.
|
|
218
|
+
- `mainFunctions.extract_images_to_nifti` is now `extract_images` (functional form) or
|
|
219
|
+
`extract_images_generator` (generator). The replacements allow for both writing
|
|
220
|
+
images to a directory (e.g., in NIfTI or numpy format) and returning them as function output.
|
|
221
|
+
- `mainFunctions.extract_images_for_deep_learning` has been replaced by
|
|
222
|
+
`deep_learning_preprocessing` (functional form) and
|
|
223
|
+
`deep_learning_preprocessing_generator` (generator).
|
|
224
|
+
- `mainFunctions.get_file_structure_parameters` and `mainFunctions.parse_file_structure` are deprecated, as the
|
|
225
|
+
the file import system used in version 2 no longer requires a rigid directory structure.
|
|
226
|
+
- `mainFunctions.get_roi_labels` is now `extract_mask_labels`.
|
|
227
|
+
- `mainFunctions.get_image_acquisition_parameters` is now `extract_image_parameters`.
|
|
228
|
+
|
|
229
|
+
For advanced users and developers, the following changes are relevant:
|
|
230
|
+
- MIRP previously relied on `ImageClass` and `RoiClass` objects. These have been completely replaced by `GenericImage`
|
|
231
|
+
(and its subclasses, e.g. `CTImage`) and `BaseMask` objects, respectively. New image modalities can be added as
|
|
232
|
+
subclass of `GenericImage` in the `mirp.images` submodule.
|
|
233
|
+
- File import, e.g. from DICOM or NIfTI files, in version 1 was implemented in an ad-hoc manner, and required a rigid
|
|
234
|
+
directory structure. Since version 2, file import is implemented using an object-oriented approach, and directory
|
|
235
|
+
structures are more flexible. File import of new modalities can be implemented as a relevant subclass of `ImageFile`.
|
|
236
|
+
- MIRP now uses the `ray` package for parallel processing.
|
|
237
|
+
|
|
238
|
+
# Citation info
|
|
239
|
+
MIRP has been published in *Journal of Open Source Software*:
|
|
240
|
+
```Zwanenburg A, Löck S. MIRP: A Python package for standardised radiomics. J Open Source Softw. 2024;9: 6413. doi:10.21105/joss.06413```
|
|
241
|
+
|
|
242
|
+
# Contributing
|
|
243
|
+
If you have ideas for improving MIRP, please read the short [contribution guide](./CONTRIBUTING.md).
|
|
244
|
+
|
|
245
|
+
# Developers and contributors
|
|
246
|
+
|
|
247
|
+
MIRP is developed by:
|
|
248
|
+
* Alex Zwanenburg
|
|
249
|
+
|
|
250
|
+
We would like thank the following contributors:
|
|
251
|
+
* Stefan Leger
|
|
252
|
+
* Sebastian Starke
|
|
@@ -2,6 +2,7 @@ from functools import lru_cache
|
|
|
2
2
|
from typing import Generator
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
5
6
|
|
|
6
7
|
from mirp._features.cm_matrix import MatrixCM
|
|
7
8
|
from mirp._images.generic_image import GenericImage
|
|
@@ -187,7 +188,7 @@ class FeatureCMJointEntropy(FeatureCM):
|
|
|
187
188
|
return -np.sum(matrix.pij.pij * np.log2(matrix.pij.pij))
|
|
188
189
|
|
|
189
190
|
|
|
190
|
-
class
|
|
191
|
+
class FeatureCMDifferenceAverage(FeatureCM):
|
|
191
192
|
def __init__(self, **kwargs):
|
|
192
193
|
super().__init__(**kwargs)
|
|
193
194
|
self.name = "CM - difference average"
|
|
@@ -536,13 +537,88 @@ class FeatureCMInformationCorrelation2(FeatureCM):
|
|
|
536
537
|
return np.sqrt(1.0 - np.exp(-2.0 * (hxy_2 - hxy)))
|
|
537
538
|
|
|
538
539
|
|
|
540
|
+
class FeatureCMMaximumCorrelationCoefficient(FeatureCM):
|
|
541
|
+
def __init__(self, **kwargs):
|
|
542
|
+
super().__init__(**kwargs)
|
|
543
|
+
self.name = "CM - maximum correlation coefficient"
|
|
544
|
+
self.abbr_name = "cm_mcc"
|
|
545
|
+
|
|
546
|
+
# MCC is not part of the IBSI corpus and has no assigned identifier.
|
|
547
|
+
self.ibsi_compliant = False
|
|
548
|
+
|
|
549
|
+
@staticmethod
|
|
550
|
+
def _compute(matrix: MatrixCM) -> float:
|
|
551
|
+
if matrix.is_empty():
|
|
552
|
+
return np.nan
|
|
553
|
+
|
|
554
|
+
# MCC is defined as the square root of the second largest eigen value of Q (Haralick, R.M., Shanmugam,
|
|
555
|
+
# K. and Dinstein, I. (1973) ‘Textural Features for Image Classification’, IEEE transactions on systems, man,
|
|
556
|
+
# and cybernetics, SMC-3(6), pp. 610–621. Available at: https://doi.org/10.1109/TSMC.1973.4309314.)
|
|
557
|
+
|
|
558
|
+
# Special case: matrix with a single element.
|
|
559
|
+
if matrix.n_g == 1.0:
|
|
560
|
+
return 1.0
|
|
561
|
+
|
|
562
|
+
def _pij_lookup(mat: MatrixCM, i: float, j: float) -> float:
|
|
563
|
+
mat = mat.pij
|
|
564
|
+
pij = mat[(mat.i == i) & (mat.j == j)].pij.values
|
|
565
|
+
if len(pij) == 0:
|
|
566
|
+
return 0.0
|
|
567
|
+
return pij[0]
|
|
568
|
+
|
|
569
|
+
def _pi_lookup(mat: MatrixCM, i: float) -> float:
|
|
570
|
+
mat = mat.pi
|
|
571
|
+
return mat[mat.i == i].pi.values[0]
|
|
572
|
+
|
|
573
|
+
def _pj_lookup(mat: MatrixCM, j: float) -> float:
|
|
574
|
+
mat = mat.pj
|
|
575
|
+
return mat[mat.j == j].pj.values[0]
|
|
576
|
+
|
|
577
|
+
q_mat = np.zeros((int(matrix.n_g), int(matrix.n_g)), dtype=float)
|
|
578
|
+
|
|
579
|
+
# Non-zero entries ONLY exist for each row in the pij table. Moreover, non-zero contributions of k only exist
|
|
580
|
+
# for the intersection of k-values where entries exist for intensities corresponding to elements i and j (due
|
|
581
|
+
# to symmetry).
|
|
582
|
+
for row in matrix.pij.itertuples(index=False):
|
|
583
|
+
i = row.i
|
|
584
|
+
j = row.j
|
|
585
|
+
k = np.intersect1d(
|
|
586
|
+
matrix.pij[matrix.pij.i == i].j.values,
|
|
587
|
+
matrix.pij[matrix.pij.i == j].j.values
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
element_value = 0.0
|
|
591
|
+
for kk in k:
|
|
592
|
+
pik = _pij_lookup(matrix, i, kk) ## p(i,k)
|
|
593
|
+
pjk = _pij_lookup(matrix, j, kk) ## p(i,j)
|
|
594
|
+
|
|
595
|
+
# If either p(i,k) or p(j,k) are 0.0, there is no contribution.
|
|
596
|
+
if pik == 0.0 or pjk == 0.0:
|
|
597
|
+
continue
|
|
598
|
+
|
|
599
|
+
pi = _pi_lookup(matrix, i) ## px(i)
|
|
600
|
+
pk = _pj_lookup(matrix, kk) ## py(k)
|
|
601
|
+
|
|
602
|
+
element_value += pik * pjk / (pi * pk) ## p(i,k) * p(j,k) / (px(i), py(k))
|
|
603
|
+
|
|
604
|
+
# Update Q.
|
|
605
|
+
q_mat[int(i) - 1, int(j) - 1] = element_value
|
|
606
|
+
|
|
607
|
+
# Compute eigen values and sort.
|
|
608
|
+
eigen_values = np.linalg.eigvals(q_mat)
|
|
609
|
+
eigen_values.sort()
|
|
610
|
+
|
|
611
|
+
# Return square root of second largest eigenvalue.
|
|
612
|
+
return np.sqrt(eigen_values[-2])
|
|
613
|
+
|
|
614
|
+
|
|
539
615
|
def get_cm_class_dict() -> dict[str, FeatureCM]:
|
|
540
616
|
class_dict = {
|
|
541
617
|
"cm_joint_max": FeatureCMJointMax,
|
|
542
618
|
"cm_joint_avg": FeatureCMJointAverage,
|
|
543
619
|
"cm_joint_var": FeatureCMJointVariance,
|
|
544
620
|
"cm_joint_entr": FeatureCMJointEntropy,
|
|
545
|
-
"cm_diff_avg":
|
|
621
|
+
"cm_diff_avg": FeatureCMDifferenceAverage,
|
|
546
622
|
"cm_diff_var": FeatureCMDifferenceVariance,
|
|
547
623
|
"cm_diff_entr": FeatureCMDifferenceEntropy,
|
|
548
624
|
"cm_sum_avg": FeatureCMSumAverage,
|
|
@@ -562,7 +638,8 @@ def get_cm_class_dict() -> dict[str, FeatureCM]:
|
|
|
562
638
|
"cm_clust_shade": FeatureCMClusterShade,
|
|
563
639
|
"cm_clust_prom": FeatureCMClusterProminence,
|
|
564
640
|
"cm_info_corr1": FeatureCMInformationCorrelation1,
|
|
565
|
-
"cm_info_corr2": FeatureCMInformationCorrelation2
|
|
641
|
+
"cm_info_corr2": FeatureCMInformationCorrelation2,
|
|
642
|
+
"cm_mcc": FeatureCMMaximumCorrelationCoefficient
|
|
566
643
|
}
|
|
567
644
|
|
|
568
645
|
return class_dict
|
|
@@ -380,7 +380,7 @@ class FeatureIVHAreaUnderCurve(FeatureIntensityVolumeHistogram):
|
|
|
380
380
|
self.ibsi_compliant = False
|
|
381
381
|
|
|
382
382
|
def _compute(self, data: DataIntensityVolumeHistogram):
|
|
383
|
-
return np.
|
|
383
|
+
return np.trapezoid(y=data.data.nu, x=data.data.gamma)
|
|
384
384
|
|
|
385
385
|
|
|
386
386
|
def get_intensity_volume_histogram_class_dict() -> dict[str, FeatureIntensityVolumeHistogram]:
|
|
@@ -65,7 +65,7 @@ class StandardWorkflow(BaseWorkflow):
|
|
|
65
65
|
|
|
66
66
|
return " ".join(message_str)
|
|
67
67
|
|
|
68
|
-
def standard_image_processing(self) -> tuple[GenericImage, list[BaseMask]]:
|
|
68
|
+
def standard_image_processing(self) -> None | tuple[GenericImage, list[BaseMask]]:
|
|
69
69
|
from mirp._image_processing.cropping import crop
|
|
70
70
|
from mirp._image_processing.tissue_mask import create_tissue_mask
|
|
71
71
|
from mirp._image_processing.alter_mask import alter_mask
|
|
@@ -11,9 +11,9 @@ class FeatureExtractionSettingsClass:
|
|
|
11
11
|
|
|
12
12
|
Parameters
|
|
13
13
|
----------
|
|
14
|
-
by_slice:
|
|
15
|
-
Defines whether calculations should be performed in 2D (True) or 3D (False)
|
|
16
|
-
|
|
14
|
+
by_slice: bool, optional, default: False
|
|
15
|
+
Defines whether calculations should be performed in 2D (True) or 3D (False).
|
|
16
|
+
See :class:`~mirp.settings.general_parameters.GeneralSettingsClass`.
|
|
17
17
|
|
|
18
18
|
no_approximation: bool, optional, default: False
|
|
19
19
|
Disables approximation of features, such as Geary's c-measure. Can be True or False (default). See
|
|
@@ -14,9 +14,9 @@ class ImageInterpolationSettingsClass:
|
|
|
14
14
|
|
|
15
15
|
Parameters
|
|
16
16
|
----------
|
|
17
|
-
by_slice:
|
|
18
|
-
Defines whether calculations should be performed in 2D (True) or 3D (False)
|
|
19
|
-
|
|
17
|
+
by_slice: bool, optional, default: False
|
|
18
|
+
Defines whether calculations should be performed in 2D (True) or 3D (False).
|
|
19
|
+
See :class:`~mirp.settings.general_parameters.GeneralSettingsClass`.
|
|
20
20
|
|
|
21
21
|
new_spacing: float or list of float or list of list of float, optional:
|
|
22
22
|
Sets voxel spacing after interpolation. A single value represents the spacing that will be applied in all
|
|
@@ -26,9 +26,9 @@ class ImageTransformationSettingsClass:
|
|
|
26
26
|
|
|
27
27
|
Parameters
|
|
28
28
|
----------
|
|
29
|
-
by_slice:
|
|
30
|
-
Defines whether calculations should be performed in 2D (True) or 3D (False)
|
|
31
|
-
|
|
29
|
+
by_slice: bool, optional, default: False
|
|
30
|
+
Defines whether calculations should be performed in 2D (True) or 3D (False).
|
|
31
|
+
See :class:`~mirp.settings.general_parameters.GeneralSettingsClass`.
|
|
32
32
|
|
|
33
33
|
ibsi_compliant: bool, optional, default: True
|
|
34
34
|
Limits use of filters to those that exist in the IBSI reference standard.
|