Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check EDFs for signal labels that include a dash
# gem install edfize --no-document
# ruby check_signal_contains_dash.rb
require 'rubygems'
require 'edfize'
VALID_LABELS = [
'C-Pres'
]
def strings_match?(a, b)
a.casecmp(b).zero?
end
def dash_in_signal_label?(signal)
return false if VALID_LABELS.count { |label| strings_match?(label, signal.label) } > 0
!(/-/ =~ signal.label).nil?
end
good_count = 0
bad_count = 0
edf_files_count = Edfize.edf_paths.count
Edfize.edfs.each_with_index do |edf, index|
print "\rChecking EDF #{index + 1} of #{edf_files_count}"
bad_found = false
edf.signals.each do |signal|
if dash_in_signal_label?(signal)
puts "\n\n" if bad_found == false
bad_found = true
puts "BAD".colorize(:red) + " #{signal.label}"
end
end
if bad_found
puts " #{edf.filename}\n\n"
bad_count += 1
else
good_count += 1
end
end
puts "\n\n" + good_count.to_s.colorize(good_count > 0 ? :green : nil) + " EDF#{good_count == 1 ? ' ' : 's'} passed"
puts bad_count.to_s.colorize(bad_count > 0 ? :red : nil) + " EDF#{bad_count == 1 ? ' ' : 's'} failed"
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.