Skip to main content

pyDICOS is a python package for working with DICOS files.

Project description

pyDICOS

License run-tests codecov PyPI PyPI - Downloads

Motivations

This project was initiated to enable the usage of DICOS data in machine learning workflows. PyDICOS is intended to be a simple python wrapper of Stratovan's C++ DICOS library. Note that this is NOT an open source implementation of the DICOS standard.

PyDICOS relies on pybind11 to wrap DICOS user-level API to python. It depends on NumPy to load data in python and can easily be installed via pip.

PyDICOS is unrelated to pydicom in its implementation and contributors, while being similar in its core spirit (enabling python data manipulations).

Open Architecture

We firmly believe that by releasing this library, we will encourage and support the Open Architecture framework. We welcome all actors of airport security to review and use this library.

Scope

  • Provide a Pythonized API for the DICOS toolkit
    • First release : read/write functions for CT, DX and TDR, user-level API
    • First releases : DICOS protocol, client/server functions
    • Future release : more pure python functions to shave off heavy CPP signatures (dcsread, dcswrite, get_data, set_data and CT::generate_tdr)
    • Future release : library indexed in PyPi
    • Out of scope for now : Windows release
    • Out of scope for now : AIT2D, AIT3D, QR
    • Out of scope for now : Module and Tag level APIs
  • Stay up to date with Stratovan latest releases
    • Currently tested and supported DICOS version : v3

Install

✨ NEW ✨ : pyDICOS is now available for windows

Using PyPi index (recommended)

Using pip directly from PyPi index :

pip install pydicos

⚠️ pyDICOS is currently available for Linux on x86 and windows on x64 platforms

Building from source (dev mode)

To setup the build environment, clone the repository, create your virtual environment and install required dependencies

git clone https://github.com/Auxilia-tech/pyDICOS
cd pyDICOS
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Install the Stratovan toolkit in the opt folder. If the library is already installed in another folder, skip this step and change the SDICOS path variable in setup.sh.

chmod +x ./sdicos_lin_ubuntu-20-{version}.run
./sdicos_lin_ubuntu-20-{version}.run --unattendedmodeui none --mode unattended --prefix /opt/stratovan/sdicos
chmod 755 -R /opt/stratovan/sdicos

To generate a python wheel :

chmod +x setup.sh
./setup.sh

The lib wheel should be produced in the dist folder and can be installed via pip in any local virtual environment.

Usage

Concept diagram

Script usage

Refer to our example files to explore the bound methods. The Stratovan example files were entirely translated in python.

Here is a quick example for a script that reads and rewrites a CT and DX scan, and a TDR.

from pydicos import dcsread, dcswrite

ct = dcsread("SimpleCT/SimpleCT.dcs")
data = ct.get_data() # list of 3-dimentionnal numpy arrays
dcswrite(ct, "SimpleCT/SimpleCT_2.dcs")

dx = dcsread("DXFiles/SimpleDX.dcs")
data = dx.get_data() # 2-dimentionnal numpy array
dcswrite(dx, "DXFiles/SimpleDX_2.dcs")

tdr = dcsread("SimpleTDR/SimpleTDR.dcs")
data = tdr.get_data() # dictionnay of metadata
dcswrite(tdr, "SimpleTDR/SimpleTDR_2.dcs")

✨ NEW ✨ : refer to our notebook tutorial for instructions and examples to change an object main attribute.

Advanced usage

More complex operations can be addressed by using the C++ functions directly. They can be invoked using the pyDICOS modules. For example, the previous script would look like this :

from pyDICOS import CT, DX, TDR, ErrorLog, Filename
   
ct, err, file = CT(), ErrorLog(), Filename("SimpleCT/SimpleCT.dcs")
if not ct.Read(file, err, None):
   raise RuntimeError(f"Failed to read DICOS file: {file.Get()}\n{err.GetErrorLog().Get()}")
data = ... # This is very long, refer to pydicos._loaders::CTLoader.get_data for full script
if not ct.Write(Filename("SimpleCT/SimpleCT_2.dcs"), err):
   raise RuntimeError(f"Failed to write DICOS file: SimpleCT/SimpleCT_2.dcs\n{err.GetErrorLog().Get()}")

dx, err, file = DX(), ErrorLog(), Filename("SimpleDX/SimpleDX.dcs")
if not dx.Read(file, err, None):
   raise RuntimeError(f"Failed to read DICOS file: {file.Get()}\n{err.GetErrorLog().Get()}")
data = np.array(dx.GetXRayData().GetUnsigned16(), copy=False)
if not dx.Write(Filename("SimpleDX/SimpleDX_2.dcs"), err):
   raise RuntimeError(f"Failed to write DICOS file: SimpleDX/SimpleDX_2.dcs\n{err.GetErrorLog().Get()}")

tdr, err, file = TDR(), ErrorLog(), Filename("SimpleTDR/SimpleTDR.dcs")
if not tdr.Read(file, err, None):
   raise RuntimeError(f"Failed to read DICOS file: {filename}\n{err.GetErrorLog().Get()}")
data = ... # This is very long, refer to pydicos._loaders::TDRLoader.get_data for full script
if not tdr.Write(Filename("SimpleTDR/SimpleTDR_2.dcs"), err):
   raise RuntimeError(f"Failed to write DICOS file: SimpleTDR/SimpleTDR_2.dcs\n{err.GetErrorLog().Get()}")

As you can see, pyDICOS is the direct translation of the C++ classes and in-place method signatures. The objects of the pydicos library inherit the methods available in pyDICOS. More details in architecture.

Testing

The library can be tested via pytest

pytest tests/

Note for Linux Users: If your system clock is set to local time, you may need to export the TZ environment variable to UTC before running tests.

export TZ=UTC

Contributing

As our resources are limited, we very much value your contributions, be it bug fixes, new core features, or documentation improvements. For more information, please read our contribution guide.

Contributors acknowledgement

Many thanks to our main contributors :

  • Ahmad Audi is a freelance developer specialized in C++ and python. He is available for similar work on upwork. LinkedIn
  • Louis Combaldieu is the cofounder and CTO of Auxilia. He specializes in deep learning and computer vision. Get in touch with him through our contact form to learn more about pyDICOS and Auxilia's line of products.

License

This software is released under the MIT license.

Stratovan inherited disclaimer

##############################################################################
### Stratovan Corporation Copyright and Disclaimer Notice:
###
### Copyright (c) 2014 Stratovan Corporation. All Rights Reserved.
###
### Permission to use, copy, modify, and distribute this software and its
### documentation without a signed licensing agreement, is hereby granted,
### provided that this copyright notice, this paragraph and the following two
### paragraphs appear in all copies, modifications, and distributions.
###
### IN NO EVENT SHALL STRATOVAN BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
### SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
### ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
### STRATOVAN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###
### STRATOVAN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED
### TO, THE IMPLIED WARRANTIES OF USE AND FITNESS FOR A PARTICULAR PURPOSE. THE
### SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS
### PROVIDED "AS IS". STRATOVAN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
### SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS UNLESS DIRECTED BY THE
### U.S. GOVERNMENT'S TRANSPORTATION SECURITY ADMINISTRATION (TSA).
###
##############################################################################

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pydicos-1.3.0-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

pydicos-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pydicos-1.3.0-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

pydicos-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pydicos-1.3.0-cp39-cp39-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.9Windows x86-64

pydicos-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pydicos-1.3.0-cp38-cp38-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.8Windows x86-64

pydicos-1.3.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pydicos-1.3.0-cp37-cp37m-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.7mWindows x86-64

pydicos-1.3.0-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pydicos-1.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pydicos-1.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pydicos-1.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 053611850d35eccb64595c69e57caee209dd0a012e03a27988cb5244bf4dc1ce
MD5 7f39687f1a7a3ac9ae875dc48db5c51b
BLAKE2b-256 52ad260f3ac54cdf921c9b3ee640260b3950b5eace421a0899a216a541747d21

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp311-cp311-win_amd64.whl:

Publisher: publish-windows.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pydicos-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 83b2f012cb4ee89cf140c43054d54d5187f3cc13d258c58a8998ab821f2473fc
MD5 633b3e7d1489f2a643a5bbc05d9821dd
BLAKE2b-256 176715c9f431f6f0f05e1d73a9cba1317123af0d6c4433672dfb1d4afcdaaafa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-pypi-deploy.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pydicos-1.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pydicos-1.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6d285c7942bd45ab9fa4f2cec4e04614ba43a2cb691227f86d27a11802407220
MD5 ed2ae244b0b428284a1a77f2a27aed2c
BLAKE2b-256 54e4371d0cb827a032920988614fa166b1d4c34322320c8a134303610e145de2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp310-cp310-win_amd64.whl:

Publisher: publish-windows.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pydicos-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9bcce251f1016b9ccfda4236f4942719538b96bbc1c72cb0e49077aeec109b2
MD5 7e829e467b4a05a7fd7594a587a870f8
BLAKE2b-256 5eb554a64e2d2b4894de7eb7f343cf6a603a252cb1bdc0be87ab4edd7824a492

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-pypi-deploy.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pydicos-1.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pydicos-1.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c2ee008c974db12e041ed8d9c7fcbf1a46954505bf6fd2535cb050769afa0d16
MD5 d88d129711c32364b9b4709f59dccba4
BLAKE2b-256 0d80e64d2a75a9d8c18d2b2c13018500afd6f9813e3b4f6446f0a0f56b5ad492

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp39-cp39-win_amd64.whl:

Publisher: publish-windows.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pydicos-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1bbbcc8ad96ce49b644d57a5df9a888f997fb9ca7c6bf6323f24103cfeba885e
MD5 95a7b09554787269ab7763209d5623d2
BLAKE2b-256 f06c8c2377fc028427f2774390948e67c1a02bf230f59d2c34fce2f4c262ed83

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-pypi-deploy.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pydicos-1.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pydicos-1.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6af86f3867a1f6b11bc01156be8f033314c617fd7592d5b8ee401806a082ad48
MD5 65a73b4592846aae65bcd09f5fbfe4a1
BLAKE2b-256 f7c32a3779065e0f5b81ad95d61196fb3e71aa54c14ddfcac5bb7e115dcd4450

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp38-cp38-win_amd64.whl:

Publisher: publish-windows.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pydicos-1.3.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4cfc69aeaffbf2d8505d0b23b9efa722de3e60b540cdbc9206dcd04405103084
MD5 60f1212c486e3d7e99478826ee4f94de
BLAKE2b-256 1d0345244af51becbe50be9956e9388a9565177c29a02377df772f93bc2e8318

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-pypi-deploy.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pydicos-1.3.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pydicos-1.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 bc8994ea0f48f865b4fb86b25c75a6a5945cee6f37495e293614feb02d583b5c
MD5 d696809f5625775f6c4182636aeacdc0
BLAKE2b-256 34d49e49e16ecb9e93eefa0d2eb79c7b18cf9e24794b095cf16f96af8bb31c0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp37-cp37m-win_amd64.whl:

Publisher: publish-windows.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydicos-1.3.0-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pydicos-1.3.0-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67bcdcd25f5c7d23c260e264735b85607f95ec1a47b37bb91cd48b02667be08f
MD5 317f2483a4f6dbe58b947ab0aa96bfad
BLAKE2b-256 0af66a70d094c0449f5fef0b18ac6b9e4e9a1fbcd39ab798b4dfb08c6790de6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydicos-1.3.0-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: publish-pypi-deploy.yml on Auxilia-tech/pyDICOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page