class RTP::Field

The treatment Field class.

@note Relations:

* Parent: Prescription
* Children: ExtendedField, ControlPoint

Attributes

arc_direction[R]
arc_mu_degree[R]
arc_start_angle[R]
arc_stop_angle[R]
block[R]
bolus[R]
collimator_angle[R]
collimator_x1[R]
collimator_x2[R]
collimator_y1[R]
collimator_y2[R]
compensator[R]
control_points[R]

An array of ControlPoint records (if any) that belongs to this Field.

couch_angle[R]
couch_lateral[R]
couch_longitudinal[R]
couch_pedestal[R]
couch_vertical[R]
doserate[R]
dynamic_wedge[R]
e_applicator[R]
e_field_def_aperture[R]
energy[R]
extended_field[R]

The ExtendedField record (if any) that belongs to this Field.

field_dose[R]
field_id[R]
field_monitor_units[R]
field_name[R]
field_note[R]
field_x[R]
field_x_mode[R]
field_y[R]
field_y_mode[R]
gantry_angle[R]
iso_pos_x[R]
iso_pos_y[R]
iso_pos_z[R]
modality[R]
parent[RW]

The Record which this instance belongs to.

portfilm_coeff_open[R]
portfilm_coeff_treat[R]
portfilm_delta_open[R]
portfilm_mu_open[R]
portfilm_mu_treat[R]
rx_site_name[R]
sad[R]
ssd[R]
time[R]
tolerance_table[R]
treatment_machine[R]
treatment_type[R]
wedge[R]
wedge_monitor_units[R]

Public Class Methods

load(string, parent) click to toggle source

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
new(parent) click to toggle source

Creates a new (treatment) Field.

@param [Record] parent a record which is used to determine the proper parent of this instance

Calls superclass method
# 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

==(other) click to toggle source

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
Also aliased as: eql?
add_control_point(child) click to toggle source

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
add_extended_field(child) click to toggle source

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
arc_direction=(value) click to toggle source

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
arc_mu_degree=(value) click to toggle source

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
arc_start_angle=(value) click to toggle source

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
arc_stop_angle=(value) click to toggle source

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
block=(value) click to toggle source

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
bolus=(value) click to toggle source

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
children() click to toggle source

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
collimator_angle=(value) click to toggle source

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
collimator_x1=(value) click to toggle source

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
collimator_x2=(value) click to toggle source

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
collimator_y1=(value) click to toggle source

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
collimator_y2=(value) click to toggle source

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
compensator=(value) click to toggle source

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
couch_angle=(value) click to toggle source

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
couch_lateral=(value) click to toggle source

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
couch_longitudinal=(value) click to toggle source

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
couch_pedestal=(value) click to toggle source

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
couch_vertical=(value) click to toggle source

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
dcm_collimator_x1() click to toggle source

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
dcm_collimator_x2() click to toggle source

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
dcm_collimator_y1() click to toggle source

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
dcm_collimator_y2() click to toggle source

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
delete(record) click to toggle source

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
delete_control_points() click to toggle source

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
delete_extended_field() click to toggle source

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
doserate=(value) click to toggle source

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
dynamic_wedge=(value) click to toggle source

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
e_applicator=(value) click to toggle source

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
e_field_def_aperture=(value) click to toggle source

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
energy=(value) click to toggle source

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
eql?(other)
Alias for: ==
field_dose=(value) click to toggle source

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
field_id=(value) click to toggle source

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
field_monitor_units=(value) click to toggle source

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
field_name=(value) click to toggle source

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
field_note=(value) click to toggle source

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
field_x=(value) click to toggle source

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
field_x_mode=(value) click to toggle source

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
field_y=(value) click to toggle source

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
field_y_mode=(value) click to toggle source

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
gantry_angle=(value) click to toggle source

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
hash() click to toggle source

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
iso_pos_x=(value) click to toggle source

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
iso_pos_y=(value) click to toggle source

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
iso_pos_z=(value) click to toggle source

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
modality=(value) click to toggle source

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
portfilm_coeff_open=(value) click to toggle source

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
portfilm_coeff_treat=(value) click to toggle source

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
portfilm_delta_open=(value) click to toggle source

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
portfilm_mu_open=(value) click to toggle source

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
portfilm_mu_treat=(value) click to toggle source

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
rx_site_name=(value) click to toggle source

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
sad=(value) click to toggle source

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
ssd=(value) click to toggle source

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
time=(value) click to toggle source

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
to_field() click to toggle source

Returns self.

@return [Field] self

# File lib/rtp-connect/field.rb, line 264
def to_field
  self
end
tolerance_table=(value) click to toggle source

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
treatment_machine=(value) click to toggle source

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
treatment_type=(value) click to toggle source

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
wedge=(value) click to toggle source

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
wedge_monitor_units=(value) click to toggle source

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

dcm_collimator1(axis) click to toggle source

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