_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q22900
RTKIT.DataSet.add
train
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
ruby
{ "resource": "" }
q22901
RTKIT.DataSet.add_frame
train
def add_frame(frame) raise ArgumentError, "Invalid argument 'frame'. Expected Frame, got #{frame.class}." unless frame.is_a?(Frame) # Do not add it again if the frame already belongs to this instance: @frames << frame unless @associated_frames[frame.uid] @associated_frames[frame.uid] = frame ...
ruby
{ "resource": "" }
q22902
RTKIT.DataSet.add_patient
train
def add_patient(patient) raise ArgumentError, "Invalid argument 'patient'. Expected Patient, got #{patient.class}." unless patient.is_a?(Patient) # Do not add it again if the patient already belongs to this instance: @patients << patient unless @associated_patients[patient.id] @associated_patien...
ruby
{ "resource": "" }
q22903
RTKIT.DataSet.print
train
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 ...
ruby
{ "resource": "" }
q22904
RTKIT.DataSet.print_rt
train
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 " ...
ruby
{ "resource": "" }
q22905
Radius.Context.stack
train
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) ...
ruby
{ "resource": "" }
q22906
Radius.Context.numeric_specificity
train
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 ...
ruby
{ "resource": "" }
q22907
RTKIT.Coordinate.translate
train
def translate(x, y, z) @x += x.to_f @y += y.to_f @z += z.to_f end
ruby
{ "resource": "" }
q22908
DCell.ResourceManager.register
train
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
ruby
{ "resource": "" }
q22909
DCell.ResourceManager.each
train
def each @lock.synchronize do @items.each do |id, ref| begin yield id, ref.__getobj__ rescue WeakRef::RefError end end end end
ruby
{ "resource": "" }
q22910
DCell.ResourceManager.clear
train
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
ruby
{ "resource": "" }
q22911
DCell.ResourceManager.find
train
def find(id) @lock.synchronize do begin ref = @items[id] return unless ref ref.__getobj__ rescue WeakRef::RefError # :nocov: @items.delete id nil # :nocov: end end end
ruby
{ "resource": "" }
q22912
RTKIT.Attenuation.vector_attenuation
train
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 # Note that the lengths are converted to units of cm in the calculation. # The exponentia...
ruby
{ "resource": "" }
q22913
RTKIT.Attenuation.determine_coefficient
train
def determine_coefficient # Array of photon energies (in units of MeV). @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, ...
ruby
{ "resource": "" }
q22914
Harvest.User.timezone=
train
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_a...
ruby
{ "resource": "" }
q22915
RTKIT.Dose.bed
train
def bed(d, alpha_beta) # FIXME: Perhaps better to use number of fractions instead of fraction dose?! 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
ruby
{ "resource": "" }
q22916
RTKIT.Ray.trace
train
def trace # Set up instance varibles which depends on the initial conditions. # Delta positions determines whether the ray's travel is positive # or negative in the three directions. delta_x = @p1.x < @p2.x ? 1 : -1 delta_y = @p1.y < @p2.y ? 1 : -1 delta_z = @p1.z < @p2.z ? 1 : -1 ...
ruby
{ "resource": "" }
q22917
RTKIT.Ray.alpha_min
train
def alpha_min(fractions) fractions.compact.collect { |a| a >= 0 ? a : nil}.compact.min end
ruby
{ "resource": "" }
q22918
RTKIT.Ray.first_intersection_point_in_voxel_space
train
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...
ruby
{ "resource": "" }
q22919
RTKIT.Ray.indices_first_intersection
train
def indices_first_intersection(axf, ayf, azf) i, j, k = nil, nil, nil # In cases of perpendicular ray travel, one or two arguments may be # -INFINITY, which must be excluded when searching for the minimum value: af_min = alpha_min([axf, ayf, azf]) sorted_real_alpha_values([axf, ayf, azf])....
ruby
{ "resource": "" }
q22920
RTKIT.Ray.indices_within_voxel_space
train
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
ruby
{ "resource": "" }
q22921
RTKIT.Ray.sorted_real_alpha_values
train
def sorted_real_alpha_values(fractions) fractions.compact.collect { |a| a >= 0 && a.finite? ? a : nil}.compact.sort end
ruby
{ "resource": "" }
q22922
Radius.Parser.parse
train
def parse(string) @stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ] tokenize(string) stack_up @stack.last.to_s end
ruby
{ "resource": "" }
q22923
RTKIT.Series.add_attributes_to_dcm
train
def add_attributes_to_dcm(dcm) # Series level: dcm.add_element(SOP_CLASS, @class_uid) dcm.add_element(SERIES_UID, @series_uid) dcm.add_element(SERIES_NUMBER, '1') # Study level: dcm.add_element(STUDY_DATE, @study.date) dcm.add_element(STUDY_TIME, @study.time) dcm.add_elem...
ruby
{ "resource": "" }
q22924
RTKIT.Staple.solve
train
def solve set_parameters # Vectors holding the values used for calculating the weights: a = NArray.float(@n) b = NArray.float(@n) # Set an initial estimate for the probabilities of true segmentation: @n.times do |i| @weights_current[i] = @decisions[i, true].mean end ...
ruby
{ "resource": "" }
q22925
RTKIT.Staple.construct_segmentation_volume
train
def construct_segmentation_volume if @volumes.first.shape == @original_volumes.first.shape # Just reshape the vector (and ensure that it remains byte type): @true_segmentation = @true_segmentation_vector.reshape(*@original_volumes.first.shape).to_type(1) else # Need to take into acco...
ruby
{ "resource": "" }
q22926
RTKIT.Staple.set_parameters
train
def set_parameters # Convert the volumes to vectors: @vectors = Array.new @volumes.each {|volume| @vectors << volume.flatten} verify_equal_vector_lengths # Number of voxels: @n = @vectors.first.length # Number of raters: @r = @vectors.length # Decisions array: ...
ruby
{ "resource": "" }
q22927
RTKIT.Staple.verify_equal_vector_lengths
train
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
ruby
{ "resource": "" }
q22928
RTKIT.Study.add
train
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 # New series (series subclass depends on m...
ruby
{ "resource": "" }
q22929
RTKIT.Study.add_series
train
def add_series(series) raise ArgumentError, "Invalid argument 'series'. Expected Series, got #{series.class}." unless series.is_a?(Series) # Do not add it again if the series already belongs to this instance: @series << series unless @associated_series[series.uid] @image_series << series if seri...
ruby
{ "resource": "" }
q22930
RTKIT.Selection.shift
train
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 = @i...
ruby
{ "resource": "" }
q22931
RTKIT.Selection.shift_columns
train
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 # Set new indices: @indices = Array.new(new_columns.length...
ruby
{ "resource": "" }
q22932
DCell.NodeManager.each
train
def each Directory.each do |id| remote = NodeCache.register id next unless remote yield remote end end
ruby
{ "resource": "" }
q22933
RTKIT.CRSeries.add_image
train
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
ruby
{ "resource": "" }
q22934
DCell.ClassMethods.find
train
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
ruby
{ "resource": "" }
q22935
DCell.ClassMethods.run!
train
def run! Directory[id].actors = local_actors Directory[id].pubkey = crypto ? crypto_keys[:pubkey] : nil DCell::SupervisionGroup.run! end
ruby
{ "resource": "" }
q22936
DCell.ClassMethods.generate_node_id
train
def generate_node_id # a little bit more creative 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
ruby
{ "resource": "" }
q22937
DCell.Node.find
train
def find(name) request = Message::Find.new(Thread.mailbox, name) methods = send_request request return nil if methods.is_a? NilClass rsocket # open relay pipe to avoid race conditions actor = DCell::ActorProxy.create.new self, name, methods add_actor actor end
ruby
{ "resource": "" }
q22938
DCell.Node.actors
train
def actors request = Message::List.new(Thread.mailbox) list = send_request request list.map!(&:to_sym) end
ruby
{ "resource": "" }
q22939
DCell.Node.ping
train
def ping(timeout=nil) request = Message::Ping.new(Thread.mailbox) send_request request, :request, timeout end
ruby
{ "resource": "" }
q22940
DCell.Node.shutdown
train
def shutdown transition :shutdown kill_actors close_comm NodeCache.delete @id MailboxManager.delete Thread.mailbox instance_variables.each { |iv| remove_instance_variable iv } end
ruby
{ "resource": "" }
q22941
RTKIT.Slice.add_contour
train
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
ruby
{ "resource": "" }
q22942
RTKIT.Slice.bin_image
train
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) # Delineate and fill for each contour, then create the final image: ...
ruby
{ "resource": "" }
q22943
RTKIT.Slice.plane
train
def plane # Such a change is only possible if the Slice instance has a Contour with at least three Coordinates: 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 d...
ruby
{ "resource": "" }
q22944
RTKIT.Structure.ss_item
train
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 item end
ruby
{ "resource": "" }
q22945
RTKIT.Patient.add
train
def add(dcm) s = study(dcm.value(STUDY_UID)) if s s.add(dcm) else add_study(Study.load(dcm, self)) end end
ruby
{ "resource": "" }
q22946
RTKIT.Patient.add_study
train
def add_study(study) raise ArgumentError, "Invalid argument 'study'. Expected Study, got #{study.class}." unless study.is_a?(Study) # Do not add it again if the study already belongs to this instance: @studies << study unless @associated_studies[study.uid] @associated_studies[study.uid] = study ...
ruby
{ "resource": "" }
q22947
Limelight.Prop.play_sound
train
def play_sound(filename) path = Java::limelight.Context.fs.path_to(scene.path, filename) @peer.play_sound(path) end
ruby
{ "resource": "" }
q22948
Limelight.Scene.open_production
train
def open_production(production_path) Thread.new { Java::limelight.Context.instance.studio.open(production_path) } end
ruby
{ "resource": "" }
q22949
Limelight.Scene.find_by_id
train
def find_by_id(id) peer_result = @peer.find(id.to_s) peer_result.nil? ? nil : peer_result.proxy end
ruby
{ "resource": "" }
q22950
RTKIT.CollimatorSetup.to_item
train
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
ruby
{ "resource": "" }
q22951
RTKIT.ROI.add_slice
train
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
ruby
{ "resource": "" }
q22952
RTKIT.ROI.create_slices
train
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) # Sort the contours by slices: slice_collection = Hash.new contour_sequence.each do |slice_conto...
ruby
{ "resource": "" }
q22953
RTKIT.ROI.distribution
train
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 Struc...
ruby
{ "resource": "" }
q22954
RTKIT.ROI.translate
train
def translate(x, y, z) @slices.each do |s| s.translate(x, y, z) end end
ruby
{ "resource": "" }
q22955
Limelight.Pen.smooth=
train
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
ruby
{ "resource": "" }
q22956
Limelight.Pen.fill_oval
train
def fill_oval(x, y, width, height) @context.fillOval(x, y, width, height) end
ruby
{ "resource": "" }
q22957
RTKIT.Image.draw_lines
train
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_indi...
ruby
{ "resource": "" }
q22958
RTKIT.Image.extract_pixels
train
def extract_pixels(x_coords, y_coords, z_coords) # FIXME: This method (along with some other methods in this class, doesn't # actually work for a pure Image instance. This should probably be # refactored (mix-in module instead more appropriate?) # Get image indices (nearest neighbour): col...
ruby
{ "resource": "" }
q22959
RTKIT.Image.flood_fill
train
def flood_fill(col, row, image, fill_value) # If the given starting point is out of bounds, put it at the array boundary: 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 ...
ruby
{ "resource": "" }
q22960
RTKIT.Image.print_img
train
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
ruby
{ "resource": "" }
q22961
RTKIT.Image.create_general_dicom_image_scaffold
train
def create_general_dicom_image_scaffold # Some tags are created/updated only if no DICOM object already exists: unless @dcm @dcm = DICOM::DObject.new # Group 0008: @dcm.add_element(SPECIFIC_CHARACTER_SET, 'ISO_IR 100') @dcm.add_element(IMAGE_TYPE, 'DERIVED\SECONDARY\DRR') ...
ruby
{ "resource": "" }
q22962
RTKIT.Image.update_dicom_image
train
def update_dicom_image # General image attributes: @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) # Pixel data: @dcm.pixels = @narray # Higher ...
ruby
{ "resource": "" }
q22963
RTKIT.RTDose.add_volume
train
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
ruby
{ "resource": "" }
q22964
RTKIT.Plan.add_beam
train
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
ruby
{ "resource": "" }
q22965
RTKIT.Plan.add_rt_dose
train
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
ruby
{ "resource": "" }
q22966
RTKIT.Plan.add_rt_image
train
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
ruby
{ "resource": "" }
q22967
RTKIT.Beam.add_collimator
train
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
ruby
{ "resource": "" }
q22968
RTKIT.Beam.add_control_point
train
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
ruby
{ "resource": "" }
q22969
RTKIT.Beam.beam_item
train
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)) # Add Contour items to the Contour Sequence (one or several items per Slice): @slices....
ruby
{ "resource": "" }
q22970
RTKIT.Beam.control_point
train
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?(args.fi...
ruby
{ "resource": "" }
q22971
RTKIT.Beam.ref_beam_item
train
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)) return item end
ruby
{ "resource": "" }
q22972
RTKIT.ImageParent.to_voxel_space
train
def to_voxel_space raise "This image series has no associated images. Unable to create a VoxelSpace." unless @images.length > 0 img = @images.first # Create the voxel space: vs = VoxelSpace.create(img.columns, img.rows, @images.length, img.col_spacing, img.row_spacing, slice_spacing, Coordinate....
ruby
{ "resource": "" }
q22973
RTKIT.ImageParent.update_image_position
train
def update_image_position(image, new_pos) raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image) # Remove old position key: @image_positions.delete(image.pos_slice) # Add the new position: @image_positions[new_pos] = image end
ruby
{ "resource": "" }
q22974
RTKIT.StructureSet.add_plan
train
def add_plan(plan) raise ArgumentError, "Invalid argument 'plan'. Expected Plan, got #{plan.class}." unless plan.is_a?(Plan) @plans << plan unless @associated_plans[plan.uid] @associated_plans[plan.uid] = plan end
ruby
{ "resource": "" }
q22975
RTKIT.StructureSet.add_poi
train
def add_poi(poi) raise ArgumentError, "Invalid argument 'poi'. Expected POI, got #{poi.class}." unless poi.is_a?(POI) @structures << poi unless @structures.include?(poi) end
ruby
{ "resource": "" }
q22976
RTKIT.StructureSet.add_structure
train
def add_structure(structure) raise ArgumentError, "Invalid argument 'structure'. Expected ROI/POI, got #{structure.class}." unless structure.respond_to?(:to_roi) or structure.respond_to?(:to_poi) @structures << structure unless @structures.include?(structure) end
ruby
{ "resource": "" }
q22977
RTKIT.StructureSet.add_roi
train
def add_roi(roi) raise ArgumentError, "Invalid argument 'roi'. Expected ROI, got #{roi.class}." unless roi.is_a?(ROI) @structures << roi unless @structures.include?(roi) end
ruby
{ "resource": "" }
q22978
RTKIT.StructureSet.create_roi
train
def create_roi(frame, options={}) raise ArgumentError, "Expected Frame, got #{frame.class}." unless frame.is_a?(Frame) # Set values: algorithm = options[:algorithm] || 'Automatic' name = options[:name] || 'RTKIT-VOLUME' interpreter = options[:interpreter] || 'RTKIT' type = options[:t...
ruby
{ "resource": "" }
q22979
RTKIT.StructureSet.remove_structure
train
def remove_structure(instance_or_number) raise ArgumentError, "Invalid argument 'instance_or_number'. Expected a ROI Instance or an Integer (ROI Number). Got #{instance_or_number.class}." unless [ROI, Integer].include?(instance_or_number.class) s_instance = instance_or_number if instance_or_number.is_...
ruby
{ "resource": "" }
q22980
RTKIT.StructureSet.structure_names
train
def structure_names names = Array.new @structures.each do |s| names << s.name end return names end
ruby
{ "resource": "" }
q22981
RTKIT.StructureSet.structure_numbers
train
def structure_numbers numbers = Array.new @structures.each do |s| numbers << s.number end return numbers end
ruby
{ "resource": "" }
q22982
RTKIT.StructureSet.to_dcm
train
def to_dcm # Use the original DICOM object as a starting point (keeping all non-sequence elements): #@dcm[REF_FRAME_OF_REF_SQ].delete_children @dcm[STRUCTURE_SET_ROI_SQ].delete_children @dcm[ROI_CONTOUR_SQ].delete_children @dcm[RT_ROI_OBS_SQ].delete_children # Create DICOM @roi...
ruby
{ "resource": "" }
q22983
RTKIT.StructureSet.load_structures
train
def load_structures if @dcm[STRUCTURE_SET_ROI_SQ] && @dcm[ROI_CONTOUR_SQ] && @dcm[RT_ROI_OBS_SQ] # Load the information in a nested hash: item_group = Hash.new @dcm[STRUCTURE_SET_ROI_SQ].each do |roi_item| item_group[roi_item.value(ROI_NUMBER)] = {:roi => roi_item} end ...
ruby
{ "resource": "" }
q22984
RTKIT.Frame.add_image
train
def add_image(image) raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image) @associated_instance_uids[image.uid] = image # If the ImageSeries of an added Image is not connected to this Frame yet, do so: add_series(image.series) unless serie...
ruby
{ "resource": "" }
q22985
RTKIT.Frame.add_series
train
def add_series(series) raise ArgumentError, "Invalid argument 'series' Expected ImageSeries or DoseVolume, got #{series.class}." unless [ImageSeries, DoseVolume].include?(series.class) @image_series << series @associated_series[series.uid] = series end
ruby
{ "resource": "" }
q22986
RTKIT.Contour.add_coordinate
train
def add_coordinate(coordinate) raise ArgumentError, "Invalid argument 'coordinate'. Expected Coordinate, got #{coordinate.class}." unless coordinate.is_a?(Coordinate) @coordinates << coordinate unless @coordinates.include?(coordinate) end
ruby
{ "resource": "" }
q22987
RTKIT.Contour.coords
train
def coords x, y, z = Array.new, Array.new, Array.new @coordinates.each do |coord| x << coord.x y << coord.y z << coord.z end return x, y, z end
ruby
{ "resource": "" }
q22988
RTKIT.Contour.create_coordinates
train
def create_coordinates(contour_data) raise ArgumentError, "Invalid argument 'contour_data'. Expected String (or nil), got #{contour_data.class}." unless [String, NilClass].include?(contour_data.class) if contour_data && contour_data != "" # Split the number strings, sperated by a '\', into an array:...
ruby
{ "resource": "" }
q22989
RTKIT.Contour.to_item
train
def to_item # FIXME: We need to decide on how to principally handle the situation when an image series has not been # loaded, and how to set up the ROI slices. A possible solution is to create Image instances if they hasn't been loaded. item = DICOM::Item.new item.add(DICOM::Sequence.new(CONTOUR...
ruby
{ "resource": "" }
q22990
RTKIT.Contour.translate
train
def translate(x, y, z) @coordinates.each do |c| c.translate(x, y, z) end end
ruby
{ "resource": "" }
q22991
DCell.MessageHandler.handle_message
train
def handle_message(message) begin message = decode_message message rescue InvalidMessageError => ex Logger.crash("couldn't decode message", ex) return end begin message.dispatch rescue => ex Logger.crash("message dispatch failed", ex) end ...
ruby
{ "resource": "" }
q22992
DCell.MessageHandler.decode_message
train
def decode_message(message) begin msg = MessagePack.unpack(message, symbolize_keys: true) rescue => ex raise InvalidMessageError, "couldn't unpack message: #{ex}" end begin klass = Utils.full_const_get msg[:type] o = klass.new(*msg[:args]) o.id = msg[:id] ...
ruby
{ "resource": "" }
q22993
DCell.Server.run
train
def run while true message = @socket.read_multipart if @socket.is_a? Celluloid::ZMQ::RouterSocket message = message[1] else message = message[0] end handle_message message end end
ruby
{ "resource": "" }
q22994
Radius.Scanner.operate
train
def operate(prefix, data) data = Radius::OrdString.new data @nodes = [''] re = scanner_regex(prefix) if md = re.match(data) remainder = '' while md start_tag, attributes, self_enclosed, end_tag = $1, $2, $3, $4 flavor = self_enclosed == '/' ? :...
ruby
{ "resource": "" }
q22995
Limelight.Theater.add_stage
train
def add_stage(name, options = {}) stage = build_stage(name, options).proxy @peer.add(stage.peer) return stage end
ruby
{ "resource": "" }
q22996
RTKIT.BinMatcher.fill_blanks
train
def fill_blanks if @volumes.length > 0 # Register all unique images referenced by the various volumes: images = Set.new # Include the master volume (if it is present): [@volumes, @master].flatten.compact.each do |volume| volume.bin_images.each do |bin_image| i...
ruby
{ "resource": "" }
q22997
RTKIT.DoseVolume.add_image
train
def add_image(image) raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image) @images << image unless @associated_images[image.uid] @associated_images[image.uid] = image @image_positions[image.pos_slice.round(2)] = image end
ruby
{ "resource": "" }
q22998
RTKIT.DoseVolume.image_by_slice_pos
train
def image_by_slice_pos(pos) # Step 1: Try for an (exact) match: image = @image_positions[pos.round(2)] # Step 2: If no match, try to search for a close match: # (A close match is defined as the given slice position being within 1/3 of the # slice distance from an existing image instance in...
ruby
{ "resource": "" }
q22999
Dradis::Plugins.Settings.dirty_or_db_setting_or_default
train
def dirty_or_db_setting_or_default(key) if @dirty_options.key?(key) @dirty_options[key] elsif Configuration.exists?(name: namespaced_key(key)) db_setting(key) else @default_options[key] end end
ruby
{ "resource": "" }