edfize 0.3.0 → 0.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +21 -1
- data/lib/edfize/edf.rb +15 -0
- data/lib/edfize/version.rb +2 -2
- data/lib/edfize.rb +20 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74554485101498071683bd23ef8fa0870363753b
|
4
|
+
data.tar.gz: f8e9707242fb9f083fd4f3cc9fbc170280f1effb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eedb38dbc3be913932d53439b7ae53e1638d9257330234379ec33ec629994fb328ea02ca05f2c3c469469a16ef2d07fa8057a2deff8b28f820a99612d2c37e5b
|
7
|
+
data.tar.gz: 0e0e20bb7073dededd9bdb8b21f7e98c2e4b761d74125400f88d72f221dd1d0d787c13922ac2cfc9e20ed275c28c2d791e647d69a62187be0d5dcec7300de88c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 0.4.0
|
2
|
+
|
3
|
+
### Enhancements
|
4
|
+
- **Scripting Changes**
|
5
|
+
- Edfize now provides an enumerator to iterate through a folder of EDFs:
|
6
|
+
- `Edfize.edfs` # Current directory and subdirectories
|
7
|
+
- `Edfize.edfs(recursive: false)` # Only current directory
|
8
|
+
- Deprecated `edfs_in_current_directory_and_subdirectories` in favor of
|
9
|
+
`edf_paths`
|
10
|
+
- Note that while `edf_paths` is a direct replacement for
|
11
|
+
`edfs_in_current_directory_and_subdirectories`, it is recommended to use
|
12
|
+
the new `edfs` enumerator instead
|
13
|
+
- Added `Edf::update` method that allows portions of the header to be updated
|
14
|
+
- Change an EDF's start_date_of_recording to the clipping date, 1 Jan 1985
|
15
|
+
- `edf.update(start_date_of_recording: '01.01.85')`
|
16
|
+
- Change an EDF's start_time_of_recording to midnight
|
17
|
+
- `edf.update(start_time_of_recording: '00.00.00')`
|
18
|
+
|
1
19
|
## 0.3.0 (December 7, 2016)
|
2
20
|
|
3
21
|
### Enhancements
|
data/README.md
CHANGED
@@ -50,6 +50,26 @@ Use `edfize version` to check the version of Edfize.
|
|
50
50
|
|
51
51
|
edfize version
|
52
52
|
|
53
|
+
### Example of how to rewrite the start date of recording for a folder of EDFs
|
54
|
+
|
55
|
+
This will update all EDFs in the current directory and subdirectories with a
|
56
|
+
start date of 1 Jan 1985.
|
57
|
+
|
58
|
+
`rewrite_signal_date.rb`
|
59
|
+
```ruby
|
60
|
+
# gem install edfize --no-document
|
61
|
+
# ruby rewrite_signal_date.rb
|
62
|
+
|
63
|
+
require 'rubygems'
|
64
|
+
require 'edfize'
|
65
|
+
|
66
|
+
CLIPPING_DATE = '01.01.85'.freeze
|
67
|
+
|
68
|
+
Edfize.edfs do |edf|
|
69
|
+
edf.update(start_date_of_recording: CLIPPING_DATE)
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
53
73
|
### Example of how to Load and Analyze EDFs in a Ruby Script
|
54
74
|
|
55
75
|
The following Ruby file demonstrates how to make use of the Edfize gem to load EDF signals into arrays for analysis.
|
@@ -58,7 +78,7 @@ The following Ruby file demonstrates how to make use of the Edfize gem to load E
|
|
58
78
|
```ruby
|
59
79
|
# Tutorial 01 - Load EDF and Signals
|
60
80
|
#
|
61
|
-
# gem install edfize
|
81
|
+
# gem install edfize --no-document
|
62
82
|
#
|
63
83
|
# ruby tutorial_01_load_edf_and_signals.rb
|
64
84
|
#
|
data/lib/edfize/edf.rb
CHANGED
@@ -156,6 +156,21 @@ module Edfize
|
|
156
156
|
nil
|
157
157
|
end
|
158
158
|
|
159
|
+
def update(hash)
|
160
|
+
hash.each do |section, value|
|
161
|
+
update_header_section(section, value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def update_header_section(section, value)
|
166
|
+
return false unless HEADER_CONFIG.keys.include?(section)
|
167
|
+
send "#{section}=", value
|
168
|
+
size = HEADER_CONFIG[section][:size]
|
169
|
+
string = format("%-#{size}.#{size}s", send(section).to_s)
|
170
|
+
IO.binwrite(filename, string, send(:compute_offset, section))
|
171
|
+
true
|
172
|
+
end
|
173
|
+
|
159
174
|
protected
|
160
175
|
|
161
176
|
def read_header
|
data/lib/edfize/version.rb
CHANGED
data/lib/edfize.rb
CHANGED
@@ -23,8 +23,7 @@ module Edfize
|
|
23
23
|
|
24
24
|
def self.print_headers
|
25
25
|
puts '----------------'
|
26
|
-
|
27
|
-
edf = Edfize::Edf.new(edf_file_name)
|
26
|
+
edfs.each do |edf|
|
28
27
|
edf.print_header
|
29
28
|
puts '----------------'
|
30
29
|
end
|
@@ -36,16 +35,16 @@ module Edfize
|
|
36
35
|
|
37
36
|
def self.check(argv)
|
38
37
|
test_start_time = Time.now
|
39
|
-
edf_count =
|
38
|
+
edf_count = 0
|
40
39
|
test_count = 0
|
41
40
|
failure_count = 0
|
42
41
|
puts "Started\n"
|
43
|
-
|
44
|
-
edf = Edfize::Edf.new(edf_file_name)
|
42
|
+
edfs.each do |edf|
|
45
43
|
runner = Edfize::Tests::Runner.new(edf, argv)
|
46
44
|
runner.run_tests
|
47
45
|
test_count += runner.tests_run
|
48
46
|
failure_count += runner.tests_failed
|
47
|
+
edf_count += 1
|
49
48
|
end
|
50
49
|
puts "\nFinished in #{Time.now - test_start_time}s"
|
51
50
|
puts "#{edf_count} EDF#{'s' unless edf_count == 1}, #{test_count} test#{'s' unless test_count == 1}, " + "#{failure_count} failure#{'s' unless failure_count == 1}".colorize(failure_count == 0 ? :green : :red)
|
@@ -70,7 +69,22 @@ EOT
|
|
70
69
|
puts help_message
|
71
70
|
end
|
72
71
|
|
72
|
+
# TODO: Remove in 0.5.0
|
73
73
|
def self.edfs_in_current_directory_and_subdirectories
|
74
|
-
|
74
|
+
warn "[DEPRECATION] `edfs_in_current_directory_and_subdirectories` is deprecated. Please use `edf_paths` instead."
|
75
|
+
edf_paths(recursive: true)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns an enumerator of EDFs.
|
79
|
+
def self.edfs(recursive: true)
|
80
|
+
return enum_for(:edfs, recursive: recursive) unless block_given?
|
81
|
+
edf_paths(recursive: recursive).each do |file_path|
|
82
|
+
yield Edf.new(file_path)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.edf_paths(recursive: true)
|
87
|
+
path = "#{'**/' if recursive}*.edf"
|
88
|
+
Dir.glob(path, File::FNM_CASEFOLD)
|
75
89
|
end
|
76
90
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edfize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
@@ -94,9 +94,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- - "
|
97
|
+
- - ">"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version:
|
99
|
+
version: 1.3.1
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
102
|
rubygems_version: 2.6.8
|