From 923d3f1b1730eb0322f8bf2edddb0ff8cae265f2 Mon Sep 17 00:00:00 2001 From: Apoorv Saraogee <136734128+asaraog@users.noreply.github.com> Date: Fri, 25 Sep 2026 18:10:05 -0700 Subject: [PATCH 1/2] Test that Volume.copy keeps channels --- tests/test_volume.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_volume.py b/tests/test_volume.py index 91ba3891..08516eed 100644 --- a/tests/test_volume.py +++ b/tests/test_volume.py @@ -1584,3 +1584,15 @@ def test_reassign_dtype(dtype): ) ): volume.array = np.zeros((10, 10, 10), dtype=dtype) + + +def test_copy_keeps_channels(): + vol = Volume( + array=np.zeros((2, 3, 3, 2), dtype=np.uint8), + affine=np.eye(4), + coordinate_system="PATIENT", + channels={'SegmentNumber': [1, 2]}, + ) + copied = vol.copy() + assert copied.channel_shape == vol.channel_shape + assert copied.get_channel_values('SegmentNumber') == [1, 2] From 67b0c33be79999134f72e2765c233bbce9d9555e Mon Sep 17 00:00:00 2001 From: Apoorv Saraogee <136734128+asaraog@users.noreply.github.com> Date: Fri, 25 Sep 2026 18:29:09 -0700 Subject: [PATCH 2/2] Keep channels in Volume.copy --- src/highdicom/volume.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/highdicom/volume.py b/src/highdicom/volume.py index 467cb553..8da45581 100644 --- a/src/highdicom/volume.py +++ b/src/highdicom/volume.py @@ -2972,6 +2972,7 @@ def copy(self) -> Self: affine=self._affine.copy(), coordinate_system=self.coordinate_system, frame_of_reference_uid=self.frame_of_reference_uid, + channels=self._channels, ) def with_array(