Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ipynb -linguist-detectable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.benchmarks
niivue-images/
pydicom-data/
downloaded_testfiles/
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ rmpv = "1.0.0"
safetensors = "0.3.0"
serde = { version = "1.0.156", features = ["derive"] }
serde_json = "1.0.94"
snafu = { version = "0.7.4", features = ["rust_1_61", "backtraces-impl-std"] }

11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ prep_test:

test: prep_test
cargo test
pytest
pytest --benchmark-disable

bench: prep_test
pytest --benchmark-enable --benchmark-group-by=fullfunc

bench-dicom-baselines:
pytest test/dicom_baseline_comparisons.py --benchmark-group-by=param -s --benchmark-save=dicom_baselines_comparisons

bench-nifti-baselines:
pytest test/nifti_baseline_comparisons.py --benchmark-group-by=param -s --benchmark-save=nifti_baselines_comparisons

fmt:
cargo fmt
Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@

Nimble Digital Imaging for Medicine

Near lossless and easy conversion from DICOM and back
- Done
## Pipeline

Support for fast and random access of metadata
- Done
### Completed

Extremely fast and zero-copy loading to CPU/GPU
- Done
- [x] Near lossless and easy conversion from DICOM and back
- [x] Support for fast and random access of metadata
- [x] Extremely fast and zero-copy loading to CPU/GPU
- [x] Safe: no codegen/exec based on the metadata
- [x] Support for ITK file formats [[ref](https://simpleitk.readthedocs.io/en/v1.2.4/Documentation/docs/source/IO.html#images)], including NIfTI

### WIP
All relevant data types including uint16, f16, bf16, complex64 and complex128
- Currently supports f32, trivial to support other datatypes

Bindings for Python and conversion to NumPy/CuPy/JAX/Torch tensors
- Currently supports loading to Torch tensors (easily extensible)

Safe: no codegen/exec based on the metadata
- Done

Support for ITK file formats [[ref](https://simpleitk.readthedocs.io/en/v1.2.4/Documentation/docs/source/IO.html#images)], including NIfTI
- Done


## Installation

Expand Down Expand Up @@ -51,7 +47,7 @@ dimble.dicom_to_dimble('xray.dicom', 'xray.dimble')
dataset = dimble.load_dimble('xray.dimble', fields=["7FE00010"], device="cpu")

# load a dimble file's pixel data sliced to a 224x224 chunk offset by 100 in each dimension
dataset = dimble.load_dimble('xray.dimble', fields=["7FE00010"], device="cpu", slices=[slice(100:100+224), slice(100:100+224)])
dataset = dimble.load_dimble('xray.dimble', fields=["7FE00010"], device="cpu", slices=[slice(100,100+224), slice(100,100+224)])

# convert back to dicom
dimble.dimble_to_dicom("xray.dimble", "xray.dicom")
Expand Down
4 changes: 4 additions & 0 deletions dimble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
dimble_to_nifti,
load_dimble,
nifti_to_dimble,
rglob_dicom,
)

rglob_dicom

__all__ = [
"dicom_to_dimble",
"dimble_to_dicom",
"load_dimble",
"nifti_to_dimble",
"dimble_to_nifti",
"_create_temp_dir",
"rglob_dicom",
]
4 changes: 4 additions & 0 deletions dimble/dimble.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,7 @@ def dimble_to_nifti(dimble_path: Path, output_path: Path) -> None:
sitk.WriteImage(itk_image, output_path)
finally:
ir_path.unlink(missing_ok=True)

def rglob_dicom(path: Path) -> list[Path]:
dicom_extensions = [".dcm", ".dicom", ".DCM", ".DICOM"]
return [p for p in path.rglob("*") if p.suffix in dicom_extensions]
Loading