Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download EDFs programmatically
# tutorial_01.rb
# sleepdata.org
# author: @remomueller
#
# Required Gems:
#
# gem install colorize edfize nsrr --no-document
#
# To Run Script:
#
# ruby tutorial_01.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))
Nsrr::Commands::Download.run(%w(download learn/polysomnography/edfs/learn-nsrr02.edf --token=public))
Nsrr::Commands::Download.run(%w(download learn/polysomnography/edfs/learn-nsrr03.edf --token=public))
puts "EDFs Downloaded: #{Edfize.edf_paths.count}"
Edfize.edfs.each do |edf|
puts " #{edf.filename}"
end
puts 'GOOD'.colorize(:green) + " Ruby #{RUBY_VERSION}"
puts 'GOOD'.colorize(:green) + " Edfize #{Edfize::VERSION::STRING}"
puts 'GOOD'.colorize(:green) + " NSRR Gem #{Nsrr::VERSION::STRING}"
if Edfize.edf_paths.count.zero?
puts "EDFs weren't downloaded.".colorize(:red).on_white
else
puts "Congrats! You have completed your first tutorial!".colorize(:green).on_white
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment