idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
12,000 | def value ( tag ) check_key ( tag , :value ) if exists? ( tag ) if self [ tag ] . is_parent? raise ArgumentError , "Illegal parameter '#{tag}'. Parent elements, like the referenced '#{@tags[tag].class}', have no value. Only Element tags are valid." else return self [ tag ] . value end else return nil end end | Gives the value of a specific Element child of this parent . |
12,001 | def check_key ( tag_or_index , method ) if tag_or_index . is_a? ( String ) logger . warn ( "Parent##{method} called with an invalid tag argument: #{tag_or_index}" ) unless tag_or_index . tag? elsif tag_or_index . is_a? ( Integer ) logger . warn ( "Parent##{method} called with a negative Integer argument: #{tag_or_index... | Checks the given key argument and logs a warning if an obviously incorrect key argument is used . |
12,002 | def await_release segments = receive_single_transmission info = segments . first if info [ :pdu ] != PDU_RELEASE_REQUEST if info [ :valid ] logger . error ( "Unexpected message type received (PDU: #{info[:pdu]}). Expected a release request. Closing the connection." ) handle_abort ( false ) else logger . error ( "Timed ... | Creates a Link instance which is used by both DClient and DServer to handle network communication . |
12,003 | def build_association_request ( presentation_contexts , user_info ) @outgoing . endian = @net_endian @outgoing . reset append_application_context append_presentation_contexts ( presentation_contexts , ITEM_PRESENTATION_CONTEXT_REQUEST , request = true ) append_user_information ( user_info ) append_association_header ( ... | Builds the binary string which is sent as the association request . |
12,004 | def build_command_fragment ( pdu , context , flags , command_elements ) @outgoing . endian = @data_endian @outgoing . reset command_elements . each do | element | @outgoing . add_last ( @outgoing . encode_tag ( element [ 0 ] ) ) value = @outgoing . encode_value ( element [ 2 ] , element [ 1 ] ) @outgoing . encode_last ... | Builds the binary string which is sent as a command fragment . |
12,005 | def build_data_fragment ( data_elements , presentation_context_id ) set_transfer_syntax ( @presentation_contexts [ presentation_context_id ] ) @outgoing . endian = @data_endian @outgoing . reset data_elements . each do | element | @outgoing . add_last ( @outgoing . encode_tag ( element [ 0 ] ) ) vr = LIBRARY . element ... | Builds the binary string which is sent as a data fragment . |
12,006 | def build_storage_fragment ( pdu , context , flags , body ) @outgoing . endian = @net_endian @outgoing . reset @outgoing . add_last ( body ) @outgoing . encode_first ( flags , "HEX" ) @outgoing . encode_first ( context , "BY" ) @outgoing . encode_first ( @outgoing . string . length , "UL" ) append_header ( pdu ) end | Builds the binary string which makes up a C - STORE data fragment . |
12,007 | def forward_to_interpret ( message , pdu , file = nil ) case pdu when PDU_ASSOCIATION_REQUEST info = interpret_association_request ( message ) when PDU_ASSOCIATION_ACCEPT info = interpret_association_accept ( message ) when PDU_ASSOCIATION_REJECT info = interpret_association_reject ( message ) when PDU_DATA info = inte... | Delegates an incoming message to its appropriate interpreter method based on its pdu type . Returns the interpreted information hash . |
12,008 | def handle_incoming_data ( path ) segments = receive_multiple_transmissions ( file = true ) @command_results = Array . new @data_results = Array . new file_transfer_syntaxes = Array . new files = Array . new single_file_data = Array . new segments . each do | info | if info [ :valid ] if info [ :presentation_context_fl... | Processes incoming command & data fragments for the DServer . Returns a success boolean and an array of status messages . |
12,009 | def handle_response command_elements = Array . new command_elements << [ "0000,0002" , "UI" , @command_request [ "0000,0002" ] ] command_elements << [ "0000,0100" , "US" , command_field_response ( @command_request [ "0000,0100" ] ) ] command_elements << [ "0000,0120" , "US" , @command_request [ "0000,0110" ] ] command_... | Handles the command fragment response . |
12,010 | def interpret ( message , file = nil ) if @first_part message = @first_part + message @first_part = nil end segments = Array . new if message . length > 8 msg = Stream . new ( message , @net_endian ) pdu = msg . decode ( 1 , "HEX" ) msg . skip ( 1 ) specified_length = msg . decode ( 4 , "UL" ) if msg . rest_length > sp... | Decodes the header of an incoming message analyzes its real length versus expected length and handles any deviations to make sure that message strings are split up appropriately before they are being forwarded to interpretation . Returns an array of information hashes . |
12,011 | def interpret_abort ( message ) info = Hash . new msg = Stream . new ( message , @net_endian ) reserved_bytes = msg . skip ( 2 ) info [ :source ] = msg . decode ( 1 , "HEX" ) info [ :reason ] = msg . decode ( 1 , "HEX" ) process_source ( info [ :source ] ) process_reason ( info [ :reason ] ) stop_receiving @abort = tru... | Decodes the message received when the remote node wishes to abort the session . Returns the processed information hash . |
12,012 | def interpret_association_reject ( message ) info = Hash . new msg = Stream . new ( message , @net_endian ) msg . skip ( 1 ) info [ :result ] = msg . decode ( 1 , "BY" ) info [ :source ] = msg . decode ( 1 , "BY" ) info [ :reason ] = msg . decode ( 1 , "BY" ) logger . warn ( "ASSOCIATE Request was rejected by the host.... | Decodes the association reject message and extracts the error reasons given . Returns the processed information hash . |
12,013 | def interpret_release_request ( message ) info = Hash . new msg = Stream . new ( message , @net_endian ) reserved_bytes = msg . decode ( 4 , "HEX" ) handle_release info [ :valid ] = true return info end | Decodes the message received in the release request and calls the handle_release method . Returns the processed information hash . |
12,014 | def interpret_release_response ( message ) info = Hash . new msg = Stream . new ( message , @net_endian ) reserved_bytes = msg . decode ( 4 , "HEX" ) stop_receiving info [ :valid ] = true return info end | Decodes the message received in the release response and closes the connection . Returns the processed information hash . |
12,015 | def receive_multiple_transmissions ( file = nil ) @listen = true segments = Array . new while @listen data = receive_transmission ( @min_length ) current_segments = interpret ( data , file ) if current_segments current_segments . each do | cs | segments << cs end end end segments << { :valid => false } unless segments ... | Handles the reception of multiple incoming transmissions . Returns an array of interpreted message information hashes . |
12,016 | def receive_single_transmission min_length = 8 data = receive_transmission ( min_length ) segments = interpret ( data ) segments << { :valid => false } unless segments . length > 0 return segments end | Handles the reception of a single expected incoming transmission and returns the interpreted received data . |
12,017 | def process_reason ( reason ) case reason when "00" logger . error ( "Reason specified for abort: Reason not specified" ) when "01" logger . error ( "Reason specified for abort: Unrecognized PDU" ) when "02" logger . error ( "Reason specified for abort: Unexpected PDU" ) when "04" logger . error ( "Reason specified for... | Processes the value of the reason byte received in the association abort and prints an explanation of the error . |
12,018 | def process_result ( result ) unless result == 0 case result when 1 logger . warn ( "DICOM Request was rejected by the host, reason: 'User-rejection'" ) when 2 logger . warn ( "DICOM Request was rejected by the host, reason: 'No reason (provider rejection)'" ) when 3 logger . warn ( "DICOM Request was rejected by the h... | Processes the value of the result byte received in the association response . Prints an explanation if an error is indicated . |
12,019 | def receive_transmission ( min_length = 0 ) data = receive_transmission_data if data unless min_length == 0 if data . length < min_length addition = receive_transmission_data data = data + addition if addition end end else data = "" end data end | Handles an incoming network transmission . Returns the binary string data received . |
12,020 | def receive_transmission_data data = false response = IO . select ( [ @session ] , nil , nil , @timeout ) if response . nil? logger . error ( "No answer was received within the specified timeout period. Aborting." ) stop_receiving else data = @session . recv ( @max_receive_size ) end data end | Receives the data from an incoming network transmission . Returns the binary string data received . |
12,021 | def set_transfer_syntax ( syntax ) @transfer_syntax = syntax ts = LIBRARY . uid ( @transfer_syntax ) @explicit = ts ? ts . explicit? : true @data_endian = ts ? ts . big_endian? : false logger . warn ( "Invalid/unknown transfer syntax encountered: #{@transfer_syntax} Will try to continue, but errors may occur." ) unless... | Set instance variables related to a transfer syntax . |
12,022 | def bin = ( new_bin ) raise ArgumentError , "Invalid parameter type. String was expected, got #{new_bin.class}." unless new_bin . is_a? ( String ) if new_bin . length . odd? @bin = new_bin + "\x00" else @bin = new_bin end @value = nil @length = @bin . length end | Sets the binary string that the Item will contain . |
12,023 | def decompress ( blobs ) raise ArgumentError , "Expected Array or String, got #{blobs.class}." unless [ String , Array ] . include? ( blobs . class ) blobs = [ blobs ] unless blobs . is_a? ( Array ) begin return image_module . decompress ( blobs ) rescue return false end end | Creates image objects from one or more compressed binary string blobs . |
12,024 | def import_pixels ( blob , columns , rows , depth , photometry ) raise ArgumentError , "Expected String, got #{blob.class}." unless blob . is_a? ( String ) image_module . import_pixels ( blob , columns , rows , depth , photometry ) end | Creates an image object from a binary string blob . |
12,025 | def coordinates_for_place ( place_name ) result = Geocoder . search ( place_name ) if result . empty? raise "No result found for '#{place}'" end { latitude : result . first . latitude , longitude : result . first . longitude } end | Get the latitude and longitude for a certain place resolved via Google maps api . This hash can be used in set_location . |
12,026 | 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." ) end @audit_trail . write ( @audit_t... | Anonymizes the given DObject or array of DICOM objects with the settings of this Anonymizer instance . |
12,027 | 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 | Specifies that the given tag is to be completely deleted from the anonymized DICOM objects . |
12,028 | 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 @values [ pos ] = options [ :value ] if options [ :value ] @en... | Sets the anonymization settings for the specified tag . If the tag is already present in the list of tags to be anonymized its settings are updated and if not a new tag entry is created . |
12,029 | 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 tag (#{tag}) was not ... | Gives the value which will be used when anonymizing this tag . |
12,030 | def anonymize_dcm ( dcm ) parents = element_parents ( dcm ) parents . each do | parent | @tags . each_index do | j | if parent . exists? ( @tags [ j ] ) element = parent [ @tags [ j ] ] if element . is_a? ( Element ) if @blank value = '' elsif @enumeration old_value = element . value if old_value value = enumerated_val... | Performs anonymization on a DICOM object . |
12,031 | def anonymize_file ( file ) @original_level = logger . level logger . level = @logger_level dcm = DObject . read ( file ) logger . level = @original_level anonymize_dcm ( dcm ) dcm end | Performs anonymization of a DICOM file . |
12,032 | 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 return '' end end | Determines a default value to use for anonymizing the given tag . |
12,033 | def destination ( dcm ) 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 ) target_folders = @write_path . split ( File :: SEPARATOR ) source_f... | Creates a write path for the given DICOM object based on the object s original file path and the write_path attribute . |
12,034 | def enumerated_value ( original , j ) if @enumerations [ j ] if @audit_trail replacement = @audit_trail . replacement ( @tags [ j ] , at_value ( original ) ) unless replacement index = @audit_trail . records ( @tags [ j ] ) . length + 1 if @values [ j ] . is_a? ( String ) replacement = @values [ j ] + index . to_s else... | Handles the enumeration for the given data element tag . If its value has been encountered before its corresponding enumerated replacement value is retrieved and if a new original value is encountered a new enumerated replacement value is found by increasing an index by 1 . |
12,035 | 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 if @audit_trail replacement = @audit_trail . replacement ( 'uids' , original ) unless replacemen... | Replaces the UIDs of the given DICOM object . |
12,036 | def set_defaults @static_uids = { '0002,0100' => true , '0004,1432' => true , '0008,010C' => true , '0008,010D' => true , '0002,0010' => true , '0400,0010' => true , '0400,0510' => true , '0004,1512' => true , '0000,0002' => true , '0000,0003' => true , '0002,0002' => true , '0004,1510' => true , '0004,151A' => true , ... | Sets up some default information variables that are used by the Anonymizer . |
12,037 | def write ( dcm ) if @write_path path = destination ( dcm ) if @random_file_name file_name = "#{SecureRandom.hex(16)}.dcm" else file_name = File . basename ( dcm . source ) end dcm . write ( File . join ( path , file_name ) ) else dcm . write ( dcm . source ) end end | Writes a DICOM object to file . |
12,038 | def value = ( new_value ) if VALUE_CONVERSION [ @vr ] == :to_s character_set = ( @tag != '0008,0005' && top_parent . is_a? ( DObject ) ) ? top_parent . value ( '0008,0005' ) : nil @value = new_value . to_s . encode ( ENCODING_NAME [ character_set ] , new_value . to_s . encoding . name ) @bin = encode ( @value ) else if... | Sets the value of the Element instance . |
12,039 | 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 ... | Attach the current Calabash run - loop to a console . |
12,040 | 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 ) end | Performs a pan between two elements . |
12,041 | 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 ) end | Performs a flick between two elements . |
12,042 | def evaluate_javascript_in ( query , javascript ) wait_for_view ( query , timeout : Calabash :: Gestures :: DEFAULT_GESTURE_WAIT_TIMEOUT ) _evaluate_javascript_in ( query , javascript ) end | Evaluate javascript in a Web View . On iOS an implicit return is inserted on Android an explicit return is needed . |
12,043 | 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 | Waits for a keyboard to appear . |
12,044 | 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 | Waits for the keyboard to disappear . |
12,045 | def find_series ( query_params = { } ) set_default_presentation_context ( "1.2.840.10008.5.1.4.1.2.2.1" ) default_query_params = { "0008,0052" => "SERIES" , "0008,0060" => "" , "0020,000E" => "" , "0020,0011" => "" } query_params . keys . each do | tag | raise ArgumentError , "The supplied tag (#{tag}) is not valid. It... | Queries a service class provider for series that match the specified criteria . |
12,046 | def move_image ( destination , options = { } ) set_default_presentation_context ( "1.2.840.10008.5.1.4.1.2.2.2" ) set_command_fragment_move ( destination ) set_data_fragment_move_image set_data_options ( options ) perform_move end | Moves a single image to a DICOM server . |
12,047 | def move_study ( destination , options = { } ) set_default_presentation_context ( "1.2.840.10008.5.1.4.1.2.2.2" ) set_command_fragment_move ( destination ) set_data_fragment_move_study set_data_options ( options ) perform_move end | Move an entire study to a DICOM server . |
12,048 | 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 [ EXPLICIT_BIG_ENDIAN , IMPLICIT_LITTLE_E... | Returns an array of supported transfer syntaxes for the specified transfer syntax . For compressed transfer syntaxes we currently do not support reencoding these to other syntaxes . |
12,049 | def establish_association @association = false @request_approved = false @link . build_association_request ( @presentation_contexts , @user_information ) @link . start_session ( @host_ip , @port ) @link . transmit info = @link . receive_multiple_transmissions . first if info && info [ :valid ] if info [ :pdu ] == PDU_A... | Opens a TCP session with the server and handles the association request as well as the response . |
12,050 | 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_transmission . first @link . stop_session if info [ :pdu ] ... | Handles the release request along with the response as well as closing the TCP connection . |
12,051 | 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 file_or_object . is_a? ( String ) cli... | Loads one or more DICOM files . Returns an array of DObject instances an array of unique abstract syntaxes found among the files a status boolean and a message string . |
12,052 | def perform_echo establish_association if association_established? if request_approved? set_command_fragment_echo @link . build_command_fragment ( PDU_DATA , presentation_context_id , COMMAND_LAST_FRAGMENT , @command_elements ) @link . transmit segments = @link . receive_multiple_transmissions process_returned_data ( s... | Handles the communication involved in a DICOM C - ECHO . Build the necessary strings and send the command and data element that makes up the echo request . Listens for and interpretes the incoming echo response . |
12,053 | def perform_get ( path ) establish_association if association_established? if request_approved? @link . build_command_fragment ( PDU_DATA , presentation_context_id , COMMAND_LAST_FRAGMENT , @command_elements ) @link . transmit @link . build_data_fragment ( @data_elements , presentation_context_id ) @link . transmit suc... | Handles the communication involved in a DICOM C - GET . Builds and sends command & data fragment then receives the incoming file data . |
12,054 | def perform_send ( objects ) objects . each_with_index do | dcm , index | sop_class = dcm . value ( "0008,0016" ) sop_instance = dcm . value ( "0008,0018" ) if sop_class and sop_instance if @approved_syntaxes [ sop_class ] message_id = index + 1 set_command_fragment_store ( sop_class , sop_instance , message_id ) prese... | Handles the communication involved in DICOM C - STORE . For each file builds and sends command fragment then builds and sends the data fragments that conveys the information from the selected DICOM file . |
12,055 | def process_presentation_context_response ( presentation_contexts ) @approved_syntaxes = Hash . new rejected = Hash . new @link . presentation_contexts = Hash . new accepted_pc = 0 presentation_contexts . each do | pc | id = pc [ :presentation_context_id ] raise "Error! Even presentation context ID received in the asso... | Processes the presentation contexts that are received in the association response to extract the transfer syntaxes which have been accepted for the various abstract syntaxes . |
12,056 | def process_returned_data ( segments ) @command_results = Array . new @data_results = Array . new segments . each do | info | if info [ :valid ] if info [ :presentation_context_flag ] == COMMAND_LAST_FRAGMENT @command_results << info [ :results ] elsif info [ :presentation_context_flag ] == DATA_LAST_FRAGMENT @data_res... | Processes the array of information hashes that was returned from the interaction with the SCP and transfers it to the instance variables where command and data results are stored . |
12,057 | 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_syntaxes }... | Creates the presentation context used for the non - file - transmission association requests .. |
12,058 | def set_data_elements ( options ) @data_elements = [ ] options . keys . sort . each do | tag | @data_elements << [ tag , options [ tag ] ] unless options [ tag ] . nil? end end | Sets the data_elements instance array with the given options . |
12,059 | def reload_git_files files_to_reload = ( ` ` . lines . grep ( / / ) . map { | l | l . split ( " " ) . last . gsub ( '../' , '' ) } + ` ` . lines ) . map ( & :chomp ) $LOADED_FEATURES . each do | file | files_to_reload . each do | reload_name | if file . end_with? ( reload_name ) puts "LOADING #{file}" load file break e... | Reloads all required files that have git changes |
12,060 | def cal_methods c = Class . new ( BasicObject ) do include Calabash end ConsoleHelpers . puts_unbound_methods ( c , 'cal.' ) true end | Outputs all calabash methods |
12,061 | def cal_method ( method ) c = Class . new ( BasicObject ) do include Calabash end ConsoleHelpers . puts_unbound_method ( c , method . to_sym , 'cal.' ) true end | Outputs a calabash method |
12,062 | def cal_ios_methods c = Class . new ( BasicObject ) do include Calabash :: IOSInternal end ConsoleHelpers . puts_unbound_methods ( c , 'cal_ios.' ) true end | Outputs all calabash iOS methods |
12,063 | def cal_android_methods c = Class . new ( BasicObject ) do include Calabash :: AndroidInternal end ConsoleHelpers . puts_unbound_methods ( c , 'cal_android.' ) true end | Outputs all calabash Android methods |
12,064 | def tree ConsoleHelpers . dump ( Calabash :: Internal . with_current_target { | target | target . dump } ) true end | Outputs all visible elements as a tree . |
12,065 | 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 | Turn on debug logging . |
12,066 | 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 | Turn off debug logging . |
12,067 | 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 . length if... | Decodes a section of the instance string . The instance index is offset in accordance with the length read . |
12,068 | def decode_tag length = 4 tag = nil if ( @index + length ) <= @string . length 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]}" else tag = "#{str[0..3]},#{str[4..7]}" end skip ( length ) end tag end | Decodes 4 bytes of the instance string and formats it as a ruby - dicom tag string . |
12,069 | 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 | Encodes a given value to a binary string . |
12,070 | 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 string is longer than the allowed maxi... | Appends a string with trailling spaces to achieve a target length and encodes it to a binary string . |
12,071 | def encode_value ( value , vr ) if vr == 'AT' bin = encode_tag ( value ) else value = [ value ] unless value . is_a? ( Array ) type = vr_to_str ( vr ) bin = value . pack ( type ) bin = "#{bin}#{@pad_byte[vr]}" if bin . length . odd? end return bin end | Encodes a value and if the the resulting binary string has an odd length appends a proper padding byte to make it even length . |
12,072 | def backdoor ( name , * arguments ) Calabash :: Internal . with_current_target { | target | target . backdoor ( name , * arguments ) } end | Invoke a method in your application . |
12,073 | 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 | Creates a DServer instance . |
12,074 | 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 | Adds a transfer syntax to the list of transfer syntaxes that the server will accept . |
12,075 | def print_abstract_syntaxes 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_uid-pair[0].length)} #{pair[1]}" end end | Prints the list of accepted abstract syntaxes to the screen . |
12,076 | 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 timeout_message ||= lambda do | wait_options | "Waited #{wait_option... | Waits for query to match one or more views . |
12,077 | 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 cannot be nil' end timeout_message ||= lambda do |... | Waits for all queries to simultaneously match at least one view . |
12,078 | 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' end timeout_message ||= lambda do | wait_options | "Waited #{wait_opt... | Waits for query not to match any views |
12,079 | 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 ArgumentError , 'Query cannot be nil' end timeout_message ||= lambda d... | Waits for all queries to simultaneously match no views |
12,080 | def view_exists? ( query ) if query . nil? raise ArgumentError , 'Query cannot be nil' end result = query ( query ) ! result . empty? end | Does the given query match at least one view? |
12,081 | 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 | Does the given queries all match at least one view? |
12,082 | 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 | Expect query to match at least one view . Raise an exception if it does not . |
12,083 | 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 | Expect queries to each match at least one view . Raise an exception if they do not . |
12,084 | 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 | Expect query to match no views . Raise an exception if it does . |
12,085 | 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 end | Expect queries to each match no views . Raise an exception if they do . |
12,086 | 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 : timeout , timeout_message : timeout_message , retry_frequency : retry_fr... | Waits for a view containing text . |
12,087 | 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}'}" , timeout : timeout , timeout_message : timeout_message , retry_frequency : re... | Waits for no views containing text . |
12,088 | def add_record ( tag , original , replacement ) @dictionary [ tag ] = Hash . new unless @dictionary . key? ( tag ) @dictionary [ tag ] [ original ] = replacement end | Creates a new AuditTrail instance . |
12,089 | def original ( tag , replacement ) original = nil if @dictionary . key? ( tag ) original = @dictionary [ tag ] . key ( replacement ) end return original end | Retrieves the original value used for the given combination of tag & replacement value . |
12,090 | def replacement ( tag , original ) replacement = nil replacement = @dictionary [ tag ] [ original ] if @dictionary . key? ( tag ) return replacement end | Retrieves the replacement value used for the given combination of tag & original value . |
12,091 | 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 "Can n... | Encodes the DICOM object into a series of binary string segments with a specified maximum length . |
12,092 | def summary sys_info = Array . new info = Array . new sys_info << "Ruby DICOM version: #{VERSION}" cpu = ( CPU_ENDIAN ? "Big Endian" : "Little Endian" ) sys_info << "Byte Order (CPU): #{cpu}" if @source if @source == :str source = "Binary string #{@read_success ? '(successfully parsed)' : '(failed to parse)'}" el... | Gathers key information about the DObject as well as some system data and prints this information to the screen . This information includes properties like encoding byte order modality and various image properties . |
12,093 | def transfer_syntax = ( new_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 , "Invalid/unknown existing transfer syntax: #{new_syn... | Changes the transfer syntax Element of the DObject instance and performs re - encoding of all numerical values if a switch of endianness is implied . |
12,094 | 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 , :sign... | Writes the DICOM object to file . |
12,095 | 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 + vr + length + element . bin . length end group_length end | Determines the length of the meta group in the DObject instance . |
12,096 | def add_element ( tag , value , options = { } ) add ( e = Element . new ( tag , value , options ) ) e end | Creates an Element with the given arguments and connects it to self . |
12,097 | def add_sequence ( tag , options = { } ) add ( s = Sequence . new ( tag , options ) ) s end | Creates a Sequence with the given arguments and connects it to self . |
12,098 | def color? begin photometric = photometry if photometric . include? ( 'COLOR' ) or photometric . include? ( 'RGB' ) or photometric . include? ( 'YBR' ) return true else return false end rescue return false end end | Checks if colored pixel data is present . |
12,099 | def decode_pixels ( bin , stream = @stream ) raise ArgumentError , "Expected String, got #{bin.class}." unless bin . is_a? ( String ) pixels = false bit_depth_element = self [ '0028,0100' ] pixel_representation_element = self [ '0028,0103' ] if bit_depth_element and pixel_representation_element stream . set_string ( bi... | Unpacks pixel values from a binary pixel string . The decode is performed using values defined in the image related elements of the DObject instance . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.