Class: Edfize::Signal
- Inherits:
-
Object
- Object
- Edfize::Signal
- Defined in:
- lib/edfize/signal.rb
Constant Summary collapse
- SIGNAL_CONFIG =
{ label: { size: 16, after_read: :strip, name: 'Label' }, transducer_type: { size: 80, after_read: :strip, name: 'Transducer Type' }, physical_dimension: { size: 8, after_read: :strip, name: 'Physical Dimension' }, physical_minimum: { size: 8, after_read: :to_f, name: 'Physical Minimum' }, physical_maximum: { size: 8, after_read: :to_f, name: 'Physical Maximum' }, digital_minimum: { size: 8, after_read: :to_i, name: 'Digital Minimum' }, digital_maximum: { size: 8, after_read: :to_i, name: 'Digital Maximum' }, prefiltering: { size: 80, after_read: :strip, name: 'Prefiltering' }, samples_per_data_record: { size: 8, after_read: :to_i, name: 'Samples Per Data Record' }, reserved_area: { size: 32, name: 'Reserved Area' } }
Instance Attribute Summary collapse
-
#digital_maximum ⇒ Object
Returns the value of attribute digital_maximum.
-
#digital_minimum ⇒ Object
Returns the value of attribute digital_minimum.
-
#digital_values ⇒ Object
Returns the value of attribute digital_values.
-
#label ⇒ Object
Returns the value of attribute label.
-
#physical_dimension ⇒ Object
Returns the value of attribute physical_dimension.
-
#physical_maximum ⇒ Object
Returns the value of attribute physical_maximum.
-
#physical_minimum ⇒ Object
Returns the value of attribute physical_minimum.
-
#physical_values ⇒ Object
Returns the value of attribute physical_values.
-
#prefiltering ⇒ Object
Returns the value of attribute prefiltering.
-
#reserved_area ⇒ Object
Returns the value of attribute reserved_area.
-
#samples_per_data_record ⇒ Object
Returns the value of attribute samples_per_data_record.
-
#transducer_type ⇒ Object
Returns the value of attribute transducer_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#calculate_physical_values! ⇒ Object
Physical value (dimension PhysiDim) = (ASCIIvalue-DigiMin)*(PhysiMax-PhysiMin)/(DigiMax-DigiMin) + PhysiMin.
-
#initialize ⇒ Signal
constructor
A new instance of Signal.
- #print_header ⇒ Object
- #samples ⇒ Object
Constructor Details
#initialize ⇒ Signal
Returns a new instance of Signal.
22 23 24 25 26 |
# File 'lib/edfize/signal.rb', line 22 def initialize @digital_values = [] @physical_values = [] self end |
Instance Attribute Details
#digital_maximum ⇒ Object
Returns the value of attribute digital_maximum.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def digital_maximum @digital_maximum end |
#digital_minimum ⇒ Object
Returns the value of attribute digital_minimum.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def digital_minimum @digital_minimum end |
#digital_values ⇒ Object
Returns the value of attribute digital_values.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def digital_values @digital_values end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def label @label end |
#physical_dimension ⇒ Object
Returns the value of attribute physical_dimension.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def physical_dimension @physical_dimension end |
#physical_maximum ⇒ Object
Returns the value of attribute physical_maximum.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def physical_maximum @physical_maximum end |
#physical_minimum ⇒ Object
Returns the value of attribute physical_minimum.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def physical_minimum @physical_minimum end |
#physical_values ⇒ Object
Returns the value of attribute physical_values.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def physical_values @physical_values end |
#prefiltering ⇒ Object
Returns the value of attribute prefiltering.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def prefiltering @prefiltering end |
#reserved_area ⇒ Object
Returns the value of attribute reserved_area.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def reserved_area @reserved_area end |
#samples_per_data_record ⇒ Object
Returns the value of attribute samples_per_data_record.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def samples_per_data_record @samples_per_data_record end |
#transducer_type ⇒ Object
Returns the value of attribute transducer_type.
3 4 5 |
# File 'lib/edfize/signal.rb', line 3 def transducer_type @transducer_type end |
Class Method Details
.create {|signal| ... } ⇒ Object
28 29 30 31 32 |
# File 'lib/edfize/signal.rb', line 28 def self.create(&block) signal = self.new yield signal if block_given? signal end |
Instance Method Details
#calculate_physical_values! ⇒ Object
Physical value (dimension PhysiDim) = (ASCIIvalue-DigiMin)*(PhysiMax-PhysiMin)/(DigiMax-DigiMin) + PhysiMin.
41 42 43 |
# File 'lib/edfize/signal.rb', line 41 def calculate_physical_values! @physical_values = @digital_values.collect{|sample| ( sample - @digital_minimum ) * ( @physical_maximum - @physical_minimum ) / ( @digital_maximum - @digital_minimum) + @physical_minimum } end |
#print_header ⇒ Object
34 35 36 37 38 |
# File 'lib/edfize/signal.rb', line 34 def print_header SIGNAL_CONFIG.each do |section, hash| puts " #{hash[:name]}#{' '*(29 - hash[:name].size)}: " + self.send(section).to_s end end |
#samples ⇒ Object
45 46 47 |
# File 'lib/edfize/signal.rb', line 45 def samples @physical_values end |