Nekton
A python package for DICOM to NifTi and NifTi to DICOM-SEG and GSPS conversion
SETUP
The python package is available for use on PyPI. It can be setup simply via pip
pip install nekton
To the check the setup, simply check the version number of the nekton package by
python -c 'import nekton; print(nekton.__version__)'
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.2.6
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.2.6.tar.gz | 24.1 MB | Without provenance | Details for nekton-0.2.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nekton-0.2.6-py3-none-any.whl | Python 3 | none | any | Details for nekton-0.2.6-py3-none-any.whl |
Total release size: 48.4 MB
Release files / nekton-0.2.6.tar.gz
| Download URL | nekton-0.2.6.tar.gz |
|---|---|
| Size | 24.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0b1228edcd2ae7460d695214ef1b879ed49e149471868fa4e47186258b531a3
|
|
BLAKE2b-256 checksum How to use checksums |
8f3524074d89e6f789084c5c2040d1279874307f81f2abb710f1ace3d2c1ace0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.4 Darwin/22.2.0
|
Release files / nekton-0.2.6-py3-none-any.whl
| Download URL | nekton-0.2.6-py3-none-any.whl |
|---|---|
| Size | 24.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5eca702f1c0dc6ed8a410939ae9cc7e13e7bdc9adde98f6cbd87b945875c5da9
|
|
BLAKE2b-256 checksum How to use checksums |
40ad91c4105902e1249eebb937b41f5fed40e2f9e21099c127da0e5154992b84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.4 Darwin/22.2.0
|
Security for nekton 0.2.6
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.