Skip to content
Closed
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 src/highdicom/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Loading