Skip to content

Commit

Permalink
Update test_handler_util.py
Browse files Browse the repository at this point in the history
Adding unit tests to check get_expected_length() for pixel and byte counts for multiframe DICOM missing NumberOfFrames in the header.
  • Loading branch information
luissantosHCIT committed Apr 3, 2024
1 parent 5dc2859 commit 7889bf4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_handler_util.py
Expand Up @@ -1207,6 +1207,35 @@ def test_length_ybr_422(self, shape, bits, length):

assert length[2] == get_expected_length(ds, unit="bytes")

@pytest.mark.parametrize("shape, bits, length", REFERENCE_LENGTH)
def test_length_bytes_multiframe_nonumberofframes(self, shape, bits, length):
"""Test get_expected_length(ds, unit='bytes') against a multiframe dicom scenario without NumberOfFrames defined."""
frames = 3
if shape[3] != 3 or bits == 1:
ds = Dataset()
ds.PhotometricInterpretation = "MONOCHROME2"
ds.Rows = shape[1]
ds.Columns = shape[2]
ds.BitsAllocated = bits
ds.SamplesPerPixel = shape[3]
ds.PixelData = 'a' * (shape[1] * shape[2] * (bits // 8) * shape[3]) * frames

assert (length[0] * frames) == get_expected_length(ds, unit="bytes")

@pytest.mark.parametrize("shape, bits, length", REFERENCE_LENGTH)
def test_length_in_pixels_multiframe_nonumberofframes(self, shape, bits, length):
"""Test get_expected_length(ds, unit='pixels') against a multiframe dicom scenario without NumberOfFrames defined."""
frames = 3
ds = Dataset()
ds.PhotometricInterpretation = "MONOCHROME2"
ds.Rows = shape[1]
ds.Columns = shape[2]
ds.BitsAllocated = bits
ds.SamplesPerPixel = shape[3]
ds.PixelData = 'a' * (shape[1] * shape[2] * (bits // 8) * shape[3]) * frames

assert (length[1] * frames) == get_expected_length(ds, unit="pixels")


@pytest.mark.skipif(not HAVE_NP, reason="Numpy is not available")
class TestNumpy_ModalityLUT:
Expand Down

0 comments on commit 7889bf4

Please sign in to comment.