idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
12,600
def find ( id ) return nil unless id meta = DCell . registry . get_node ( id ) DirectoryMeta . new ( id , meta ) end
Get the address for a particular Node ID
12,601
def add_collimator ( coll ) raise ArgumentError , "Invalid argument 'coll'. Expected CollimatorSetup, got #{coll.class}." unless coll . is_a? ( CollimatorSetup ) @collimators << coll unless @associated_collimators [ coll . type ] @associated_collimators [ coll . type ] = coll end
Adds a CollimatorSetup instance to this ControlPoint .
12,602
def load_pixel_data ( dcm ) raise ArgumentError , "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm . is_a? ( DICOM :: DObject ) raise ArgumentError , "Invalid argument 'dcm'. Expected modality 'RTIMAGE', got #{dcm.value(MODALITY)}." unless dcm . value ( MODALITY ) == 'RTIMAGE' @dcm = dcm @narray...
Transfers the pixel data as well as the related image properties and the DObject instance itself to the image instance .
12,603
def create_projection_image_dicom_scaffold unless @dcm create_general_dicom_image_scaffold @dcm . add_element ( RT_IMAGE_LABEL , @beam . description ) @dcm . add_element ( RT_IMAGE_NAME , @beam . name ) @dcm . add_element ( RT_IMAGE_DESCRIPTION , @beam . plan . name ) @dcm . add_element ( RT_IMAGE_PLANE , 'NORMAL' ) @d...
Creates a new DICOM object with a set of basic attributes needed for a valid DICOM file of modality RTIMAGE .
12,604
def d ( percent ) raise RangeError , "Argument 'percent' must be in the range [0-100]." if percent . to_f < 0 or percent . to_f > 100 d_index = ( ( @doses . length - 1 ) * ( 1 - percent . to_f * 0.01 ) ) . round return @doses [ d_index ] end
Calculates the dose that at least the specified percentage of the volume receives .
12,605
def v ( dose ) raise RangeError , "Argument 'dose' cannot be negative." if dose . to_f < 0 num_above = ( @doses . ge dose . to_f ) . where . length return num_above / @doses . length . to_f * 100 end
Calculates the percentage of the volume that receives a dose higher than or equal to the specified dose .
12,606
def size = ( * values ) values = values [ 0 ] if values . size == 1 && values [ 0 ] . is_a? ( Array ) @peer . set_size_styles ( values [ 0 ] , values [ 1 ] ) end
Sets the width and height styles of the Stage .
12,607
def location = ( * values ) values = values [ 0 ] if values . size == 1 && values [ 0 ] . is_a? ( Array ) @peer . set_location_styles ( values [ 0 ] , values [ 1 ] ) end
Sets the location styles of the Stage .
12,608
def alert ( message ) Thread . new do begin Java :: limelight . Context . instance . studio . utilities_production . alert ( message ) rescue StandardError => e puts "Error on alert: #{e}" end end end
Pops up a simple modal dialog with the provided message .
12,609
def add_image ( image ) raise ArgumentError , "Invalid argument 'image'. Expected Image, got #{image.class}." unless image . is_a? ( Image ) @images << image unless @frame . image ( image . uid ) @slices [ image . uid ] = image . pos_slice @image_positions [ image . pos_slice . round ( 2 ) ] = image @sop_uids [ image ....
Adds an Image to this ImageSeries .
12,610
def add_struct ( struct ) raise ArgumentError , "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct . is_a? ( StructureSet ) @structs << struct unless @associated_structs [ struct . uid ] @associated_structs [ struct . uid ] = struct end
Adds a StructureSet to this ImageSeries .
12,611
def match_image ( plane ) raise ArgumentError , "Invalid argument 'plane'. Expected Plane, got #{plane.class}." unless plane . is_a? ( Plane ) matching_image = nil planes_in_series = Array . new @images . each do | image | col_indices = NArray . to_na ( [ 0 , image . columns / 2 , image . columns - 1 ] ) row_indices = ...
Analyses the images belonging to this ImageSeries to determine if there is any image with a geometry that matches the specified plane .
12,612
def set_resolution ( columns , rows , options = { } ) @images . each do | img | img . set_resolution ( columns , rows , options ) end end
Sets the resolution of the associated images . The images will either be expanded or cropped depending on whether the specified resolution is bigger or smaller than the existing one .
12,613
def struct ( * args ) raise ArgumentError , "Expected one or none arguments, got #{args.length}." unless [ 0 , 1 ] . include? ( args . length ) if args . length == 1 raise ArgumentError , "Expected String (or nil), got #{args.first.class}." unless [ String , NilClass ] . include? ( args . first . class ) return @associ...
Gives the StructureSet instance mathcing the specified UID .
12,614
def coordinate ( i , j ) x = @pos . x + ( i * @delta_col * @cosines [ 0 ] ) + ( j * @delta_row * @cosines [ 3 ] ) y = @pos . y + ( i * @delta_col * @cosines [ 1 ] ) + ( j * @delta_row * @cosines [ 4 ] ) z = @pos . z + ( i * @delta_col * @cosines [ 2 ] ) + ( j * @delta_row * @cosines [ 5 ] ) Coordinate . new ( x , y , z...
Calculates the cartesian coordinate of the given pixel index pair .
12,615
def cosines = ( array ) raise ArgumentError , "Invalid parameter 'array'. Exactly 6 elements needed, got #{array.length}" unless array . length == 6 @cosines = array . collect { | val | val . to_f } end
Sets the cosines attribute .
12,616
def binary_image ( coords_x , coords_y , coords_z ) raise ArgumentError , "Invalid argument 'coords_x'. Expected at least 3 elements, got #{coords_x.length}" unless coords_x . length >= 3 raise ArgumentError , "Invalid argument 'coords_y'. Expected at least 3 elements, got #{coords_y.length}" unless coords_y . length >...
Creates a new SliceImage instance . The SOP Instance UID tag value is used to uniquely identify an image .
12,617
def to_dcm create_slice_image_dicom_scaffold update_dicom_image @dcm . add_element ( IMAGE_POSITION , [ @pos_x , @pos_y , @pos_slice ] . join ( "\\" ) ) @dcm . add_element ( SPACING , [ @row_spacing , @col_spacing ] . join ( "\\" ) ) @dcm . add_element ( IMAGE_ORIENTATION , [ @cosines ] . join ( "\\" ) ) @dcm end
Converts the Image instance to a DICOM object .
12,618
def to_roi ( struct , options = { } ) raise ArgumentError , "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct . is_a? ( StructureSet ) algorithm = options [ :algorithm ] name = options [ :name ] || 'BinVolume' number = options [ :number ] interpreter = options [ :interpreter ] type ...
Creates a ROI instance from the segmentation of this BinVolume .
12,619
def narray = ( image ) raise ArgumentError , "Invalid argument 'image'. Expected NArray, got #{image.class}." unless image . is_a? ( NArray ) raise ArgumentError , "Invalid argument 'image'. Expected two-dimensional NArray, got #{image.shape.length} dimensions." unless image . shape . length == 2 raise ArgumentError , ...
Sets a new binary array for this BinImage instance .
12,620
def to_contours ( slice ) raise ArgumentError , "Invalid argument 'slice. Expected Slice, got #{slice.class}." unless slice . is_a? ( Slice ) contours = Array . new contour_indices . each do | contour | x , y , z = coordinates_from_indices ( NArray . to_na ( contour . columns ) , NArray . to_na ( contour . rows ) ) x =...
Creates an array of Contour instances from the segmentation of this BinImage .
12,621
def to_dcm dcm = DICOM :: DObject . new @image . dcm . each_element do | element | begin if element . value DICOM :: Element . new ( element . tag , element . value , :parent => dcm ) else DICOM :: Element . new ( element . tag , element . bin , :encoded => true , :parent => dcm ) end rescue DICOM :: Element . new ( el...
Creates a DICOM object from the BinImage instance . This is achieved by copying the elements of the DICOM object of the Image instance referenced by this BinImage and replacing its pixel data with the NArray of this instance .
12,622
def to_slice ( roi ) raise ArgumentError , "Invalid argument 'roi'. Expected ROI, got #{roi.class}." unless roi . is_a? ( ROI ) s = Slice . new ( @image . uid , roi ) to_contours ( s ) return s end
Creates a Slice instance from the segmentation of this BinImage .
12,623
def external_contour start_index = ( @narray > 0 ) . where [ 0 ] - 1 s_col , s_row = indices_general_to_specific ( start_index , columns ) col , row = s_col , s_row row_indices = Array . new ( 1 , row ) col_indices = Array . new ( 1 , col ) last_dir = :north directions = { :north => { :dir => [ :east , :north , :west ,...
Determines a set of pixel indices which enclose the structure .
12,624
def extract_contours contours = Array . new if @narray . segmented? corners , continuous = extract_single_contour if continuous . indices . length < 3 roi = continuous else contours << corners roi = roi_indices ( continuous ) raise "Unexpected result: #{roi.indices.length}. Raising an error to avoid an infinite recursi...
This is a recursive method which extracts a contour determines all pixels belonging to this contour removes them from the binary image then repeats collecting contours until there are no more pixels left .
12,625
def initialize_contour_reorder_structures @reorder = Hash . new @reorder [ :west ] = NArray [ 0 , 1 , 2 , 5 , 8 , 7 , 6 , 3 ] @reorder [ :nw ] = NArray [ 1 , 2 , 5 , 8 , 7 , 6 , 3 , 0 ] @reorder [ :north ] = NArray [ 2 , 5 , 8 , 7 , 6 , 3 , 0 , 1 ] @reorder [ :ne ] = NArray [ 5 , 8 , 7 , 6 , 3 , 0 , 1 , 2 ] @reorder [ ...
Initializes a couple of instance variables containing directional information which are used by the contour algorithm .
12,626
def add ( dcm ) id = dcm . value ( PATIENTS_ID ) p = patient ( id ) if p p . add ( dcm ) else add_patient ( Patient . load ( dcm , self ) ) end end
Adds a DICOM object to the dataset by adding it to an existing Patient or creating a new Patient .
12,627
def add_frame ( frame ) raise ArgumentError , "Invalid argument 'frame'. Expected Frame, got #{frame.class}." unless frame . is_a? ( Frame ) @frames << frame unless @associated_frames [ frame . uid ] @associated_frames [ frame . uid ] = frame end
Adds a Frame to this DataSet .
12,628
def add_patient ( patient ) raise ArgumentError , "Invalid argument 'patient'. Expected Patient, got #{patient.class}." unless patient . is_a? ( Patient ) @patients << patient unless @associated_patients [ patient . id ] @associated_patients [ patient . id ] = patient end
Adds a Patient to this DataSet .
12,629
def print @patients . each do | p | puts p . name p . studies . each do | st | puts " #{st.uid}" st . series . each do | se | puts " #{se.modality}" if se . respond_to? ( :images ) && se . images puts " (#{se.images.length} images)" end end end end end
Prints the nested structure of patient - study - series - images that have been loaded in the DataSet instance .
12,630
def print_rt @patients . each do | p | puts p . name p . studies . each do | st | puts " Study (UID: #{st.uid})" st . image_series . each do | is | puts " #{is.modality} (#{is.images.length} images - UID: #{is.uid})" is . structs . each do | struct | puts " StructureSet (#{struct.rois.length} ROIs - UID: #{str...
Prints the nested structure of the DataSet from a radiotherapy point of view where the various series beneath the patient - study level is presented in a hiearchy of image series structure set rt plan rt dose and rt image in accordance with the object hiearchy used by RTKIT .
12,631
def stack ( name , attributes , block ) previous = @tag_binding_stack . last previous_locals = previous . nil? ? globals : previous . locals locals = DelegatingOpenStruct . new ( previous_locals ) binding = TagBinding . new ( self , locals , name , attributes , block ) @tag_binding_stack . push ( binding ) result = yie...
A convienence method for managing the various parts of the tag binding stack .
12,632
def numeric_specificity ( tag_name , nesting_parts ) nesting_parts = nesting_parts . dup name_parts = tag_name . split ( ':' ) specificity = 0 value = 1 if nesting_parts . last == name_parts . last while nesting_parts . size > 0 if nesting_parts . last == name_parts . last specificity += value name_parts . pop end nest...
Returns the specificity for + tag_name + at nesting defined by + nesting_parts + as a number .
12,633
def translate ( x , y , z ) @x += x . to_f @y += y . to_f @z += z . to_f end
Moves the coordinate according to the given offset vector .
12,634
def register ( id , & block ) ref = __get id return ref . __getobj__ if ref && ref . weakref_alive? item = block . call return nil unless item __register id , item end
Register an item inside the cache if it does not yet exist If the item is not found inside the cache the block attached should return a valid reference
12,635
def each @lock . synchronize do @items . each do | id , ref | begin yield id , ref . __getobj__ rescue WeakRef :: RefError end end end end
Iterates over registered and alive items
12,636
def clear @lock . synchronize do if block_given? @items . each do | id , ref | begin yield id , ref . __getobj__ rescue WeakRef :: RefError end end end @items . clear end end
Clears all items from the cache If block is given iterates over the cached items
12,637
def find ( id ) @lock . synchronize do begin ref = @items [ id ] return unless ref ref . __getobj__ rescue WeakRef :: RefError @items . delete id nil end end end
Finds an item by its ID
12,638
def vector_attenuation ( h_units , lengths ) raise ArgumentError , "Incosistent arguments. Expected both NArrays to have the same length, go #{h_units.length} and #{lengths.length}" if h_units . length != lengths . length 1 - Math . exp ( - ( attenuation_coefficients ( h_units ) * 0.1 * lengths ) . sum ) end
Calculates the attentuation for a vector pair of hounsfield units and lengths .
12,639
def determine_coefficient @energies = [ 0.001 , 0.0015 , 0.002 , 0.003 , 0.004 , 0.005 , 0.006 , 0.008 , 0.01 , 0.015 , 0.02 , 0.03 , 0.04 , 0.05 , 0.06 , 0.08 , 0.1 , 0.15 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.8 , 1.0 , 1.25 , 1.5 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 8.0 , 10.0 , 15.0 , 20.0 ] @att_coeffs = [ 4078 , 1376 , 617...
Determines the attenuation coefficient to use based on the given energy .
12,640
def timezone = ( timezone ) tz = timezone . to_s . downcase case tz when 'cst' , 'cdt' then self . timezone = 'america/chicago' when 'est' , 'edt' then self . timezone = 'america/new_york' when 'mst' , 'mdt' then self . timezone = 'america/denver' when 'pst' , 'pdt' then self . timezone = 'america/los_angeles' else if ...
Sets the timezone for the user . This can be done in a variety of ways .
12,641
def bed ( d , alpha_beta ) raise ArgumentError , "A positive alpha_beta factor is required (got: #{alpha_beta})." unless alpha_beta . to_f > 0.0 @value * ( 1 + d . to_f / alpha_beta . to_f ) end
Calculates the biologically equivalent dose BED . This is the theoretical limit of the equivalent dose delivered in small fractions i . e . when complete repair takes place .
12,642
def trace delta_x = @p1 . x < @p2 . x ? 1 : - 1 delta_y = @p1 . y < @p2 . y ? 1 : - 1 delta_z = @p1 . z < @p2 . z ? 1 : - 1 @delta_i = @p1 . x == @p2 . x ? 0 : delta_x @delta_j = @p1 . y == @p2 . y ? 0 : delta_y @delta_k = @p1 . z == @p2 . z ? 0 : delta_z @delta_ax = @vs . delta_x / ( @p2 . x - @p1 . x ) . abs @delta_a...
Performs ray tracing where the ray s possible intersection of the associated voxel space is investigated for the ray s movement from its source coordinate to its target coordinate .
12,643
def alpha_min ( fractions ) fractions . compact . collect { | a | a >= 0 ? a : nil } . compact . min end
Gives the minimum value among the directional fractions given taking into account that some of them may be nil negative or even - INFINITY and thus needs to be excluded before extracting the valid minimum value .
12,644
def first_intersection_point_in_voxel_space a_x_min = ax ( @i_min ) a_y_min = ay ( @j_min ) a_z_min = az ( @k_min ) a_x_max = ax ( @i_max ) a_y_max = ay ( @j_max ) a_z_max = az ( @k_max ) alpha_x = alpha_min_first_intersection ( [ a_x_min , a_x_max ] ) alpha_y = alpha_min_first_intersection ( [ a_y_min , a_y_max ] ) al...
Determines the alpha values for the first intersection after the ray has entered the voxel space .
12,645
def indices_first_intersection ( axf , ayf , azf ) i , j , k = nil , nil , nil af_min = alpha_min ( [ axf , ayf , azf ] ) sorted_real_alpha_values ( [ axf , ayf , azf ] ) . each do | a | alpha_mean = ( a + @alpha_min ) * 0.5 i0 = phi_x ( alpha_mean ) j0 = phi_y ( alpha_mean ) k0 = phi_z ( alpha_mean ) if indices_within...
Determines the voxel indices of the first intersection .
12,646
def indices_within_voxel_space ( i , j , k ) if [ i , j , k ] . min >= 0 if i < @vs . nx && j < @vs . nz && k < @vs . nz true else false end else false end end
Checks whether the given voxel indices describe an index that is within the associated voxel space .
12,647
def sorted_real_alpha_values ( fractions ) fractions . compact . collect { | a | a >= 0 && a . finite? ? a : nil } . compact . sort end
Gives a sorted array of the directional fractions given taking into account that some of them may be nil negative or even - INFINITY and thus needs to be excluded before sorting .
12,648
def parse ( string ) @stack = [ ParseContainerTag . new { | t | Utility . array_to_s ( t . contents ) } ] tokenize ( string ) stack_up @stack . last . to_s end
Creates a new parser object initialized with a Context . Parses string for tags expands them and returns the result .
12,649
def add_attributes_to_dcm ( dcm ) dcm . add_element ( SOP_CLASS , @class_uid ) dcm . add_element ( SERIES_UID , @series_uid ) dcm . add_element ( SERIES_NUMBER , '1' ) dcm . add_element ( STUDY_DATE , @study . date ) dcm . add_element ( STUDY_TIME , @study . time ) dcm . add_element ( STUDY_UID , @study . study_uid ) d...
Creates a new Series instance . The Series Instance UID string is used to uniquely identify a Series .
12,650
def solve set_parameters a = NArray . float ( @n ) b = NArray . float ( @n ) @n . times do | i | @weights_current [ i ] = @decisions [ i , true ] . mean end k = 0 while k < max_iterations do @weights_previous = @weights_current . dup @n . times do | i | voxel_decisions = @decisions [ i , true ] positive_indices , negat...
Applies the STAPLE algorithm to the dataset to determine the true hidden segmentation as well as scoring the various segmentations .
12,651
def construct_segmentation_volume if @volumes . first . shape == @original_volumes . first . shape @true_segmentation = @true_segmentation_vector . reshape ( * @original_volumes . first . shape ) . to_type ( 1 ) else @true_segmentation = NArray . byte ( * @original_volumes . first . shape ) true_segmentation_in_reduced...
Reshapes the true segmentation vector to a volume which is comparable with the input volumes for the Staple instance . If volume reduction has been peformed this must be taken into account .
12,652
def set_parameters @vectors = Array . new @volumes . each { | volume | @vectors << volume . flatten } verify_equal_vector_lengths @n = @vectors . first . length @r = @vectors . length @decisions = NArray . int ( @n , @r ) @p = NArray . float ( @r ) @q = NArray . float ( @r ) @p . fill! ( 0.99999 ) @q . fill! ( 0.99999 ...
Sets the instance attributes used by the STAPLE algorithm .
12,653
def verify_equal_vector_lengths vector_lengths = @vectors . collect { | vector | vector . length } raise IndexError , "Unexpected behaviour: The vectors going into the STAPLE analysis have different lengths." unless vector_lengths . uniq . length == 1 end
Ensures that the number of voxels are the same for all segmentation vectors going into the STAPLE analysis .
12,654
def add ( dcm ) raise ArgumentError , "Invalid argument 'dcm'. Expected DObject, got #{dcm.class}." unless dcm . is_a? ( DICOM :: DObject ) existing_series = @associated_series [ dcm . value ( SERIES_UID ) ] if existing_series existing_series . add ( dcm ) else case dcm . value ( MODALITY ) when * IMAGE_SERIES s = Imag...
Creates a new Study instance . The Study Instance UID string is used to uniquely identify a study .
12,655
def add_series ( series ) raise ArgumentError , "Invalid argument 'series'. Expected Series, got #{series.class}." unless series . is_a? ( Series ) @series << series unless @associated_series [ series . uid ] @image_series << series if series . is_a? ( ImageSeries ) && ! @associated_series [ series . uid ] @associated_...
Adds a Series to this Study .
12,656
def shift ( delta_col , delta_row ) raise ArgumentError , "Invalid argument 'delta_col'. Expected Integer, got #{delta_col.class}." unless delta_col . is_a? ( Integer ) raise ArgumentError , "Invalid argument 'delta_row'. Expected Integer, got #{delta_row.class}." unless delta_row . is_a? ( Integer ) new_columns = @ind...
Shifts the indices of this selection by the specified number of columns and rows . Positive arguments increment the column and row indices .
12,657
def shift_columns ( delta ) raise ArgumentError , "Invalid argument 'delta'. Expected Integer, got #{delta.class}." unless delta . is_a? ( Integer ) new_columns = @indices . collect { | index | index % @bin_image . columns + delta } new_rows = rows @indices = Array . new ( new_columns . length ) { | i | new_columns [ i...
Shifts the indices of this selection by the specified number of columns . A positive argument increment the column indices .
12,658
def each Directory . each do | id | remote = NodeCache . register id next unless remote yield remote end end
Iterate across all available nodes
12,659
def add_image ( image ) raise ArgumentError , "Invalid argument 'image'. Expected Image, got #{image.class}." unless image . is_a? ( Image ) @images << image @associated_images [ image . uid ] = image end
Adds an Image to this CRSeries .
12,660
def find ( actor ) Directory . each_with_object ( [ ] ) do | id , actors | next if id == DCell . id node = Directory [ id ] next unless node next unless node . actors . include? actor ractor = get_remote_actor actor , id actors << ractor if ractor end end
Returns actors from multiple nodes
12,661
def run! Directory [ id ] . actors = local_actors Directory [ id ] . pubkey = crypto ? crypto_keys [ :pubkey ] : nil DCell :: SupervisionGroup . run! end
Run the DCell application in the background
12,662
def generate_node_id if @registry . respond_to? :unique @registry . unique else digest = Digest :: SHA512 . new seed = :: Socket . gethostname + rand . to_s + Time . now . to_s + SecureRandom . hex digest . update ( seed ) . to_s end end
Attempt to generate a unique node ID for this machine
12,663
def find ( name ) request = Message :: Find . new ( Thread . mailbox , name ) methods = send_request request return nil if methods . is_a? NilClass rsocket actor = DCell :: ActorProxy . create . new self , name , methods add_actor actor end
Find an call registered with a given name on this node
12,664
def actors request = Message :: List . new ( Thread . mailbox ) list = send_request request list . map! ( & :to_sym ) end
List all registered actors on this node
12,665
def ping ( timeout = nil ) request = Message :: Ping . new ( Thread . mailbox ) send_request request , :request , timeout end
Send a ping message with a given timeout
12,666
def shutdown transition :shutdown kill_actors close_comm NodeCache . delete @id MailboxManager . delete Thread . mailbox instance_variables . each { | iv | remove_instance_variable iv } end
Graceful termination of the node
12,667
def add_contour ( contour ) raise ArgumentError , "Invalid argument 'contour'. Expected Contour, got #{contour.class}." unless contour . is_a? ( Contour ) @contours << contour unless @contours . include? ( contour ) end
Adds a Contour instance to this Slice .
12,668
def bin_image ( source_image = @image ) raise "Referenced ROI Slice Image is missing from the dataset. Unable to construct image." unless @image bin_img = BinImage . new ( NArray . byte ( source_image . columns , source_image . rows ) , source_image ) @contours . each_with_index do | contour , i | x , y , z = contour ....
Creates a binary segmented image from the contours defined for this slice applied to the referenced Image instance .
12,669
def plane raise "This Slice does not contain a Contour. Plane determination is not possible." if @contours . length == 0 raise "This Slice does not contain a Contour with at least 3 Coordinates. Plane determination is not possible." if @contours . first . coordinates . length < 3 contour = @contours . first num_coords ...
Gives a Plane corresponding to this Slice geometry . The plane is calculated from coordinates belonging to this instance .
12,670
def ss_item item = DICOM :: Item . new item . add ( DICOM :: Element . new ( ROI_NUMBER , @number . to_s ) ) item . add ( DICOM :: Element . new ( REF_FRAME_OF_REF , @frame . uid ) ) item . add ( DICOM :: Element . new ( ROI_NAME , @name ) ) item . add ( DICOM :: Element . new ( ROI_ALGORITHM , @algorithm ) ) return it...
Creates a Structure Set ROI Sequence Item from the attributes of the Structure instance .
12,671
def add ( dcm ) s = study ( dcm . value ( STUDY_UID ) ) if s s . add ( dcm ) else add_study ( Study . load ( dcm , self ) ) end end
Registers a DICOM object to the patient by adding it to an existing Study or creating a new Study .
12,672
def add_study ( study ) raise ArgumentError , "Invalid argument 'study'. Expected Study, got #{study.class}." unless study . is_a? ( Study ) @studies << study unless @associated_studies [ study . uid ] @associated_studies [ study . uid ] = study end
Adds a Study to this Patient .
12,673
def play_sound ( filename ) path = Java :: limelight . Context . fs . path_to ( scene . path , filename ) @peer . play_sound ( path ) end
Plays a sound on the computers audio output . The parameter is the filename of a . au sound file . This filename should relative to the root directory of the current Production or an absolute path .
12,674
def open_production ( production_path ) Thread . new { Java :: limelight . Context . instance . studio . open ( production_path ) } end
Creates a new Producer to open the specified Production .
12,675
def find_by_id ( id ) peer_result = @peer . find ( id . to_s ) peer_result . nil? ? nil : peer_result . proxy end
Returns a Prop with the specified id . Returns nil id the Prop doesn t exist in the Scene .
12,676
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
Creates a Beam Limiting Device Position Sequence Item from the attributes of the CollimatorSetup .
12,677
def add_slice ( slice ) raise ArgumentError , "Invalid argument 'slice'. Expected Slice, got #{slice.class}." unless slice . is_a? ( Slice ) @slices << slice unless @associated_instance_uids [ slice . uid ] @associated_instance_uids [ slice . uid ] = slice end
Adds a Slice instance to this ROI .
12,678
def create_slices ( contour_sequence ) raise ArgumentError , "Invalid argument 'contour_sequence'. Expected DICOM::Sequence, got #{contour_sequence.class}." unless contour_sequence . is_a? ( DICOM :: Sequence ) slice_collection = Hash . new contour_sequence . each do | slice_contour_item | sop_uid = slice_contour_item ...
Creates Slice instances from the contour sequence items of the contour sequence and connects these slices to this ROI instance .
12,679
def distribution ( dose_volume = @struct . plan . rt_dose . sum ) raise ArgumentError , "Invalid argument 'dose_volume'. Expected DoseVolume, got #{dose_volume.class}." unless dose_volume . is_a? ( DoseVolume ) raise ArgumentError , "Invalid argument 'dose_volume'. The specified DoseVolume does not belong to this ROI's...
Creates a DoseDistribution based on the delineation by this ROI in the specified RTDose series .
12,680
def translate ( x , y , z ) @slices . each do | s | s . translate ( x , y , z ) end end
Moves the ROI by applying the given offset vector to its coordinates .
12,681
def smooth = ( value ) hint = value ? java . awt . RenderingHints :: VALUE_ANTIALIAS_ON : java . awt . RenderingHints :: VALUE_ANTIALIAS_OFF @context . setRenderingHint ( java . awt . RenderingHints :: KEY_ANTIALIASING , hint ) end
Specifies whether the pen will use anti - aliasing to draw smooth shapes or not . Shapes will appear pixilated when smooth is set to false .
12,682
def fill_oval ( x , y , width , height ) @context . fillOval ( x , y , width , height ) end
Fills an oval specified by the bounding rectangle . See draw_oval .
12,683
def draw_lines ( column_indices , row_indices , image , value ) raise ArgumentError , "Invalid argument 'column_indices'. Expected Array, got #{column_indices.class}." unless column_indices . is_a? ( Array ) raise ArgumentError , "Invalid argument 'row_indices'. Expected Array, got #{row_indices.class}." unless row_ind...
Fills the provided pixel array with lines of a specified value based on two vectors of column and row indices .
12,684
def extract_pixels ( x_coords , y_coords , z_coords ) column_indices , row_indices = coordinates_to_indices ( x_coords , y_coords , z_coords ) indices = indices_specific_to_general ( column_indices , row_indices ) return @narray [ indices ] . to_a . flatten end
Extracts pixels based on cartesian coordinate arrays .
12,685
def flood_fill ( col , row , image , fill_value ) col = col > image . shape [ 0 ] ? - 1 : col row = row > image . shape [ 1 ] ? - 1 : row existing_value = image [ col , row ] queue = Array . new queue . push ( [ col , row ] ) until queue . empty? col , row = queue . shift if image [ col , row ] == existing_value west_c...
Replaces all pixels of a specific value that are contained by pixels of a different value .
12,686
def print_img ( narr = @narray ) puts "Image dimensions: #{@columns}*#{@rows}" narr . shape [ 0 ] . times do | i | puts narr [ true , i ] . to_a . to_s end end
A convenience method for printing image information .
12,687
def create_general_dicom_image_scaffold unless @dcm @dcm = DICOM :: DObject . new @dcm . add_element ( SPECIFIC_CHARACTER_SET , 'ISO_IR 100' ) @dcm . add_element ( IMAGE_TYPE , 'DERIVED\SECONDARY\DRR' ) @dcm . add_element ( ACCESSION_NUMBER , '' ) @dcm . add_element ( MODALITY , @series . modality ) @dcm . add_element ...
Creates a new DICOM object with a set of basic attributes needed for a valid DICOM image file .
12,688
def update_dicom_image @dcm . add_element ( IMAGE_DATE , @date ) @dcm . add_element ( IMAGE_TIME , @time ) @dcm . add_element ( SOP_UID , @uid ) @dcm . add_element ( COLUMNS , @columns ) @dcm . add_element ( ROWS , @rows ) @dcm . pixels = @narray @series . add_attributes_to_dcm ( dcm ) end
Creates a new DICOM object with a set of basic attributes needed for a valid DICOM file of slice type image modality .
12,689
def add_volume ( volume ) raise ArgumentError , "Invalid argument 'volume'. Expected DoseVolume, got #{volume.class}." unless volume . is_a? ( DoseVolume ) @volumes << volume unless @associated_volumes [ volume . uid ] @associated_volumes [ volume . uid ] = volume end
Adds a DoseVolume instance to this RTDose series .
12,690
def add_beam ( beam ) raise ArgumentError , "Invalid argument 'beam'. Expected Beam, got #{beam.class}." unless beam . is_a? ( Beam ) @beams << beam unless @beams . include? ( beam ) end
Adds a Beam to this Plan .
12,691
def add_rt_dose ( rt_dose ) raise ArgumentError , "Invalid argument 'rt_dose'. Expected RTDose, got #{rt_dose.class}." unless rt_dose . is_a? ( RTDose ) @rt_doses << rt_dose unless @associated_rt_doses [ rt_dose . uid ] @associated_rt_doses [ rt_dose . uid ] = rt_dose end
Adds a RTDose series to this Plan .
12,692
def add_rt_image ( rt_image ) raise ArgumentError , "Invalid argument 'rt_image'. Expected RTImage, got #{rt_image.class}." unless rt_image . is_a? ( RTImage ) @rt_images << rt_image unless @rt_images . include? ( rt_image ) end
Adds a RTImage Series to this Plan .
12,693
def add_collimator ( coll ) raise ArgumentError , "Invalid argument 'coll'. Expected Collimator, got #{coll.class}." unless coll . is_a? ( Collimator ) @collimators << coll unless @associated_collimators [ coll . type ] @associated_collimators [ coll . type ] = coll end
Adds a Collimator instance to this Beam .
12,694
def add_control_point ( cp ) raise ArgumentError , "Invalid argument 'cp'. Expected ControlPoint, got #{cp.class}." unless cp . is_a? ( ControlPoint ) @control_points << cp unless @associated_control_points [ cp ] @associated_control_points [ cp ] = true end
Adds a ControlPoint instance to this Beam .
12,695
def beam_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 ) ) @slices . each do | slice | slice . contours . each do | contour | s . add_item ( co...
Creates a Beam Sequence Item from the attributes of the Beam instance .
12,696
def control_point ( * args ) raise ArgumentError , "Expected one or none arguments, got #{args.length}." unless [ 0 , 1 ] . include? ( args . length ) if args . length == 1 raise ArgumentError , "Invalid argument 'index'. Expected Integer (or nil), got #{args.first.class}." unless [ Integer , NilClass ] . include? ( ar...
Gives the ControlPoint instance mathcing the specified index .
12,697
def ref_beam_item item = DICOM :: Item . new item . add ( DICOM :: Element . new ( OBS_NUMBER , @number . to_s ) ) item . add ( DICOM :: Element . new ( REF_ROI_NUMBER , @number . to_s ) ) item . add ( DICOM :: Element . new ( ROI_TYPE , @type ) ) item . add ( DICOM :: Element . new ( ROI_INTERPRETER , @interpreter ) )...
Creates a Referenced Beam Sequence Item from the attributes of the Beam instance .
12,698
def to_voxel_space raise "This image series has no associated images. Unable to create a VoxelSpace." unless @images . length > 0 img = @images . first vs = VoxelSpace . create ( img . columns , img . rows , @images . length , img . col_spacing , img . row_spacing , slice_spacing , Coordinate . new ( img . pos_x , img ...
Creates a VoxelSpace instance from the image instances belonging to this image series .
12,699
def update_image_position ( image , new_pos ) raise ArgumentError , "Invalid argument 'image'. Expected Image, got #{image.class}." unless image . is_a? ( Image ) @image_positions . delete ( image . pos_slice ) @image_positions [ new_pos ] = image end
Updates the position that is registered for the image instance for this series .