Skip to content

Commit

Permalink
Version 0.13.0 (#101)
Browse files Browse the repository at this point in the history
Closes #90
  • Loading branch information
jmsmkn authored Jul 17, 2023
1 parent e45664e commit 0b25efb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# History

## 0.13.0 (2023-07-17)

* Increased maximum number of segments to 64
* Required segmentations to be of type Int8 or UInt8
* Reduced memory usage

## 0.12.0 (2023-06-02)

* Add support for conversion of DICOM-WSI files to TIFF
Expand Down
6 changes: 6 additions & 0 deletions panimg/image_builders/metaio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ def load_sitk_image(

headers = validate_and_clean_additional_mh_headers(reader=reader)

if reader.GetNumberOfComponents() > 4:
raise ValidationError(
"Images with more than 4 channels not supported. "
"For 4D data please use the 4th dimension instead."
)

# Header has been validated, read the pixel data
if reader.GetDimension() in (2, 3, 4):
sitk_image = reader.Execute()
Expand Down
6 changes: 1 addition & 5 deletions panimg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ def depth(self) -> Optional[int]:

return depth or None

@property
def is_4d(self):
return len(self.image.GetSize()) == 4

@staticmethod
def _extract_first_float(value: str) -> float:
if value.startswith("["):
Expand Down Expand Up @@ -273,7 +269,7 @@ def segments(self) -> Optional[FrozenSet[int]]:

im_arr = GetArrayViewFromImage(self.image)

if self.is_4d:
if self.image.GetDimension() == 4:
segments = set()
n_volumes = self.image.GetSize()[3]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "panimg"
version = "0.12.0"
version = "0.13.0"
description = "Conversion of medical images to MHA and TIFF."
license = "Apache-2.0"
authors = ["James Meakin <[email protected]>"]
Expand Down
Binary file added tests/resources/channels/5_1_1_1_invalid.mha
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,23 @@ def test_segments(

image = result.new_images.pop()
assert image.segments == segments


def test_invalid_4d(tmp_path_factory):
file = RESOURCE_PATH / "channels" / "5_1_1_1_invalid.mha"
result = _build_files(
builder=image_builders.image_builder_mhd,
files={file},
output_directory=tmp_path_factory.mktemp("output"),
)

assert result.consumed_files == set()
assert len(result.new_images) == 0
assert result.file_errors == {
file: [
(
"Mhd image builder: Images with more than 4 channels not supported. "
"For 4D data please use the 4th dimension instead."
)
]
}

0 comments on commit 0b25efb

Please sign in to comment.