-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_structures.rb
More file actions
63 lines (55 loc) · 1.82 KB
/
data_structures.rb
File metadata and controls
63 lines (55 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Base
def attributes
Hash[instance_variables.map { |name|
value = instance_variable_get name
value = "" if value.nil?
value = value.strftime "%Y-%m-%d/%H:%M:%S%z" if value.is_a? Time
[ name.to_s.delete("@"), value ]
}]
end
def update_attributes(params={})
params.each {|name,value| instance_variable_set "@#{name}", value}
end
def to_s
attributes.to_a.flatten.join " "
end
end
class EDFHeader < Base
attr_accessor :patient, :recorder
attr_accessor :start_time
attr_accessor :data_format # identification code
attr_accessor :header_bytes # number of bytes in header record
attr_accessor :manufacturer_id # version / data format / manufacturer
attr_accessor :record_count # number of data records, -1 if unknown
attr_accessor :record_seconds # duration of data record
end
class EDFChannelHeader < Base
attr_accessor :label
attr_accessor :transducer_type
attr_accessor :dimension_unit # physical dimension of channel, e.g. uV
attr_accessor :physical_minimal # minimal physical value (in above units)
attr_accessor :physical_maximal # maximal physical value
attr_accessor :digital_minimal # minimal digital value
attr_accessor :digital_maximal # maximal digital value
attr_accessor :prefiltering # pre-filtering description
attr_accessor :sample_count # number of samples in each record/data chunk
end
class EDFConfig < Base
attr_accessor :header
attr_accessor :channel_headers
def initialize
@header = EDFHeader.new
@channel_headers = []
super
end
def to_s
channel_attrs = @channel_headers.collect { |c| c.to_s }.flatten.join " "
[ header.to_s, channel_attrs ].join " "
end
end
class EDFInputIterator
attr_accessor :edf_config
attr_accessor :data_record_num
attr_accessor :sample_num
attr_accessor :data_record
end