How to use the pylinac.core.geometry.Point 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 / tests_basic / test_vmat.py View on Github external
filepaths = ('DRGSopen-105-example.dcm', 'DRGSdmlc-105-example.dcm')
    klass = DRGS
    segment_positions = {0: Point(371, 384), 2: Point(478, 384)}
    segment_values = {
        0: {'r_dev': 1.385, 'r_corr': 15.12},
        4: {'r_dev': -0.8, 'r_corr': 14.8},
    }
    avg_abs_r_deviation = 0.68
    max_r_deviation = 1.38


class TestDRMLC2(VMATMixin, TestCase):
    """Tests of the result values of MLCS images at 105cm SID."""
    filepaths = ('DRMLC#2_open.dcm', 'DRMLC#2_dmlc.dcm')
    klass = DRMLC
    segment_positions = {0: Point(199, 192), 2: Point(275, 192)}
    segment_values = {
        0: {'r_dev': 0.77, 'r_corr': 6.1},
        2: {'r_dev': -1.1, 'r_corr': 6},
    }
    avg_abs_r_deviation = 1.4
    max_r_deviation = 1.98
    passes = False


class TestDRGS2(VMATMixin, TestCase):
    """Tests of the result values of DRMLC images at 105cm SID."""
    filepaths = ('DRGS#2_open.dcm', 'DRGS#2_dmlc.dcm')
    klass = DRGS
    segment_positions = {0: Point(191, 192), 2: Point(242, 192)}
    segment_values = {
        0: {'r_dev': 1.5, 'r_corr': 6.4},
github jrkerns / pylinac / tests_basic / test_vmat.py View on Github external
filepaths = ('DRMLCopen-105-example.dcm', 'DRMLCdmlc-105-example.dcm')
    segment_positions = {0: Point(391, 384), 2: Point(552, 384)}
    segment_values = {
        0: {'r_dev': -2.1, 'r_corr': 13.6},
        2: {'r_dev': 0.22, 'r_corr': 14},
    }
    avg_abs_r_deviation = 1.06
    max_r_deviation = 2.11
    passes = False


class TestDRGS105(VMATMixin, TestCase):
    """Tests of the result values of DRMLC images at 105cm SID."""
    filepaths = ('DRGSopen-105-example.dcm', 'DRGSdmlc-105-example.dcm')
    klass = DRGS
    segment_positions = {0: Point(371, 384), 2: Point(478, 384)}
    segment_values = {
        0: {'r_dev': 1.385, 'r_corr': 15.12},
        4: {'r_dev': -0.8, 'r_corr': 14.8},
    }
    avg_abs_r_deviation = 0.68
    max_r_deviation = 1.38


class TestDRMLC2(VMATMixin, TestCase):
    """Tests of the result values of MLCS images at 105cm SID."""
    filepaths = ('DRMLC#2_open.dcm', 'DRMLC#2_dmlc.dcm')
    klass = DRMLC
    segment_positions = {0: Point(199, 192), 2: Point(275, 192)}
    segment_values = {
        0: {'r_dev': 0.77, 'r_corr': 6.1},
        2: {'r_dev': -1.1, 'r_corr': 6},
github jrkerns / pylinac / tests_basic / test_cbct.py View on Github external
def test_phan_center(self):
        """Test locations of the phantom center."""
        known_phan_center = Point(257, 255)
        self.cbct.analyze()
        self.assertAlmostEqual(self.cbct.ctp404.phan_center.x, known_phan_center.x, delta=0.7)
        self.assertAlmostEqual(self.cbct.ctp404.phan_center.y, known_phan_center.y, delta=0.7)
github jrkerns / pylinac / pylinac / planar_imaging.py View on Github external
averaged over all the detected circles to give a more robust value.

        Returns
        -------
        center : Point
        """
        if self._phantom_center is not None:
            return self._phantom_center
        circles = [roi for roi in self._blobs if
                   np.isclose(self._regions[roi].major_axis_length, self.phantom_radius * 3.35, rtol=0.3)]

        # get average center of all circles
        circle_rois = [self._regions[roi] for roi in circles]
        y = np.mean([bbox_center(roi).y for roi in circle_rois])
        x = np.mean([bbox_center(roi).x for roi in circle_rois])
        return Point(x, y)
github jrkerns / pylinac / pylinac / core / profile.py View on Github external
def subdivide(self, interpolation_factor: int=100, interpolation_type: str='linear') -> List[SingleProfile]:
        """Subdivide the profile data into SingleProfiles.

        Returns
        -------
        list
            List of :class:`~pylinac.core.profile.SingleProfile`
        """
        # append the peak list to include the endpoints of the profile
        peaks = self.peaks.copy()
        peaks.insert(0, Point(idx=0))
        peaks.append(Point(idx=len(self.values)))

        # create a list of single profiles from segments of original profile data.
        # New profiles are segmented by initial peak locations.
        subprofiles = []
        for idx in range(len(peaks)-2):
            left_end = peaks[idx].idx
            peak_idx = peaks[idx+1].idx - left_end
            right_end = peaks[idx+2].idx

            values = self.values[int(left_end):int(right_end)]

            subprofile = SingleProfile(values, initial_peak=peak_idx)
            subprofile.interpolation_factor = interpolation_factor
            subprofile.interpolation_type = interpolation_type
            subprofiles.append(subprofile)
github jrkerns / pylinac / pylinac / winston_lutz.py View on Github external
def cax_line_projection(self) -> Line:
        """The projection of the field CAX through space around the area of the BB.
        Used for determining gantry isocenter size.

        Returns
        -------
        Line
            The virtual line in space made by the beam CAX.
        """
        p1 = Point()
        p2 = Point()
        # point 1 - ray origin
        p1.x = self.cax2bb_vector.x*cos(self.gantry_angle) + 20 * sin(self.gantry_angle)
        p1.y = self.cax2bb_vector.x*-sin(self.gantry_angle) + 20 * cos(self.gantry_angle)
        p1.z = self.cax2bb_vector.y
        # point 2 - ray destination
        p2.x = self.cax2bb_vector.x*cos(self.gantry_angle) - 20 * sin(self.gantry_angle)
        p2.y = self.cax2bb_vector.x*-sin(self.gantry_angle) - 20 * cos(self.gantry_angle)
        p2.z = self.cax2bb_vector.y
        l = Line(p1, p2)
        return l
github jrkerns / pylinac / pylinac / winston_lutz.py View on Github external
def _find_max_distance_between_points(images) -> float:
        """Find the maximum distance between a set of points. Used for 2D images like collimator and couch."""
        points = [Point(image.cax2bb_vector.x, image.cax2bb_vector.y) for image in images]
        dists = []
        for point1 in points:
            for point2 in points:
                p = point1.distance_to(point2)
                dists.append(p)
        return max(dists)
github jrkerns / pylinac / pylinac / starshot.py View on Github external
def distance(p, lines):
            """Calculate the maximum distance to any line from the given point."""
            return max(line.distance_to(Point(p[0], p[1])) for line in lines)
github jrkerns / pylinac / pylinac / core / geometry.py View on Github external
def bl_corner(self) -> Point:
        """The location of the bottom left corner."""
        return Point(self.center.x - self.width / 2, self.center.y - self.height / 2, as_int=self._as_int)