Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
Rewrite EDF Header Start Date of Recording
# tutorial_03.rb
# sleepdata.org
# author: @remomueller
#
# Required Gems:
#
# gem install colorize edfize nsrr --no-document
#
# To Run Script:
#
# ruby tutorial_03.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/invalid/learn-nsrr01-invalid-date.edf --token=public))
puts "EDFs Downloaded: #{Edfize.edf_paths.count}"
INVALID_DATE = '00.00.00'
CLIPPING_DATE = '01.01.85'
Edfize.edfs do |edf|
if edf.start_date_of_recording == INVALID_DATE
initial_date = edf.start_date_of_recording
edf.update(start_date_of_recording: CLIPPING_DATE)
puts initial_date.colorize(:red) + " to " + edf.start_date_of_recording.colorize(:green) + " for #{edf.filename}"
else
puts " OK".colorize(:green) + " #{edf.start_date_of_recording} for #{edf.filename}"
end
end
puts "\nCongrats! You have completed your third 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.