예제 #1
0
    def cax_line_projection(self):
        """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()
        UPPER_QUADRANT = self.gantry_angle <= 45 or self.gantry_angle >= 315 or 225 >= self.gantry_angle > 135
        LR_QUADRANT = 45 < self.gantry_angle <= 135 or 225 < self.gantry_angle < 315
        if UPPER_QUADRANT:
            p1.y = 2
            p2.y = -2
            p1.z = self.z_offset
            p2.z = self.z_offset
            p1.x = 2 * tan(self.gantry_angle) + self.x_offset * cos(self.gantry_angle)
            p2.x = - 2 * tan(self.gantry_angle) + self.x_offset * cos(self.gantry_angle)
        elif LR_QUADRANT:
            p1.x = 2
            p2.x = -2
            p1.z = self.z_offset
            p2.z = self.z_offset
            p1.y = 2 / tan(self.gantry_angle) + self.y_offset * cos(self.gantry_angle - 90)
            p2.y = - 2 / tan(self.gantry_angle) + self.y_offset * cos(self.gantry_angle - 90)
        l = Line(p1, p2)
        return l
예제 #2
0
 def _create_phantom_outline_object(self):
     """Construct the phantom outline object which will be plotted on the image for visual inspection."""
     outline_type = list(self.phantom_outline_object)[0]
     outline_settings = list(self.phantom_outline_object.values())[0]
     settings = {}
     if outline_type == 'Rectangle':
         side_a = self.phantom_radius*outline_settings['width ratio']
         side_b = self.phantom_radius*outline_settings['height ratio']
         half_hyp = np.sqrt(side_a**2 + side_b**2)/2
         internal_angle = ia = np.rad2deg(np.arctan(side_b/side_a))
         new_x = self.phantom_center.x + half_hyp*(geometry.cos(ia)-geometry.cos(ia+self.phantom_angle))
         new_y = self.phantom_center.y + half_hyp*(geometry.sin(ia)-geometry.sin(ia+self.phantom_angle))
         obj = Rectangle(width=self.phantom_radius*outline_settings['width ratio'],
                         height=self.phantom_radius*outline_settings['height ratio'],
                         center=Point(new_x, new_y))
         settings['angle'] = self.phantom_angle
     elif outline_type == 'Circle':
         obj = Circle(center_point=self.phantom_center,
                      radius=self.phantom_radius*outline_settings['radius ratio'])
     else:
         raise ValueError("An outline object was passed but was not a Circle or Rectangle.")
     return obj, settings
예제 #3
0
 def x_offset(self):
     """The offset or distance between the field CAX and BB in the x-direction (LR)."""
     return cos(self.gantry_angle) * self.cax2bb_vector.x