@@ -144,13 +144,30 @@ def test_slice_indicator():
144144 dw_empty = didw .Wrapper ()
145145 assert_true (dw_empty .slice_indicator is None )
146146
147+
147148@dicom_test
148- def test_slice_normal ():
149- dw = didw .wrapper_from_file (DATA_FILE_SLC_NORM )
150-
149+ def test_orthogonal ():
151150 #Test that the slice normal is sufficiently orthogonal
151+ dw = didw .wrapper_from_file (DATA_FILE_SLC_NORM )
152152 R = dw .rotation_matrix
153153 assert np .allclose (np .eye (3 ),
154154 np .dot (R , R .T ),
155155 atol = 1e-6 )
156-
156+
157+ @dicom_test
158+ def test_use_csa_sign ():
159+ #Test that we get the same slice normal, even after swapping the iop
160+ #directions
161+ dw = didw .wrapper_from_file (DATA_FILE_SLC_NORM )
162+ iop = dw .image_orient_patient
163+ dw .image_orient_patient = np .c_ [iop [:,1 ], iop [:,0 ]]
164+ dw2 = didw .wrapper_from_file (DATA_FILE_SLC_NORM )
165+ assert np .allclose (dw .slice_normal , dw2 .slice_normal )
166+
167+ @dicom_test
168+ def test_assert_parallel ():
169+ #Test that we get an AssertionError if the cross product and the CSA
170+ #slice normal are not parallel
171+ dw = didw .wrapper_from_file (DATA_FILE_SLC_NORM )
172+ dw .image_orient_patient = np .c_ [[1. , 0. , 0. ], [0. , 1. , 0. ]]
173+ assert_raises (AssertionError , dw .__getattribute__ , 'slice_normal' )
0 commit comments