DOSMA: Deep Open-Source Medical Image Analysis
Documentation | Questionnaire | DOSMA Basics Tutorial
DOSMA is an AI-powered Python library for medical image analysis. This includes, but is not limited to:
- image processing (denoising, super-resolution, registration, segmentation, etc.)
- quantitative fitting and image analysis
- anatomical visualization and analysis (patellar tilt, femoral cartilage thickness, etc.)
We hope that this open-source pipeline will be useful for quick anatomy/pathology analysis and will serve as a hub for adding support for analyzing different anatomies and scan sequences.
Installation
DOSMA requires Python 3.6+. The core module depends on numpy, nibabel, nipype, pandas, pydicom, scikit-image, scipy, PyYAML, and tqdm.
Additional AI features can be unlocked by installing tensorflow and keras. To enable built-in registration functionality, download elastix. Details can be found in the setup documentation.
To install DOSMA, run:
pip install dosma
# To install with AI support
pip install dosma[ai]
If you would like to contribute to DOSMA, we recommend you clone the repository and
install DOSMA with pip in editable mode.
git clone git@github.com:ad12/DOSMA.git
cd DOSMA
pip install -e '.[dev,docs]'
make dev
To run tests, build documentation and contribute, run
make autoformat test build-docs
Features
Simplified, Efficient I/O
DOSMA provides efficient readers for DICOM and NIfTI formats built on nibabel and pydicom. Multi-slice DICOM data can be loaded in parallel with multiple workers and structured into the appropriate 3D volume(s). For example, multi-echo and dynamic contrast-enhanced (DCE) MRI scans have multiple volumes acquired at different echo times and trigger times, respectively. These can be loaded into multiple volumes with ease:
import dosma as dm
multi_echo_scan = dm.load("/path/to/multi-echo/scan", group_by="EchoNumbers", num_workers=8, verbose=True)
dce_scan = dm.load("/path/to/dce/scan", group_by="TriggerTime")
Data-Embedded Medical Images
DOSMA's MedicalVolume data structure supports array-like operations (arithmetic, slicing, etc.) on medical images while preserving spatial attributes and accompanying metadata. This structure supports NumPy interoperability, intelligent reformatting, fast low-level computations, and native GPU support. For example, given MedicalVolumes mvA and mvB we can do the following:
# Reformat image into Superior->Inferior, Anterior->Posterior, Left->Right directions.
mvA = mvA.reformat(("SI", "AP", "LR"))
# Get and set metadata
study_description = mvA.get_metadata("StudyDescription")
mvA.set_metadata("StudyDescription", "A sample study")
# Perform NumPy operations like you would on image data.
rss = np.sqrt(mvA**2 + mvB**2)
# Move to GPU 0 for CuPy operations
mv_gpu = mvA.to(dosma.Device(0))
# Take slices. Metadata will be sliced appropriately.
mv_subvolume = mvA[10:20, 10:20, 4:6]
Built-in AI Models
DOSMA is built to be a hub for machine/deep learning models. A complete list of models and corresponding publications can be found here.
We can use one of the knee segmentation models to segment a MedicalVolume mv and model
weights downloaded locally:
from dosma.models import IWOAIOAIUnet2DNormalized
# Reformat such that sagittal plane is last dimension.
mv = mv.reformat(("SI", "AP", "LR"))
# Do segmentation
model = IWOAIOAIUnet2DNormalized(input_shape=mv.shape[:2] + (1,), weights_path=weights)
masks = model.generate_mask(mv)
Parallelizable Operations
DOSMA supports parallelization for compute-heavy operations, like curve fitting and image registration. Image registration is supported thru the elastix/transformix libraries. For example we can use multiple workers to register volumes to a target, and use the registered outputs for per-voxel monoexponential fitting:
# Register images mvA, mvB, mvC to target image mv_tgt in parallel
_, (mvA_reg, mvB_reg, mvC_reg) = dosma.register(
mv_tgt,
moving=[mvA, mvB, mvC],
parameters="/path/to/elastix/registration/file",
num_workers=3,
return_volumes=True,
show_pbar=True,
)
# Perform monoexponential fitting.
def monoexponential(x, a, b):
return a * np.exp(b*x)
fitter = dosma.CurveFitter(
monoexponential,
num_workers=4,
p0={"a": 1.0, "b": -1/30},
)
popt, r2 = fitter.fit(x=[1, 2, 3, 4], [mv_tgt, mvA_reg, mvB_reg, mvC_reg])
a_fit, b_fit = popt[..., 0], popt[..., 1]
Citation
@inproceedings{desai2019dosma,
title={DOSMA: A deep-learning, open-source framework for musculoskeletal MRI analysis},
author={Desai, Arjun D and Barbieri, Marco and Mazzoli, Valentina and Rubin, Elka and Black, Marianne S and Watkins, Lauren E and Gold, Garry E and Hargreaves, Brian A and Chaudhari, Akshay S},
booktitle={Proc 27th Annual Meeting ISMRM, Montreal},
pages={1135},
year={2019}
}
In addition to DOSMA, please also consider citing the work that introduced the method used for analysis.
Metadata
Release files for dosma 0.1.2
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 |
|---|---|---|---|---|
| dosma-0.1.2.tar.gz | 147.3 kB | Without provenance | Details for dosma-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dosma-0.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for dosma-0.1.2-py2.py3-none-any.whl |
Total release size: 324.4 kB
Release files / dosma-0.1.2.tar.gz
| Download URL | dosma-0.1.2.tar.gz |
|---|---|
| Size | 147.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c077a595b3ef49f8bea2369fa65ebab9883cfd889d749a2c4eaa6c2fc8df6965
|
|
BLAKE2b-256 checksum How to use checksums |
92e6b95c8ceed6726ff4ecc5617b12e0d26ec98b0f26ae8f7316351daa9f3859
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.3.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
|
Release files / dosma-0.1.2-py2.py3-none-any.whl
| Download URL | dosma-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 177.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c0594606b343f199c383a2b4dd896bf3074c17efb8cd0c365d2c0d594a3b82ba
|
|
BLAKE2b-256 checksum How to use checksums |
23a77c1cdf088e315901f347f5e56dbb696f869e51b467b8574565de47a9c6fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.3.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9
|
Security for dosma 0.1.2
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.