Module: RTKIT

Includes:
Logging
Defined in:
lib/rtkit/data_set.rb,
lib/rtkit/roi.rb,
lib/rtkit/beam.rb,
lib/rtkit/dose.rb,
lib/rtkit/plan.rb,
lib/rtkit/frame.rb,
lib/rtkit/image.rb,
lib/rtkit/plane.rb,
lib/rtkit/setup.rb,
lib/rtkit/slice.rb,
lib/rtkit/study.rb,
lib/rtkit/series.rb,
lib/rtkit/staple.rb,
lib/rtkit/contour.rb,
lib/rtkit/logging.rb,
lib/rtkit/methods.rb,
lib/rtkit/patient.rb,
lib/rtkit/rt_dose.rb,
lib/rtkit/version.rb,
lib/rtkit/rt_image.rb,
lib/rtkit/bin_image.rb,
lib/rtkit/constants.rb,
lib/rtkit/selection.rb,
lib/rtkit/variables.rb,
lib/rtkit/bin_volume.rb,
lib/rtkit/collimator.rb,
lib/rtkit/coordinate.rb,
lib/rtkit/pixel_data.rb,
lib/rtkit/bin_matcher.rb,
lib/rtkit/dose_volume.rb,
lib/rtkit/image_series.rb,
lib/rtkit/control_point.rb,
lib/rtkit/structure_set.rb,
lib/rtkit/collimator_setup.rb,
lib/rtkit/dose_distribution.rb,
lib/rtkit/mixins/image_parent.rb

Overview

Copyright 2012 Christoffer Lervag

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Defined Under Namespace

Modules: ImageParent, Logging Classes: Beam, BinImage, BinMatcher, BinVolume, Collimator, CollimatorSetup, Contour, ControlPoint, Coordinate, DataSet, Dose, DoseDistribution, DoseVolume, Frame, Image, ImageSeries, Patient, PixelData, Plan, Plane, ROI, RTDose, RTImage, Selection, Series, Setup, Slice, Staple, StructureSet, Study

Constant Summary collapse

VERSION =

The RTKIT version string.

"0.7"
IMAGE_DATE =

Instance Creation Date.

'0008,0012'
IMAGE_TIME =

Instance Creation Time.

'0008,0013'
SOP_CLASS =

SOP Class UID.

'0008,0016'
SOP_UID =

SOP Instance UID.

'0008,0018'
STUDY_DATE =

Study Date.

'0008,0020'
SERIES_DATE =

Series Date.

'0008,0021'
STUDY_TIME =

Study Time.

'0008,0030'
SERIES_TIME =

Series Time.

'0008,0031'
MODALITY =

Modality.

'0008,0060'
STUDY_DESCR =

Study description.

'0008,1030'
SERIES_DESCR =

Series description.

'0008,103E'
REF_SOP_CLASS_UID =

Referenced SOP Class UID.

'0008,1150'
REF_SOP_UID =

Referenced SOP Instance UID.

'0008,1155'
PATIENTS_NAME =

Patient’s Name.

'0010,0010'
PATIENTS_ID =

Patient’s Name.

'0010,0020'
BIRTH_DATE =

Patient’s Name.

'0010,0030'
SEX =

Patient’s Name.

'0010,0040'
PATIENT_POSITION =

Patient Position.

'0018,5100'
STUDY_UID =

Study Instance UID.

'0020,000D'
SERIES_UID =

Series Instance UID.

'0020,000E'
STUDY_ID =

Study ID.

'0020,0010'
IMAGE_POSITION =

Image Position (Patient).

'0020,0032'
IMAGE_ORIENTATION =

Image Orientation (Patient):

'0020,0037'
FRAME_OF_REF =

Frame of Reference UID.

'0020,0052'
POS_REF_INDICATOR =

Position Reference Indicator.

'0020,1040'
NR_FRAMES =

Number of Frames.

'0028,0008'
ROWS =

Rows.

'0028,0010'
COLUMNS =

Columns.

'0028,0011'
SPACING =

Pixel Spacing.

'0028,0030'
IMAGE_PLANE_SPACING =

Image Plane Pixel Spacing.

'3002,0011'
RT_IMAGE_POSITION =

RT Image Position.

'3002,0012'
GRID_FRAME_OFFSETS =

Grid Frame Offset Vector.

'3004,000C'
DOSE_GRID_SCALING =

Dose Grid Scaling.

'3004,000E'
REF_FRAME_OF_REF_SQ =

Referenced Frame of Reference Sequence.

'3006,0010'
RT_REF_STUDY_SQ =

RT Referenced Study Sequence.

'3006,0012'
RT_REF_SERIES_SQ =

RT Referenced Series Sequence.

'3006,0014'
CONTOUR_IMAGE_SQ =

Contour Image Sequence.

'3006,0016'
STRUCTURE_SET_ROI_SQ =

Structure Set ROI Sequence.

'3006,0020'
ROI_NUMBER =

ROI Number.

'3006,0022'
REF_FRAME_OF_REF =

Referenced Frame of Reference UID.

'3006,0024'
ROI_NAME =

ROI Name.

'3006,0026'
ROI_COLOR =

ROI Display Color.

'3006,002A'
ROI_ALGORITHM =

ROI Generation Algorithm.

'3006,0036'
ROI_CONTOUR_SQ =

ROI Contour Sequence.

'3006,0039'
CONTOUR_SQ =

Contour Sequence.

'3006,0040'
CONTOUR_GEO_TYPE =

Contour Geometric Type.

'3006,0042'
NR_CONTOUR_POINTS =

Number of Contour Points.

'3006,0046'
CONTOUR_NUMBER =

Contour Number.

'3006,0048'
CONTOUR_DATA =

Contour Data.

'3006,0050'
RT_ROI_OBS_SQ =

RT ROI Observations Sequence.

'3006,0080'
OBS_NUMBER =

Obervation Number.

'3006,0082'
REF_ROI_NUMBER =

Referenced ROI Number.

'3006,0084'
ROI_TYPE =

RT ROI Interpreted Type.

'3006,00A4'
ROI_INTERPRETER =

ROI Interpreter.

'3006,00A6'
FRAME_OF_REF_REL_SQ =

Frame of Reference Relationship Sequence.

'3006,00C0'
FRACTION_GROUP_SQ =

Fraction Group Sequence.

'300A,0070'
FRACTION_GROUP_NUMBER =

Fraction Group Number.

'300A,0071'
BEAM_METERSET =

Beam Meterset.

'300A,0086'
BEAM_SQ =

Beam Sequence.

'300A,00B0'
MACHINE_NAME =

Treatment Machine Name.

'300A,00B2'
DOSIMETER_UNIT =

Primary Dosimeter Unit.

'300A,00B3'
SAD =

Source-Axis Distance.

'300A,00B4'
COLL_SQ =

RT Beam Limiting Device Sequence.

'300A,00B6'
COLL_TYPE =

RT Beam Limiting Device Type.

'300A,00B8'
NR_COLLIMATORS =

Number of Leaf/Jaw Pairs.

'300A,00BC'
COLL_BOUNDARIES =

Leaf Position Boundaries.

'300A,00BE'
BEAM_NUMBER =

Beam Number.

'300A,00C0'
BEAM_NAME =

Beam Name.

'300A,00C2'
BEAM_DESCR =

Beam Description.

'300A,00C3'
BEAM_TYPE =

Beam Type.

'300A,00C4'
RAD_TYPE =

Radiation Type.

'300A,00C6'
DELIVERY_TYPE =

Treatment Delivery Type.

'300A,00CE'
FINAL_METERSET_WEIGHT =

Final Cumulative Meterset Weight.

'300A,010E'
CONTROL_POINT_SQ =

Control Point Sequence.

'300A,0111'
CONTROL_POINT_INDEX =

Cumulative Meterset Weight.

'300A,0112'
BEAM_ENERGY =

Nominal Beam Energy.

'300A,0114'
COLL_POS_SQ =

RT Beam Limiting Device Type Sequence.

'300A,011A'
COLL_POS =

Leaf/Jaw Positions.

'300A,011C'
GANTRY_ANGLE =

Gantry Angle.

'300A,011E'
GANTRY_DIRECTION =

Gantry Rotation Direction.

'300A,011F'
COLL_ANGLE =

Beam Limiting Device Angle.

'300A,0120'
COLL_DIRECTION =

Beam Limiting Device Rotation Direction.

'300A,0121'
PEDESTAL_ANGLE =

Patient Support Angle.

'300A,0122'
PEDESTAL_DIRECTION =

Patient Support Rotation Direction.

'300A,0123'
TABLE_TOP_ANGLE =

Table Top Eccentric Angle.

'300A,0125'
TABLE_TOP_DIRECTION =

Table Top Eccentric Rotation Direction.

'300A,0126'
TABLE_TOP_VERTICAL =

Table Top Vertical Position.

'300A,0128'
TABLE_TOP_LONGITUDINAL =

Table Top Longitudinal Position.

'300A,0129'
TABLE_TOP_LATERAL =

Table Top Lateral Position.

'300A,012A'
ISO_POS =

Isocenter Position.

'300A,012C'
SSD =

Source to Surface Distance.

'300A,0130'
CUM_METERSET_WEIGHT =

Cumulative Meterset Weight.

'300A,0134'
PATIENT_SETUP_SQ =

Patient Setup Sequence.

'300A,0180'
PATIENT_SETUP_NUMBER =

Patient Setup Number.

'300A,0182'
SETUP_TECHNIQUE =

Setup technique.

'300A,01B0'
OFFSET_VERTICAL =

Table Top Vertical Setup Displacement.

'300A,01D2'
OFFSET_LONG =

Table Top Longitudinal Setup Displacement.

'300A,01D4'
OFFSET_LATERAL =

Table Top Lateral Setup Displacement.

'300A,01D6'
REF_PLAN_SQ =

Referenced RT Plan Sequence.

'300C,0002'
REF_BEAM_SQ =

Referenced Beam Sequence.

'300C,0004'
REF_BEAM_NUMBER =

Referenced Beam Number.

'300C,0006'
REF_STRUCT_SQ =

Referenced Structure Set Sequence.

'300C,0060'
IMAGE_SERIES =

The modalities that contain multiple images per series.

['CT', 'MR']
IMAGE_MODALITIES =

The modalities that contain pixel data:

['CT', 'MR', 'RTDOSE', 'RTIMAGE']
SUPPORTED_MODALITIES =

The modalities supported by RTKIT.

['CT', 'MR', 'RTDOSE', 'RTIMAGE', 'RTPLAN', 'RTSTRUCT']

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Logging

included, #logger

Class Attribute Details

.contour_algorithmObject

The algorithm used for contouring a filled area.



10
11
12
# File 'lib/rtkit/variables.rb', line 10

def contour_algorithm
  @contour_algorithm
end

.dicom_rootObject

The DICOM Root used when generation UIDs.



12
13
14
# File 'lib/rtkit/variables.rb', line 12

def dicom_root
  @dicom_root
end

Class Method Details

.files(path_or_paths) ⇒ Object

Finds all files contained in the specified folder or folders (including any sub-folders). Returns an array containing the discovered file strings.

Parameters

  • path_or_paths – String or Array of strings. The path(s) in which to find all files.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rtkit/methods.rb', line 16

def files(path_or_paths)
  raise ArgumentError, "Invalid argument 'path_or_paths'. Expected String or Array, got #{paths.class}." unless [String, Array].include?(path_or_paths.class)
  raise ArgumentError, "Invalid argument 'path_or_paths'. Expected Array to contain only strings, got #{path_or_paths.collect{|p| p.class}.uniq}." if path_or_paths.is_a?(Array) && path_or_paths.collect{|p| p.class}.uniq != [String]
  paths = path_or_paths.is_a?(Array) ? path_or_paths : [path_or_paths]
  files = Array.new
  # Iterate the folders (and their subfolders) to extract all files:
  for dir in paths
    Find.find(dir) do |path|
      if FileTest.directory?(path)
        next
      else
        # Store the file in our array:
        files << path
      end
    end
  end
  return files
end

.frame_uidObject

Generates and returns a random Frame Instance UID string.



37
38
39
# File 'lib/rtkit/methods.rb', line 37

def frame_uid
  return self.generate_uids('9').first
end

.generate_uids(prefix, instances = 1) ⇒ Object

Generates one or several random UID strings. The UIDs are based on the RTKIT dicom_root attribute, a type prefix, a datetime part, a random number part, and an index part (when multiple UIDs are requested, e.g. for a SOP Instances in a Series). Returns the UIDs in a string array.

Parameters

  • prefix – String. A (numerical) type string which sits between the dicom root and the random part of the UID.

  • instances – Integer. The number of UIDs to generate. Defaults to 1.

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rtkit/methods.rb', line 52

def generate_uids(prefix, instances=1)
  raise ArgumentError, "Invalid argument 'prefix'. Expected (integer) String, got #{prefix.class}." unless prefix.is_a?(String)
  raise ArgumentError, "Invalid argument 'instances'. Expected Integer (when defined), got #{instances.class}." if instances && !instances.is_a?(Integer)
  raise ArgumentError, "Invalid argument 'prefix'. Expected non-zero Integer (String), got #{prefix}." if prefix.to_i == 0
  raise ArgumentError, "Invalid argument 'instances'. Expected positive Integer (when defined), got #{instances}." if instances && instances < 0
  prefix = prefix.to_i
  # NB! For UIDs, leading zeroes after a dot is not allowed, and must be removed:
  date = Time.now.strftime("%Y%m%d").to_i.to_s
  time = Time.now.strftime("%H%M%S").to_i.to_s
  random = rand(99999) + 1 # (Minimum 1, max. 99999)
  base_uid = [RTKIT.dicom_root, prefix, date, time, random].join('.')
  uids = Array.new
  if instances == 1
    uids << base_uid
  else
    (1..instances).to_a.each do |i|
      uids << "#{base_uid}.#{i}"
    end
  end
  return uids
end

.series_uidObject

Generates and returns a random Series Instance UID string.



76
77
78
# File 'lib/rtkit/methods.rb', line 76

def series_uid
  return self.generate_uids('2').first
end

.sop_uidObject

Generates and returns a random SOP Instance UID string.



82
83
84
# File 'lib/rtkit/methods.rb', line 82

def sop_uid
  return self.generate_uids('3').first
end

.sop_uids(instances) ⇒ Object

Generates and returns a collection of random SOP Instance UID strings.

Parameters

  • instances – Integer. The number of UIDs to generate.

Raises:

  • (ArgumentError)


92
93
94
95
# File 'lib/rtkit/methods.rb', line 92

def sop_uids(instances)
  raise ArgumentError, "Invalid argument 'instances'. Expected Integer, got #{instances.class}." unless instances.is_a?(Integer)
  return self.generate_uids('3', instances)
end

.study_uidObject

Generates and returns a random Study Instance UID string.



99
100
101
# File 'lib/rtkit/methods.rb', line 99

def study_uid
  return self.generate_uids('1').first
end