Class: RTKIT::CollimatorSetup

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


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_pointObject (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

#positionsObject

Collimator pairs of positions.



15
16
17
# File 'lib/rtkit/collimator_setup.rb', line 15

def positions
  @positions
end

#typeObject

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.

Raises:

  • (ArgumentError)


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)
  options = 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

#hashObject

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_setupObject

Returns self.



100
101
102
# File 'lib/rtkit/collimator_setup.rb', line 100

def to_collimator_setup
  self
end

#to_itemObject

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