Class: RTP::ControlPoint

Inherits:
Record
  • Object
show all
Defined in:
lib/rtp-connect/control_point.rb

Overview

Note:

Relations:

  • Parent: Field

  • Children: none

The ControlPoint class.

Constant Summary collapse

NR_SURPLUS_ATTRIBUTES =

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

198

Instance Attribute Summary collapse

Attributes inherited from Record

#attributes, #crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #load, #to_record, #to_s

Constructor Details

#initialize(parent) ⇒ ControlPoint

Creates a new ControlPoint.

Parameters:

  • parent (Record)

    a record which is used to determine the proper parent of this instance



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# 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

Instance Attribute Details

#collimator_angleObject

Returns the value of attribute collimator_angle.



32
33
34
# File 'lib/rtp-connect/control_point.rb', line 32

def collimator_angle
  @collimator_angle
end

#collimator_dirObject

Returns the value of attribute collimator_dir.



33
34
35
# File 'lib/rtp-connect/control_point.rb', line 33

def collimator_dir
  @collimator_dir
end

#collimator_x1Object

Returns the value of attribute collimator_x1.



36
37
38
# File 'lib/rtp-connect/control_point.rb', line 36

def collimator_x1
  @collimator_x1
end

#collimator_x2Object

Returns the value of attribute collimator_x2.



37
38
39
# File 'lib/rtp-connect/control_point.rb', line 37

def collimator_x2
  @collimator_x2
end

#collimator_y1Object

Returns the value of attribute collimator_y1.



40
41
42
# File 'lib/rtp-connect/control_point.rb', line 40

def collimator_y1
  @collimator_y1
end

#collimator_y2Object

Returns the value of attribute collimator_y2.



41
42
43
# File 'lib/rtp-connect/control_point.rb', line 41

def collimator_y2
  @collimator_y2
end

#control_pt_numberObject

Returns the value of attribute control_pt_number.



22
23
24
# File 'lib/rtp-connect/control_point.rb', line 22

def control_pt_number
  @control_pt_number
end

#couch_angleObject

Returns the value of attribute couch_angle.



45
46
47
# File 'lib/rtp-connect/control_point.rb', line 45

def couch_angle
  @couch_angle
end

#couch_dirObject

Returns the value of attribute couch_dir.



46
47
48
# File 'lib/rtp-connect/control_point.rb', line 46

def couch_dir
  @couch_dir
end

#couch_lateralObject

Returns the value of attribute couch_lateral.



43
44
45
# File 'lib/rtp-connect/control_point.rb', line 43

def couch_lateral
  @couch_lateral
end

#couch_longitudinalObject

Returns the value of attribute couch_longitudinal.



44
45
46
# File 'lib/rtp-connect/control_point.rb', line 44

def couch_longitudinal
  @couch_longitudinal
end

#couch_ped_dirObject

Returns the value of attribute couch_ped_dir.



48
49
50
# File 'lib/rtp-connect/control_point.rb', line 48

def couch_ped_dir
  @couch_ped_dir
end

#couch_pedestalObject

Returns the value of attribute couch_pedestal.



47
48
49
# File 'lib/rtp-connect/control_point.rb', line 47

def couch_pedestal
  @couch_pedestal
end

#couch_verticalObject

Returns the value of attribute couch_vertical.



42
43
44
# File 'lib/rtp-connect/control_point.rb', line 42

def couch_vertical
  @couch_vertical
end

#doserateObject

Returns the value of attribute doserate.



27
28
29
# File 'lib/rtp-connect/control_point.rb', line 27

def doserate
  @doserate
end

#energyObject

Returns the value of attribute energy.



26
27
28
# File 'lib/rtp-connect/control_point.rb', line 26

def energy
  @energy
end

#field_idObject

Returns the value of attribute field_id.



18
19
20
# File 'lib/rtp-connect/control_point.rb', line 18

def field_id
  @field_id
end

#field_xObject

Returns the value of attribute field_x.



35
36
37
# File 'lib/rtp-connect/control_point.rb', line 35

def field_x
  @field_x
end

#field_x_modeObject

Returns the value of attribute field_x_mode.



34
35
36
# File 'lib/rtp-connect/control_point.rb', line 34

def field_x_mode
  @field_x_mode
end

#field_yObject

Returns the value of attribute field_y.



39
40
41
# File 'lib/rtp-connect/control_point.rb', line 39

def field_y
  @field_y
end

#field_y_modeObject

Returns the value of attribute field_y_mode.



38
39
40
# File 'lib/rtp-connect/control_point.rb', line 38

def field_y_mode
  @field_y_mode
end

#gantry_angleObject

Returns the value of attribute gantry_angle.



30
31
32
# File 'lib/rtp-connect/control_point.rb', line 30

def gantry_angle
  @gantry_angle
end

#gantry_dirObject

Returns the value of attribute gantry_dir.



31
32
33
# File 'lib/rtp-connect/control_point.rb', line 31

def gantry_dir
  @gantry_dir
end

#iso_pos_xObject

Returns the value of attribute iso_pos_x.



49
50
51
# File 'lib/rtp-connect/control_point.rb', line 49

def iso_pos_x
  @iso_pos_x
end

#iso_pos_yObject

Returns the value of attribute iso_pos_y.



50
51
52
# File 'lib/rtp-connect/control_point.rb', line 50

def iso_pos_y
  @iso_pos_y
end

#iso_pos_zObject

Returns the value of attribute iso_pos_z.



51
52
53
# File 'lib/rtp-connect/control_point.rb', line 51

def iso_pos_z
  @iso_pos_z
end

#mlc_leavesObject

Returns the value of attribute mlc_leaves.



20
21
22
# File 'lib/rtp-connect/control_point.rb', line 20

def mlc_leaves
  @mlc_leaves
end

#mlc_lp_aObject

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



53
54
55
# File 'lib/rtp-connect/control_point.rb', line 53

def mlc_lp_a
  @mlc_lp_a
end

#mlc_lp_bObject

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



55
56
57
# File 'lib/rtp-connect/control_point.rb', line 55

def mlc_lp_b
  @mlc_lp_b
end

#mlc_shapeObject (readonly)

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



17
18
19
# File 'lib/rtp-connect/control_point.rb', line 17

def mlc_shape
  @mlc_shape
end

#mlc_typeObject

Returns the value of attribute mlc_type.



19
20
21
# File 'lib/rtp-connect/control_point.rb', line 19

def mlc_type
  @mlc_type
end

#monitor_unitsObject

Returns the value of attribute monitor_units.



24
25
26
# File 'lib/rtp-connect/control_point.rb', line 24

def monitor_units
  @monitor_units
end

#mu_conventionObject

Returns the value of attribute mu_convention.



23
24
25
# File 'lib/rtp-connect/control_point.rb', line 23

def mu_convention
  @mu_convention
end

#parentObject

The Record which this instance belongs to.



15
16
17
# File 'lib/rtp-connect/control_point.rb', line 15

def parent
  @parent
end

#scale_conventionObject

Returns the value of attribute scale_convention.



29
30
31
# File 'lib/rtp-connect/control_point.rb', line 29

def scale_convention
  @scale_convention
end

#ssdObject

Returns the value of attribute ssd.



28
29
30
# File 'lib/rtp-connect/control_point.rb', line 28

def ssd
  @ssd
end

#total_control_pointsObject

Returns the value of attribute total_control_points.



21
22
23
# File 'lib/rtp-connect/control_point.rb', line 21

def total_control_points
  @total_control_points
end

#wedge_positionObject

Returns the value of attribute wedge_position.



25
26
27
# File 'lib/rtp-connect/control_point.rb', line 25

def wedge_position
  @wedge_position
end

Class Method Details

.load(string, parent) ⇒ ControlPoint

Creates a new ControlPoint by parsing a RTPConnect string line.

Parameters:

  • string (#to_s)

    the control point definition record string line

  • parent (Record)

    a record which is used to determine the proper parent of this instance

Returns:

Raises:

  • (ArgumentError)

    if given a string containing an invalid number of elements



64
65
66
67
# File 'lib/rtp-connect/control_point.rb', line 64

def self.load(string, parent)
  cp = self.new(parent)
  cp.load(string)
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Checks for equality.

Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.

Parameters:

  • other

    an object to be compared with self.

Returns:

  • (Boolean)

    true if self and other are considered equivalent



132
133
134
135
136
# File 'lib/rtp-connect/control_point.rb', line 132

def ==(other)
  if other.respond_to?(:to_control_point)
    other.send(:state) == state
  end
end

#childrenArray

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.

Returns:

  • (Array)

    an emtpy array



145
146
147
148
# File 'lib/rtp-connect/control_point.rb', line 145

def children
  #return [@mlc_shape]
  return Array.new
end

#dcm_collimator_x1(scale = nil) ⇒ Float

Converts the collimator_x1 attribute to proper DICOM format.

Parameters:

  • scale (Symbol) (defaults to: nil)

    if set, relevant device parameters are converted from a native readout format to IEC1217 (supported values are :elekta & :varian)

Returns:

  • (Float)

    the DICOM-formatted collimator_x1 attribute



155
156
157
# 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) ⇒ Float

Converts the collimator_x2 attribute to proper DICOM format.

Parameters:

  • scale (Symbol) (defaults to: nil)

    if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian)

Returns:

  • (Float)

    the DICOM-formatted collimator_x2 attribute



164
165
166
167
# 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) ⇒ Float

Converts the collimator_y1 attribute to proper DICOM format.

Parameters:

  • scale (Symbol) (defaults to: nil)

    if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian)

Returns:

  • (Float)

    the DICOM-formatted collimator_y1 attribute



174
175
176
# 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) ⇒ Float

Converts the collimator_y2 attribute to proper DICOM format.

Parameters:

  • scale (Symbol) (defaults to: nil)

    if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian)

Returns:

  • (Float)

    the DICOM-formatted collimator_y2 attribute



183
184
185
186
# 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) ⇒ String

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

Parameters:

  • scale (Symbol) (defaults to: nil)

    if set, relevant device parameters are converted from native readout format to IEC1217 (supported values are :elekta & :varian)

Returns:

  • (String)

    the DICOM-formatted leaf pair positions



193
194
195
196
197
198
199
# 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

#hashFixnum

Note:

Two objects with the same attributes will have the same hash code.

Computes a hash code for this object.

Returns:

  • (Fixnum)

    the object’s hash code



207
208
209
# File 'lib/rtp-connect/control_point.rb', line 207

def hash
  state.hash
end

#indexFixnum

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

Returns:

  • (Fixnum)

    the control point’s index



216
217
218
# File 'lib/rtp-connect/control_point.rb', line 216

def index
  @parent.control_points.index(self)
end

#to_control_pointControlPoint

Returns self.

Returns:



271
272
273
# File 'lib/rtp-connect/control_point.rb', line 271

def to_control_point
  self
end

#valuesArray<String> Also known as: state

Note:

The CRC is not considered part of the actual values and is excluded.

Collects the values (attributes) of this instance.

Returns:

  • (Array<String>)

    an array of attributes (in the same order as they appear in the RTP string)



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# 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