How to use the pylinac.log_analyzer.Axis function in pylinac

To help you get started, we’ve selected a few pylinac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
self.num_snapshots = np.size(matrix, 0)

        # assignment of snapshot values
        # There is no "expected" MU in dynalogs, but for fluence calc purposes, it is set to that of the actual
        self.mu = Axis(matrix[:,0], matrix[:,0])
        self.DVA_segment = Axis(matrix[:,1])
        self.beam_hold = Axis(matrix[:,2])
        self.beam_on = Axis(matrix[:,3])
        self.prior_dose_idx = matrix[:, 4]  # currently not used for anything
        self.next_dose_idx = matrix[:, 5]  # ditto
        self.gantry = Axis(matrix[:, 6])
        self.collimator = Axis(matrix[:, 7])
        self.jaw_y1 = Axis(matrix[:, 8])
        self.jaw_y2 = Axis(matrix[:, 9])
        self.jaw_x1 = Axis(matrix[:, 10])
        self.jaw_x2 = Axis(matrix[:, 11])
        self.carriageA = Axis(matrix[:, 12])
        self.carriage_B = Axis(matrix[:, 13])
        # MLC positions are in hundredths of mm in the physical leaf plane. Positive is retracted, negative is extented.
        # Positions will be scaled to isocenter plane after bank B positions are added to matrix.
        self.mlc = {}
        for leaf in range(1, (self.num_mlc_leaves//2)+1):
            self.mlc[leaf] = Axis(expected=matrix[leaf-1, 14::4],
                                  actual=matrix[leaf-1, 15::4])
        # self._mlc_expected[:60,:] = matrix[:, 14::4].transpose()
        # self._mlc_actual[:60,:] = matrix[:, 15::4].transpose()

        # read in "B"-file to get bank B MLC positions. The file must be in the same folder as the "A"-file.
        # The header info is repeated but we already have that.
        with open(bfile) as csvf:
            dlgdata = csv.reader(csvf, delimiter=',')
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
self.beam_on = Axis(nx())
        self.prior_dose_index = Axis(nx())  # currently not used for anything
        self.next_dose_index = Axis(nx())  # ditto
        self.gantry = GantryAxis(nx() / 10)
        self.collimator = HeadAxis(nx() / 10)

        # jaws are in mm; convert to cm by /10
        jaw_y1 = HeadAxis(nx() / 10)
        jaw_y2 = HeadAxis(nx() / 10)
        jaw_x1 = HeadAxis(nx() / 10)
        jaw_x2 = HeadAxis(nx() / 10)
        self.jaws = JawStruct(jaw_x1, jaw_y1, jaw_x2, jaw_y2)

        # carriages are in 100ths of mm; converted to cm.
        self.carriage_A = Axis(nx() / 1000)
        self.carriage_B = Axis(nx() / 1000)

        if log.exclude_beam_off:
            hold_idx = np.where(self.beam_hold.actual == 0)[0]
            beamon_idx = np.where(self.beam_on.actual == 1)[0]
            snapshot_idx = np.intersect1d(hold_idx, beamon_idx)
        else:
            snapshot_idx = list(range(self.num_snapshots))

        self.num_snapshots = self.num_snapshots
        self.mlc = MLC.from_dlog(log, self.jaws, snapshot_data, snapshot_idx)
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
self.beam_on = Axis(matrix[:,3])
        self.prior_dose_idx = matrix[:, 4]  # currently not used for anything
        self.next_dose_idx = matrix[:, 5]  # ditto
        self.gantry = Axis(matrix[:, 6])
        self.collimator = Axis(matrix[:, 7])
        self.jaw_y1 = Axis(matrix[:, 8])
        self.jaw_y2 = Axis(matrix[:, 9])
        self.jaw_x1 = Axis(matrix[:, 10])
        self.jaw_x2 = Axis(matrix[:, 11])
        self.carriageA = Axis(matrix[:, 12])
        self.carriage_B = Axis(matrix[:, 13])
        # MLC positions are in hundredths of mm in the physical leaf plane. Positive is retracted, negative is extented.
        # Positions will be scaled to isocenter plane after bank B positions are added to matrix.
        self.mlc = {}
        for leaf in range(1, (self.num_mlc_leaves//2)+1):
            self.mlc[leaf] = Axis(expected=matrix[leaf-1, 14::4],
                                  actual=matrix[leaf-1, 15::4])
        # self._mlc_expected[:60,:] = matrix[:, 14::4].transpose()
        # self._mlc_actual[:60,:] = matrix[:, 15::4].transpose()

        # read in "B"-file to get bank B MLC positions. The file must be in the same folder as the "A"-file.
        # The header info is repeated but we already have that.
        with open(bfile) as csvf:
            dlgdata = csv.reader(csvf, delimiter=',')
            matrix = np.array([line for line in dlgdata if int(dlgdata.line_num) >= 7], dtype=float)

        # Add bank B MLC positions to mlc snapshot arrays
        for leaf in range(1, (self.num_mlc_leaves//2)+1):
            self.mlc[leaf+self.num_mlc_leaves//2] = Axis(expected=matrix[leaf-1, 14::4],
                                  actual=matrix[leaf-1, 15::4])
            # self._mlc_expected[60:, :] = matrix[:, 14::4].transpose()
            # self._mlc_actual[60:, :] = matrix[:, 15::4].transpose()
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
self.num_snapshots = np.size(matrix, 0)

        # assignment of snapshot values
        # There is no "expected" MU in dynalogs, but for fluence calc purposes, it is set to that of the actual
        self.mu = Axis(matrix[:,0], matrix[:,0])
        self.DVA_segment = Axis(matrix[:,1])
        self.beam_hold = Axis(matrix[:,2])
        self.beam_on = Axis(matrix[:,3])
        self.prior_dose_idx = matrix[:, 4]  # currently not used for anything
        self.next_dose_idx = matrix[:, 5]  # ditto
        self.gantry = Axis(matrix[:, 6])
        self.collimator = Axis(matrix[:, 7])
        self.jaw_y1 = Axis(matrix[:, 8])
        self.jaw_y2 = Axis(matrix[:, 9])
        self.jaw_x1 = Axis(matrix[:, 10])
        self.jaw_x2 = Axis(matrix[:, 11])
        self.carriageA = Axis(matrix[:, 12])
        self.carriage_B = Axis(matrix[:, 13])
        # MLC positions are in hundredths of mm in the physical leaf plane. Positive is retracted, negative is extented.
        # Positions will be scaled to isocenter plane after bank B positions are added to matrix.
        self.mlc = {}
        for leaf in range(1, (self.num_mlc_leaves//2)+1):
            self.mlc[leaf] = Axis(expected=matrix[leaf-1, 14::4],
                                  actual=matrix[leaf-1, 15::4])
        # self._mlc_expected[:60,:] = matrix[:, 14::4].transpose()
        # self._mlc_actual[:60,:] = matrix[:, 15::4].transpose()

        # read in "B"-file to get bank B MLC positions. The file must be in the same folder as the "A"-file.
        # The header info is repeated but we already have that.
        with open(bfile) as csvf:
            dlgdata = csv.reader(csvf, delimiter=',')
            matrix = np.array([line for line in dlgdata if int(dlgdata.line_num) >= 7], dtype=float)
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
def plot_expected(self):
        plt.plot(self.expected)
        plt.show()

    def plot_difference(self):
        plt.plot(self.difference)
        plt.show()

class GantryAxis(Axis):
    pass

class LeafAxis(Axis):
    def __init__(self, actual, expected):
        super().__init__(actual, expected)

class HeadAxis(Axis):
    pass

class CouchAxis(Axis):
    pass

class BeamAxis(Axis):
    pass

class MLCBank(Axis):
    def __init__(self):
        super().__init__()


class MLC(dict):

    def __init__(self, beam_on_idx=None):
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
if mu_array[-1] == 25000:
                return mu_array
            else:
                abs_diff = list(np.abs(np.diff(mu_array)))
                # this is the cumulative gantry diff, a surrogate for MU. Normalize to 25000 to look like a "normal" dynalog
                cum_gantry_diff = np.array([0,] + list(np.cumsum(abs_diff)/np.sum(abs_diff))) * 25000
                return cum_gantry_diff

        corrected_mu = correct_vmat_mu(mu)

        self.mu = Axis(corrected_mu, corrected_mu)
        self.previous_segment_num = Axis(nx())
        self.beam_hold = Axis(nx())
        self.beam_on = Axis(nx())
        self.prior_dose_index = Axis(nx())  # currently not used for anything
        self.next_dose_index = Axis(nx())  # ditto
        self.gantry = GantryAxis(nx() / 10)
        self.collimator = HeadAxis(nx() / 10)

        # jaws are in mm; convert to cm by /10
        jaw_y1 = HeadAxis(nx() / 10)
        jaw_y2 = HeadAxis(nx() / 10)
        jaw_x1 = HeadAxis(nx() / 10)
        jaw_x2 = HeadAxis(nx() / 10)
        self.jaws = JawStruct(jaw_x1, jaw_y1, jaw_x2, jaw_y2)

        # carriages are in 100ths of mm; converted to cm.
        self.carriage_A = Axis(nx() / 1000)
        self.carriage_B = Axis(nx() / 1000)

        if log.exclude_beam_off:
            hold_idx = np.where(self.beam_hold.actual == 0)[0]
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
def plot_difference(self):
        plt.plot(self.difference)
        plt.show()

class GantryAxis(Axis):
    pass

class LeafAxis(Axis):
    def __init__(self, actual, expected):
        super().__init__(actual, expected)

class HeadAxis(Axis):
    pass

class CouchAxis(Axis):
    pass

class BeamAxis(Axis):
    pass

class MLCBank(Axis):
    def __init__(self):
        super().__init__()


class MLC(dict):

    def __init__(self, beam_on_idx=None):
        super().__init__()
        self.beam_on_idx = beam_on_idx
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
# This reads in all snapshots, then assigns them. The reason this cannot be iterated over is because the
            # snapshots are column-order, not row order, so all rows must be read before any data can be assigned.
            matrix = np.array([line for line in dlgdata], dtype=float)

        self.num_snapshots = np.size(matrix, 0)

        # assignment of snapshot values
        # There is no "expected" MU in dynalogs, but for fluence calc purposes, it is set to that of the actual
        self.mu = Axis(matrix[:,0], matrix[:,0])
        self.DVA_segment = Axis(matrix[:,1])
        self.beam_hold = Axis(matrix[:,2])
        self.beam_on = Axis(matrix[:,3])
        self.prior_dose_idx = matrix[:, 4]  # currently not used for anything
        self.next_dose_idx = matrix[:, 5]  # ditto
        self.gantry = Axis(matrix[:, 6])
        self.collimator = Axis(matrix[:, 7])
        self.jaw_y1 = Axis(matrix[:, 8])
        self.jaw_y2 = Axis(matrix[:, 9])
        self.jaw_x1 = Axis(matrix[:, 10])
        self.jaw_x2 = Axis(matrix[:, 11])
        self.carriageA = Axis(matrix[:, 12])
        self.carriage_B = Axis(matrix[:, 13])
        # MLC positions are in hundredths of mm in the physical leaf plane. Positive is retracted, negative is extented.
        # Positions will be scaled to isocenter plane after bank B positions are added to matrix.
        self.mlc = {}
        for leaf in range(1, (self.num_mlc_leaves//2)+1):
            self.mlc[leaf] = Axis(expected=matrix[leaf-1, 14::4],
                                  actual=matrix[leaf-1, 15::4])
        # self._mlc_expected[:60,:] = matrix[:, 14::4].transpose()
        # self._mlc_actual[:60,:] = matrix[:, 15::4].transpose()

        # read in "B"-file to get bank B MLC positions. The file must be in the same folder as the "A"-file.
github jrkerns / pylinac / pylinac / log_analyzer.py View on Github external
# if treatment was vmat then MU is replaced by gantry angle (so stupid). If so, convert to normalized MU by looking at gantry movement.
        def correct_vmat_mu(mu_array):
            if mu_array[-1] == 25000:
                return mu_array
            else:
                abs_diff = list(np.abs(np.diff(mu_array)))
                # this is the cumulative gantry diff, a surrogate for MU. Normalize to 25000 to look like a "normal" dynalog
                cum_gantry_diff = np.array([0,] + list(np.cumsum(abs_diff)/np.sum(abs_diff))) * 25000
                return cum_gantry_diff

        corrected_mu = correct_vmat_mu(mu)

        self.mu = Axis(corrected_mu, corrected_mu)
        self.previous_segment_num = Axis(nx())
        self.beam_hold = Axis(nx())
        self.beam_on = Axis(nx())
        self.prior_dose_index = Axis(nx())  # currently not used for anything
        self.next_dose_index = Axis(nx())  # ditto
        self.gantry = GantryAxis(nx() / 10)
        self.collimator = HeadAxis(nx() / 10)

        # jaws are in mm; convert to cm by /10
        jaw_y1 = HeadAxis(nx() / 10)
        jaw_y2 = HeadAxis(nx() / 10)
        jaw_x1 = HeadAxis(nx() / 10)
        jaw_x2 = HeadAxis(nx() / 10)
        self.jaws = JawStruct(jaw_x1, jaw_y1, jaw_x2, jaw_y2)

        # carriages are in 100ths of mm; converted to cm.
        self.carriage_A = Axis(nx() / 1000)
        self.carriage_B = Axis(nx() / 1000)