File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -756,7 +756,7 @@ Creating a volume from an ITK Image:
756756 im = itk.image(... )
757757
758758 # Reverse array dimension order
759- array = np.transpose( itk.array_from_image(im), [2 , 1 , 0 ])
759+ array = itk.array_from_image(im).transpose( [2 , 1 , 0 ])
760760
761761 vol2 = hd.Volume.from_components(
762762 array = array,
@@ -771,14 +771,13 @@ Creating an ITK Image from a Volume:
771771.. code-block :: python
772772
773773 import itk
774- import numpy as np
775774 import highdicom as hd
776775
777776
778777 vol = hd.Volume(... )
779778
780779 # Reverse array dimension order
781- array = np.transpose( vol.array, [2 , 1 , 0 ])
780+ array = vol.array.transpose( [2 , 1 , 0 ])
782781
783782 im = itk.image_from_array(array)
784783 im.SetOrigin(vol.position)
Original file line number Diff line number Diff line change @@ -3847,8 +3847,8 @@ def get_volume(
38473847
38483848 affine = volume_geometry [
38493849 :,
3850- row_start - 1 :,
3851- column_start - 1 :,
3850+ row_start :,
3851+ column_start :,
38523852 ].affine
38533853 else :
38543854 # Check that the combination of frame numbers and segment numbers
Original file line number Diff line number Diff line change @@ -5131,6 +5131,24 @@ def test_tiled_full_no_dimension_index(self):
51315131 tpm2 = seg_no_dim_ind .get_total_pixel_matrix ()
51325132 assert np .array_equal (tpm1 , tpm2 )
51335133
5134+ def test_tiled_full_volume (self ):
5135+ # Check that a tiled segmentation is read with the correct affine
5136+ file_path = Path (__file__ )
5137+ data_dir = file_path .parent .parent .joinpath ('data' )
5138+ f = data_dir / 'test_files/seg_image_sm_dots_tiled_full.dcm'
5139+ seg = segread (f )
5140+ origin_seq = seg .TotalPixelMatrixOriginSequence [0 ]
5141+
5142+ expected = np .array (
5143+ [
5144+ origin_seq .XOffsetInSlideCoordinateSystem ,
5145+ origin_seq .YOffsetInSlideCoordinateSystem ,
5146+ 0.0
5147+ ]
5148+ )
5149+ vol = seg .get_volume ()
5150+ assert np .array_equal (vol .position , expected )
5151+
51345152 def test_shared_referenced_segment (self ):
51355153 # Test parsing when the referenced segment is in the shared functional
51365154 # groups
You can’t perform that action at this time.
0 commit comments