Skip to content

Instantly share code, notes, and snippets.

@remomueller remomueller/tutorial_04.rb
Last active Jan 31, 2017

Embed
What would you like to do?
Compute EDF Signal Averages
# tutorial_04.rb
# sleepdata.org
# author: @remomueller
#
# Required Gems:
#
# gem install colorize edfize nsrr --no-document
#
# To Run Script:
#
# ruby tutorial_04.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 do |edf|
puts "\nEDF: #{edf.filename}"
edf.load_signals
puts " Signal Average"
edf.signals.each do |signal|
physical_values_average = signal.physical_values.inject(&:+) / signal.physical_values.count
puts " #{format("%16s", signal.label)} #{physical_values_average.round(2).to_s.colorize(:green)} #{signal.physical_dimension}"
end
end
puts "\nCongrats! You have completed your fourth tutorial!".colorize(:green).on_white
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.