deep-learning-with-pytorch / dlwpt-code

Code for the book Deep Learning with PyTorch by Eli Stevens, Luca Antiga, and Thomas Viehmann.
https://www.manning.com/books/deep-learning-with-pytorch
4.69k stars 1.98k forks source link

Ch10.10 dsets.py Why do you convert to 3x3 matrix? #90

Open cmosguy opened 2 years ago

cmosguy commented 2 years ago

In the function for reading in the XYZ space of the CT .mhd file, why do you convert to 3x3 matrix?

class Ct:
  def __init__(self, series_uid):
    mhd_path = glob.glob('data-unversioned/part2/luna/subset*/{}.mhd'.format(series_uid))[0]

        ct_mhd = sitk.ReadImage(mhd_path)
        # ... line 91
        self.origin_xyz = XyzTuple(*ct_mhd.GetOrigin())
        self.vxSize_xyz = XyzTuple(*ct_mhd.GetSpacing())
        self.direction_a = np.array(ct_mhd.GetDirection()).reshape(3, 3)

I see the text to Converts the directions to an array, and reshapes the nine-element array to it's proper 3x3 matrix but why is 3x3 matrix for xyz?