_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22300 | DICOM.Anonymizer.anonymize | train | def anonymize(dicom)
dicom = Array[dicom] unless dicom.respond_to?(:to_ary)
if @tags.length > 0
prepare_anonymization
dicom.each do |dcm|
anonymize_dcm(dcm.to_dcm)
end
else
logger.warn("No tags have been selected for anonymization. Aborting anonymization.")
... | ruby | {
"resource": ""
} |
q22301 | DICOM.Anonymizer.delete_tag | train | def delete_tag(tag)
raise ArgumentError, "Expected String, got #{tag.class}." unless tag.is_a?(String)
raise ArgumentError, "Expected a valid tag of format 'GGGG,EEEE', got #{tag}." unless tag.tag?
@delete[tag] = true
end | ruby | {
"resource": ""
} |
q22302 | DICOM.Anonymizer.set_tag | train | def set_tag(tag, options={})
raise ArgumentError, "Expected String, got #{tag.class}." unless tag.is_a?(String)
raise ArgumentError, "Expected a valid tag of format 'GGGG,EEEE', got #{tag}." unless tag.tag?
pos = @tags.index(tag)
if pos
# Update existing values:
@values[pos] = op... | ruby | {
"resource": ""
} |
q22303 | DICOM.Anonymizer.value | train | def value(tag)
raise ArgumentError, "Expected String, got #{tag.class}." unless tag.is_a?(String)
raise ArgumentError, "Expected a valid tag of format 'GGGG,EEEE', got #{tag}." unless tag.tag?
pos = @tags.index(tag)
if pos
return @values[pos]
else
logger.warn("The specified... | ruby | {
"resource": ""
} |
q22304 | DICOM.Anonymizer.anonymize_dcm | train | def anonymize_dcm(dcm)
# Extract the data element parents to investigate:
parents = element_parents(dcm)
parents.each do |parent|
# Anonymize the desired tags:
@tags.each_index do |j|
if parent.exists?(@tags[j])
element = parent[@tags[j]]
if element.is... | ruby | {
"resource": ""
} |
q22305 | DICOM.Anonymizer.anonymize_file | train | def anonymize_file(file)
# Temporarily adjust the ruby-dicom log threshold (to suppress messages from the DObject class):
@original_level = logger.level
logger.level = @logger_level
dcm = DObject.read(file)
logger.level = @original_level
anonymize_dcm(dcm)
dcm
end | ruby | {
"resource": ""
} |
q22306 | DICOM.Anonymizer.default_value | train | def default_value(tag)
name, vr = LIBRARY.name_and_vr(tag)
conversion = VALUE_CONVERSION[vr]
case conversion
when :to_i then return 0
when :to_f then return 0.0
else
# Assume type is string and return an empty string:
return ''
end
end | ruby | {
"resource": ""
} |
q22307 | DICOM.Anonymizer.destination | train | def destination(dcm)
# Separate the path from the source file string:
file_start = dcm.source.rindex(File.basename(dcm.source))
if file_start == 0
source_dir = "."
else
source_dir = dcm.source[0..(file_start-1)]
end
source_folders = source_dir.split(File::SEPARATOR)
... | ruby | {
"resource": ""
} |
q22308 | DICOM.Anonymizer.enumerated_value | train | def enumerated_value(original, j)
# Is enumeration requested for this tag?
if @enumerations[j]
if @audit_trail
# Check if the UID has been encountered already:
replacement = @audit_trail.replacement(@tags[j], at_value(original))
unless replacement
# This ori... | ruby | {
"resource": ""
} |
q22309 | DICOM.Anonymizer.replace_uids | train | def replace_uids(parents)
parents.each do |parent|
parent.each_element do |element|
if element.vr == ('UI') and !@static_uids[element.tag]
original = element.value
if original && original.length > 0
# We have a UID value, go ahead and replace it:
... | ruby | {
"resource": ""
} |
q22310 | DICOM.Anonymizer.set_defaults | train | def set_defaults
# Some UIDs should not be remapped even if uid anonymization has been requested:
@static_uids = {
# Private related:
'0002,0100' => true,
'0004,1432' => true,
# Coding scheme related:
'0008,010C' => true,
'0008,010D' => true,
# Transfe... | ruby | {
"resource": ""
} |
q22311 | DICOM.Anonymizer.write | train | def write(dcm)
if @write_path
# The DICOM object is to be written to a separate directory. If the
# original and the new directories have a common root, this is taken into
# consideration when determining the object's write path:
path = destination(dcm)
if @random_file_name... | ruby | {
"resource": ""
} |
q22312 | DICOM.Element.value= | train | def value=(new_value)
if VALUE_CONVERSION[@vr] == :to_s
# Unless this is actually the Character Set data element,
# get the character set (note that it may not be available):
character_set = (@tag != '0008,0005' && top_parent.is_a?(DObject)) ? top_parent.value('0008,0005') : nil
# ... | ruby | {
"resource": ""
} |
q22313 | Calabash.ConsoleHelpers.console_attach | train | def console_attach(uia_strategy=nil)
Calabash::Application.default = Calabash::IOS::Application.default_from_environment
identifier = Calabash::IOS::Device.default_identifier_for_application(Calabash::Application.default)
server = Calabash::IOS::Server.default
device = Calabash::IOS::Device.n... | ruby | {
"resource": ""
} |
q22314 | Calabash.Device.pan_between | train | def pan_between(query_from, query_to, options={})
ensure_query_class_or_nil(query_from)
ensure_query_class_or_nil(query_to)
gesture_options = options.dup
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
_pan_between(query_from, query_to, gesture_options)
... | ruby | {
"resource": ""
} |
q22315 | Calabash.Device.flick_between | train | def flick_between(query_from, query_to, options={})
ensure_query_class_or_nil(query_from)
ensure_query_class_or_nil(query_to)
gesture_options = options.dup
gesture_options[:timeout] ||= Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT
_flick_between(query_from, query_to, gesture_options... | ruby | {
"resource": ""
} |
q22316 | Calabash.Web.evaluate_javascript_in | train | def evaluate_javascript_in(query, javascript)
wait_for_view(query,
timeout: Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT)
_evaluate_javascript_in(query, javascript)
end | ruby | {
"resource": ""
} |
q22317 | Calabash.Text.wait_for_keyboard | train | def wait_for_keyboard(timeout: nil)
keyboard_timeout = keyboard_wait_timeout(timeout)
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to appear"
wait_for(message, timeout: keyboard_timeout) do
keyboard_visible?
end
end | ruby | {
"resource": ""
} |
q22318 | Calabash.Text.wait_for_no_keyboard | train | def wait_for_no_keyboard(timeout: nil)
keyboard_timeout = keyboard_wait_timeout(timeout)
message = "Timed out after #{keyboard_timeout} seconds waiting for the keyboard to disappear"
wait_for(message, timeout: keyboard_timeout) do
!keyboard_visible?
end
end | ruby | {
"resource": ""
} |
q22319 | DICOM.DClient.find_series | train | def find_series(query_params={})
# Study Root Query/Retrieve Information Model - FIND:
set_default_presentation_context("1.2.840.10008.5.1.4.1.2.2.1")
# Every query attribute with a value != nil (required) will be sent in the dicom query.
# The query parameters with nil-value (optional) are left... | ruby | {
"resource": ""
} |
q22320 | DICOM.DClient.move_image | train | def move_image(destination, options={})
# Study Root Query/Retrieve Information Model - MOVE:
set_default_presentation_context("1.2.840.10008.5.1.4.1.2.2.2")
# Transfer the current options to the data_elements hash:
set_command_fragment_move(destination)
# Prepare data elements for this op... | ruby | {
"resource": ""
} |
q22321 | DICOM.DClient.move_study | train | def move_study(destination, options={})
# Study Root Query/Retrieve Information Model - MOVE:
set_default_presentation_context("1.2.840.10008.5.1.4.1.2.2.2")
# Transfer the current options to the data_elements hash:
set_command_fragment_move(destination)
# Prepare data elements for this op... | ruby | {
"resource": ""
} |
q22322 | DICOM.DClient.available_transfer_syntaxes | train | def available_transfer_syntaxes(transfer_syntax)
case transfer_syntax
when IMPLICIT_LITTLE_ENDIAN
return [IMPLICIT_LITTLE_ENDIAN, EXPLICIT_LITTLE_ENDIAN]
when EXPLICIT_LITTLE_ENDIAN
return [EXPLICIT_LITTLE_ENDIAN, IMPLICIT_LITTLE_ENDIAN]
when EXPLICIT_BIG_ENDIAN
return [E... | ruby | {
"resource": ""
} |
q22323 | DICOM.DClient.establish_association | train | def establish_association
# Reset some variables:
@association = false
@request_approved = false
# Initiate the association:
@link.build_association_request(@presentation_contexts, @user_information)
@link.start_session(@host_ip, @port)
@link.transmit
info = @link.receive... | ruby | {
"resource": ""
} |
q22324 | DICOM.DClient.establish_release | train | def establish_release
@release = false
if @abort
@link.stop_session
logger.info("Association has been closed. (#{@host_ae}, #{@host_ip})")
else
unless @link.session.closed?
@link.build_release_request
@link.transmit
info = @link.receive_single_tran... | ruby | {
"resource": ""
} |
q22325 | DICOM.DClient.load_files | train | def load_files(files_or_objects)
files_or_objects = [files_or_objects] unless files_or_objects.is_a?(Array)
status = true
message = ""
objects = Array.new
abstracts = Array.new
id = 1
@presentation_contexts = Hash.new
files_or_objects.each do |file_or_object|
if f... | ruby | {
"resource": ""
} |
q22326 | DICOM.DClient.perform_echo | train | def perform_echo
# Open a DICOM link:
establish_association
if association_established?
if request_approved?
# Continue with our echo, since the request was accepted.
# Set the query command elements array:
set_command_fragment_echo
@link.build_command_f... | ruby | {
"resource": ""
} |
q22327 | DICOM.DClient.perform_get | train | def perform_get(path)
# Open a DICOM link:
establish_association
if association_established?
if request_approved?
# Continue with our operation, since the request was accepted.
@link.build_command_fragment(PDU_DATA, presentation_context_id, COMMAND_LAST_FRAGMENT, @command_e... | ruby | {
"resource": ""
} |
q22328 | DICOM.DClient.perform_send | train | def perform_send(objects)
objects.each_with_index do |dcm, index|
# Gather necessary information from the object (SOP Class & Instance UID):
sop_class = dcm.value("0008,0016")
sop_instance = dcm.value("0008,0018")
if sop_class and sop_instance
# Only send the image if its... | ruby | {
"resource": ""
} |
q22329 | DICOM.DClient.process_presentation_context_response | train | def process_presentation_context_response(presentation_contexts)
# Storing approved syntaxes in an Hash with the syntax as key and the value being an array with presentation context ID and the transfer syntax chosen by the SCP.
@approved_syntaxes = Hash.new
rejected = Hash.new
# Reset the presen... | ruby | {
"resource": ""
} |
q22330 | DICOM.DClient.process_returned_data | train | def process_returned_data(segments)
# Reset command results arrays:
@command_results = Array.new
@data_results = Array.new
# Try to extract data:
segments.each do |info|
if info[:valid]
# Determine if it is command or data:
if info[:presentation_context_flag] ==... | ruby | {
"resource": ""
} |
q22331 | DICOM.DClient.set_default_presentation_context | train | def set_default_presentation_context(abstract_syntax)
raise ArgumentError, "Expected String, got #{abstract_syntax.class}" unless abstract_syntax.is_a?(String)
id = 1
transfer_syntaxes = [IMPLICIT_LITTLE_ENDIAN, EXPLICIT_LITTLE_ENDIAN, EXPLICIT_BIG_ENDIAN]
item = {:transfer_syntaxes => transfer_... | ruby | {
"resource": ""
} |
q22332 | DICOM.DClient.set_data_elements | train | def set_data_elements(options)
@data_elements = []
options.keys.sort.each do |tag|
@data_elements << [ tag, options[tag] ] unless options[tag].nil?
end
end | ruby | {
"resource": ""
} |
q22333 | Calabash.ConsoleHelpers.reload_git_files | train | def reload_git_files
files_to_reload =
(`git status`.lines.grep(/modified/).map{|l| l.split(" ").last.gsub('../', '')} +
`git ls-files --others --exclude-standard`.lines).map(&:chomp)
$LOADED_FEATURES.each do |file|
files_to_reload.each do |reload_name|
if file.end... | ruby | {
"resource": ""
} |
q22334 | Calabash.ConsoleHelpers.cal_methods | train | def cal_methods
c = Class.new(BasicObject) do
include Calabash
end
ConsoleHelpers.puts_unbound_methods(c, 'cal.')
true
end | ruby | {
"resource": ""
} |
q22335 | Calabash.ConsoleHelpers.cal_method | train | def cal_method(method)
c = Class.new(BasicObject) do
include Calabash
end
ConsoleHelpers.puts_unbound_method(c, method.to_sym, 'cal.')
true
end | ruby | {
"resource": ""
} |
q22336 | Calabash.ConsoleHelpers.cal_ios_methods | train | def cal_ios_methods
c = Class.new(BasicObject) do
include Calabash::IOSInternal
end
ConsoleHelpers.puts_unbound_methods(c, 'cal_ios.')
true
end | ruby | {
"resource": ""
} |
q22337 | Calabash.ConsoleHelpers.cal_android_methods | train | def cal_android_methods
c = Class.new(BasicObject) do
include Calabash::AndroidInternal
end
ConsoleHelpers.puts_unbound_methods(c, 'cal_android.')
true
end | ruby | {
"resource": ""
} |
q22338 | Calabash.ConsoleHelpers.tree | train | def tree
ConsoleHelpers.dump(Calabash::Internal.with_current_target {|target| target.dump})
true
end | ruby | {
"resource": ""
} |
q22339 | Calabash.ConsoleHelpers.verbose | train | def verbose
if Calabash::Logger.log_levels.include?(:debug)
puts Color.blue('Debug logging is already turned on.')
else
Calabash::Logger.log_levels << :debug
puts Color.blue('Turned on debug logging.')
end
true
end | ruby | {
"resource": ""
} |
q22340 | Calabash.ConsoleHelpers.quiet | train | def quiet
if Calabash::Logger.log_levels.include?(:debug)
puts Color.blue('Turned off debug logging.')
Calabash::Logger.log_levels.delete(:debug)
else
puts Color.blue('Debug logging is already turned off.')
end
true
end | ruby | {
"resource": ""
} |
q22341 | DICOM.Stream.decode | train | def decode(length, type)
raise ArgumentError, "Invalid argument length. Expected Integer, got #{length.class}" unless length.is_a?(Integer)
raise ArgumentError, "Invalid argument type. Expected string, got #{type.class}" unless type.is_a?(String)
value = nil
if (@index + length) <= @string.lengt... | ruby | {
"resource": ""
} |
q22342 | DICOM.Stream.decode_tag | train | def decode_tag
length = 4
tag = nil
if (@index + length) <= @string.length
# There are sufficient bytes remaining to extract a full tag:
str = @string.slice(@index, length).unpack(@hex)[0].upcase
if @equal_endian
tag = "#{str[2..3]}#{str[0..1]},#{str[6..7]}#{str[4..5]... | ruby | {
"resource": ""
} |
q22343 | DICOM.Stream.encode | train | def encode(value, type)
raise ArgumentError, "Invalid argument type. Expected string, got #{type.class}" unless type.is_a?(String)
value = [value] unless value.is_a?(Array)
return value.pack(vr_to_str(type))
end | ruby | {
"resource": ""
} |
q22344 | DICOM.Stream.encode_string_with_trailing_spaces | train | def encode_string_with_trailing_spaces(string, target_length)
length = string.length
if length < target_length
return "#{[string].pack(@str)}#{['20'*(target_length-length)].pack(@hex)}"
elsif length == target_length
return [string].pack(@str)
else
raise "The specified str... | ruby | {
"resource": ""
} |
q22345 | DICOM.Stream.encode_value | train | def encode_value(value, vr)
if vr == 'AT'
bin = encode_tag(value)
else
# Make sure the value is in an array:
value = [value] unless value.is_a?(Array)
# Get the proper pack string:
type = vr_to_str(vr)
# Encode:
bin = value.pack(type)
# Add an ... | ruby | {
"resource": ""
} |
q22346 | Calabash.Interactions.backdoor | train | def backdoor(name, *arguments)
Calabash::Internal.with_current_target {|target| target.backdoor(name, *arguments)}
end | ruby | {
"resource": ""
} |
q22347 | DICOM.DServer.add_abstract_syntax | train | def add_abstract_syntax(uid)
lib_uid = LIBRARY.uid(uid)
raise "Invalid/unknown UID: #{uid}" unless lib_uid
@accepted_abstract_syntaxes[uid] = lib_uid.name
end | ruby | {
"resource": ""
} |
q22348 | DICOM.DServer.add_transfer_syntax | train | def add_transfer_syntax(uid)
lib_uid = LIBRARY.uid(uid)
raise "Invalid/unknown UID: #{uid}" unless lib_uid
@accepted_transfer_syntaxes[uid] = lib_uid.name
end | ruby | {
"resource": ""
} |
q22349 | DICOM.DServer.print_abstract_syntaxes | train | def print_abstract_syntaxes
# Determine length of longest key to ensure pretty print:
max_uid = @accepted_abstract_syntaxes.keys.collect{|k| k.length}.max
puts "Abstract syntaxes which are accepted by this SCP:"
@accepted_abstract_syntaxes.sort.each do |pair|
puts "#{pair[0]}#{' '*(max_u... | ruby | {
"resource": ""
} |
q22350 | Calabash.Wait.wait_for_view | train | def wait_for_view(query,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
if query.nil?
raise ArgumentError, 'Query cannot be nil'
end
t... | ruby | {
"resource": ""
} |
q22351 | Calabash.Wait.wait_for_views | train | def wait_for_views(*queries,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
if queries.nil? || queries.any?(&:nil?)
raise ArgumentError, 'Query ... | ruby | {
"resource": ""
} |
q22352 | Calabash.Wait.wait_for_no_view | train | def wait_for_no_view(query,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
if query.nil?
raise ArgumentError, 'Query cannot be nil'
... | ruby | {
"resource": ""
} |
q22353 | Calabash.Wait.wait_for_no_views | train | def wait_for_no_views(*queries,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
if queries.nil? || queries.any?(&:nil?)
raise ArgumentEr... | ruby | {
"resource": ""
} |
q22354 | Calabash.Wait.view_exists? | train | def view_exists?(query)
if query.nil?
raise ArgumentError, 'Query cannot be nil'
end
result = query(query)
!result.empty?
end | ruby | {
"resource": ""
} |
q22355 | Calabash.Wait.views_exist? | train | def views_exist?(*queries)
if queries.nil? || queries.any?(&:nil?)
raise ArgumentError, 'Query cannot be nil'
end
results = queries.map{|query| view_exists?(query)}
results.all?
end | ruby | {
"resource": ""
} |
q22356 | Calabash.Wait.expect_view | train | def expect_view(query)
if query.nil?
raise ArgumentError, 'Query cannot be nil'
end
unless view_exists?(query)
raise ViewNotFoundError,
"No view matched #{Wait.parse_query_list(query)}"
end
true
end | ruby | {
"resource": ""
} |
q22357 | Calabash.Wait.expect_views | train | def expect_views(*queries)
if queries.nil? || queries.any?(&:nil?)
raise ArgumentError, 'Query cannot be nil'
end
unless views_exist?(*queries)
raise ViewNotFoundError,
"Not all queries #{Wait.parse_query_list(queries)} matched a view"
end
true
end | ruby | {
"resource": ""
} |
q22358 | Calabash.Wait.do_not_expect_view | train | def do_not_expect_view(query)
if query.nil?
raise ArgumentError, 'Query cannot be nil'
end
if view_exists?(query)
raise ViewFoundError, "A view matched #{Wait.parse_query_list(query)}"
end
true
end | ruby | {
"resource": ""
} |
q22359 | Calabash.Wait.do_not_expect_views | train | def do_not_expect_views(*queries)
if queries.nil? || queries.any?(&:nil?)
raise ArgumentError, 'Query cannot be nil'
end
if queries.map{|query| view_exists?(query)}.any?
raise ViewFoundError,
"Some views matched #{Wait.parse_query_list(queries)}"
end
true
... | ruby | {
"resource": ""
} |
q22360 | Calabash.Wait.wait_for_text | train | def wait_for_text(text,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
wait_for_view("* {text CONTAINS[c] '#{text}'}",
timeout: timeou... | ruby | {
"resource": ""
} |
q22361 | Calabash.Wait.wait_for_no_text | train | def wait_for_no_text(text,
timeout: Calabash::Wait.default_options[:timeout],
timeout_message: nil,
retry_frequency: Calabash::Wait.default_options[:retry_frequency])
wait_for_no_view("* {text CONTAINS[c] '#{text}'}",
... | ruby | {
"resource": ""
} |
q22362 | DICOM.AuditTrail.add_record | train | def add_record(tag, original, replacement)
@dictionary[tag] = Hash.new unless @dictionary.key?(tag)
@dictionary[tag][original] = replacement
end | ruby | {
"resource": ""
} |
q22363 | DICOM.AuditTrail.original | train | def original(tag, replacement)
original = nil
if @dictionary.key?(tag)
original = @dictionary[tag].key(replacement)
end
return original
end | ruby | {
"resource": ""
} |
q22364 | DICOM.AuditTrail.replacement | train | def replacement(tag, original)
replacement = nil
replacement = @dictionary[tag][original] if @dictionary.key?(tag)
return replacement
end | ruby | {
"resource": ""
} |
q22365 | DICOM.DObject.encode_segments | train | def encode_segments(max_size, transfer_syntax=IMPLICIT_LITTLE_ENDIAN)
raise ArgumentError, "Invalid argument. Expected an Integer, got #{max_size.class}." unless max_size.is_a?(Integer)
raise ArgumentError, "Argument too low (#{max_size}), please specify a bigger Integer." unless max_size > 16
raise "... | ruby | {
"resource": ""
} |
q22366 | DICOM.DObject.summary | train | def summary
# FIXME: Perhaps this method should be split up in one or two separate methods
# which just builds the information arrays, and a third method for printing this to the screen.
sys_info = Array.new
info = Array.new
# Version of Ruby DICOM used:
sys_info << "Ruby DICOM versi... | ruby | {
"resource": ""
} |
q22367 | DICOM.DObject.transfer_syntax= | train | def transfer_syntax=(new_syntax)
# Verify old and new transfer syntax:
new_uid = LIBRARY.uid(new_syntax)
old_uid = LIBRARY.uid(transfer_syntax)
raise ArgumentError, "Invalid/unknown transfer syntax specified: #{new_syntax}" unless new_uid && new_uid.transfer_syntax?
raise ArgumentError, "I... | ruby | {
"resource": ""
} |
q22368 | DICOM.DObject.write | train | def write(file_name, options={})
raise ArgumentError, "Invalid file_name. Expected String, got #{file_name.class}." unless file_name.is_a?(String)
@include_empty_parents = options[:include_empty_parents]
insert_missing_meta unless options[:ignore_meta]
write_elements(:file_name => file_name, :si... | ruby | {
"resource": ""
} |
q22369 | DICOM.DObject.meta_group_length | train | def meta_group_length
group_length = 0
meta_elements = group(META_GROUP)
tag = 4
vr = 2
meta_elements.each do |element|
case element.vr
when "OB","OW","OF","SQ","UN","UT"
length = 6
else
length = 2
end
group_length += tag ... | ruby | {
"resource": ""
} |
q22370 | DICOM.ImageItem.add_element | train | def add_element(tag, value, options={})
add(e = Element.new(tag, value, options))
e
end | ruby | {
"resource": ""
} |
q22371 | DICOM.ImageItem.add_sequence | train | def add_sequence(tag, options={})
add(s = Sequence.new(tag, options))
s
end | ruby | {
"resource": ""
} |
q22372 | DICOM.ImageItem.color? | train | def color?
# "Photometric Interpretation" is contained in the data element "0028,0004":
begin
photometric = photometry
if photometric.include?('COLOR') or photometric.include?('RGB') or photometric.include?('YBR')
return true
else
return false
end
re... | ruby | {
"resource": ""
} |
q22373 | DICOM.ImageItem.decode_pixels | train | def decode_pixels(bin, stream=@stream)
raise ArgumentError, "Expected String, got #{bin.class}." unless bin.is_a?(String)
pixels = false
# We need to know what kind of bith depth and integer type the pixel data is saved with:
bit_depth_element = self['0028,0100']
pixel_representation_eleme... | ruby | {
"resource": ""
} |
q22374 | DICOM.ImageItem.encode_pixels | train | def encode_pixels(pixels, stream=@stream)
raise ArgumentError, "Expected Array, got #{pixels.class}." unless pixels.is_a?(Array)
bin = false
# We need to know what kind of bith depth and integer type the pixel data is saved with:
bit_depth_element = self['0028,0100']
pixel_representation_e... | ruby | {
"resource": ""
} |
q22375 | DICOM.ImageItem.images | train | def images(options={})
images = Array.new
if exists?(PIXEL_TAG)
# Gather the pixel data strings, and pick a single frame if indicated by options:
strings = image_strings(split_to_frames=true)
strings = [strings[options[:frame]]] if options[:frame]
if compression?
# ... | ruby | {
"resource": ""
} |
q22376 | DICOM.ImageItem.image_to_file | train | def image_to_file(file)
raise ArgumentError, "Expected #{String}, got #{file.class}." unless file.is_a?(String)
# Split the file name in case of multiple fragments:
parts = file.split('.')
if parts.length > 1
base = parts[0..-2].join
extension = '.' + parts.last
else
... | ruby | {
"resource": ""
} |
q22377 | DICOM.ImageItem.pixels | train | def pixels(options={})
pixels = nil
if exists?(PIXEL_TAG)
# For now we only support returning pixel data of the first frame, if the image is located in multiple pixel data items:
if compression?
pixels = decompress(image_strings.first)
else
pixels = decode_pixels(... | ruby | {
"resource": ""
} |
q22378 | DICOM.ImageItem.decode_rle | train | def decode_rle(cols, rows, string)
# FIXME: Remove cols and rows (were only added for debugging).
pixels = Array.new
# RLE header specifying the number of segments:
header = string[0...64].unpack('L*')
image_segments = Array.new
# Extracting all start and endpoints of the different s... | ruby | {
"resource": ""
} |
q22379 | DICOM.ImageItem.process_presentation_values | train | def process_presentation_values(pixel_data, min_allowed, max_allowed, level=nil)
# Process pixel data for presentation according to the image information in the DICOM object:
center, width, intercept, slope = window_level_values
# Have image leveling been requested?
if level
# If custom ... | ruby | {
"resource": ""
} |
q22380 | DICOM.ImageItem.process_presentation_values_narray | train | def process_presentation_values_narray(pixel_data, min_allowed, max_allowed, level=nil)
# Process pixel data for presentation according to the image information in the DICOM object:
center, width, intercept, slope = window_level_values
# Have image leveling been requested?
if level
# If ... | ruby | {
"resource": ""
} |
q22381 | DICOM.ImageItem.read_image | train | def read_image(pixel_data, columns, rows, options={})
raise ArgumentError, "Expected Array for pixel_data, got #{pixel_data.class}" unless pixel_data.is_a?(Array)
raise ArgumentError, "Expected Integer for columns, got #{columns.class}" unless columns.is_a?(Integer)
raise ArgumentError, "Expected Rows... | ruby | {
"resource": ""
} |
q22382 | DICOM.ImageItem.window_level_values | train | def window_level_values
center = (self['0028,1050'].is_a?(Element) == true ? self['0028,1050'].value.to_i : nil)
width = (self['0028,1051'].is_a?(Element) == true ? self['0028,1051'].value.to_i : nil)
intercept = (self['0028,1052'].is_a?(Element) == true ? self['0028,1052'].value.to_i : 0)
slope... | ruby | {
"resource": ""
} |
q22383 | DICOM.ImageItem.write_pixels | train | def write_pixels(bin)
if self.exists?(PIXEL_TAG)
# Update existing Data Element:
self[PIXEL_TAG].bin = bin
else
# Create new Data Element:
pixel_element = Element.new(PIXEL_TAG, bin, :encoded => true, :parent => self)
end
end | ruby | {
"resource": ""
} |
q22384 | DICOM.Parent.parse | train | def parse(bin, syntax, switched=false, explicit=true)
raise ArgumentError, "Invalid argument 'bin'. Expected String, got #{bin.class}." unless bin.is_a?(String)
raise ArgumentError, "Invalid argument 'syntax'. Expected String, got #{syntax.class}." unless syntax.is_a?(String)
read(bin, signature=false... | ruby | {
"resource": ""
} |
q22385 | DICOM.Parent.check_duplicate | train | def check_duplicate(tag, elemental)
if @current_parent[tag]
gp = @current_parent.parent ? "#{@current_parent.parent.representation} => " : ''
p = @current_parent.representation
logger.warn("Duplicate #{elemental} (#{tag}) detected at level: #{gp}#{p}")
end
end | ruby | {
"resource": ""
} |
q22386 | DICOM.Parent.check_header | train | def check_header
# According to the official DICOM standard, a DICOM file shall contain 128 consequtive (zero) bytes,
# followed by 4 bytes that spell the string 'DICM'. Apparently, some providers seems to skip this in their DICOM files.
# Check that the string is long enough to contain a valid header... | ruby | {
"resource": ""
} |
q22387 | DICOM.Parent.process_data_element | train | def process_data_element
# FIXME: This method has grown a bit messy and isn't very pleasant to read. Cleanup possible?
# After having been into a possible unknown sequence with undefined length, we may need to reset
# explicitness from implicit to explicit:
if !@original_explicit.nil? && @explic... | ruby | {
"resource": ""
} |
q22388 | DICOM.Parent.read | train | def read(string, signature=true, options={})
# (Re)Set variables:
@str = string
@overwrite = options[:overwrite]
# Presence of the official DICOM signature:
@signature = false
# Default explicitness of start of DICOM string (if undefined it defaults to true):
@explicit = option... | ruby | {
"resource": ""
} |
q22389 | DICOM.Parent.add_with_segmentation | train | def add_with_segmentation(string)
# As the encoded DICOM string will be cut in multiple, smaller pieces, we need to monitor the length of our encoded strings:
if (string.length + @stream.length) > @max_size
split_and_add(string)
elsif (30 + @stream.length) > @max_size
# End the current... | ruby | {
"resource": ""
} |
q22390 | DICOM.Parent.check_encapsulated_image | train | def check_encapsulated_image(element)
# If DICOM object contains encapsulated pixel data, we need some special handling for its items:
if element.tag == PIXEL_TAG and element.parent.is_a?(DObject)
@enc_image = true if element.length <= 0
end
end | ruby | {
"resource": ""
} |
q22391 | DICOM.Parent.encode_in_segments | train | def encode_in_segments(max_size, options={})
@max_size = max_size
@transfer_syntax = options[:syntax]
# Until a DICOM write has completed successfully the status is 'unsuccessful':
@write_success = false
# Default explicitness of start of DICOM file:
@explicit = true
# Default ... | ruby | {
"resource": ""
} |
q22392 | DICOM.Parent.split_and_add | train | def split_and_add(string)
# Duplicate the string as not to ruin the binary of the data element with our slicing:
segment = string.dup
append = segment.slice!(0, @max_size-@stream.length)
# Clear out the stream along with a small part of the string:
@segments << @stream.export + append
... | ruby | {
"resource": ""
} |
q22393 | DICOM.Parent.write_data_element | train | def write_data_element(element)
# Step 1: Write tag:
write_tag(element.tag)
# Step 2: Write [VR] and value length:
write_vr_length(element.tag, element.vr, element.length)
# Step 3: Write value (Insert the already encoded binary string):
write_value(element.bin)
check_encapsula... | ruby | {
"resource": ""
} |
q22394 | DICOM.Parent.write_delimiter | train | def write_delimiter(element)
delimiter_tag = (element.tag == ITEM_TAG ? ITEM_DELIMITER : SEQUENCE_DELIMITER)
write_tag(delimiter_tag)
write_vr_length(delimiter_tag, ITEM_VR, 0)
end | ruby | {
"resource": ""
} |
q22395 | DICOM.Parent.write_elements | train | def write_elements(options={})
# Check if we are able to create given file:
open_file(options[:file_name])
# Go ahead and write if the file was opened successfully:
if @file
# Initiate necessary variables:
@transfer_syntax = options[:syntax]
# Until a DICOM write has comp... | ruby | {
"resource": ""
} |
q22396 | DICOM.Elemental.stream | train | def stream
if top_parent.is_a?(DObject)
return top_parent.stream
else
return Stream.new(nil, file_endian=false)
end
end | ruby | {
"resource": ""
} |
q22397 | DICOM.DLibrary.add_element | train | def add_element(element)
raise ArgumentError, "Invalid argument 'element'. Expected DictionaryElement, got #{element.class}" unless element.is_a?(DictionaryElement)
# We store the elements in a hash with tag as key and the element instance as value:
@elements[element.tag] = element
# Populate th... | ruby | {
"resource": ""
} |
q22398 | DICOM.DLibrary.add_element_dictionary | train | def add_element_dictionary(file)
File.open(file, :encoding => 'utf-8').each do |record|
fields = record.split("\t")
add_element(DictionaryElement.new(fields[0], fields[1], fields[2].split(","), fields[3].rstrip, fields[4].rstrip))
end
end | ruby | {
"resource": ""
} |
q22399 | DICOM.DLibrary.add_uid_dictionary | train | def add_uid_dictionary(file)
File.open(file, :encoding => 'utf-8').each do |record|
fields = record.split("\t")
add_uid(UID.new(fields[0], fields[1], fields[2].rstrip, fields[3].rstrip))
end
end | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.