dicom_volume/
lib.rs

1//! # DICOM-volume library
2//!
3//! This crate serves a high-level API for handling multiple DICOM files as
4//! volumes
5
6//!
7//! This library is part of the dicom-rs ecosystem and leverages its component
8//! to provide a volume representation of multiple DICOM files.
9//! Volumes can either be loaded from multiple [`FileDicomObject<InMemDicomObject>`] or from a
10//! specified folder where each ".dcm" file is read from.
11//! If the environment supports it the DICOM files are loaded in parallel
12//! using rayon. The volume can be sliced in the three different medical axes:
13//!  - Axial
14//!  - Coronal
15//!  - Sagittal
16//!
17//!  Library consumers can chose whether the Coronal and Sagittal slices
18//!  should be interpolated to preserve the aspect ratios between of the
19//!  images. DICOM files are assumed to have the following attributes:
20//!   - Axial data set (Only Coronal and Sagittal axes are interpolated)
21//!   - No multiframe (always the first frame is used)
22//!   - Images from the same series (Series Instance UID) and acquisition
23//!     (Acquisition Number)
24//!
25//!   Contributions are highly welcome!
26//!
27//! # Roadmap
28//!
29//!  - GPU processor for interpolation using WGPU and compute shaders
30//!  - Trilinear interpolation
31//!  - Cubic interpolation
32//!  - Caching of images
33//!
34//! # Examples
35//!
36//! ## Reading multiple DICOM files into a volume
37//!
38//! To read all DICOM files from the dicom/ directory, sort them by
39//! InstanceNumber. Then get the image at the center of the volume in the
40//! Sagittal axis.
41//!
42//! ```no_run
43//! # use dicom_volume::{VolumeLoader, Orientation, Interpolation, Processor, SortBy};
44//! # use std::path::PathBuf;
45//! let volume = VolumeLoader::load_from_directory(&PathBuf::from("dicom"), SortBy::InstanceNumber)
46//!     .expect("should have loaded files from directory");
47//! let image = volume
48//!     .get_image_from_axis(
49//!         volume.dim().2 / 2,
50//!         Orientation::Sagittal,
51//!         Interpolation::Bilinear(Processor::CPU),
52//!     )
53//!     .expect("should have returned image at center of volume");
54//! image.save("result.png");
55//! ```
56//!
57//! [`FileDicomObject<InMemDicomObject>`]: https://docs.rs/dicom-object/latest/dicom_object/struct.FileDicomObject.html
58
59pub mod enums;
60mod interpolator;
61pub mod volume;
62pub mod volume_loader;