repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
celluloid/dcell | lib/dcell/directory.rb | DCell.Directory.find | def find(id)
return nil unless id
meta = DCell.registry.get_node(id)
DirectoryMeta.new(id, meta)
end | ruby | def find(id)
return nil unless id
meta = DCell.registry.get_node(id)
DirectoryMeta.new(id, meta)
end | [
"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 | [
"Get",
"the",
"address",
"for",
"a",
"particular",
"Node",
"ID"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/directory.rb#L67-L71 | train |
dicom/rtkit | lib/rtkit/control_point.rb | RTKIT.ControlPoint.add_collimator | 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 | ruby | 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 | [
"def",
"add_collimator",
"(",
"coll",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'coll'. Expected CollimatorSetup, got #{coll.class}.\"",
"unless",
"coll",
".",
"is_a?",
"(",
"CollimatorSetup",
")",
"@collimators",
"<<",
"coll",
"unless",
"@associated_collimators... | Adds a CollimatorSetup instance to this ControlPoint.
@param [CollimatorSetup] coll a collimator setup instance to be associated with this control point | [
"Adds",
"a",
"CollimatorSetup",
"instance",
"to",
"this",
"ControlPoint",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/control_point.rb#L132-L136 | train |
dicom/rtkit | lib/rtkit/projection_image.rb | RTKIT.ProjectionImage.load_pixel_data | 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'
# Set attributes ... | ruby | 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'
# Set attributes ... | [
"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... | Transfers the pixel data, as well as the related image properties and the
DObject instance itself, to the image instance.
@param [DICOM::DObject] dcm an instance of a DICOM object
@raise [ArgumentError] if the given dicom object doesn't have a projection image type modality | [
"Transfers",
"the",
"pixel",
"data",
"as",
"well",
"as",
"the",
"related",
"image",
"properties",
"and",
"the",
"DObject",
"instance",
"itself",
"to",
"the",
"image",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/projection_image.rb#L71-L102 | train |
dicom/rtkit | lib/rtkit/projection_image.rb | RTKIT.ProjectionImage.create_projection_image_dicom_scaffold | def create_projection_image_dicom_scaffold
# Some tags are created/updated only if no DICOM object already exists:
unless @dcm
# Setup general image attributes:
create_general_dicom_image_scaffold
# Group 3002:
@dcm.add_element(RT_IMAGE_LABEL, @beam.description)
@dcm.... | ruby | def create_projection_image_dicom_scaffold
# Some tags are created/updated only if no DICOM object already exists:
unless @dcm
# Setup general image attributes:
create_general_dicom_image_scaffold
# Group 3002:
@dcm.add_element(RT_IMAGE_LABEL, @beam.description)
@dcm.... | [
"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... | Creates a new DICOM object with a set of basic attributes needed
for a valid DICOM file of modality RTIMAGE. | [
"Creates",
"a",
"new",
"DICOM",
"object",
"with",
"a",
"set",
"of",
"basic",
"attributes",
"needed",
"for",
"a",
"valid",
"DICOM",
"file",
"of",
"modality",
"RTIMAGE",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/projection_image.rb#L152-L186 | train |
dicom/rtkit | lib/rtkit/dose_distribution.rb | RTKIT.DoseDistribution.d | 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 | ruby | 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 | [
"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"... | Calculates the dose that at least the specified
percentage of the volume receives.
@param [#to_f] percent a percentage (number in the range 0-100)
@return [Float] the corresponding dose (in units of Gy)
@example Calculate the near minimum dose (e.g. up to 2 % of the volume receives a dose less than this):
near_... | [
"Calculates",
"the",
"dose",
"that",
"at",
"least",
"the",
"specified",
"percentage",
"of",
"the",
"volume",
"receives",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/dose_distribution.rb#L80-L84 | train |
dicom/rtkit | lib/rtkit/dose_distribution.rb | RTKIT.DoseDistribution.v | def v(dose)
raise RangeError, "Argument 'dose' cannot be negative." if dose.to_f < 0
# How many dose values are higher than the threshold?
num_above = (@doses.ge dose.to_f).where.length
# Divide by total number of elements and convert to percentage:
return num_above / @doses.length.to_f * ... | ruby | def v(dose)
raise RangeError, "Argument 'dose' cannot be negative." if dose.to_f < 0
# How many dose values are higher than the threshold?
num_above = (@doses.ge dose.to_f).where.length
# Divide by total number of elements and convert to percentage:
return num_above / @doses.length.to_f * ... | [
"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_abov... | Calculates the percentage of the volume that receives a dose higher than
or equal to the specified dose.
@param [#to_f] dose the dose threshold value to apply to the dose distribution (in units of Gy)
@return [Float] the corresponding percentage
@example Calculate the low dose spread (e.g. the percentage of the lu... | [
"Calculates",
"the",
"percentage",
"of",
"the",
"volume",
"that",
"receives",
"a",
"dose",
"higher",
"than",
"or",
"equal",
"to",
"the",
"specified",
"dose",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/dose_distribution.rb#L203-L209 | train |
slagyr/limelight | ruby/lib/limelight/stage.rb | Limelight.Stage.size= | def size=(*values)
values = values[0] if values.size == 1 && values[0].is_a?(Array)
@peer.set_size_styles(values[0], values[1])
end | ruby | def size=(*values)
values = values[0] if values.size == 1 && values[0].is_a?(Array)
@peer.set_size_styles(values[0], values[1])
end | [
"def",
"size",
"=",
"(",
"*",
"values",
")",
"values",
"=",
"values",
"[",
"0",
"]",
"if",
"values",
".",
"size",
"==",
"1",
"&&",
"values",
"[",
"0",
"]",
".",
"is_a?",
"(",
"Array",
")",
"@peer",
".",
"set_size_styles",
"(",
"values",
"[",
"0",... | Sets the width and height styles of the Stage.
state.size = [100, 200]
state.size = ["50%", "100%"] # consuming 50% of the width and 100% of the height of the screen | [
"Sets",
"the",
"width",
"and",
"height",
"styles",
"of",
"the",
"Stage",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/stage.rb#L76-L79 | train |
slagyr/limelight | ruby/lib/limelight/stage.rb | Limelight.Stage.location= | def location=(*values)
values = values[0] if values.size == 1 && values[0].is_a?(Array)
@peer.set_location_styles(values[0], values[1])
end | ruby | def location=(*values)
values = values[0] if values.size == 1 && values[0].is_a?(Array)
@peer.set_location_styles(values[0], values[1])
end | [
"def",
"location",
"=",
"(",
"*",
"values",
")",
"values",
"=",
"values",
"[",
"0",
"]",
"if",
"values",
".",
"size",
"==",
"1",
"&&",
"values",
"[",
"0",
"]",
".",
"is_a?",
"(",
"Array",
")",
"@peer",
".",
"set_location_styles",
"(",
"values",
"["... | Sets the location styles of the Stage.
stage.location = [500, 200] | [
"Sets",
"the",
"location",
"styles",
"of",
"the",
"Stage",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/stage.rb#L93-L96 | train |
slagyr/limelight | ruby/lib/limelight/stage.rb | Limelight.Stage.alert | 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 | ruby | 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 | [
"def",
"alert",
"(",
"message",
")",
"Thread",
".",
"new",
"do",
"begin",
"Java",
"::",
"limelight",
".",
"Context",
".",
"instance",
".",
"studio",
".",
"utilities_production",
".",
"alert",
"(",
"message",
")",
"rescue",
"StandardError",
"=>",
"e",
"puts... | Pops up a simple modal dialog with the provided message. | [
"Pops",
"up",
"a",
"simple",
"modal",
"dialog",
"with",
"the",
"provided",
"message",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/stage.rb#L234-L242 | train |
dicom/rtkit | lib/rtkit/image_series.rb | RTKIT.ImageSeries.add_image | 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.pos_sl... | ruby | 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.pos_sl... | [
"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",
"... | Adds an Image to this ImageSeries.
@param [Image] image an image instance to be associated with this image series | [
"Adds",
"an",
"Image",
"to",
"this",
"ImageSeries",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image_series.rb#L119-L127 | train |
dicom/rtkit | lib/rtkit/image_series.rb | RTKIT.ImageSeries.add_struct | def add_struct(struct)
raise ArgumentError, "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct.is_a?(StructureSet)
# Do not add it again if the struct already belongs to this instance:
@structs << struct unless @associated_structs[struct.uid]
@associated_struc... | ruby | def add_struct(struct)
raise ArgumentError, "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct.is_a?(StructureSet)
# Do not add it again if the struct already belongs to this instance:
@structs << struct unless @associated_structs[struct.uid]
@associated_struc... | [
"def",
"add_struct",
"(",
"struct",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'struct'. Expected StructureSet, got #{struct.class}.\"",
"unless",
"struct",
".",
"is_a?",
"(",
"StructureSet",
")",
"@structs",
"<<",
"struct",
"unless",
"@associated_structs",
"["... | Adds a StructureSet to this ImageSeries.
@param [Image] struct a structure set instance to be associated with this image series | [
"Adds",
"a",
"StructureSet",
"to",
"this",
"ImageSeries",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image_series.rb#L133-L138 | train |
dicom/rtkit | lib/rtkit/image_series.rb | RTKIT.ImageSeries.match_image | 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|
# Get three coordinates from the image:
col_indices = NArray.to_na([0,im... | ruby | 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|
# Get three coordinates from the image:
col_indices = NArray.to_na([0,im... | [
"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",
... | Analyses the images belonging to this ImageSeries to determine if there
is any image with a geometry that matches the specified plane.
@param [Plane] plane an image plane to be compared against the associated images
@return [SliceImage, NilClass] the matched image (or nil if no image is matched) | [
"Analyses",
"the",
"images",
"belonging",
"to",
"this",
"ImageSeries",
"to",
"determine",
"if",
"there",
"is",
"any",
"image",
"with",
"a",
"geometry",
"that",
"matches",
"the",
"specified",
"plane",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image_series.rb#L213-L233 | train |
dicom/rtkit | lib/rtkit/image_series.rb | RTKIT.ImageSeries.set_resolution | def set_resolution(columns, rows, options={})
@images.each do |img|
img.set_resolution(columns, rows, options)
end
end | ruby | def set_resolution(columns, rows, options={})
@images.each do |img|
img.set_resolution(columns, rows, options)
end
end | [
"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.
@param [Integer] columns the number of columns in the resized images
@param [Integer] rows the number of rows in the resized images
... | [
"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",
"existi... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image_series.rb#L245-L249 | train |
dicom/rtkit | lib/rtkit/image_series.rb | RTKIT.ImageSeries.struct | 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 @associat... | ruby | 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 @associat... | [
"def",
"struct",
"(",
"*",
"args",
")",
"raise",
"ArgumentError",
",",
"\"Expected one or none arguments, got #{args.length}.\"",
"unless",
"[",
"0",
",",
"1",
"]",
".",
"include?",
"(",
"args",
".",
"length",
")",
"if",
"args",
".",
"length",
"==",
"1",
"ra... | Gives the StructureSet instance mathcing the specified UID.
@overload struct(uid)
@param [String] uid the structure set SOP instance UID
@return [StructureSet, NilClass] the matched structure set (or nil if no structure set is matched)
@overload struct
@return [StructureSet, NilClass] the first structure se... | [
"Gives",
"the",
"StructureSet",
"instance",
"mathcing",
"the",
"specified",
"UID",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image_series.rb#L259-L268 | train |
dicom/rtkit | lib/rtkit/drr/pixel_space.rb | RTKIT.PixelSpace.coordinate | 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)
end | ruby | 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)
end | [
"def",
"coordinate",
"(",
"i",
",",
"j",
")",
"x",
"=",
"@pos",
".",
"x",
"+",
"(",
"i",
"*",
"@delta_col",
"*",
"@cosines",
"[",
"0",
"]",
")",
"+",
"(",
"j",
"*",
"@delta_row",
"*",
"@cosines",
"[",
"3",
"]",
")",
"y",
"=",
"@pos",
".",
"... | Calculates the cartesian coordinate of the given pixel index pair.
@param [Integer] i the image column index
@param [Integer] j the image row index
@return [Coordinate] the cartesian coordinate of the pixel | [
"Calculates",
"the",
"cartesian",
"coordinate",
"of",
"the",
"given",
"pixel",
"index",
"pair",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/pixel_space.rb#L118-L123 | train |
dicom/rtkit | lib/rtkit/drr/pixel_space.rb | RTKIT.PixelSpace.cosines= | 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 | ruby | 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 | [
"def",
"cosines",
"=",
"(",
"array",
")",
"raise",
"ArgumentError",
",",
"\"Invalid parameter 'array'. Exactly 6 elements needed, got #{array.length}\"",
"unless",
"array",
".",
"length",
"==",
"6",
"@cosines",
"=",
"array",
".",
"collect",
"{",
"|",
"val",
"|",
"va... | Sets the cosines attribute.
@param [Array<Float>] array the 6 directional cosines which describes the orientation of the image | [
"Sets",
"the",
"cosines",
"attribute",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/pixel_space.rb#L129-L132 | train |
dicom/rtkit | lib/rtkit/slice_image.rb | RTKIT.SliceImage.binary_image | def binary_image(coords_x, coords_y, coords_z)
# FIXME: Should we test whether the coordinates go outside the bounds of this image, and
# give a descriptive warning/error instead of letting the code crash with a more cryptic error?!
raise ArgumentError, "Invalid argument 'coords_x'. Expected at least ... | ruby | def binary_image(coords_x, coords_y, coords_z)
# FIXME: Should we test whether the coordinates go outside the bounds of this image, and
# give a descriptive warning/error instead of letting the code crash with a more cryptic error?!
raise ArgumentError, "Invalid argument 'coords_x'. Expected at least ... | [
"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",
"... | Creates a new SliceImage instance. The SOP Instance UID tag value is
used to uniquely identify an image.
@param [String] sop_uid the SOP Instance UID value
@param [String] pos_slice the slice position of this image
@param [Series] series the Series instance which this SliceImage is associated with
@raise [Argumen... | [
"Creates",
"a",
"new",
"SliceImage",
"instance",
".",
"The",
"SOP",
"Instance",
"UID",
"tag",
"value",
"is",
"used",
"to",
"uniquely",
"identify",
"an",
"image",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/slice_image.rb#L68-L103 | train |
dicom/rtkit | lib/rtkit/slice_image.rb | RTKIT.SliceImage.to_dcm | def to_dcm
# Setup general dicom image attributes:
create_slice_image_dicom_scaffold
update_dicom_image
# Add/update tags that are specific for the slice image type:
@dcm.add_element(IMAGE_POSITION, [@pos_x, @pos_y, @pos_slice].join("\\"))
@dcm.add_element(SPACING, [@row_spacing, @co... | ruby | def to_dcm
# Setup general dicom image attributes:
create_slice_image_dicom_scaffold
update_dicom_image
# Add/update tags that are specific for the slice image type:
@dcm.add_element(IMAGE_POSITION, [@pos_x, @pos_y, @pos_slice].join("\\"))
@dcm.add_element(SPACING, [@row_spacing, @co... | [
"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",
"(",
"SP... | Converts the Image instance to a DICOM object.
@note This method uses the image's original DICOM object (if present),
and updates it with attributes from the image instance.
@return [DICOM::DObject] the processed DICOM object | [
"Converts",
"the",
"Image",
"instance",
"to",
"a",
"DICOM",
"object",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/slice_image.rb#L170-L179 | train |
dicom/rtkit | lib/rtkit/bin_volume.rb | RTKIT.BinVolume.to_roi | def to_roi(struct, options={})
raise ArgumentError, "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct.is_a?(StructureSet)
# Set values:
algorithm = options[:algorithm]
name = options[:name] || 'BinVolume'
number = options[:number]
interpreter = op... | ruby | def to_roi(struct, options={})
raise ArgumentError, "Invalid argument 'struct'. Expected StructureSet, got #{struct.class}." unless struct.is_a?(StructureSet)
# Set values:
algorithm = options[:algorithm]
name = options[:name] || 'BinVolume'
number = options[:number]
interpreter = op... | [
"def",
"to_roi",
"(",
"struct",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'struct'. Expected StructureSet, got #{struct.class}.\"",
"unless",
"struct",
".",
"is_a?",
"(",
"StructureSet",
")",
"algorithm",
"=",
"options",
"[... | Creates a ROI instance from the segmentation of this BinVolume.
@param [StructureSet] struct the structure set instance which the created ROI will be associated with
@param [Hash] options the options to use for creating the ROI
@option options [String] :algorithm the ROI generation algorithm (defaults to 'STATIC')
... | [
"Creates",
"a",
"ROI",
"instance",
"from",
"the",
"segmentation",
"of",
"this",
"BinVolume",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_volume.rb#L250-L265 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.narray= | 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... | ruby | 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... | [
"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-dimensio... | Sets a new binary array for this BinImage instance.
@param [NArray] image a binary two-dimensional array | [
"Sets",
"a",
"new",
"binary",
"array",
"for",
"this",
"BinImage",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L207-L215 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.to_contours | def to_contours(slice)
raise ArgumentError, "Invalid argument 'slice. Expected Slice, got #{slice.class}." unless slice.is_a?(Slice)
contours = Array.new
# Iterate the extracted collection of contour indices and convert to Contour instances:
contour_indices.each do |contour|
# Convert co... | ruby | def to_contours(slice)
raise ArgumentError, "Invalid argument 'slice. Expected Slice, got #{slice.class}." unless slice.is_a?(Slice)
contours = Array.new
# Iterate the extracted collection of contour indices and convert to Contour instances:
contour_indices.each do |contour|
# Convert co... | [
"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",
... | Creates an array of Contour instances from the segmentation of this BinImage.
@param [Slice] slice the Slice instance which the created contours will be associated with
@return [Array<Contour>] an array of contour instances (or an empty array if no contours are created) | [
"Creates",
"an",
"array",
"of",
"Contour",
"instances",
"from",
"the",
"segmentation",
"of",
"this",
"BinImage",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L291-L305 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.to_dcm | def to_dcm
# Use the original DICOM object as a starting point (keeping all non-sequence elements):
# Note: Something like dcm.dup doesn't work here because that only performs a shallow copy on the DObject instance.
dcm = DICOM::DObject.new
@image.dcm.each_element do |element|
# A bit of... | ruby | def to_dcm
# Use the original DICOM object as a starting point (keeping all non-sequence elements):
# Note: Something like dcm.dup doesn't work here because that only performs a shallow copy on the DObject instance.
dcm = DICOM::DObject.new
@image.dcm.each_element do |element|
# A bit of... | [
"def",
"to_dcm",
"dcm",
"=",
"DICOM",
"::",
"DObject",
".",
"new",
"@image",
".",
"dcm",
".",
"each_element",
"do",
"|",
"element",
"|",
"begin",
"if",
"element",
".",
"value",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"element",
".",
"tag",
",",
"e... | 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.
@return [DICOM::DObject] the created DICOM object | [
"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",
"rep... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L314-L345 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.to_slice | def to_slice(roi)
raise ArgumentError, "Invalid argument 'roi'. Expected ROI, got #{roi.class}." unless roi.is_a?(ROI)
# Create the Slice:
s = Slice.new(@image.uid, roi)
# Create Contours:
to_contours(s)
return s
end | ruby | def to_slice(roi)
raise ArgumentError, "Invalid argument 'roi'. Expected ROI, got #{roi.class}." unless roi.is_a?(ROI)
# Create the Slice:
s = Slice.new(@image.uid, roi)
# Create Contours:
to_contours(s)
return s
end | [
"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_con... | Creates a Slice instance from the segmentation of this BinImage.
@param [ROI] roi the ROI instance which the created Slice will be associated with
@return [Slice] the created slice instance (including contour references if the binary image is segmented) | [
"Creates",
"a",
"Slice",
"instance",
"from",
"the",
"segmentation",
"of",
"this",
"BinImage",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L352-L359 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.external_contour | 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 # on first step, pretend we came from the south (go... | ruby | 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 # on first step, pretend we came from the south (go... | [
"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",
",",... | Determines a set of pixel indices which enclose the structure.
@see This implementation uses Roman Khudeevs algorithm:
A New Flood-Fill Algorithm for Closed Contour.
https://docs.google.com/viewer?a=v&q=cache:UZ6bo7pXRoIJ:file.lw23.com/file1/01611214.pdf+flood+fill+from+contour+coordinate&hl=no&gl=no&pid=bl&src... | [
"Determines",
"a",
"set",
"of",
"pixel",
"indices",
"which",
"enclose",
"the",
"structure",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L373-L405 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.extract_contours | def extract_contours
contours = Array.new
if @narray.segmented?
# Get contours:
corners, continuous = extract_single_contour
# If we dont get at least 3 indices, there is no area to fill.
if continuous.indices.length < 3
# In this case we remove the pixels and do n... | ruby | def extract_contours
contours = Array.new
if @narray.segmented?
# Get contours:
corners, continuous = extract_single_contour
# If we dont get at least 3 indices, there is no area to fill.
if continuous.indices.length < 3
# In this case we remove the pixels and do n... | [
"def",
"extract_contours",
"contours",
"=",
"Array",
".",
"new",
"if",
"@narray",
".",
"segmented?",
"corners",
",",
"continuous",
"=",
"extract_single_contour",
"if",
"continuous",
".",
"indices",
".",
"length",
"<",
"3",
"roi",
"=",
"continuous",
"else",
"co... | 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.
@return [Array<Selection>] an array of indices for all the contours derived from the segmented image | [
"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"... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L413-L436 | train |
dicom/rtkit | lib/rtkit/bin_image.rb | RTKIT.BinImage.initialize_contour_reorder_structures | 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[:east] = NArray[8,7,6,3,0,1,2,5]
@... | ruby | 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[:east] = NArray[8,7,6,3,0,1,2,5]
@... | [
"def",
"initialize_contour_reorder_structures",
"@reorder",
"=",
"Hash",
".",
"new",
"@reorder",
"[",
":west",
"]",
"=",
"NArray",
"[",
"0",
",",
"1",
",",
"2",
",",
"5",
",",
"8",
",",
"7",
",",
"6",
",",
"3",
"]",
"@reorder",
"[",
":nw",
"]",
"="... | Initializes a couple of instance variables containing directional information, which are used by the contour algorithm.
The directional vectors of indices are used for extracting a vector of neighbour pixels from a 3*3 pixel array,
where the resulting vector contains 7 neighbour pixels (the previous pixel is removed... | [
"Initializes",
"a",
"couple",
"of",
"instance",
"variables",
"containing",
"directional",
"information",
"which",
"are",
"used",
"by",
"the",
"contour",
"algorithm",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/bin_image.rb#L525-L546 | train |
dicom/rtkit | lib/rtkit/data_set.rb | RTKIT.DataSet.add | 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 | 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 | [
"def",
"add",
"(",
"dcm",
")",
"id",
"=",
"dcm",
".",
"value",
"(",
"PATIENTS_ID",
")",
"p",
"=",
"patient",
"(",
"id",
")",
"if",
"p",
"p",
".",
"add",
"(",
"dcm",
")",
"else",
"add_patient",
"(",
"Patient",
".",
"load",
"(",
"dcm",
",",
"self... | Adds a DICOM object to the dataset, by adding it
to an existing Patient, or creating a new Patient.
@note To ensure a correct relationship between objects of different
modality, please add DICOM objects in the specific order: images,
structs, plans, doses, rtimages. Alternatively, use the class method
DataS... | [
"Adds",
"a",
"DICOM",
"object",
"to",
"the",
"dataset",
"by",
"adding",
"it",
"to",
"an",
"existing",
"Patient",
"or",
"creating",
"a",
"new",
"Patient",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/data_set.rb#L140-L148 | train |
dicom/rtkit | lib/rtkit/data_set.rb | RTKIT.DataSet.add_frame | 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 | 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
... | [
"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",
".",
... | Adds a Frame to this DataSet.
@param [Frame] frame a Frame object to be added to this data set | [
"Adds",
"a",
"Frame",
"to",
"this",
"DataSet",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/data_set.rb#L154-L159 | train |
dicom/rtkit | lib/rtkit/data_set.rb | RTKIT.DataSet.add_patient | 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 | 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... | [
"def",
"add_patient",
"(",
"patient",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'patient'. Expected Patient, got #{patient.class}.\"",
"unless",
"patient",
".",
"is_a?",
"(",
"Patient",
")",
"@patients",
"<<",
"patient",
"unless",
"@associated_patients",
"[",
... | Adds a Patient to this DataSet.
@param [Patient] patient a Patient object to be added to this data set | [
"Adds",
"a",
"Patient",
"to",
"this",
"DataSet",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/data_set.rb#L165-L170 | train |
dicom/rtkit | lib/rtkit/data_set.rb | RTKIT.DataSet.print | 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 | 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
... | [
"def",
"print",
"@patients",
".",
"each",
"do",
"|",
"p",
"|",
"puts",
"p",
".",
"name",
"p",
".",
"studies",
".",
"each",
"do",
"|",
"st",
"|",
"puts",
"\" #{st.uid}\"",
"st",
".",
"series",
".",
"each",
"do",
"|",
"se",
"|",
"puts",
"\" #{se.... | Prints the nested structure of patient - study - series - images that
have been loaded in the DataSet instance. | [
"Prints",
"the",
"nested",
"structure",
"of",
"patient",
"-",
"study",
"-",
"series",
"-",
"images",
"that",
"have",
"been",
"loaded",
"in",
"the",
"DataSet",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/data_set.rb#L223-L236 | train |
dicom/rtkit | lib/rtkit/data_set.rb | RTKIT.DataSet.print_rt | 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 | 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 " ... | [
"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",
"|",
... | 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. | [
"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",
"imag... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/data_set.rb#L243-L265 | train |
jlong/radius | lib/radius/context.rb | Radius.Context.stack | 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 | 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)
... | [
"def",
"stack",
"(",
"name",
",",
"attributes",
",",
"block",
")",
"previous",
"=",
"@tag_binding_stack",
".",
"last",
"previous_locals",
"=",
"previous",
".",
"nil?",
"?",
"globals",
":",
"previous",
".",
"locals",
"locals",
"=",
"DelegatingOpenStruct",
".",
... | A convienence method for managing the various parts of the
tag binding stack. | [
"A",
"convienence",
"method",
"for",
"managing",
"the",
"various",
"parts",
"of",
"the",
"tag",
"binding",
"stack",
"."
] | e7b4eab374c6a15e105524ccd663767b8bc91e5b | https://github.com/jlong/radius/blob/e7b4eab374c6a15e105524ccd663767b8bc91e5b/lib/radius/context.rb#L95-L104 | train |
jlong/radius | lib/radius/context.rb | Radius.Context.numeric_specificity | 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 | 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
... | [
"def",
"numeric_specificity",
"(",
"tag_name",
",",
"nesting_parts",
")",
"nesting_parts",
"=",
"nesting_parts",
".",
"dup",
"name_parts",
"=",
"tag_name",
".",
"split",
"(",
"':'",
")",
"specificity",
"=",
"0",
"value",
"=",
"1",
"if",
"nesting_parts",
".",
... | Returns the specificity for +tag_name+ at nesting defined
by +nesting_parts+ as a number. | [
"Returns",
"the",
"specificity",
"for",
"+",
"tag_name",
"+",
"at",
"nesting",
"defined",
"by",
"+",
"nesting_parts",
"+",
"as",
"a",
"number",
"."
] | e7b4eab374c6a15e105524ccd663767b8bc91e5b | https://github.com/jlong/radius/blob/e7b4eab374c6a15e105524ccd663767b8bc91e5b/lib/radius/context.rb#L128-L145 | train |
dicom/rtkit | lib/rtkit/coordinate.rb | RTKIT.Coordinate.translate | def translate(x, y, z)
@x += x.to_f
@y += y.to_f
@z += z.to_f
end | ruby | def translate(x, y, z)
@x += x.to_f
@y += y.to_f
@z += z.to_f
end | [
"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.
@param [Float] x the offset along the x axis (in units of mm)
@param [Float] y the offset along the y axis (in units of mm)
@param [Float] z the offset along the z axis (in units of mm) | [
"Moves",
"the",
"coordinate",
"according",
"to",
"the",
"given",
"offset",
"vector",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/coordinate.rb#L85-L89 | train |
celluloid/dcell | lib/dcell/resource_manager.rb | DCell.ResourceManager.register | 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 | 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 | [
"def",
"register",
"(",
"id",
",",
"&",
"block",
")",
"ref",
"=",
"__get",
"id",
"return",
"ref",
".",
"__getobj__",
"if",
"ref",
"&&",
"ref",
".",
"weakref_alive?",
"item",
"=",
"block",
".",
"call",
"return",
"nil",
"unless",
"item",
"__register",
"i... | 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 | [
"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"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/resource_manager.rb#L44-L50 | train |
celluloid/dcell | lib/dcell/resource_manager.rb | DCell.ResourceManager.each | def each
@lock.synchronize do
@items.each do |id, ref|
begin
yield id, ref.__getobj__
rescue WeakRef::RefError
end
end
end
end | ruby | def each
@lock.synchronize do
@items.each do |id, ref|
begin
yield id, ref.__getobj__
rescue WeakRef::RefError
end
end
end
end | [
"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 | [
"Iterates",
"over",
"registered",
"and",
"alive",
"items"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/resource_manager.rb#L53-L62 | train |
celluloid/dcell | lib/dcell/resource_manager.rb | DCell.ResourceManager.clear | 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 | 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 | [
"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",... | Clears all items from the cache
If block is given, iterates over the cached items | [
"Clears",
"all",
"items",
"from",
"the",
"cache",
"If",
"block",
"is",
"given",
"iterates",
"over",
"the",
"cached",
"items"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/resource_manager.rb#L66-L78 | train |
celluloid/dcell | lib/dcell/resource_manager.rb | DCell.ResourceManager.find | 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 | 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 | [
"def",
"find",
"(",
"id",
")",
"@lock",
".",
"synchronize",
"do",
"begin",
"ref",
"=",
"@items",
"[",
"id",
"]",
"return",
"unless",
"ref",
"ref",
".",
"__getobj__",
"rescue",
"WeakRef",
"::",
"RefError",
"@items",
".",
"delete",
"id",
"nil",
"end",
"e... | Finds an item by its ID | [
"Finds",
"an",
"item",
"by",
"its",
"ID"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/resource_manager.rb#L81-L94 | train |
dicom/rtkit | lib/rtkit/drr/attenuation.rb | RTKIT.Attenuation.vector_attenuation | 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 | 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... | [
"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",... | Calculates the attentuation for a vector pair of hounsfield units and lengths.
@param [NArray<Integer>] h_units a vector of Hounsfield units
@param [NArray<Float>] lengths a vector of lengths (in units of mm)
@return [Float] the calculated attenuation of a ray through the given medium | [
"Calculates",
"the",
"attentuation",
"for",
"a",
"vector",
"pair",
"of",
"hounsfield",
"units",
"and",
"lengths",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/attenuation.rb#L118-L123 | train |
dicom/rtkit | lib/rtkit/drr/attenuation.rb | RTKIT.Attenuation.determine_coefficient | 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 | 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,
... | [
"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.... | Determines the attenuation coefficient to use, based on the given energy. | [
"Determines",
"the",
"attenuation",
"coefficient",
"to",
"use",
"based",
"on",
"the",
"given",
"energy",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/attenuation.rb#L131-L232 | train |
zmoazeni/harvested | lib/harvest/user.rb | Harvest.User.timezone= | 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 | 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... | [
"def",
"timezone",
"=",
"(",
"timezone",
")",
"tz",
"=",
"timezone",
".",
"to_s",
".",
"downcase",
"case",
"tz",
"when",
"'cst'",
",",
"'cdt'",
"then",
"self",
".",
"timezone",
"=",
"'america/chicago'",
"when",
"'est'",
",",
"'edt'",
"then",
"self",
".",... | Sets the timezone for the user. This can be done in a variety of ways.
== Examples
user.timezone = :cst # the easiest way. CST, EST, MST, and PST are supported
user.timezone = 'america/chicago' # a little more verbose
user.timezone = 'Central Time (US & Canada)' # the most explicit way | [
"Sets",
"the",
"timezone",
"for",
"the",
"user",
".",
"This",
"can",
"be",
"done",
"in",
"a",
"variety",
"of",
"ways",
"."
] | 33d26049651fde6adf651d5c8aff8fff97156210 | https://github.com/zmoazeni/harvested/blob/33d26049651fde6adf651d5c8aff8fff97156210/lib/harvest/user.rb#L42-L56 | train |
dicom/rtkit | lib/rtkit/dose.rb | RTKIT.Dose.bed | 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 | 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 | [
"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",... | 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.
@param [#to_f] d fraction dose
@param [#to_f] alpha_beta the alpha/beta tissue factor to be used
@return [Float] the biologically equivalent d... | [
"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",
... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/dose.rb#L59-L63 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.trace | 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 | 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
... | [
"def",
"trace",
"delta_x",
"=",
"@p1",
".",
"x",
"<",
"@p2",
".",
"x",
"?",
"1",
":",
"-",
"1",
"delta_y",
"=",
"@p1",
".",
"y",
"<",
"@p2",
".",
"y",
"?",
"1",
":",
"-",
"1",
"delta_z",
"=",
"@p1",
".",
"z",
"<",
"@p2",
".",
"z",
"?",
... | 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.
The resulting density experienced by the ray through the voxel space
is stored in the 'd' attribute. The indices of the voxel space
... | [
"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",
"coordi... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L306-L361 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.alpha_min | def alpha_min(fractions)
fractions.compact.collect { |a| a >= 0 ? a : nil}.compact.min
end | ruby | def alpha_min(fractions)
fractions.compact.collect { |a| a >= 0 ? a : nil}.compact.min
end | [
"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.
@param [Array<Float, NilClass>] fractions a collection of alpha values
@return [Float] the minimum v... | [
"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",... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L374-L376 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.first_intersection_point_in_voxel_space | 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 | 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... | [
"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",
... | Determines the alpha values for the first intersection after
the ray has entered the voxel space.
@return [Array<Float>] directional x, y and z alpha values | [
"Determines",
"the",
"alpha",
"values",
"for",
"the",
"first",
"intersection",
"after",
"the",
"ray",
"has",
"entered",
"the",
"voxel",
"space",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L403-L414 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.indices_first_intersection | 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 | 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]).... | [
"def",
"indices_first_intersection",
"(",
"axf",
",",
"ayf",
",",
"azf",
")",
"i",
",",
"j",
",",
"k",
"=",
"nil",
",",
"nil",
",",
"nil",
"af_min",
"=",
"alpha_min",
"(",
"[",
"axf",
",",
"ayf",
",",
"azf",
"]",
")",
"sorted_real_alpha_values",
"(",... | Determines the voxel indices of the first intersection.
@param [Float] axf a directional x alpha value for the ray's first intersection in voxel space
@param [Float] ayf a directional y alpha value for the ray's first intersection in voxel space
@param [Float] azf a directional z alpha value for the ray's first int... | [
"Determines",
"the",
"voxel",
"indices",
"of",
"the",
"first",
"intersection",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L423-L439 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.indices_within_voxel_space | 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 | 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 | [
"def",
"indices_within_voxel_space",
"(",
"i",
",",
"j",
",",
"k",
")",
"if",
"[",
"i",
",",
"j",
",",
"k",
"]",
".",
"min",
">=",
"0",
"if",
"i",
"<",
"@vs",
".",
"nx",
"&&",
"j",
"<",
"@vs",
".",
"nz",
"&&",
"k",
"<",
"@vs",
".",
"nz",
... | Checks whether the given voxel indices describe an index
that is within the associated voxel space.
@param [Integer] i the first volume index (column)
@param [Integer] j the second volume index (row)
@param [Integer] k the third volume index (slice)
@return [Boolean] true if within, and false if not | [
"Checks",
"whether",
"the",
"given",
"voxel",
"indices",
"describe",
"an",
"index",
"that",
"is",
"within",
"the",
"associated",
"voxel",
"space",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L449-L459 | train |
dicom/rtkit | lib/rtkit/drr/ray.rb | RTKIT.Ray.sorted_real_alpha_values | def sorted_real_alpha_values(fractions)
fractions.compact.collect { |a| a >= 0 && a.finite? ? a : nil}.compact.sort
end | ruby | def sorted_real_alpha_values(fractions)
fractions.compact.collect { |a| a >= 0 && a.finite? ? a : nil}.compact.sort
end | [
"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.
@param [Array<Float, NilClass>] fractions a collection of alpha values
@return [Array<Float>] sorted (valid) alpha values | [
"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",
"be... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/drr/ray.rb#L621-L623 | train |
jlong/radius | lib/radius/parser.rb | Radius.Parser.parse | def parse(string)
@stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ]
tokenize(string)
stack_up
@stack.last.to_s
end | ruby | def parse(string)
@stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ]
tokenize(string)
stack_up
@stack.last.to_s
end | [
"def",
"parse",
"(",
"string",
")",
"@stack",
"=",
"[",
"ParseContainerTag",
".",
"new",
"{",
"|",
"t",
"|",
"Utility",
".",
"array_to_s",
"(",
"t",
".",
"contents",
")",
"}",
"]",
"tokenize",
"(",
"string",
")",
"stack_up",
"@stack",
".",
"last",
".... | Creates a new parser object initialized with a Context.
Parses string for tags, expands them, and returns the result. | [
"Creates",
"a",
"new",
"parser",
"object",
"initialized",
"with",
"a",
"Context",
".",
"Parses",
"string",
"for",
"tags",
"expands",
"them",
"and",
"returns",
"the",
"result",
"."
] | e7b4eab374c6a15e105524ccd663767b8bc91e5b | https://github.com/jlong/radius/blob/e7b4eab374c6a15e105524ccd663767b8bc91e5b/lib/radius/parser.rb#L30-L35 | train |
dicom/rtkit | lib/rtkit/series.rb | RTKIT.Series.add_attributes_to_dcm | 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 | 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... | [
"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'",
")",
"dc... | Creates a new Series instance. The Series Instance UID string is used to
uniquely identify a Series.
@param [String] series_uid the Series Instance UID string
@param [String] modality the modality string of the series (e.g. 'CT', 'RTSTRUCT')
@param [Study] study the Study instance which this Series belongs to
@pa... | [
"Creates",
"a",
"new",
"Series",
"instance",
".",
"The",
"Series",
"Instance",
"UID",
"string",
"is",
"used",
"to",
"uniquely",
"identify",
"a",
"Series",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/series.rb#L62-L83 | train |
dicom/rtkit | lib/rtkit/staple.rb | RTKIT.Staple.solve | 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 | 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
... | [
"def",
"solve",
"set_parameters",
"a",
"=",
"NArray",
".",
"float",
"(",
"@n",
")",
"b",
"=",
"NArray",
".",
"float",
"(",
"@n",
")",
"@n",
".",
"times",
"do",
"|",
"i",
"|",
"@weights_current",
"[",
"i",
"]",
"=",
"@decisions",
"[",
"i",
",",
"t... | Applies the STAPLE algorithm to the dataset to determine the true hidden
segmentation as well as scoring the various segmentations. | [
"Applies",
"the",
"STAPLE",
"algorithm",
"to",
"the",
"dataset",
"to",
"determine",
"the",
"true",
"hidden",
"segmentation",
"as",
"well",
"as",
"scoring",
"the",
"various",
"segmentations",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/staple.rb#L141-L215 | train |
dicom/rtkit | lib/rtkit/staple.rb | RTKIT.Staple.construct_segmentation_volume | 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 | 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... | [
"def",
"construct_segmentation_volume",
"if",
"@volumes",
".",
"first",
".",
"shape",
"==",
"@original_volumes",
".",
"first",
".",
"shape",
"@true_segmentation",
"=",
"@true_segmentation_vector",
".",
"reshape",
"(",
"*",
"@original_volumes",
".",
"first",
".",
"sh... | 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. | [
"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",
"... | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/staple.rb#L233-L245 | train |
dicom/rtkit | lib/rtkit/staple.rb | RTKIT.Staple.set_parameters | 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 | 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:
... | [
"def",
"set_parameters",
"@vectors",
"=",
"Array",
".",
"new",
"@volumes",
".",
"each",
"{",
"|",
"volume",
"|",
"@vectors",
"<<",
"volume",
".",
"flatten",
"}",
"verify_equal_vector_lengths",
"@n",
"=",
"@vectors",
".",
"first",
".",
"length",
"@r",
"=",
... | Sets the instance attributes used by the STAPLE algorithm. | [
"Sets",
"the",
"instance",
"attributes",
"used",
"by",
"the",
"STAPLE",
"algorithm",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/staple.rb#L249-L281 | train |
dicom/rtkit | lib/rtkit/staple.rb | RTKIT.Staple.verify_equal_vector_lengths | 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 | 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 | [
"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",
... | Ensures that the number of voxels are the same for all segmentation
vectors going into the STAPLE analysis.
raise [IndexError] if the vectors to be compared in the STAPLE analysis are of different lengths | [
"Ensures",
"that",
"the",
"number",
"of",
"voxels",
"are",
"the",
"same",
"for",
"all",
"segmentation",
"vectors",
"going",
"into",
"the",
"STAPLE",
"analysis",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/staple.rb#L320-L323 | train |
dicom/rtkit | lib/rtkit/study.rb | RTKIT.Study.add | 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 | 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... | [
"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",
... | Creates a new Study instance. The Study Instance UID string is used to
uniquely identify a study.
@param [String] study_uid the Study Instance UID string
@param [Patient] patient the Patient instance which this Study is associated with
@param [Hash] options the options to use for creating the study
@option option... | [
"Creates",
"a",
"new",
"Study",
"instance",
".",
"The",
"Study",
"Instance",
"UID",
"string",
"is",
"used",
"to",
"uniquely",
"identify",
"a",
"study",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/study.rb#L92-L119 | train |
dicom/rtkit | lib/rtkit/study.rb | RTKIT.Study.add_series | 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 | 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... | [
"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",
... | Adds a Series to this Study.
@param [Series] series a series instance to be associated with this study | [
"Adds",
"a",
"Series",
"to",
"this",
"Study",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/study.rb#L141-L148 | train |
dicom/rtkit | lib/rtkit/selection.rb | RTKIT.Selection.shift | 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 | 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... | [
"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 argumen... | Shifts the indices of this selection by the specified number of columns
and rows. Positive arguments increment the column and row indices.
@note No out of bounds check is performed for indices that are shifted
past the image boundary!
@param [Integer] delta_col the desired column shift
@param [Integer] delta_ro... | [
"Shifts",
"the",
"indices",
"of",
"this",
"selection",
"by",
"the",
"specified",
"number",
"of",
"columns",
"and",
"rows",
".",
"Positive",
"arguments",
"increment",
"the",
"column",
"and",
"row",
"indices",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/selection.rb#L117-L124 | train |
dicom/rtkit | lib/rtkit/selection.rb | RTKIT.Selection.shift_columns | 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 | 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... | [
"def",
"shift_columns",
"(",
"delta",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'delta'. Expected Integer, got #{delta.class}.\"",
"unless",
"delta",
".",
"is_a?",
"(",
"Integer",
")",
"new_columns",
"=",
"@indices",
".",
"collect",
"{",
"|",
"index",
"|... | Shifts the indices of this selection by the specified number of columns.
A positive argument increment the column indices.
@note No out of bounds check is performed for indices that are shifted
past the image boundary.
@param [Integer] delta the desired column shift
@return [Array] the shifted indices | [
"Shifts",
"the",
"indices",
"of",
"this",
"selection",
"by",
"the",
"specified",
"number",
"of",
"columns",
".",
"A",
"positive",
"argument",
"increment",
"the",
"column",
"indices",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/selection.rb#L160-L166 | train |
celluloid/dcell | lib/dcell/node_manager.rb | DCell.NodeManager.each | def each
Directory.each do |id|
remote = NodeCache.register id
next unless remote
yield remote
end
end | ruby | def each
Directory.each do |id|
remote = NodeCache.register id
next unless remote
yield remote
end
end | [
"def",
"each",
"Directory",
".",
"each",
"do",
"|",
"id",
"|",
"remote",
"=",
"NodeCache",
".",
"register",
"id",
"next",
"unless",
"remote",
"yield",
"remote",
"end",
"end"
] | Iterate across all available nodes | [
"Iterate",
"across",
"all",
"available",
"nodes"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/node_manager.rb#L51-L57 | train |
dicom/rtkit | lib/rtkit/cr_series.rb | RTKIT.CRSeries.add_image | 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 | 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 | [
"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",
"]"... | Adds an Image to this CRSeries.
@param [Image] image an image instance to be associated with this series | [
"Adds",
"an",
"Image",
"to",
"this",
"CRSeries",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/cr_series.rb#L94-L98 | train |
celluloid/dcell | lib/dcell.rb | DCell.ClassMethods.find | 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 | 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 | [
"def",
"find",
"(",
"actor",
")",
"Directory",
".",
"each_with_object",
"(",
"[",
"]",
")",
"do",
"|",
"id",
",",
"actors",
"|",
"next",
"if",
"id",
"==",
"DCell",
".",
"id",
"node",
"=",
"Directory",
"[",
"id",
"]",
"next",
"unless",
"node",
"next... | Returns actors from multiple nodes | [
"Returns",
"actors",
"from",
"multiple",
"nodes"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell.rb#L100-L109 | train |
celluloid/dcell | lib/dcell.rb | DCell.ClassMethods.run! | def run!
Directory[id].actors = local_actors
Directory[id].pubkey = crypto ? crypto_keys[:pubkey] : nil
DCell::SupervisionGroup.run!
end | ruby | def run!
Directory[id].actors = local_actors
Directory[id].pubkey = crypto ? crypto_keys[:pubkey] : nil
DCell::SupervisionGroup.run!
end | [
"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 | [
"Run",
"the",
"DCell",
"application",
"in",
"the",
"background"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell.rb#L113-L117 | train |
celluloid/dcell | lib/dcell.rb | DCell.ClassMethods.generate_node_id | 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 | 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 | [
"def",
"generate_node_id",
"if",
"@registry",
".",
"respond_to?",
":unique",
"@registry",
".",
"unique",
"else",
"digest",
"=",
"Digest",
"::",
"SHA512",
".",
"new",
"seed",
"=",
"::",
"Socket",
".",
"gethostname",
"+",
"rand",
".",
"to_s",
"+",
"Time",
".... | Attempt to generate a unique node ID for this machine | [
"Attempt",
"to",
"generate",
"a",
"unique",
"node",
"ID",
"for",
"this",
"machine"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell.rb#L165-L174 | train |
celluloid/dcell | lib/dcell/node.rb | DCell.Node.find | 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 | 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 | [
"def",
"find",
"(",
"name",
")",
"request",
"=",
"Message",
"::",
"Find",
".",
"new",
"(",
"Thread",
".",
"mailbox",
",",
"name",
")",
"methods",
"=",
"send_request",
"request",
"return",
"nil",
"if",
"methods",
".",
"is_a?",
"NilClass",
"rsocket",
"acto... | Find an call registered with a given name on this node | [
"Find",
"an",
"call",
"registered",
"with",
"a",
"given",
"name",
"on",
"this",
"node"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/node.rb#L60-L67 | train |
celluloid/dcell | lib/dcell/node.rb | DCell.Node.actors | def actors
request = Message::List.new(Thread.mailbox)
list = send_request request
list.map!(&:to_sym)
end | ruby | def actors
request = Message::List.new(Thread.mailbox)
list = send_request request
list.map!(&:to_sym)
end | [
"def",
"actors",
"request",
"=",
"Message",
"::",
"List",
".",
"new",
"(",
"Thread",
".",
"mailbox",
")",
"list",
"=",
"send_request",
"request",
"list",
".",
"map!",
"(",
"&",
":to_sym",
")",
"end"
] | List all registered actors on this node | [
"List",
"all",
"registered",
"actors",
"on",
"this",
"node"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/node.rb#L71-L75 | train |
celluloid/dcell | lib/dcell/node.rb | DCell.Node.ping | def ping(timeout=nil)
request = Message::Ping.new(Thread.mailbox)
send_request request, :request, timeout
end | ruby | def ping(timeout=nil)
request = Message::Ping.new(Thread.mailbox)
send_request request, :request, timeout
end | [
"def",
"ping",
"(",
"timeout",
"=",
"nil",
")",
"request",
"=",
"Message",
"::",
"Ping",
".",
"new",
"(",
"Thread",
".",
"mailbox",
")",
"send_request",
"request",
",",
":request",
",",
"timeout",
"end"
] | Send a ping message with a given timeout | [
"Send",
"a",
"ping",
"message",
"with",
"a",
"given",
"timeout"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/node.rb#L79-L82 | train |
celluloid/dcell | lib/dcell/node.rb | DCell.Node.shutdown | 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 | def shutdown
transition :shutdown
kill_actors
close_comm
NodeCache.delete @id
MailboxManager.delete Thread.mailbox
instance_variables.each { |iv| remove_instance_variable iv }
end | [
"def",
"shutdown",
"transition",
":shutdown",
"kill_actors",
"close_comm",
"NodeCache",
".",
"delete",
"@id",
"MailboxManager",
".",
"delete",
"Thread",
".",
"mailbox",
"instance_variables",
".",
"each",
"{",
"|",
"iv",
"|",
"remove_instance_variable",
"iv",
"}",
... | Graceful termination of the node | [
"Graceful",
"termination",
"of",
"the",
"node"
] | a8fecfae220cb2c20d3761bc27880e4133aba498 | https://github.com/celluloid/dcell/blob/a8fecfae220cb2c20d3761bc27880e4133aba498/lib/dcell/node.rb#L110-L117 | train |
dicom/rtkit | lib/rtkit/slice.rb | RTKIT.Slice.add_contour | 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 | 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 | [
"def",
"add_contour",
"(",
"contour",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'contour'. Expected Contour, got #{contour.class}.\"",
"unless",
"contour",
".",
"is_a?",
"(",
"Contour",
")",
"@contours",
"<<",
"contour",
"unless",
"@contours",
".",
"include?... | Adds a Contour instance to this Slice.
@param [Contour] contour a contour instance to be associated with this slice | [
"Adds",
"a",
"Contour",
"instance",
"to",
"this",
"Slice",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/slice.rb#L83-L86 | train |
dicom/rtkit | lib/rtkit/slice.rb | RTKIT.Slice.bin_image | 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 | 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:
... | [
"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",
"."... | Creates a binary segmented image, from the contours defined for this
slice, applied to the referenced Image instance.
@param [Image] source_image the image on which the binary image will be applied (defaults to the referenced (anatomical) image, but may be e.g. a dose image)
@return [BinImage] the derived binary im... | [
"Creates",
"a",
"binary",
"segmented",
"image",
"from",
"the",
"contours",
"defined",
"for",
"this",
"slice",
"applied",
"to",
"the",
"referenced",
"Image",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/slice.rb#L131-L140 | train |
dicom/rtkit | lib/rtkit/slice.rb | RTKIT.Slice.plane | 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 | 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... | [
"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"... | Gives a Plane corresponding to this Slice geometry. The plane is
calculated from coordinates belonging to this instance.
@return [Plane] the derived plane
@raise [RuntimeError] unless the required number of coordinates are present (at least 3) | [
"Gives",
"a",
"Plane",
"corresponding",
"to",
"this",
"Slice",
"geometry",
".",
"The",
"plane",
"is",
"calculated",
"from",
"coordinates",
"belonging",
"to",
"this",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/slice.rb#L166-L177 | train |
dicom/rtkit | lib/rtkit/structure.rb | RTKIT.Structure.ss_item | 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 | 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 | [
"def",
"ss_item",
"item",
"=",
"DICOM",
"::",
"Item",
".",
"new",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"ROI_NUMBER",
",",
"@number",
".",
"to_s",
")",
")",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new"... | Creates a Structure Set ROI Sequence Item from the attributes of the Structure instance.
@return [DICOM::Item] a structure set ROI sequence item | [
"Creates",
"a",
"Structure",
"Set",
"ROI",
"Sequence",
"Item",
"from",
"the",
"attributes",
"of",
"the",
"Structure",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/structure.rb#L268-L275 | train |
dicom/rtkit | lib/rtkit/patient.rb | RTKIT.Patient.add | def add(dcm)
s = study(dcm.value(STUDY_UID))
if s
s.add(dcm)
else
add_study(Study.load(dcm, self))
end
end | ruby | def add(dcm)
s = study(dcm.value(STUDY_UID))
if s
s.add(dcm)
else
add_study(Study.load(dcm, self))
end
end | [
"def",
"add",
"(",
"dcm",
")",
"s",
"=",
"study",
"(",
"dcm",
".",
"value",
"(",
"STUDY_UID",
")",
")",
"if",
"s",
"s",
".",
"add",
"(",
"dcm",
")",
"else",
"add_study",
"(",
"Study",
".",
"load",
"(",
"dcm",
",",
"self",
")",
")",
"end",
"en... | Registers a DICOM object to the patient, by adding it to an existing
Study, or creating a new Study.
@param [DICOM::DObject] dcm a DICOM object | [
"Registers",
"a",
"DICOM",
"object",
"to",
"the",
"patient",
"by",
"adding",
"it",
"to",
"an",
"existing",
"Study",
"or",
"creating",
"a",
"new",
"Study",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/patient.rb#L99-L106 | train |
dicom/rtkit | lib/rtkit/patient.rb | RTKIT.Patient.add_study | 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 | 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
... | [
"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",
".",
... | Adds a Study to this Patient.
@param [Study] study a study instance to be associated with this patient | [
"Adds",
"a",
"Study",
"to",
"this",
"Patient",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/patient.rb#L123-L128 | train |
slagyr/limelight | ruby/lib/limelight/prop.rb | Limelight.Prop.play_sound | def play_sound(filename)
path = Java::limelight.Context.fs.path_to(scene.path, filename)
@peer.play_sound(path)
end | ruby | def play_sound(filename)
path = Java::limelight.Context.fs.path_to(scene.path, filename)
@peer.play_sound(path)
end | [
"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. | [
"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",
"cu... | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/prop.rb#L260-L263 | train |
slagyr/limelight | ruby/lib/limelight/scene.rb | Limelight.Scene.open_production | def open_production(production_path)
Thread.new { Java::limelight.Context.instance.studio.open(production_path) }
end | ruby | def open_production(production_path)
Thread.new { Java::limelight.Context.instance.studio.open(production_path) }
end | [
"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. | [
"Creates",
"a",
"new",
"Producer",
"to",
"open",
"the",
"specified",
"Production",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/scene.rb#L96-L98 | train |
slagyr/limelight | ruby/lib/limelight/scene.rb | Limelight.Scene.find_by_id | def find_by_id(id)
peer_result = @peer.find(id.to_s)
peer_result.nil? ? nil : peer_result.proxy
end | ruby | def find_by_id(id)
peer_result = @peer.find(id.to_s)
peer_result.nil? ? nil : peer_result.proxy
end | [
"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. | [
"Returns",
"a",
"Prop",
"with",
"the",
"specified",
"id",
".",
"Returns",
"nil",
"id",
"the",
"Prop",
"doesn",
"t",
"exist",
"in",
"the",
"Scene",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/scene.rb#L109-L112 | train |
dicom/rtkit | lib/rtkit/collimator_setup.rb | RTKIT.CollimatorSetup.to_item | 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 | 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 | [
"def",
"to_item",
"item",
"=",
"DICOM",
"::",
"Item",
".",
"new",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"COLL_TYPE",
",",
"@type",
")",
")",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"COLL_POS... | Creates a Beam Limiting Device Position Sequence Item
from the attributes of the CollimatorSetup.
@return [DICOM::Item] the created DICOM item | [
"Creates",
"a",
"Beam",
"Limiting",
"Device",
"Position",
"Sequence",
"Item",
"from",
"the",
"attributes",
"of",
"the",
"CollimatorSetup",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/collimator_setup.rb#L113-L118 | train |
dicom/rtkit | lib/rtkit/roi.rb | RTKIT.ROI.add_slice | 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 | 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 | [
"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",
... | Adds a Slice instance to this ROI.
@param [Slice] slice a slice instance to be associated with this ROI | [
"Adds",
"a",
"Slice",
"instance",
"to",
"this",
"ROI",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/roi.rb#L65-L69 | train |
dicom/rtkit | lib/rtkit/roi.rb | RTKIT.ROI.create_slices | 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 | 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... | [
"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_collec... | Creates Slice instances from the contour sequence items of the contour
sequence, and connects these slices to this ROI instance.
@param [DICOM::Sequence] contour_sequence a Contour Sequence | [
"Creates",
"Slice",
"instances",
"from",
"the",
"contour",
"sequence",
"items",
"of",
"the",
"contour",
"sequence",
"and",
"connects",
"these",
"slices",
"to",
"this",
"ROI",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/roi.rb#L143-L156 | train |
dicom/rtkit | lib/rtkit/roi.rb | RTKIT.ROI.distribution | 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 | 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... | [
"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?",
"(",
"DoseV... | Creates a DoseDistribution based on the delineation by this ROI in the
specified RTDose series.
@param [DoseVolume] dose_volume the dose volume to extract the dose distribution from (defaults to the sum of the dose volumes of the first RTDose of the first plan of the parent StructureSet)
@raise [ArgumentError] if g... | [
"Creates",
"a",
"DoseDistribution",
"based",
"on",
"the",
"delineation",
"by",
"this",
"ROI",
"in",
"the",
"specified",
"RTDose",
"series",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/roi.rb#L164-L172 | train |
dicom/rtkit | lib/rtkit/roi.rb | RTKIT.ROI.translate | def translate(x, y, z)
@slices.each do |s|
s.translate(x, y, z)
end
end | ruby | def translate(x, y, z)
@slices.each do |s|
s.translate(x, y, z)
end
end | [
"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.
@param [Float] x the offset along the x axis (in units of mm)
@param [Float] y the offset along the y axis (in units of mm)
@param [Float] z the offset along the z axis (in units of mm) | [
"Moves",
"the",
"ROI",
"by",
"applying",
"the",
"given",
"offset",
"vector",
"to",
"its",
"coordinates",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/roi.rb#L314-L318 | train |
slagyr/limelight | ruby/lib/limelight/pen.rb | Limelight.Pen.smooth= | 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 | 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 | [
"def",
"smooth",
"=",
"(",
"value",
")",
"hint",
"=",
"value",
"?",
"java",
".",
"awt",
".",
"RenderingHints",
"::",
"VALUE_ANTIALIAS_ON",
":",
"java",
".",
"awt",
".",
"RenderingHints",
"::",
"VALUE_ANTIALIAS_OFF",
"@context",
".",
"setRenderingHint",
"(",
... | Specifies whether the pen will use anti-aliasing to draw smooth shapes or not. Shapes will appear pixilated when
smooth is set to false. | [
"Specifies",
"whether",
"the",
"pen",
"will",
"use",
"anti",
"-",
"aliasing",
"to",
"draw",
"smooth",
"shapes",
"or",
"not",
".",
"Shapes",
"will",
"appear",
"pixilated",
"when",
"smooth",
"is",
"set",
"to",
"false",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/pen.rb#L45-L48 | train |
slagyr/limelight | ruby/lib/limelight/pen.rb | Limelight.Pen.fill_oval | def fill_oval(x, y, width, height)
@context.fillOval(x, y, width, height)
end | ruby | def fill_oval(x, y, width, height)
@context.fillOval(x, y, width, height)
end | [
"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. | [
"Fills",
"an",
"oval",
"specified",
"by",
"the",
"bounding",
"rectangle",
".",
"See",
"draw_oval",
"."
] | 2e8db684771587422d55a9329e895481e9b56a26 | https://github.com/slagyr/limelight/blob/2e8db684771587422d55a9329e895481e9b56a26/ruby/lib/limelight/pen.rb#L77-L79 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.draw_lines | 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 | 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... | [
"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",
")"... | Fills the provided pixel array with lines of a specified value, based on
two vectors of column and row indices.
@param [Array] column_indices an array (vector) of pixel column indices
@param [Array] row_indices an array (vector) of pixel row indices
@param [NArray] image a two-dimensional numerical pixel array
@p... | [
"Fills",
"the",
"provided",
"pixel",
"array",
"with",
"lines",
"of",
"a",
"specified",
"value",
"based",
"on",
"two",
"vectors",
"of",
"column",
"and",
"row",
"indices",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L175-L186 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.extract_pixels | 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 | 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... | [
"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_... | Extracts pixels based on cartesian coordinate arrays.
@note No interpolation is performed in the case of a given coordinate
being located between pixel indices. In these cases a basic nearest
neighbour algorithm is used.
@param [NArray] x_coords a numerical array (vector) of pixel x coordinates
@param [NArra... | [
"Extracts",
"pixels",
"based",
"on",
"cartesian",
"coordinate",
"arrays",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L199-L209 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.flood_fill | 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 | 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 ... | [
"def",
"flood_fill",
"(",
"col",
",",
"row",
",",
"image",
",",
"fill_value",
")",
"col",
"=",
"col",
">",
"image",
".",
"shape",
"[",
"0",
"]",
"?",
"-",
"1",
":",
"col",
"row",
"=",
"row",
">",
"image",
".",
"shape",
"[",
"1",
"]",
"?",
"-"... | Replaces all pixels of a specific value that are contained by pixels of
a different value.
Uses an iterative, queue based flood fill algorithm. It seems that a
recursive method is not suited for Ruby, due to its limited stack space
(which is known to be a problem in general for scripting languages).
@param [Inte... | [
"Replaces",
"all",
"pixels",
"of",
"a",
"specific",
"value",
"that",
"are",
"contained",
"by",
"pixels",
"of",
"a",
"different",
"value",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L224-L253 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.print_img | 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 | 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 | [
"def",
"print_img",
"(",
"narr",
"=",
"@narray",
")",
"puts",
"\"Image dimensions: #{@columns}*#{@rows}\"",
"narr",
".",
"shape",
"[",
"0",
"]",
".",
"times",
"do",
"|",
"i",
"|",
"puts",
"narr",
"[",
"true",
",",
"i",
"]",
".",
"to_a",
".",
"to_s",
"e... | A convenience method for printing image information.
@deprecated NB! This has been used only for debugging, and will soon be removed.
@param [NArray] narr a numerical array | [
"A",
"convenience",
"method",
"for",
"printing",
"image",
"information",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L368-L373 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.create_general_dicom_image_scaffold | 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 | 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')
... | [
"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\\SEC... | Creates a new DICOM object with a set of basic attributes needed
for a valid DICOM image file. | [
"Creates",
"a",
"new",
"DICOM",
"object",
"with",
"a",
"set",
"of",
"basic",
"attributes",
"needed",
"for",
"a",
"valid",
"DICOM",
"image",
"file",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L500-L527 | train |
dicom/rtkit | lib/rtkit/image.rb | RTKIT.Image.update_dicom_image | 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 | 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 ... | [
"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",
"(",
... | Creates a new DICOM object with a set of basic attributes needed
for a valid DICOM file of slice type image modality. | [
"Creates",
"a",
"new",
"DICOM",
"object",
"with",
"a",
"set",
"of",
"basic",
"attributes",
"needed",
"for",
"a",
"valid",
"DICOM",
"file",
"of",
"slice",
"type",
"image",
"modality",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/image.rb#L641-L653 | train |
dicom/rtkit | lib/rtkit/rt_dose.rb | RTKIT.RTDose.add_volume | 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 | 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 | [
"def",
"add_volume",
"(",
"volume",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'volume'. Expected DoseVolume, got #{volume.class}.\"",
"unless",
"volume",
".",
"is_a?",
"(",
"DoseVolume",
")",
"@volumes",
"<<",
"volume",
"unless",
"@associated_volumes",
"[",
... | Adds a DoseVolume instance to this RTDose series.
@param [DoseVolume] volume a dose volume instance to be associated with this RTDose | [
"Adds",
"a",
"DoseVolume",
"instance",
"to",
"this",
"RTDose",
"series",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/rt_dose.rb#L141-L145 | train |
dicom/rtkit | lib/rtkit/plan.rb | RTKIT.Plan.add_beam | 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 | 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 | [
"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",
")",
"... | Adds a Beam to this Plan.
@param [Beam] beam a beam instance to be associated with this plan | [
"Adds",
"a",
"Beam",
"to",
"this",
"Plan",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/plan.rb#L167-L170 | train |
dicom/rtkit | lib/rtkit/plan.rb | RTKIT.Plan.add_rt_dose | 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 | 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 | [
"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",
"[",
... | Adds a RTDose series to this Plan.
@param [RTDose] rt_dose an RTDose instance to be associated with this plan | [
"Adds",
"a",
"RTDose",
"series",
"to",
"this",
"Plan",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/plan.rb#L176-L180 | train |
dicom/rtkit | lib/rtkit/plan.rb | RTKIT.Plan.add_rt_image | 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 | 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 | [
"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",
".",
"... | Adds a RTImage Series to this Plan.
@param [RTImage] rt_image an RTImage instance to be associated with this plan | [
"Adds",
"a",
"RTImage",
"Series",
"to",
"this",
"Plan",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/plan.rb#L186-L189 | train |
dicom/rtkit | lib/rtkit/beam.rb | RTKIT.Beam.add_collimator | 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 | 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 | [
"def",
"add_collimator",
"(",
"coll",
")",
"raise",
"ArgumentError",
",",
"\"Invalid argument 'coll'. Expected Collimator, got #{coll.class}.\"",
"unless",
"coll",
".",
"is_a?",
"(",
"Collimator",
")",
"@collimators",
"<<",
"coll",
"unless",
"@associated_collimators",
"[",
... | Adds a Collimator instance to this Beam.
@param [Collimator] coll a collimator instance to be associated with this beam | [
"Adds",
"a",
"Collimator",
"instance",
"to",
"this",
"Beam",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/beam.rb#L136-L140 | train |
dicom/rtkit | lib/rtkit/beam.rb | RTKIT.Beam.add_control_point | 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 | 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 | [
"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",
"[... | Adds a ControlPoint instance to this Beam.
@param [ControlPoint] cp a control point instance to be associated with this beam | [
"Adds",
"a",
"ControlPoint",
"instance",
"to",
"this",
"Beam",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/beam.rb#L146-L150 | train |
dicom/rtkit | lib/rtkit/beam.rb | RTKIT.Beam.beam_item | 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 | 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.... | [
"def",
"beam_item",
"item",
"=",
"DICOM",
"::",
"Item",
".",
"new",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"ROI_COLOR",
",",
"@color",
")",
")",
"s",
"=",
"DICOM",
"::",
"Sequence",
".",
"new",
"(",
"CONTOUR_SQ",
")",
"... | Creates a Beam Sequence Item from the attributes of the Beam instance.
@return [DICOM::Item] a beam sequence item | [
"Creates",
"a",
"Beam",
"Sequence",
"Item",
"from",
"the",
"attributes",
"of",
"the",
"Beam",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/beam.rb#L156-L169 | train |
dicom/rtkit | lib/rtkit/beam.rb | RTKIT.Beam.control_point | 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 | 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... | [
"def",
"control_point",
"(",
"*",
"args",
")",
"raise",
"ArgumentError",
",",
"\"Expected one or none arguments, got #{args.length}.\"",
"unless",
"[",
"0",
",",
"1",
"]",
".",
"include?",
"(",
"args",
".",
"length",
")",
"if",
"args",
".",
"length",
"==",
"1"... | Gives the ControlPoint instance mathcing the specified index.
@overload control_point(index)
@param [String] index the control_point index
@return [ControlPoint, NilClass] the matched control_point (or nil if no control_point is matched)
@overload control_point
@return [ControlPoint, NilClass] the first con... | [
"Gives",
"the",
"ControlPoint",
"instance",
"mathcing",
"the",
"specified",
"index",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/beam.rb#L197-L206 | train |
dicom/rtkit | lib/rtkit/beam.rb | RTKIT.Beam.ref_beam_item | 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 | 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 | [
"def",
"ref_beam_item",
"item",
"=",
"DICOM",
"::",
"Item",
".",
"new",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
"new",
"(",
"OBS_NUMBER",
",",
"@number",
".",
"to_s",
")",
")",
"item",
".",
"add",
"(",
"DICOM",
"::",
"Element",
".",
... | Creates a Referenced Beam Sequence Item from the attributes of the Beam instance.
@return [DICOM::Item] a referenced beam sequence item | [
"Creates",
"a",
"Referenced",
"Beam",
"Sequence",
"Item",
"from",
"the",
"attributes",
"of",
"the",
"Beam",
"instance",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/beam.rb#L339-L346 | train |
dicom/rtkit | lib/rtkit/mixins/image_parent.rb | RTKIT.ImageParent.to_voxel_space | 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 | 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.... | [
"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",
"... | Creates a VoxelSpace instance from the image instances belonging
to this image series.
@return [VoxelSpace] the created VoxelSpace instance | [
"Creates",
"a",
"VoxelSpace",
"instance",
"from",
"the",
"image",
"instances",
"belonging",
"to",
"this",
"image",
"series",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/mixins/image_parent.rb#L36-L46 | train |
dicom/rtkit | lib/rtkit/mixins/image_parent.rb | RTKIT.ImageParent.update_image_position | 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 | 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 | [
"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",
".... | Updates the position that is registered for the image instance for this series.
@param [Image] image an instance belonging to this image series
@param [Float] new_pos a new slice position to be associated with the image instance | [
"Updates",
"the",
"position",
"that",
"is",
"registered",
"for",
"the",
"image",
"instance",
"for",
"this",
"series",
"."
] | 08248bf294769ae5b45ed4a9671f0620d5740252 | https://github.com/dicom/rtkit/blob/08248bf294769ae5b45ed4a9671f0620d5740252/lib/rtkit/mixins/image_parent.rb#L53-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.