This release is a pre-release and may not be stable for production use.
Nekton
A python package for DICOM to NifTi and NifTi to DICOM-SEG and GSPS conversion
Setup
Nekton supports Python 3.12. The package is available on PyPI and can be installed with pip:
pip install nekton
To check the installation, print the installed package version:
python -c 'import nekton; print(nekton.__version__)'
Development
This repository uses Poetry for dependency management. The DICOM-SEG validation schemas are stored in the nekton/externals/dcmqi git submodule, so clone with submodules or initialize them after cloning:
git clone --recurse-submodules git@github.com:deepc-health/nekton.git
cd nekton
If the repository is already cloned:
git submodule update --init --recursive
Install dependencies and run the test suite:
poetry install
poetry run pytest -c tests/pytest.ini tests
The GitHub workflows run on Python 3.12 and also check build, lint, security scanning, and coverage:
poetry build
poetry run flake8 nekton tests --exclude=nekton/externals --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run bandit -r -lll -x ./nekton/externals ./nekton ./tests
poetry run pytest tests/ --cov-report=xml --cov=nekton --junitxml=./coverage.xml
poetry run coverage report --fail-under=90 -m
DICOM to NifTi
The DICOM to NifTi conversion in the package is based on a wrapper around the dcm2niix software.
Usage
from nekton.dcm2nii import Dcm2Nii
converter = Dcm2Nii()
converted_files = converter.run(dicom_directory='/test_files/CT5N', out_directory='/test_files/CT5N', name='Test')
# Converted 5 DCM to Nifti; Output stored @ /test_files/CT5N
print(converted_files)
# ['/test_files/CT5N/Test_SmartScore_-_Gated_0.5_sec_20010101000000_5.nii.gz']
Parameters converter.run:
dicom_directory (Path): path to directory with Dicomsdicom_directory (Path, optional): directory to store the output niftiname (str, optional): Name to be given to the output file. Defaults to "".
Returns:
List[Path]: output list of Nifti files
Notes
- The renaming functionality retains the suffixes from the original program.
- The BIDS sidecar json is retained as well.
NifTi to DICOM-SEG
The NifTi to DICOM-SEG within nekton converts incoming segmentation NifTi to DICOM-SEG. The matching of the segmentation index to a text label is
done via json file using the schema suggested by dcmqi. The json can be generated using the gui also an example can be seen here.
Currently, nekton supports creation of multiclass DICOM-SEG of two types-
- single layer DICOM-SEG, where each non-empty slice has an individual file
- multi layer DICOM-SEG, where all the n slices are rolled into a single file
Usage
- NifTi to single layer DICOM-SEG
from nekton.nii2dcm import Nii2DcmSeg
import glob
converter = Nii2DcmSeg()
path_dcms = [path for path in glob.glob(dir_dcms)]
path_mapping = "mapping.json"
path_seg_nifti = "CT5N_segmentation.nii.gz"
dcmsegs = converter_dcmseg.multiclass_converter(
segfile = path_seg_nifti, segMapping= path_mapping, dcmfiles =path_dcms, multiLayer=False
)
print (len(dcmsegs))
# 3
- NifTi to multi layer DICOM-SEG
from nekton.nii2dcm import Nii2DcmSeg
import glob
converter = Nii2DcmSeg()
path_dcms = [path for path in glob.glob(dir_dcms)]
path_mapping = "mapping.json"
path_seg_nifti = "CT5N_segmentation.nii.gz"
dcmsegs = converter.multiclass_converter(
segfile = path_seg_nifti, segMapping= path_mapping, dcmfiles =path_dcms, multiLayer=True
)
print (len(dcmsegs))
# 1
Parameters converter.multiclass_converter:
segfile (Path): path to the nifti segmentation filesegMapping (Path): path to the dcmqii format segmentation mapping jsondcmfiles (List[Path]): list of paths of all the source dicom filesmultiLayer (bool, optional): create a single multilayer dicomseg. Defaults to False.
Returns:
List[Path]: list of paths of all generated dicomseg files
Notes
- Multilabel NifTi(in the form of a NifTi file for a single label) to DICOM-SEG is under development.
NifTi to GSPS
This feature will be available in a future release of the nekton
Metadata
Release files for nekton 0.3.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nekton-0.3.0rc1.tar.gz | 5.6 MB | With provenance | Details for nekton-0.3.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nekton-0.3.0rc1-py3-none-any.whl | Python 3 | none | any | Details for nekton-0.3.0rc1-py3-none-any.whl |
Total release size: 11.3 MB
Release files / nekton-0.3.0rc1.tar.gz
| Download URL | nekton-0.3.0rc1.tar.gz |
|---|---|
| Size | 5.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d271b9d8c4fba4e092db0fbd33986b17dc62451249ab46a256441ac776acbc0
|
|
BLAKE2b-256 checksum How to use checksums |
8beaad63698069ea8f6494f7e301f7f02451f51ea0c81d559a854c3258418d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / nekton-0.3.0rc1-py3-none-any.whl
| Download URL | nekton-0.3.0rc1-py3-none-any.whl |
|---|---|
| Size | 5.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
587275698bac21f36d5b1c0a04a11a1a51f6cd2e06a20d53ef9c602d69091333
|
|
BLAKE2b-256 checksum How to use checksums |
0566c82d83baa4db773d24edb2e047721827ae03dc291cf032eaaa384c268c0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for nekton 0.3.0rc1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nekton-0.3.0rc1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.