Metadata-Version: 2.5
Name: radiomicsjl
Version: 2.1.1
Summary: Python interface to Radiomics.jl: fast, IBSI-compliant radiomic feature extraction (CPU and CUDA GPU)
Project-URL: Homepage, https://github.com/pzaffino/Radiomics.jl
Project-URL: Documentation, https://github.com/pzaffino/Radiomics.jl
Project-URL: Issues, https://github.com/pzaffino/Radiomics.jl/issues
Author-email: Aldo Giuliani <aldo.giuliani@studenti.unicz.it>, Paolo Zaffino <p.zaffino@unicz.it>, Maria Francesca Spadea <mf.spadea@kit.edu>, Carlo Cosentino <carlo.cosentino@unicz.it>, Jakub Mitura <jakub.mitura14@gmail.com>, Ciro Benito Raggio <ciro.raggio@kit.edu>, Mohammadreza Javadi Namin <mohammadreza.javadi@mail.polimi.it>, Nastaran Ghaffari Elkhechi <nastaran.ghaffari@mail.polimi.it>, Michela Destito <michela.destito@unicz.it>
License-Expression: MIT
License-File: LICENSE
Keywords: CUDA Acceleration,GPU,IBSI,Medical AI,Radiomics feature maps,feature extraction,julia,medical imaging,radiomics
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.9
Requires-Dist: juliacall>=0.9.20
Requires-Dist: numpy>=1.21
Provides-Extra: sitk
Requires-Dist: simpleitk>=2.0; extra == 'sitk'
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: simpleitk>=2.0; extra == 'test'
Description-Content-Type: text/markdown

# radiomicsjl

Python interface to [Radiomics.jl](https://github.com/pzaffino/Radiomics.jl): fast, IBSI-compliant radiomic feature extraction, on CPU or NVIDIA GPU.

```bash
pip install radiomicsjl
```

No Julia installation is needed. The first call downloads Julia and Radiomics.jl into the
current Python environment (a few minutes, once); after that, start-up takes a few seconds.

## Usage

```python
import radiomicsjl as rjl

# From files (NIfTI, NRRD, DICOM file or folder): spacing is read from the header
feats = rjl.extract_radiomic_features("ct.nii.gz", "mask.nii.gz", n_bins=32)

# From numpy arrays: spacing is required, one value per array axis
feats = rjl.extract_radiomic_features(image, mask, spacing=[0.98, 0.98, 3.0], bin_width=25)

print(feats["firstorder_mean"], feats["glcm_Contrast"])
```

The arguments are the same as `Radiomics.extract_radiomic_features` in Julia:

| argument | default | |
|---|---|---|
| `features` | all | e.g. `["first_order", "glcm", "glrlm", "glszm", "gldm", "ngtdm", "shape3d"]` (`"shape2d"` for 2D images) |
| `labels` | `1` | an int, or a list of ints → `{label: features}` |
| `n_bins` / `bin_width` | 32 bins | discretisation |
| `weighting_norm` | `None` | e.g. `"euclidean"` |
| `keep_largest_only` | `True` | keep only the largest connected component |
| `slices_2d` | `None` | list of `(axis, index)`, **0-based** as in numpy: `(2, 10)` is `image[:, :, 10]` → `{(axis, index): features}` |
| `features_std` | `False` | per-direction standard deviation for GLCM/GLRLM |
| `get_raw_matrices` | `False` | also return the texture matrices (numpy arrays) |
| `use_gpu` | `False` | CUDA acceleration (see below) |
| `suv_ibsi_normalization` | `False` | SUVbw normalisation for PET DICOM |
| `verbose` | `False` | 
| `filter_type` | `None` | image filter before extraction: `"haar"`, `"log"`, `"gabor"` → `{"<filter>_<map>": features}` |
| `filter_params` | `None` | filter parameters as a dict, e.g. `{"level": 2}`, `{"sigma": [1.0, 3.0]}` |


### SimpleITK, numpy and spacing

The easiest way with SimpleITK is to pass the images themselves: array and spacing are taken
from them, in (x, y, z) order like the file readers.

```python
import SimpleITK as sitk
img, msk = sitk.ReadImage("ct.nii.gz"), sitk.ReadImage("mask.nii.gz")
feats = rjl.extract_radiomic_features(img, msk, n_bins=32)
```

With numpy arrays, `spacing` must follow the array axes. Beware that
`sitk.GetArrayFromImage` returns (z, y, x) while `GetSpacing()` is (x, y, z):
passing them together gives wrong shape and texture features. Pass the image instead,
or reverse the spacing (`GetSpacing()[::-1]`). Arrays from nibabel are already (x, y, z),
in the same order as `header.get_zooms()`.

With an image filter (Haar wavelet, Laplacian of Gaussian or Gabor):

```python
features = rjl.extract_radiomic_features('DATA_PATH/ct.nii.gz', 'DATA_PATH/mask.nii.gz',
                                         filter_type="haar", filter_params={"level": 1})
features["haar_wavelet-LLH"]["glcm_Contrast"]
```

## GPU

```bash
python -m radiomicsjl install-gpu   # adds CUDA.jl to the Julia environment (once)
```

then `use_gpu=True`. Requires an NVIDIA GPU with a recent driver.

## Other commands

```bash
python -m radiomicsjl setup     # install Julia + Radiomics.jl now instead of at first use
python -m radiomicsjl version
```

Julia uses all CPU cores by default; set `PYTHON_JULIACALL_THREADS=4` (before importing) to limit it.
The Julia environment lives inside the Python environment, so each virtualenv/conda env has its own.

## License

MIT
