Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image type derived if resampled #177

Merged
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Parsing of native pixel data with padded lenght.
- Check for supported transfer syntax when DICOMWeb client returns an iterable of frames.
- Fix for order of transfer syntax to check.
- Use `ImageType` `DERIVED` instead of `ORIGINAL` when saving resampled volume instances.

## [0.21.4] - 2024-10-30

Expand Down
2 changes: 1 addition & 1 deletion tests/metadata/dicom_schema/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def dicom_overview_label(label: Label):

def create_dicom_label(label: Label, image_type: ImageType):
dataset = Dataset()
dataset.ImageType = ["ORIGINAL", "PRIMIARY", image_type.value]
dataset.ImageType = ["ORIGINAL", "PRIMARY", image_type.value]
if image_type == ImageType.LABEL:
dataset.LabelText = label.text
dataset.BarcodeValue = label.barcode
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wsi_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_spacing_between_slices(
["image_type", "pyramid_index", "expected_image_type"],
[
(ImageType.VOLUME, 0, ["ORIGINAL", "PRIMARY", "VOLUME", "NONE"]),
(ImageType.VOLUME, 1, ["ORIGINAL", "PRIMARY", "VOLUME", "RESAMPLED"]),
(ImageType.VOLUME, 1, ["DERIVED", "PRIMARY", "VOLUME", "RESAMPLED"]),
(ImageType.LABEL, None, ["ORIGINAL", "PRIMARY", "LABEL", "NONE"]),
(ImageType.OVERVIEW, None, ["ORIGINAL", "PRIMARY", "OVERVIEW", "NONE"]),
],
Expand Down
8 changes: 7 additions & 1 deletion wsidicom/instance/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,13 @@ def create_instance_dataset(
if pyramid_index > 0:
resampled = "RESAMPLED"

dataset.ImageType = ["ORIGINAL", "PRIMARY", image_type.value, resampled]
original_or_derived = "ORIGINAL" if resampled == "NONE" else "DERIVED"
dataset.ImageType = [
original_or_derived,
"PRIMARY",
image_type.value,
resampled,
]
dataset.SOPInstanceUID = generate_uid(prefix=None)
shared_functional_group_sequence = Dataset()
if image_data.pixel_spacing is None:
Expand Down
Loading