pyDICOS is a python package for working with DICOS files.
Project description
pyDICOS
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
andCT::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
- Currently tested and supported DICOS version :
Install
⚠️ pyDICOS is currently only available for linux on x86 platform.
✨ NEW ✨ Using Pypi index (recommended)
Using pip directly from Pypi index :
pip install pydicos
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 exemple files to explore the binded methods. The stratovan exemple files were entirely translated in python.
Here is a quick exemple 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/
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 developper 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pydicos-1.2.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pydicos-1.2.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d3bb7379b63c08819e0405218d9f31ffa3832efc54c3fdae735a2d92d377d7e |
|
MD5 | f0d8999f491b525b5f8bfe81e6f291f4 |
|
BLAKE2b-256 | 061c7c7aa2ef625f99afdbd93c338101609399105b1cda99b080b2b10eecb798 |
File details
Details for the file pydicos-1.2.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pydicos-1.2.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19896cf5a26113df97215f7bd89cd331cc0157ee24b8f5497317d8d8e2a0971d |
|
MD5 | 5fbaaf5bbc9f6106ec7d3200fa83e7d8 |
|
BLAKE2b-256 | 1380a022945ca8854c17b97e34525cb1251b862981bce900d06ce20a568b4c6c |
File details
Details for the file pydicos-1.2.4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pydicos-1.2.4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d6f83bcbff979b792ae377457bcf19a59bf930d6b22ff5f1b7d94e766af557 |
|
MD5 | 8c32b7bf32c4d744b995acb0892f1d72 |
|
BLAKE2b-256 | 2861a3b119d91b6eda121d71634b6a8933b21fc6654c3320aa5ccd42fd988264 |
File details
Details for the file pydicos-1.2.4-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pydicos-1.2.4-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.8, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ba37202d16e6f3881d6fe0d39ebd4d07ca3a94f0ab635a3bebf45292a25af7 |
|
MD5 | e50f0ae05a3338b524d6ce321f9d4a6a |
|
BLAKE2b-256 | 93d61ef8ec74d4f823197decd516fb261bff992d7b4b9e1010d3166dfa00c96c |
File details
Details for the file pydicos-1.2.4-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pydicos-1.2.4-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.7m, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8201e1cf5f04c456ba82777883b898ca83b9ba0960dc0f89d22328a1f6f4ad9a |
|
MD5 | 47962d251d1bd8639f0f031aa9fda5e4 |
|
BLAKE2b-256 | 3eb2b4aa7eb671e62249646038f1935b52e9f7eb463f42d6337079cddc23dd75 |