Class: Edfize::Signal

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSignal

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_maximumObject

Returns the value of attribute digital_maximum.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def digital_maximum
  @digital_maximum
end

#digital_minimumObject

Returns the value of attribute digital_minimum.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def digital_minimum
  @digital_minimum
end

#digital_valuesObject

Returns the value of attribute digital_values.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def digital_values
  @digital_values
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def label
  @label
end

#physical_dimensionObject

Returns the value of attribute physical_dimension.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def physical_dimension
  @physical_dimension
end

#physical_maximumObject

Returns the value of attribute physical_maximum.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def physical_maximum
  @physical_maximum
end

#physical_minimumObject

Returns the value of attribute physical_minimum.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def physical_minimum
  @physical_minimum
end

#physical_valuesObject

Returns the value of attribute physical_values.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def physical_values
  @physical_values
end

#prefilteringObject

Returns the value of attribute prefiltering.



3
4
5
# File 'lib/edfize/signal.rb', line 3

def prefiltering
  @prefiltering
end

#reserved_areaObject

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_recordObject

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_typeObject

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

Yields:

  • (signal)


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


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

#samplesObject



45
46
47
# File 'lib/edfize/signal.rb', line 45

def samples
  @physical_values
end