class RTP::Field
The treatment Field
class.
@note Relations:
* Parent: Prescription * Children: ExtendedField, ControlPoint
Attributes
An array of ControlPoint
records (if any) that belongs to this Field
.
The ExtendedField
record (if any) that belongs to this Field
.
The Record
which this instance belongs to.
Public Class Methods
Creates a new (treatment) Field
by parsing a RTPConnect string line.
@param [#to_s] string the treatment field definition record string line @param [Record] parent a record which is used to determine the proper parent of this instance @return [Field] the created Field
instance @raise [ArgumentError] if given a string containing an invalid number of elements
# File lib/rtp-connect/field.rb, line 75 def self.load(string, parent) f = self.new(parent) f.load(string) end
Creates a new (treatment) Field
.
@param [Record] parent a record which is used to determine the proper parent of this instance
# File lib/rtp-connect/field.rb, line 84 def initialize(parent) super('FIELD_DEF', 27, 52) # Child records: @control_points = Array.new @extended_field = nil # Parent relation (may get more than one type of record here): @parent = get_parent(parent.to_record, Prescription) @parent.add_field(self) @attributes = [ # Required: :keyword, :rx_site_name, :field_name, :field_id, :field_note, :field_dose, :field_monitor_units, :wedge_monitor_units, :treatment_machine, :treatment_type, :modality, :energy, :time, :doserate, :sad, :ssd, :gantry_angle, :collimator_angle, :field_x_mode, :field_x, :collimator_x1, :collimator_x2, :field_y_mode, :field_y, :collimator_y1, :collimator_y2, # Optional: :couch_vertical, :couch_lateral, :couch_longitudinal, :couch_angle, :couch_pedestal, :tolerance_table, :arc_direction, :arc_start_angle, :arc_stop_angle, :arc_mu_degree, :wedge, :dynamic_wedge, :block, :compensator, :e_applicator, :e_field_def_aperture, :bolus, :portfilm_mu_open, :portfilm_coeff_open, :portfilm_delta_open, :portfilm_mu_treat, :portfilm_coeff_treat, :iso_pos_x, :iso_pos_y, :iso_pos_z ] end
Public Instance Methods
Checks for equality.
Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.
@param other an object to be compared with self. @return [Boolean] true if self and other are considered equivalent
# File lib/rtp-connect/field.rb, line 157 def ==(other) if other.respond_to?(:to_field) other.send(:state) == state end end
Adds a control point record to this instance.
@param [ControlPoint] child a ControlPoint
instance which is to be associated with self
# File lib/rtp-connect/field.rb, line 169 def add_control_point(child) @control_points << child.to_control_point child.parent = self end
Adds an extended treatment field record to this instance.
@param [ExtendedField] child an ExtendedField
instance which is to be associated with self
# File lib/rtp-connect/field.rb, line 178 def add_extended_field(child) @extended_field = child.to_extended_field child.parent = self end
Sets the arc_direction
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 520 def arc_direction=(value) @arc_direction = value && value.to_s end
Sets the arc_mu_degree
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 544 def arc_mu_degree=(value) @arc_mu_degree = value && value.to_s.strip end
Sets the arc_start_angle
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 528 def arc_start_angle=(value) @arc_start_angle = value && value.to_s.strip end
Sets the arc_stop_angle
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 536 def arc_stop_angle=(value) @arc_stop_angle = value && value.to_s.strip end
Sets the block attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 568 def block=(value) @block = value && value.to_s end
Sets the bolus attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 600 def bolus=(value) @bolus = value && value.to_s end
Collects the child records of this instance in a properly sorted array.
@return [Array<ExtendedField, ControlPoint>] a sorted array of self's child records
# File lib/rtp-connect/field.rb, line 187 def children return [@extended_field, @control_points].flatten.compact end
Sets the collimator_angle
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 400 def collimator_angle=(value) @collimator_angle = value && value.to_s.strip end
Sets the collimator_x1
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 424 def collimator_x1=(value) @collimator_x1 = value && value.to_s.strip end
Sets the collimator_x2
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 432 def collimator_x2=(value) @collimator_x2 = value && value.to_s.strip end
Sets the collimator_y1
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 456 def collimator_y1=(value) @collimator_y1 = value && value.to_s.strip end
Sets the collimator_y2
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 464 def collimator_y2=(value) @collimator_y2 = value && value.to_s.strip end
Sets the compensator attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 576 def compensator=(value) @compensator = value && value.to_s end
Sets the couch_angle
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 496 def couch_angle=(value) @couch_angle = value && value.to_s.strip.strip end
Sets the couch_lateral
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 480 def couch_lateral=(value) @couch_lateral = value && value.to_s.strip end
Sets the couch_longitudinal
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 488 def couch_longitudinal=(value) @couch_longitudinal = value && value.to_s.strip end
Sets the couch_pedestal
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 504 def couch_pedestal=(value) @couch_pedestal = value && value.to_s.strip end
Sets the couch_vertical
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 472 def couch_vertical=(value) @couch_vertical = value && value.to_s.strip end
Converts the collimator_x1
attribute to proper DICOM format.
@return [Float] the DICOM-formatted collimator_x1
attribute
# File lib/rtp-connect/field.rb, line 195 def dcm_collimator_x1 dcm_collimator1(:x) end
Converts the collimator_x2
attribute to proper DICOM format.
@return [Float] the DICOM-formatted collimator_x2
attribute
# File lib/rtp-connect/field.rb, line 203 def dcm_collimator_x2 value = @collimator_x2.to_f * 10 end
Converts the collimator_y1
attribute to proper DICOM format.
@return [Float] the DICOM-formatted collimator_y1
attribute
# File lib/rtp-connect/field.rb, line 211 def dcm_collimator_y1 dcm_collimator1(:y) end
Converts the collimator_y2
attribute to proper DICOM format.
@return [Float] the DICOM-formatted collimator_y2
attribute
# File lib/rtp-connect/field.rb, line 219 def dcm_collimator_y2 value = @collimator_y2.to_f * 10 end
Removes the reference of the given instance from this instance.
@param [ControlPoint, ExtendedField] record a child record to be removed from this instance
# File lib/rtp-connect/field.rb, line 227 def delete(record) case record when ControlPoint delete_child(:control_points, record) when ExtendedField delete_extended_field else logger.warn("Unknown class (record) given to Field#delete: #{record.class}") end end
Removes all control point references from this instance.
# File lib/rtp-connect/field.rb, line 240 def delete_control_points delete_children(:control_points) end
Removes the extended field reference from this instance.
# File lib/rtp-connect/field.rb, line 246 def delete_extended_field delete_child(:extended_field) end
Sets the doserate attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 368 def doserate=(value) @doserate = value && value.to_s.strip end
Sets the dynamic_wedge
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 560 def dynamic_wedge=(value) @dynamic_wedge = value && value.to_s end
Sets the e_applicator
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 584 def e_applicator=(value) @e_applicator = value && value.to_s end
Sets the e_field_def_aperture
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 592 def e_field_def_aperture=(value) @e_field_def_aperture = value && value.to_s end
Sets the energy attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 352 def energy=(value) @energy = value && value.to_s end
Sets the field_dose
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 304 def field_dose=(value) @field_dose = value && value.to_s.strip end
Sets the field_id
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 288 def field_id=(value) @field_id = value && value.to_s end
Sets the field_monitor_units
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 312 def field_monitor_units=(value) @field_monitor_units = value && value.to_s.strip end
Sets the field_name
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 280 def field_name=(value) @field_name = value && value.to_s end
Sets the field_note
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 296 def field_note=(value) @field_note = value && value.to_s end
Sets the field_x
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 416 def field_x=(value) @field_x = value && value.to_s.strip end
Sets the field_x_mode
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 408 def field_x_mode=(value) @field_x_mode = value && value.to_s end
Sets the field_y
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 448 def field_y=(value) @field_y = value && value.to_s.strip end
Sets the field_y_mode
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 440 def field_y_mode=(value) @field_y_mode = value && value.to_s end
Sets the gantry_angle
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 392 def gantry_angle=(value) @gantry_angle = value && value.to_s.strip end
Computes a hash code for this object.
@note Two objects with the same attributes will have the same hash code.
@return [Fixnum] the object's hash code
# File lib/rtp-connect/field.rb, line 256 def hash state.hash end
Sets the iso_pos_x
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 648 def iso_pos_x=(value) @iso_pos_x = value && value.to_s.strip end
Sets the iso_pos_y
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 656 def iso_pos_y=(value) @iso_pos_y = value && value.to_s.strip end
Sets the iso_pos_z
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 664 def iso_pos_z=(value) @iso_pos_z = value && value.to_s.strip end
Sets the modality attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 344 def modality=(value) @modality = value && value.to_s end
Sets the portfilm_coeff_open
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 616 def portfilm_coeff_open=(value) @portfilm_coeff_open = value && value.to_s end
Sets the portfilm_coeff_treat
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 640 def portfilm_coeff_treat=(value) @portfilm_coeff_treat = value && value.to_s end
Sets the portfilm_delta_open
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 624 def portfilm_delta_open=(value) @portfilm_delta_open = value && value.to_s end
Sets the portfilm_mu_open
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 608 def portfilm_mu_open=(value) @portfilm_mu_open = value && value.to_s end
Sets the portfilm_mu_treat
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 632 def portfilm_mu_treat=(value) @portfilm_mu_treat = value && value.to_s end
Sets the rx_site_name
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 272 def rx_site_name=(value) @rx_site_name = value && value.to_s end
Sets the sad attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 376 def sad=(value) @sad = value && value.to_s.strip end
Sets the ssd attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 384 def ssd=(value) @ssd = value && value.to_s.strip end
Sets the time attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 360 def time=(value) @time = value && value.to_s.strip end
Returns self.
@return [Field] self
# File lib/rtp-connect/field.rb, line 264 def to_field self end
Sets the tolerance_table
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 512 def tolerance_table=(value) @tolerance_table = value && value.to_s.strip end
Sets the treatment_machine
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 328 def treatment_machine=(value) @treatment_machine = value && value.to_s end
Sets the treatment_type
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 336 def treatment_type=(value) @treatment_type = value && value.to_s end
Sets the wedge attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 552 def wedge=(value) @wedge = value && value.to_s end
Sets the wedge_monitor_units
attribute.
@param [nil, to_s] value the new attribute value
# File lib/rtp-connect/field.rb, line 320 def wedge_monitor_units=(value) @wedge_monitor_units = value && value.to_s.strip end
Private Instance Methods
Converts the collimator attribute to proper DICOM format.
@param [Symbol] axis a representation for the axis of interest (x or y) @return [Float] the DICOM-formatted collimator attribute
# File lib/rtp-connect/field.rb, line 684 def dcm_collimator1(axis) value = self.send("collimator_#{axis}1").to_f * 10 mode = self.send("field_#{axis}_mode") if mode && mode.upcase == 'SYM' && value > 0 -value else value end end