class RTP::ControlPoint

The ControlPoint class.

@note Relations:

* Parent: Field
* Children: none

Constants

NR_SURPLUS_ATTRIBUTES

The number of attributes not having their own variable for this record (200 - 2).

Attributes

collimator_angle[R]
collimator_dir[R]
collimator_x1[R]
collimator_x2[R]
collimator_y1[R]
collimator_y2[R]
control_pt_number[R]
couch_angle[R]
couch_dir[R]
couch_lateral[R]
couch_longitudinal[R]
couch_ped_dir[R]
couch_pedestal[R]
couch_vertical[R]
doserate[R]
energy[R]
field_id[R]
field_x[R]
field_x_mode[R]
field_y[R]
field_y_mode[R]
gantry_angle[R]
gantry_dir[R]
iso_pos_x[R]
iso_pos_y[R]
iso_pos_z[R]
mlc_leaves[R]
mlc_lp_a[R]

Note: This attribute contains an array of all MLC LP A values (leaves 1..100).

mlc_lp_b[R]

Note: This attribute contains an array of all MLC LP B values (leaves 1..100).

mlc_shape[R]

The MLC shape record (if any) that belongs to this ControlPoint.

mlc_type[R]
monitor_units[R]
mu_convention[R]
parent[RW]

The Record which this instance belongs to.

scale_convention[R]
ssd[R]
total_control_points[R]
wedge_position[R]

Public Class Methods

load(string, parent) click to toggle source

Creates a new ControlPoint by parsing a RTPConnect string line.

@param [#to_s] string the control point definition record string line @param [Record] parent a record which is used to determine the proper parent of this instance @return [ControlPoint] the created ControlPoint instance @raise [ArgumentError] if given a string containing an invalid number of elements

# File lib/rtp-connect/control_point.rb, line 64
def self.load(string, parent)
  cp = self.new(parent)
  cp.load(string)
end
new(parent) click to toggle source

Creates a new ControlPoint.

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

Calls superclass method
# File lib/rtp-connect/control_point.rb, line 73
def initialize(parent)
  super('CONTROL_PT_DEF', 233, 236)
  # Child:
  @mlc_shape = nil
  # Parent relation (may get more than one type of record here):
  @parent = get_parent(parent.to_record, Field)
  @parent.add_control_point(self)
  @mlc_lp_a = Array.new(100)
  @mlc_lp_b = Array.new(100)
  @attributes = [
    # Required:
    :keyword,
    :field_id,
    :mlc_type,
    :mlc_leaves,
    :total_control_points,
    :control_pt_number,
    :mu_convention,
    :monitor_units,
    :wedge_position,
    :energy,
    :doserate,
    :ssd,
    :scale_convention,
    :gantry_angle,
    :gantry_dir,
    :collimator_angle,
    :collimator_dir,
    :field_x_mode,
    :field_x,
    :collimator_x1,
    :collimator_x2,
    :field_y_mode,
    :field_y,
    :collimator_y1,
    :collimator_y2,
    :couch_vertical,
    :couch_lateral,
    :couch_longitudinal,
    :couch_angle,
    :couch_dir,
    :couch_pedestal,
    :couch_ped_dir,
    :iso_pos_x,
    :iso_pos_y,
    :iso_pos_z,
    :mlc_lp_a,
    :mlc_lp_b
  ]
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/control_point.rb, line 132
def ==(other)
  if other.respond_to?(:to_control_point)
    other.send(:state) == state
  end
end
Also aliased as: eql?
children() click to toggle source

As of now, gives an empty array. However, by definition, this record may have an mlc shape record as child, but this is not implemented yet.

@return [Array] an emtpy array

# File lib/rtp-connect/control_point.rb, line 145
def children
  #return [@mlc_shape]
  return Array.new
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/control_point.rb, line 411
def collimator_angle=(value)
  @collimator_angle = value && value.to_s.strip
end
collimator_dir=(value) click to toggle source

Sets the collimator_dir attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 419
def collimator_dir=(value)
  @collimator_dir = value && value.to_s
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/control_point.rb, line 443
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/control_point.rb, line 451
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/control_point.rb, line 475
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/control_point.rb, line 483
def collimator_y2=(value)
  @collimator_y2 = value && value.to_s.strip
end
control_pt_number=(value) click to toggle source

Sets the control_pt_number attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 331
def control_pt_number=(value)
  @control_pt_number = value && value.to_s.strip
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/control_point.rb, line 515
def couch_angle=(value)
  @couch_angle = value && value.to_s.strip
end
couch_dir=(value) click to toggle source

Sets the couch_dir attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 523
def couch_dir=(value)
  @couch_dir = value && value.to_s
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/control_point.rb, line 499
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/control_point.rb, line 507
def couch_longitudinal=(value)
  @couch_longitudinal = value && value.to_s.strip
end
couch_ped_dir=(value) click to toggle source

Sets the couch_ped_dir attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 539
def couch_ped_dir=(value)
  @couch_ped_dir = value && value.to_s
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/control_point.rb, line 531
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/control_point.rb, line 491
def couch_vertical=(value)
  @couch_vertical = value && value.to_s.strip
end
dcm_collimator_x1(scale=nil) click to toggle source

Converts the collimator_x1 attribute to proper DICOM format.

@param [Symbol] scale if set, relevant device parameters are converted from a native readout format to IEC1217 (supported values are :elekta & :varian) @return [Float] the DICOM-formatted collimator_x1 attribute

# File lib/rtp-connect/control_point.rb, line 155
def dcm_collimator_x1(scale=nil)
  dcm_collimator_1(scale, default_axis=:x)
end
dcm_collimator_x2(scale=nil) click to toggle source

Converts the collimator_x2 attribute to proper DICOM format.

@param [Symbol] scale if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian) @return [Float] the DICOM-formatted collimator_x2 attribute

# File lib/rtp-connect/control_point.rb, line 164
def dcm_collimator_x2(scale=nil)
  axis = (scale == :elekta ? :y : :x)
  dcm_collimator(axis, coeff=1, side=2)
end
dcm_collimator_y1(scale=nil) click to toggle source

Converts the collimator_y1 attribute to proper DICOM format.

@param [Symbol] scale if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian) @return [Float] the DICOM-formatted collimator_y1 attribute

# File lib/rtp-connect/control_point.rb, line 174
def dcm_collimator_y1(scale=nil)
  dcm_collimator_1(scale, default_axis=:y)
end
dcm_collimator_y2(scale=nil) click to toggle source

Converts the collimator_y2 attribute to proper DICOM format.

@param [Symbol] scale if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian) @return [Float] the DICOM-formatted collimator_y2 attribute

# File lib/rtp-connect/control_point.rb, line 183
def dcm_collimator_y2(scale=nil)
  axis = (scale == :elekta ? :x : :y)
  dcm_collimator(axis, coeff=1, side=2)
end
dcm_mlc_positions(scale=nil) click to toggle source

Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string.

@param [Symbol] scale if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian) @return [String] the DICOM-formatted leaf pair positions

# File lib/rtp-connect/control_point.rb, line 193
def dcm_mlc_positions(scale=nil)
  coeff = (scale == :elekta ? -1 : 1)
  # As with the collimators, the first side (1/a) may need scale invertion:
  pos_a = @mlc_lp_a.collect{|p| (p.to_f * 10 * coeff).round(1) unless p.empty?}.compact
  pos_b = @mlc_lp_b.collect{|p| (p.to_f * 10).round(1) unless p.empty?}.compact
  (pos_a + pos_b).join("\\")
end
doserate=(value) click to toggle source

Sets the doserate attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 371
def doserate=(value)
  @doserate = value && value.to_s.strip
end
energy=(value) click to toggle source

Sets the energy attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 363
def energy=(value)
  @energy = value && value.to_s
end
eql?(other)
Alias for: ==
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/control_point.rb, line 299
def field_id=(value)
  @field_id = 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/control_point.rb, line 435
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/control_point.rb, line 427
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/control_point.rb, line 467
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/control_point.rb, line 459
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/control_point.rb, line 395
def gantry_angle=(value)
  @gantry_angle = value && value.to_s.strip
end
gantry_dir=(value) click to toggle source

Sets the gantry_dir attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 403
def gantry_dir=(value)
  @gantry_dir = value && value.to_s
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/control_point.rb, line 207
def hash
  state.hash
end
index() click to toggle source

Gives the index of this ControlPoint (i.e. its index among the control points belonging to the parent Field).

@return [Fixnum] the control point's index

# File lib/rtp-connect/control_point.rb, line 216
def index
  @parent.control_points.index(self)
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/control_point.rb, line 547
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/control_point.rb, line 555
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/control_point.rb, line 563
def iso_pos_z=(value)
  @iso_pos_z = value && value.to_s.strip
end
mlc_leaves=(value) click to toggle source

Sets the mlc_leaves attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 315
def mlc_leaves=(value)
  @mlc_leaves = value && value.to_s.strip
end
mlc_lp_a=(array) click to toggle source

Sets the mlc_lp_a attribute.

@note As opposed to the ordinary (string) attributes, this attribute

contains an array holding all 100 MLC leaf 'A' string values.

@param [Array<nil, to_s>] array the new attribute values

# File lib/rtp-connect/control_point.rb, line 281
def mlc_lp_a=(array)
  @mlc_lp_a = array.to_a.validate_and_process(100)
end
mlc_lp_b=(array) click to toggle source

Sets the mlc_lp_b attribute.

@note As opposed to the ordinary (string) attributes, this attribute

contains an array holding all 100 MLC leaf 'B' string values.

@param [Array<nil, to_s>] array the new attribute values

# File lib/rtp-connect/control_point.rb, line 291
def mlc_lp_b=(array)
  @mlc_lp_b = array.to_a.validate_and_process(100)
end
mlc_type=(value) click to toggle source

Sets the mlc_type attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 307
def mlc_type=(value)
  @mlc_type = value && value.to_s
end
monitor_units=(value) click to toggle source

Sets the monitor_units attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 347
def monitor_units=(value)
  @monitor_units = value && value.to_s
end
mu_convention=(value) click to toggle source

Sets the mu_convention attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 339
def mu_convention=(value)
  @mu_convention = value && value.to_s
end
scale_convention=(value) click to toggle source

Sets the scale_convention attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 387
def scale_convention=(value)
  @scale_convention = value && value.to_s
end
ssd=(value) click to toggle source

Sets the ssd attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 379
def ssd=(value)
  @ssd = value && value.to_s
end
to_control_point() click to toggle source

Returns self.

@return [ControlPoint] self

# File lib/rtp-connect/control_point.rb, line 271
def to_control_point
  self
end
total_control_points=(value) click to toggle source

Sets the total_control_points attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 323
def total_control_points=(value)
  @total_control_points = value && value.to_s.strip
end
values() click to toggle source

Collects the values (attributes) of this instance.

@note The CRC is not considered part of the actual values and is excluded. @return [Array<String>] an array of attributes (in the same order as they appear in the RTP string)

# File lib/rtp-connect/control_point.rb, line 225
def values
  [
    @keyword,
    @field_id,
    @mlc_type,
    @mlc_leaves,
    @total_control_points,
    @control_pt_number,
    @mu_convention,
    @monitor_units,
    @wedge_position,
    @energy,
    @doserate,
    @ssd,
    @scale_convention,
    @gantry_angle,
    @gantry_dir,
    @collimator_angle,
    @collimator_dir,
    @field_x_mode,
    @field_x,
    @collimator_x1,
    @collimator_x2,
    @field_y_mode,
    @field_y,
    @collimator_y1,
    @collimator_y2,
    @couch_vertical,
    @couch_lateral,
    @couch_longitudinal,
    @couch_angle,
    @couch_dir,
    @couch_pedestal,
    @couch_ped_dir,
    @iso_pos_x,
    @iso_pos_y,
    @iso_pos_z,
    *@mlc_lp_a,
    *@mlc_lp_b
  ]
end
Also aliased as: state
wedge_position=(value) click to toggle source

Sets the wedge_position attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/control_point.rb, line 355
def wedge_position=(value)
  @wedge_position = value && value.to_s
end

Private Instance Methods

dcm_collimator(axis, coeff, nr) 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) @param [Integer] coeff a coeffecient (of -1 or 1) which the attribute is multiplied with @param [Integer] nr collimator side/index (1 or 2) @return [Float] the DICOM-formatted collimator attribute

# File lib/rtp-connect/control_point.rb, line 585
def dcm_collimator(axis, coeff, nr)
  mode = self.send("field_#{axis}_mode")
  if mode && !mode.empty?
    target = self
  else
    target = @parent
  end
  target.send("collimator_#{axis}#{nr}").to_f * 10 * coeff
end
dcm_collimator_1(scale=nil, axis) click to toggle source

Converts the collimator1 attribute to proper DICOM format.

@param [Symbol] scale if set, relevant device parameters are converted from a native readout format to IEC1217 (supported values are :elekta & :varian) @return [Float] the DICOM-formatted collimator_x1 attribute

# File lib/rtp-connect/control_point.rb, line 600
def dcm_collimator_1(scale=nil, axis)
  coeff = 1
  if scale == :elekta
    axis = (axis == :x ? :y : :x)
    coeff = -1
  elsif scale == :varian
    coeff = -1
  end
  dcm_collimator(axis, coeff, side=1)
end
import_indices(length) click to toggle source

Gives an array of indices indicating where the attributes of this record gets its values from in the comma separated string which the instance is created from.

@param [Integer] length the number of elements to create in the indices array

# File lib/rtp-connect/control_point.rb, line 616
def import_indices(length)
  # Note that this method is defined in the parent Record class, where it is
  # used for most record types. However, because this record has two attributes
  # which contain an array of values, we use a custom import_indices method.
  #
  # Furthermore, as of Mosaiq version 2.64, the RTP ControlPoint record includes
  # 3 new attributes: iso_pos_x/y/z. Since these (unfortunately) are not placed
  # at the end of the record (which is the norm), but rather inserted before the
  # MLC leaf positions, we have to take special care here to make sure that this
  # gets right for records where these are included or excluded.
  #
  # Override length:
  applied_length = 235
  ind = Array.new(applied_length - NR_SURPLUS_ATTRIBUTES) { |i| [i] }
  # Override indices for mlc_pl_a and mlc_lp_b:
  # Allocation here is dependent on the RTP file version:
  # For 2.62 and earlier, where length is 232, we dont have the 3 iso_pos_x/y/z values preceeding the mlc arrays leaf position arrays.
  # For 2.64 (and later), where length is 235, we have the 3 iso_pos_x/y/z values preceeding the mlc leaf position arrays.
  if length == 232
    ind[32] = nil
    ind[33] = nil
    ind[34] = nil
    ind[35] = (32..131).to_a
    ind[36] = (132..231).to_a
  else # (length = 235)
    ind[35] = (35..134).to_a
    ind[36] = (135..234).to_a
  end
  ind
end
state()

Collects the attributes of this instance.

@note The CRC is not considered part of the attributes of interest and is excluded @return [Array<String>] an array of attributes

Alias for: values