edfize 0.1.0.beta6 → 0.1.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/edfize/edf.rb +26 -11
- data/lib/edfize/signal.rb +0 -4
- data/lib/edfize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba1a8b5aedfca32378aa7f2a33e74e905f55de59
|
4
|
+
data.tar.gz: 31c306bb6cc1eae5ff5e648825efc0fce4313d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9796b9ab7062d8852cd69e78fbdd575d101836cdba1b4d63bd3af4a1b6a9502a3bb52ce8c87e8fa2bd0312a9586b3b17bfc64f8f366ed55ee96a422e277424
|
7
|
+
data.tar.gz: 806d2e78b1d4f0173a900e09618c290213b70f3bb2fbfc0d75b344dc1985de9a2f4cc7f6c0ba1bc65ce1d371088b863a24809df4dd9729bb0751f54ba3f49c7a
|
data/lib/edfize/edf.rb
CHANGED
@@ -179,22 +179,37 @@ module Edfize
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def get_data_records
|
182
|
-
|
182
|
+
load_digital_signals()
|
183
|
+
calculate_physical_values!()
|
184
|
+
end
|
185
|
+
|
186
|
+
# 16-bit signed integer size = 2 Bytes = 2 ASCII characters
|
187
|
+
# 16-bit signed integer in "Little Endian" format (least significant byte first)
|
188
|
+
# unpack: s< 16-bit signed, (little-endian) byte order
|
189
|
+
def load_digital_signals
|
190
|
+
@all_signal_data = IO.binread(@filename, nil, size_of_header).unpack('s<*')
|
191
|
+
|
192
|
+
all_samples_per_data_record = @signals.collect{|s| s.samples_per_data_record}
|
193
|
+
total_samples_per_data_record = all_samples_per_data_record.inject(:+).to_i
|
194
|
+
|
195
|
+
offset = 0
|
196
|
+
offsets = []
|
197
|
+
all_samples_per_data_record.each do |samples_per_data_record|
|
198
|
+
offsets << offset
|
199
|
+
offset += samples_per_data_record
|
200
|
+
end
|
183
201
|
|
184
|
-
current_read_offset = size_of_header
|
185
202
|
(0..@number_of_data_records-1).to_a.each do |data_record_index|
|
186
|
-
@signals.
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
start_index = data_record_index * signal.samples_per_data_record
|
192
|
-
end_index = (data_record_index + 1) * signal.samples_per_data_record
|
193
|
-
signal.digital_values[start_index..end_index] = IO.binread(@filename, read_size, current_read_offset).unpack('s<*')
|
194
|
-
current_read_offset += read_size
|
203
|
+
@signals.each_with_index do |signal, signal_index|
|
204
|
+
read_start = data_record_index * total_samples_per_data_record + offsets[signal_index]
|
205
|
+
(0..signal.samples_per_data_record - 1).to_a.each do |value_index|
|
206
|
+
signal.digital_values << @all_signal_data[read_start+value_index]
|
207
|
+
end
|
195
208
|
end
|
196
209
|
end
|
210
|
+
end
|
197
211
|
|
212
|
+
def calculate_physical_values!
|
198
213
|
@signals.each{|signal| signal.calculate_physical_values!}
|
199
214
|
end
|
200
215
|
|
data/lib/edfize/signal.rb
CHANGED
data/lib/edfize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edfize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|