obci_readmanager.signal_processing.signal.generic_info_file_proxy module

Module providing generic info file proxy.

Author:
Mateusz Kruszyński <mateusz.kruszynski@gmail.com>
class obci_readmanager.signal_processing.signal.generic_info_file_proxy.GenericInfoFileReadProxy(p_file_path)[source]

Bases: object

Class reading info from xml file.

get_param(p_param_name)[source]

Return parameter value for p_param_name.

Raise NoParameter exception if p_param_name parameters was not found.

get_params()[source]

Return all parameters for TAGS_DEFINITIONS.

Raise NoParameter exception if p_param_name parameters was not found.

start_reading()[source]

Load xml to memory.

class obci_readmanager.signal_processing.signal.generic_info_file_proxy.GenericInfoFileWriteProxy(p_file_path)[source]

Bases: object

A class that is responsible for implementing logic of OpenBCI signal parameters storage in info file.

The file is supposed to be compatible with signalml 2.0. By now it isn`t :)

The class should be separated from all multiplexer-stuff logic.

InfoFileProxy represents a process of saving one signal parameters.

Init method gets a dictionary of signal params in format understandable by InfoFileProxy.

Public interface:

finish_saving()

finish_saving(p_signal_params={})[source]

Write xml_doc to the file, return the file`s path.

Arguments:

:arg p_file_name : a name of to-be-created info file :arg p_dir_path : a dir-path where p_file_name is to be created :arg p_signal_params : a dictionary of all signal parameters that should be stored in info file.

What is the logics flow of analysing parameters?

p_signal_params has keys representing signal parameters identificators. self._create_tags_controls creates a dictionary with the same keys, values are functions being ‘able’ to understand particular param values. Method self._process_signal_params, for every key in p_signal_params fires corresponding function from self._tags_control, giving as argument value from p_signal_params…

So, how can I implement a new parameter usage?

Let`s say that the parameter is signal`s colour. Let`s call it ‘color’, values are strings. p_signal_params should contain a pair ‘color’ -> ‘color_value’.

  1. Create function self._set_color(self, p_color)
  2. Add pair ‘color’ -> self._set_color to self._tags_control in self._create_tags_control()
  3. Implement the function so that it creates xml element for color parameter and appends it to self._xml_root. For simple params (with one value) you can fire self._set_simple_tag(‘color’, ‘color_value’).
set_attributes(p_attrs_dict)[source]

For every pair key-> value in p_attrs_dict create tag. The type of tag depends on self._tags_control.

class obci_readmanager.signal_processing.signal.generic_info_file_proxy.OpenBciDocument[source]

Bases: xml.dom.minidom.Document

Abstract class for future development, used in proxies.

obci_readmanager.signal_processing.signal.generic_info_file_proxy.TAGS_DEFINITIONS = {'blocks_per_page': ('simple', ['blocksPerPage']), 'byte_order': ('simple', ['byteOrder']), 'calibration': ('simple', ['calibration']), 'channels_gains': ('list', ['calibrationGain', 'calibrationParam']), 'channels_names': ('list', ['channelLabels', 'label']), 'channels_numbers': ('list', ['channelNumbers', 'number']), 'channels_offsets': ('list', ['calibrationOffset', 'calibrationParam']), 'export_date': ('simple', ['exportDate']), 'export_file_name': ('simple', ['exportFileName']), 'file': ('simple', ['sourceFileName']), 'file_format': ('list', ['sourceFileFormat', 'rawSignalInfo']), 'first_sample_timestamp': ('simple', ['firstSampleTimestamp']), 'number_of_channels': ('simple', ['channelCount']), 'number_of_samples': ('simple', ['sampleCount']), 'page_size': ('simple', ['pageSize']), 'sample_type': ('simple', ['sampleType']), 'sampling_frequency': ('simple', ['samplingFrequency']), 'video_file_name': ('simple', ['videoFileName']), 'video_file_offset': ('simple', ['videoFileOffset'])}

For every tag we have entry in format

'tag_universal_name':
    ('list' or 'simple',  # tag type
     [one element for 'simple', two elements for 'list']) # list of tag translations