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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd66c8588e2ded11c90880663301a6ff5c735316
4
- data.tar.gz: fa67299dca68b65f0d56393112f7b4395d5d58ed
3
+ metadata.gz: ba1a8b5aedfca32378aa7f2a33e74e905f55de59
4
+ data.tar.gz: 31c306bb6cc1eae5ff5e648825efc0fce4313d9e
5
5
  SHA512:
6
- metadata.gz: 598a5dad055dd6e3ad3b7b339961a04ce05367ef460773e221ef9f7bd6ae7213cf35e84c71ffdd976bcda481141c7cd627eb669c9b2dfed52ed13636ccfa4d69
7
- data.tar.gz: f1be2b665756ca380aac2d8f842e130f6f1f8417a4f5b5b0686b11b06fa1c2edebac07f7cd561382c1f73926c43edff64d0928fe70cb50ff29c4ac6d47b63b0f
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
- @signals.each{|signal| signal.initialize_array_sizes!(@number_of_data_records)}
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.each do |signal|
187
- # 16-bit signed integer size = 2 Bytes = 2 ASCII characters
188
- # 16-bit signed integer in "Little Endian" format (least significant byte first)
189
- # unpack: s< 16-bit signed, (little-endian) byte order
190
- read_size = signal.samples_per_data_record * SIZE_OF_SAMPLE_IN_BYTES
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
@@ -39,9 +39,5 @@ module Edfize
39
39
  @physical_values
40
40
  end
41
41
 
42
- def initialize_array_sizes!(data_records)
43
- @physical_values = Array.new(@samples_per_data_record * data_records)
44
- end
45
-
46
42
  end
47
43
  end
@@ -3,7 +3,7 @@ module Edfize
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
5
  TINY = 0
6
- BUILD = "beta6"
6
+ BUILD = "beta7"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
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.beta6
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-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize