Skip to content

Commit 7f9a470

Browse files
committed
DOC: Added some comments to clarify what is going on.
1 parent 90642bb commit 7f9a470

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ def __init__(self, dcm_data=None, csa_header=None):
407407

408408
@one_time
409409
def slice_normal(self):
410+
#The std_slice_normal comes from the cross product of the directions
411+
#in the ImageOrientationPatient
410412
std_slice_normal = super(SiemensWrapper, self).slice_normal
411413
csa_slice_normal = csar.get_slice_normal(self.csa_header)
412414
if std_slice_normal is None and csa_slice_normal is None:
@@ -416,8 +418,12 @@ def slice_normal(self):
416418
elif csa_slice_normal is None:
417419
return std_slice_normal
418420
else:
421+
#Make sure the two normals are very close to parallel unit vectors
419422
dot_prod = np.dot(csa_slice_normal, std_slice_normal)
420423
assert np.allclose(np.fabs(dot_prod), 1.0, atol=1e-5)
424+
#Use the slice normal computed with the cross product as it will
425+
#always be the most orthogonal, but take the sign from the CSA
426+
#slice normal
421427
if dot_prod < 0:
422428
return -std_slice_normal
423429
else:

0 commit comments

Comments
 (0)