Last active
January 31, 2017 14:38
-
-
Save remomueller/875dbecff94d06228e87a2f1dd279d09 to your computer and use it in GitHub Desktop.
Rewrite EDF Header Start Date of Recording
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_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