Class: RTP::ControlPoint
- Defined in:
- lib/rtp-connect/control_point.rb
Overview
Relations:
-
Parent: Field
-
Children: none
The ControlPoint class.
Instance Attribute Summary collapse
-
#collimator_angle ⇒ Object
Returns the value of attribute collimator_angle.
-
#collimator_dir ⇒ Object
Returns the value of attribute collimator_dir.
-
#collimator_x1 ⇒ Object
Returns the value of attribute collimator_x1.
-
#collimator_x2 ⇒ Object
Returns the value of attribute collimator_x2.
-
#collimator_y1 ⇒ Object
Returns the value of attribute collimator_y1.
-
#collimator_y2 ⇒ Object
Returns the value of attribute collimator_y2.
-
#control_pt_number ⇒ Object
Returns the value of attribute control_pt_number.
-
#couch_angle ⇒ Object
Returns the value of attribute couch_angle.
-
#couch_dir ⇒ Object
Returns the value of attribute couch_dir.
-
#couch_lateral ⇒ Object
Returns the value of attribute couch_lateral.
-
#couch_longitudinal ⇒ Object
Returns the value of attribute couch_longitudinal.
-
#couch_ped_dir ⇒ Object
Returns the value of attribute couch_ped_dir.
-
#couch_pedestal ⇒ Object
Returns the value of attribute couch_pedestal.
-
#couch_vertical ⇒ Object
Returns the value of attribute couch_vertical.
-
#doserate ⇒ Object
Returns the value of attribute doserate.
-
#energy ⇒ Object
Returns the value of attribute energy.
-
#field_id ⇒ Object
Returns the value of attribute field_id.
-
#field_x ⇒ Object
Returns the value of attribute field_x.
-
#field_x_mode ⇒ Object
Returns the value of attribute field_x_mode.
-
#field_y ⇒ Object
Returns the value of attribute field_y.
-
#field_y_mode ⇒ Object
Returns the value of attribute field_y_mode.
-
#gantry_angle ⇒ Object
Returns the value of attribute gantry_angle.
-
#gantry_dir ⇒ Object
Returns the value of attribute gantry_dir.
-
#mlc_leaves ⇒ Object
Returns the value of attribute mlc_leaves.
-
#mlc_lp_a ⇒ Object
Note: This attribute contains an array of all MLC LP A values (leaves 1..100).
-
#mlc_lp_b ⇒ Object
Note: This attribute contains an array of all MLC LP B values (leaves 1..100).
-
#mlc_shape ⇒ Object
readonly
The MLC shape record (if any) that belongs to this ControlPoint.
-
#mlc_type ⇒ Object
Returns the value of attribute mlc_type.
-
#monitor_units ⇒ Object
Returns the value of attribute monitor_units.
-
#mu_convention ⇒ Object
Returns the value of attribute mu_convention.
-
#parent ⇒ Object
readonly
The Record which this instance belongs to.
-
#scale_convention ⇒ Object
Returns the value of attribute scale_convention.
-
#ssd ⇒ Object
Returns the value of attribute ssd.
-
#total_control_points ⇒ Object
Returns the value of attribute total_control_points.
-
#wedge_position ⇒ Object
Returns the value of attribute wedge_position.
Attributes inherited from Record
Class Method Summary collapse
-
.load(string, parent) ⇒ ControlPoint
Creates a new ControlPoint by parsing a RTPConnect string line.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks for equality.
-
#children ⇒ Array
As of now, gives an empty array.
-
#dcm_collimator_x1(scale = nil) ⇒ Float
Converts the collimator_x1 attribute to proper DICOM format.
-
#dcm_collimator_x2(scale = nil) ⇒ Float
Converts the collimator_x2 attribute to proper DICOM format.
-
#dcm_collimator_y1(scale = nil) ⇒ Float
Converts the collimator_y1 attribute to proper DICOM format.
-
#dcm_collimator_y2(scale = nil) ⇒ Float
Converts the collimator_y2 attribute to proper DICOM format.
-
#dcm_mlc_positions(scale = nil) ⇒ String
Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string.
-
#hash ⇒ Fixnum
Computes a hash code for this object.
-
#index ⇒ Fixnum
Gives the index of this ControlPoint (i.e. its index among the control points belonging to the parent Field).
-
#initialize(parent) ⇒ ControlPoint
constructor
Creates a new ControlPoint.
-
#to_control_point ⇒ ControlPoint
Returns self.
-
#to_s ⇒ String
(also: #to_str)
Encodes the ControlPoint object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.
-
#values ⇒ Array<String>
(also: #state)
Collects the values (attributes) of this instance.
Methods inherited from Record
#encode, #get_parent, #load, #to_record
Constructor Details
#initialize(parent) ⇒ ControlPoint
Creates a new ControlPoint.
67 68 69 70 71 72 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 |
# File 'lib/rtp-connect/control_point.rb', line 67 def initialize(parent) super('CONTROL_PT_DEF', 233, 233) # 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, :mlc_lp_a, :mlc_lp_b ] end |
Instance Attribute Details
#collimator_angle ⇒ Object
Returns the value of attribute collimator_angle.
29 30 31 |
# File 'lib/rtp-connect/control_point.rb', line 29 def collimator_angle @collimator_angle end |
#collimator_dir ⇒ Object
Returns the value of attribute collimator_dir.
30 31 32 |
# File 'lib/rtp-connect/control_point.rb', line 30 def collimator_dir @collimator_dir end |
#collimator_x1 ⇒ Object
Returns the value of attribute collimator_x1.
33 34 35 |
# File 'lib/rtp-connect/control_point.rb', line 33 def collimator_x1 @collimator_x1 end |
#collimator_x2 ⇒ Object
Returns the value of attribute collimator_x2.
34 35 36 |
# File 'lib/rtp-connect/control_point.rb', line 34 def collimator_x2 @collimator_x2 end |
#collimator_y1 ⇒ Object
Returns the value of attribute collimator_y1.
37 38 39 |
# File 'lib/rtp-connect/control_point.rb', line 37 def collimator_y1 @collimator_y1 end |
#collimator_y2 ⇒ Object
Returns the value of attribute collimator_y2.
38 39 40 |
# File 'lib/rtp-connect/control_point.rb', line 38 def collimator_y2 @collimator_y2 end |
#control_pt_number ⇒ Object
Returns the value of attribute control_pt_number.
19 20 21 |
# File 'lib/rtp-connect/control_point.rb', line 19 def control_pt_number @control_pt_number end |
#couch_angle ⇒ Object
Returns the value of attribute couch_angle.
42 43 44 |
# File 'lib/rtp-connect/control_point.rb', line 42 def couch_angle @couch_angle end |
#couch_dir ⇒ Object
Returns the value of attribute couch_dir.
43 44 45 |
# File 'lib/rtp-connect/control_point.rb', line 43 def couch_dir @couch_dir end |
#couch_lateral ⇒ Object
Returns the value of attribute couch_lateral.
40 41 42 |
# File 'lib/rtp-connect/control_point.rb', line 40 def couch_lateral @couch_lateral end |
#couch_longitudinal ⇒ Object
Returns the value of attribute couch_longitudinal.
41 42 43 |
# File 'lib/rtp-connect/control_point.rb', line 41 def couch_longitudinal @couch_longitudinal end |
#couch_ped_dir ⇒ Object
Returns the value of attribute couch_ped_dir.
45 46 47 |
# File 'lib/rtp-connect/control_point.rb', line 45 def couch_ped_dir @couch_ped_dir end |
#couch_pedestal ⇒ Object
Returns the value of attribute couch_pedestal.
44 45 46 |
# File 'lib/rtp-connect/control_point.rb', line 44 def couch_pedestal @couch_pedestal end |
#couch_vertical ⇒ Object
Returns the value of attribute couch_vertical.
39 40 41 |
# File 'lib/rtp-connect/control_point.rb', line 39 def couch_vertical @couch_vertical end |
#doserate ⇒ Object
Returns the value of attribute doserate.
24 25 26 |
# File 'lib/rtp-connect/control_point.rb', line 24 def doserate @doserate end |
#energy ⇒ Object
Returns the value of attribute energy.
23 24 25 |
# File 'lib/rtp-connect/control_point.rb', line 23 def energy @energy end |
#field_id ⇒ Object
Returns the value of attribute field_id.
15 16 17 |
# File 'lib/rtp-connect/control_point.rb', line 15 def field_id @field_id end |
#field_x ⇒ Object
Returns the value of attribute field_x.
32 33 34 |
# File 'lib/rtp-connect/control_point.rb', line 32 def field_x @field_x end |
#field_x_mode ⇒ Object
Returns the value of attribute field_x_mode.
31 32 33 |
# File 'lib/rtp-connect/control_point.rb', line 31 def field_x_mode @field_x_mode end |
#field_y ⇒ Object
Returns the value of attribute field_y.
36 37 38 |
# File 'lib/rtp-connect/control_point.rb', line 36 def field_y @field_y end |
#field_y_mode ⇒ Object
Returns the value of attribute field_y_mode.
35 36 37 |
# File 'lib/rtp-connect/control_point.rb', line 35 def field_y_mode @field_y_mode end |
#gantry_angle ⇒ Object
Returns the value of attribute gantry_angle.
27 28 29 |
# File 'lib/rtp-connect/control_point.rb', line 27 def gantry_angle @gantry_angle end |
#gantry_dir ⇒ Object
Returns the value of attribute gantry_dir.
28 29 30 |
# File 'lib/rtp-connect/control_point.rb', line 28 def gantry_dir @gantry_dir end |
#mlc_leaves ⇒ Object
Returns the value of attribute mlc_leaves.
17 18 19 |
# File 'lib/rtp-connect/control_point.rb', line 17 def mlc_leaves @mlc_leaves end |
#mlc_lp_a ⇒ Object
Note: This attribute contains an array of all MLC LP A values (leaves 1..100).
47 48 49 |
# File 'lib/rtp-connect/control_point.rb', line 47 def mlc_lp_a @mlc_lp_a end |
#mlc_lp_b ⇒ Object
Note: This attribute contains an array of all MLC LP B values (leaves 1..100).
49 50 51 |
# File 'lib/rtp-connect/control_point.rb', line 49 def mlc_lp_b @mlc_lp_b end |
#mlc_shape ⇒ Object (readonly)
The MLC shape record (if any) that belongs to this ControlPoint.
14 15 16 |
# File 'lib/rtp-connect/control_point.rb', line 14 def mlc_shape @mlc_shape end |
#mlc_type ⇒ Object
Returns the value of attribute mlc_type.
16 17 18 |
# File 'lib/rtp-connect/control_point.rb', line 16 def mlc_type @mlc_type end |
#monitor_units ⇒ Object
Returns the value of attribute monitor_units.
21 22 23 |
# File 'lib/rtp-connect/control_point.rb', line 21 def monitor_units @monitor_units end |
#mu_convention ⇒ Object
Returns the value of attribute mu_convention.
20 21 22 |
# File 'lib/rtp-connect/control_point.rb', line 20 def mu_convention @mu_convention end |
#parent ⇒ Object (readonly)
The Record which this instance belongs to.
12 13 14 |
# File 'lib/rtp-connect/control_point.rb', line 12 def parent @parent end |
#scale_convention ⇒ Object
Returns the value of attribute scale_convention.
26 27 28 |
# File 'lib/rtp-connect/control_point.rb', line 26 def scale_convention @scale_convention end |
#ssd ⇒ Object
Returns the value of attribute ssd.
25 26 27 |
# File 'lib/rtp-connect/control_point.rb', line 25 def ssd @ssd end |
#total_control_points ⇒ Object
Returns the value of attribute total_control_points.
18 19 20 |
# File 'lib/rtp-connect/control_point.rb', line 18 def total_control_points @total_control_points end |
#wedge_position ⇒ Object
Returns the value of attribute wedge_position.
22 23 24 |
# File 'lib/rtp-connect/control_point.rb', line 22 def wedge_position @wedge_position end |
Class Method Details
.load(string, parent) ⇒ ControlPoint
Creates a new ControlPoint by parsing a RTPConnect string line.
58 59 60 61 |
# File 'lib/rtp-connect/control_point.rb', line 58 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.
123 124 125 126 127 |
# File 'lib/rtp-connect/control_point.rb', line 123 def ==(other) if other.respond_to?(:to_control_point) other.send(:state) == state end end |
#children ⇒ Array
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.
136 137 138 139 |
# File 'lib/rtp-connect/control_point.rb', line 136 def children #return [@mlc_shape] return Array.new end |
#dcm_collimator_x1(scale = nil) ⇒ Float
Converts the collimator_x1 attribute to proper DICOM format.
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/rtp-connect/control_point.rb', line 146 def dcm_collimator_x1(scale=nil) coeff = 1 axis = :x if scale == :elekta axis = :y coeff = -1 elsif scale == :varian coeff = -1 end dcm_collimator1(axis, coeff) end |
#dcm_collimator_x2(scale = nil) ⇒ Float
Converts the collimator_x2 attribute to proper DICOM format.
163 164 165 166 |
# File 'lib/rtp-connect/control_point.rb', line 163 def dcm_collimator_x2(scale=nil) axis = (scale == :elekta ? :y : :x) dcm_collimator2(axis, coeff=1) end |
#dcm_collimator_y1(scale = nil) ⇒ Float
Converts the collimator_y1 attribute to proper DICOM format.
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rtp-connect/control_point.rb', line 173 def dcm_collimator_y1(scale=nil) coeff = 1 axis = :y if scale == :elekta axis = :x coeff = -1 elsif scale == :varian coeff = -1 end dcm_collimator1(axis, coeff) end |
#dcm_collimator_y2(scale = nil) ⇒ Float
Converts the collimator_y2 attribute to proper DICOM format.
190 191 192 193 |
# File 'lib/rtp-connect/control_point.rb', line 190 def dcm_collimator_y2(scale=nil) axis = (scale == :elekta ? :x : :y) dcm_collimator2(axis, coeff=1) end |
#dcm_mlc_positions(scale = nil) ⇒ String
Converts the mlc_lp_a & mlc_lp_b attributes to a proper DICOM formatted string.
200 201 202 203 204 205 206 |
# File 'lib/rtp-connect/control_point.rb', line 200 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 |
#hash ⇒ Fixnum
Two objects with the same attributes will have the same hash code.
Computes a hash code for this object.
214 215 216 |
# File 'lib/rtp-connect/control_point.rb', line 214 def hash state.hash end |
#index ⇒ Fixnum
Gives the index of this ControlPoint (i.e. its index among the control points belonging to the parent Field).
223 224 225 |
# File 'lib/rtp-connect/control_point.rb', line 223 def index @parent.control_points.index(self) end |
#to_control_point ⇒ ControlPoint
Returns self.
275 276 277 |
# File 'lib/rtp-connect/control_point.rb', line 275 def to_control_point self end |
#to_s ⇒ String Also known as: to_str
Encodes the ControlPoint object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.
284 285 286 287 288 289 290 291 292 |
# File 'lib/rtp-connect/control_point.rb', line 284 def to_s str = encode if children children.each do |child| str += child.to_s end end return str end |
#values ⇒ Array<String> Also known as: state
The CRC is not considered part of the actual values and is excluded.
Collects the values (attributes) of this instance.
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 266 267 268 269 |
# File 'lib/rtp-connect/control_point.rb', line 232 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, *@mlc_lp_a, *@mlc_lp_b ] end |