MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / test_reader_kwargs

Function test_reader_kwargs

Wrapping/Python/tests/sitkImageReadWrite.py:147–174  ·  view source on GitHub ↗

Test keyword arguments in ReadImage method

(test_dir)

Source from the content-addressed store, hash-verified

145
146
147def test_reader_kwargs(test_dir):
148 """Test keyword arguments in ReadImage method"""
149 # Create test image series
150 z_size = 3
151 img = sitk.Image([32, 32, z_size], sitk.sitkUInt16)
152 for z in range(z_size):
153 img[:, :, z] = 1 + z * 5
154
155 # Write series as PNG files
156 file_paths = [test_dir / f"test_reader_kwargs_{z}.png" for z in range(z_size)]
157 sitk.WriteImage(img, file_paths)
158
159 # Test reverse order reading
160 reversed_img = sitk.ReadImage(
161 file_paths,
162 reverseOrder=True,
163 spacingWarningRelThreshold=0.0
164 )
165
166 # Verify slice order is reversed
167 for z in range(z_size):
168 orig_hash = sitk.Hash(img[:, :, z])
169 rev_hash = sitk.Hash(reversed_img[:, :, -z-1])
170 assert orig_hash == rev_hash, f"Slice mismatch at position {z}"
171
172 # Test invalid keyword argument
173 with pytest.raises(TypeError):
174 sitk.ReadImage(file_paths, nonsenseKwarg=True)
175
176
177def verify_read_write(img: sitk.Image, output_path: Path):

Callers

nothing calls this directly

Calls 1

ImageMethod · 0.80

Tested by

no test coverage detected