GithubHelp home page GithubHelp logo

deepc-health / nekton Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 1.23 MB

A python package for DICOM to NifTi and NifTi to DICOM-SEG and GSPS conversion

License: MIT License

Python 96.78% Shell 3.22%
nifti nifti-format dicom gsps dicom-seg medical-imaging

nekton's Introduction

Nekton

Python Application TestingTest and Release Python VersionsPackage version

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 Dicoms
  • dicom_directory (Path, optional): directory to store the output nifti
  • name (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

  1. 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
  1. 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 file
  • segMapping (Path): path to the dcmqii format segmentation mapping json
  • dcmfiles (List[Path]): list of paths of all the source dicom files
  • multiLayer (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

nekton's People

Contributors

a-parida12 avatar actions-user avatar myigitavci avatar yigitsoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nekton's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.