Class: RTKIT::Collimator
- Inherits:
-
Object
- Object
- RTKIT::Collimator
- Defined in:
- lib/rtkit/collimator.rb
Overview
Contains DICOM data and methods related to a RT Beam Limiting Device item, defined in a Beam.
Relations
-
A Beam has many Collimators.
Instance Attribute Summary collapse
-
#beam ⇒ Object
readonly
The Beam that the CollimatorSetup is defined for.
-
#boundaries ⇒ Object
Collimator boundaries (for multi leaf collimators only: the number of boundaries equals the number of leaves + 1).
-
#num_pairs ⇒ Object
The number of Leaf/Jaw (Collimator) Pairs.
-
#type ⇒ Object
Collimator type.
Class Method Summary collapse
-
.create_from_item(coll_item, beam) ⇒ Object
Creates a new Collimator instance from the RT Beam Limiting Device 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, num_pairs, beam, options = {}) ⇒ Collimator
constructor
Creates a new Collimator instance.
-
#to_collimator ⇒ Object
Returns self.
-
#to_item ⇒ Object
Creates and returns a Beam Limiting Device Sequence Item from the attributes of the Collimator.
Constructor Details
#initialize(type, num_pairs, beam, options = {}) ⇒ Collimator
Creates a new Collimator instance.
Parameters
-
type
– String. The RT Beam Limiting Device Type. -
num_pairs
– Integer. The Number of Leaf/Jaw Pairs. -
beam
– The Beam instance that this Collimator belongs to. -
options
– A hash of parameters.
Options
-
:boundaries
– Array/String. The Leaf Position Boundaries (300A,00BE). Defaults to nil.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rtkit/collimator.rb', line 55 def initialize(type, num_pairs, beam, ={}) raise ArgumentError, "Invalid argument 'beam'. Expected Beam, got #{beam.class}." unless beam.is_a?(Beam) # Set values: self.type = type self.num_pairs = num_pairs self.boundaries = [:boundaries] # Set references: @beam = beam # Register ourselves with the Beam: @beam.add_collimator(self) end |
Instance Attribute Details
#beam ⇒ Object (readonly)
The Beam that the CollimatorSetup is defined for.
13 14 15 |
# File 'lib/rtkit/collimator.rb', line 13 def beam @beam end |
#boundaries ⇒ Object
Collimator boundaries (for multi leaf collimators only: the number of boundaries equals the number of leaves + 1).
15 16 17 |
# File 'lib/rtkit/collimator.rb', line 15 def boundaries @boundaries end |
#num_pairs ⇒ Object
The number of Leaf/Jaw (Collimator) Pairs.
17 18 19 |
# File 'lib/rtkit/collimator.rb', line 17 def num_pairs @num_pairs end |
#type ⇒ Object
Collimator type.
19 20 21 |
# File 'lib/rtkit/collimator.rb', line 19 def type @type end |
Class Method Details
.create_from_item(coll_item, beam) ⇒ Object
Creates a new Collimator instance from the RT Beam Limiting Device item of the RTPlan file. Returns the Collimator instance.
Parameters
-
coll_item
– The patient setup item from the DObject of a RTPlan file. -
beam
– The Beam instance that this Collimator belongs to.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rtkit/collimator.rb', line 29 def self.create_from_item(coll_item, beam) raise ArgumentError, "Invalid argument 'coll_item'. Expected DICOM::Item, got #{coll_item.class}." unless coll_item.is_a?(DICOM::Item) raise ArgumentError, "Invalid argument 'beam'. Expected Beam, got #{beam.class}." unless beam.is_a?(Beam) = Hash.new # Values from the Beam Limiting Device Type Item: type = coll_item.value(COLL_TYPE) num_pairs = coll_item.value(NR_COLLIMATORS) boundaries = coll_item.value(COLL_BOUNDARIES) # Create the Collimator instance: c = self.new(type, num_pairs, beam, :boundaries => boundaries) 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.
69 70 71 72 73 |
# File 'lib/rtkit/collimator.rb', line 69 def ==(other) if other.respond_to?(:to_collimator) other.send(:state) == state end end |
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
79 80 81 |
# File 'lib/rtkit/collimator.rb', line 79 def hash state.hash end |
#to_collimator ⇒ Object
Returns self.
131 132 133 |
# File 'lib/rtkit/collimator.rb', line 131 def to_collimator self end |
#to_item ⇒ Object
Creates and returns a Beam Limiting Device Sequence Item from the attributes of the Collimator.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rtkit/collimator.rb', line 86 def to_item item = DICOM::Item.new item.add(DICOM::Element.new(ROI_COLOR, @color)) s = DICOM::Sequence.new(CONTOUR_SQ) item.add(s) item.add(DICOM::Element.new(REF_ROI_NUMBER, @number.to_s)) # Add Contour items to the Contour Sequence (one or several items per Slice): @slices.each do |slice| slice.contours.each do |contour| s.add_item(contour.to_item) end end return item end |