Class: RTKIT::CollimatorSetup
- Inherits:
-
Object
- Object
- RTKIT::CollimatorSetup
- Defined in:
- lib/rtkit/collimator_setup.rb
Overview
Contains DICOM data and methods related to a RT Beam Limiting Device Position item, defined in a ControlPoint.
Relations
-
A ControlPoint has many CollimatorSetups.
Instance Attribute Summary collapse
-
#control_point ⇒ Object
readonly
The ControlPoint that the Collimator is defined for.
-
#positions ⇒ Object
Collimator pairs of positions.
-
#type ⇒ Object
Collimator type.
Class Method Summary collapse
-
.create_from_item(coll_item, control_point) ⇒ Object
Creates a new CollimatorSetup instance from the RT Beam Limiting Device Position item of the RTPlan file.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Returns true if the argument is an instance with attributes equal to self.
-
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
-
#initialize(type, positions, control_point) ⇒ CollimatorSetup
constructor
Creates a new CollimatorSetup instance.
-
#to_collimator_setup ⇒ Object
Returns self.
-
#to_item ⇒ Object
Creates and returns a Beam Limiting Device Position Sequence Item from the attributes of the CollimatorSetup.
Constructor Details
#initialize(type, positions, control_point) ⇒ CollimatorSetup
Creates a new CollimatorSetup instance.
Parameters
-
type
– String. The RT Beam Limiting Device Type. -
positions
– Array. The collimator positions, organised in pairs of two values. -
control_point
– The ControlPoint instance that this CollimatorSetup belongs to.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rtkit/collimator_setup.rb', line 50 def initialize(type, positions, control_point) raise ArgumentError, "Invalid argument 'control_point'. Expected ControlPoint, got #{control_point.class}." unless control_point.is_a?(ControlPoint) # Set values: self.type = type self.positions = positions # Set references: @control_point = control_point # Register ourselves with the ControlPoint: @control_point.add_collimator(self) end |
Instance Attribute Details
#control_point ⇒ Object (readonly)
The ControlPoint that the Collimator is defined for.
13 14 15 |
# File 'lib/rtkit/collimator_setup.rb', line 13 def control_point @control_point end |
#positions ⇒ Object
Collimator pairs of positions.
15 16 17 |
# File 'lib/rtkit/collimator_setup.rb', line 15 def positions @positions end |
#type ⇒ Object
Collimator type.
17 18 19 |
# File 'lib/rtkit/collimator_setup.rb', line 17 def type @type end |
Class Method Details
.create_from_item(coll_item, control_point) ⇒ Object
Creates a new CollimatorSetup instance from the RT Beam Limiting Device Position item of the RTPlan file. Returns the CollimatorSetup instance.
Parameters
-
coll_item
– The RT Beam Limiting Device Position item from the DObject of a RTPlan file. -
control_point
– The ControlPoint instance that this CollimatorSetup belongs to.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rtkit/collimator_setup.rb', line 27 def self.create_from_item(coll_item, control_point) raise ArgumentError, "Invalid argument 'coll_item'. Expected DICOM::Item, got #{coll_item.class}." unless coll_item.is_a?(DICOM::Item) raise ArgumentError, "Invalid argument 'control_point'. Expected ControlPoint, got #{control_point.class}." unless control_point.is_a?(ControlPoint) = Hash.new # Values from the Beam Limiting Device Position Item: type = coll_item.value(COLL_TYPE) positions = coll_item.value(COLL_POS) #positions = coll_item.value(COLL_POS).split("\\").collect {|str| str.to_f} # Regroup the positions values so they appear in pairs: #positions = positions.each_slice(2).collect{|i| i}.transpose # Create the Collimator instance: c = self.new(type, positions, control_point) return c end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Returns true if the argument is an instance with attributes equal to self.
63 64 65 66 67 |
# File 'lib/rtkit/collimator_setup.rb', line 63 def ==(other) if other.respond_to?(:to_collimator_setup) other.send(:state) == state end end |
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
73 74 75 |
# File 'lib/rtkit/collimator_setup.rb', line 73 def hash state.hash end |
#to_collimator_setup ⇒ Object
Returns self.
100 101 102 |
# File 'lib/rtkit/collimator_setup.rb', line 100 def to_collimator_setup self end |
#to_item ⇒ Object
Creates and returns a Beam Limiting Device Position Sequence Item from the attributes of the CollimatorSetup.
107 108 109 110 111 112 |
# File 'lib/rtkit/collimator_setup.rb', line 107 def to_item item = DICOM::Item.new item.add(DICOM::Element.new(COLL_TYPE, @type)) item.add(DICOM::Element.new(COLL_POS, positions_string)) return item end |