Created
January 30, 2017 18:31
-
-
Save remomueller/340d8e8246f88e2f172378b2601f3f64 to your computer and use it in GitHub Desktop.
Read EDF Header and Signal Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tutorial_02.rb | |
# sleepdata.org | |
# author: @remomueller | |
# | |
# Required Gems: | |
# | |
# gem install colorize edfize nsrr --no-document | |
# | |
# To Run Script: | |
# | |
# ruby tutorial_02.rb | |
require 'rubygems' | |
require 'colorize' | |
require 'edfize' | |
require 'nsrr' | |
require 'nsrr/commands/download' | |
Nsrr::Commands::Download.run(%w(download learn/polysomnography/edfs/learn-nsrr01.edf --token=public)) | |
puts "EDFs Downloaded: #{Edfize.edf_paths.count}" | |
Edfize.edfs.each do |edf| | |
puts "\nEDF : #{edf.filename}" | |
puts "Total File Size : #{edf.edf_size} bytes" | |
puts "\nHeader Information" | |
puts "\nGeneral Information" | |
puts "Expected Size of Header (bytes): #{edf.expected_size_of_header}" | |
puts "Expected Size of Data (bytes): #{edf.expected_data_size}" | |
puts "Expected Total Size (bytes): #{edf.expected_edf_size}" | |
puts " version: #{edf.version}" | |
puts " local_patient_identification: #{edf.local_patient_identification}" | |
puts " local_recording_identification: #{edf.local_recording_identification}" | |
puts " start_date_of_recording: #{edf.start_date_of_recording}" | |
puts " start_time_of_recording: #{edf.start_time_of_recording}" | |
puts " number_of_bytes_in_header: #{edf.number_of_bytes_in_header}" | |
puts " reserved: #{edf.reserved}" | |
puts " number_of_data_records: #{edf.number_of_data_records}" | |
puts " duration_of_a_data_record: #{edf.duration_of_a_data_record}" | |
puts " number_of_signals: #{edf.number_of_signals}" | |
puts "\nSignal Information" | |
edf.signals.each_with_index do |signal, index| | |
puts "\n Position: #{index + 1}" | |
puts " Label: #{signal.label}" | |
puts " Transducer Type: #{signal.transducer_type}" | |
puts " Physical Dimension: #{signal.physical_dimension}" | |
puts " Physical Minimum: #{signal.physical_minimum}" | |
puts " Physical Maximum: #{signal.physical_maximum}" | |
puts " Digital Minimum: #{signal.digital_minimum}" | |
puts " Digital Maximum: #{signal.digital_maximum}" | |
puts " Prefiltering: #{signal.prefiltering}" | |
puts " Samples Per Data Record: #{signal.samples_per_data_record}" | |
puts " Reserved Area: #{signal.reserved_area}" | |
end | |
end | |
puts "\nCongrats! You have completed your second tutorial!".colorize(:green).on_white |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment