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.



24
25
26
27
28
# File 'lib/edfize/signal.rb', line 24

def initialize
  @digital_values = []
  @physical_values = []
  self
end

Instance Attribute Details

#digital_maximumObject

Returns the value of attribute digital_maximum.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def digital_maximum
  @digital_maximum
end

#digital_minimumObject

Returns the value of attribute digital_minimum.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def digital_minimum
  @digital_minimum
end

#digital_valuesObject

Returns the value of attribute digital_values.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def digital_values
  @digital_values
end

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def label
  @label
end

#physical_dimensionObject

Returns the value of attribute physical_dimension.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def physical_dimension
  @physical_dimension
end

#physical_maximumObject

Returns the value of attribute physical_maximum.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def physical_maximum
  @physical_maximum
end

#physical_minimumObject

Returns the value of attribute physical_minimum.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def physical_minimum
  @physical_minimum
end

#physical_valuesObject

Returns the value of attribute physical_values.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def physical_values
  @physical_values
end

#prefilteringObject

Returns the value of attribute prefiltering.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def prefiltering
  @prefiltering
end

#reserved_areaObject

Returns the value of attribute reserved_area.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def reserved_area
  @reserved_area
end

#samples_per_data_recordObject

Returns the value of attribute samples_per_data_record.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def samples_per_data_record
  @samples_per_data_record
end

#transducer_typeObject

Returns the value of attribute transducer_type.



5
6
7
# File 'lib/edfize/signal.rb', line 5

def transducer_type
  @transducer_type
end

Class Method Details

.create {|signal| ... } ⇒ Object

Yields:

  • (signal)


30
31
32
33
34
# File 'lib/edfize/signal.rb', line 30

def self.create(&block)
  signal = 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.



43
44
45
# File 'lib/edfize/signal.rb', line 43

def calculate_physical_values!
  @physical_values = @digital_values.collect{|sample| (( sample - @digital_minimum ) * ( @physical_maximum - @physical_minimum ) / ( @digital_maximum - @digital_minimum) + @physical_minimum rescue nil) }
end


36
37
38
39
40
# File 'lib/edfize/signal.rb', line 36

def print_header
  SIGNAL_CONFIG.each do |section, hash|
    puts "  #{hash[:name]}#{' '*(29 - hash[:name].size)}: " + self.send(section).to_s
  end
end

#samplesObject



47
48
49
# File 'lib/edfize/signal.rb', line 47

def samples
  @physical_values
end