GE Decode

Synchronize in decoder with a buffer reference, decoder GEDecode will attempt to process new data added to the buffer.

decoder = GEDecode(device.BUFFER)
decoder.process(True)

There are a set of methods for clear correctly the stored buffer and recollected data.

device.clear_buffer()  # clear input buffer.
decoder.clear_buffer()  # clear decoded data, breaks the synchrony.
decoder.clear_data()  # clear recollected data.
class pycollect.decode.FormatSubrecord(date_, header)[source]

Bases: object

Parse raw data into Pandas DataFrames.

__init__(date_, header)[source]
Parameters:
  • date (Datetime object) – Datetime of the current set.
  • header (PhysiologicalData object) – Header with raw data.
check_module(label, replace=None)[source]

Check the status module from determinate group.

Parameters:
  • label (str) – Group for check their respective module.
  • replace (dict) – Some groups are indexed for multiples modules, in that case, the indexes must be removed.
Returns:

  • bool – Module exist.
  • bool – Module is active.

format(active, filters=None)[source]

Process a subrecord (their raw header), aply shifts and get references.

Parameters:
  • active (array) – List of groups to parse.
  • filters (array, optional) – A sub list of desired subrecords.
Returns:

DataFrame with single row that contains all measures with label as headers.

Return type:

DataFrame

get_short(key)[source]

From index in header, convert data to integer, validates and return it.

Parameters:key (Header index) – Location if header of target value.
Returns:Int if valus is a signed 16 bits, None if the value is over range and bytearray in other cases.
Return type:int, None, bytearray
module_status()[source]

Return the list of present and active modules.

Based in the status bits is possible determine the state of the respective module.

Returns:
  • list – List of groups with modules availables.
  • list – List of groups with modules availables and actives.
  • list – List of measures availables and actives.
class pycollect.decode.GEDecode(buffer, filter_subrecords=None, filter_waveforms=None)[source]

Bases: object

Decode raw data into Pandas DataFrames.

There are two main objects:

  • DATA_SUBRECORD: Pandas DataFrame with the subrecords data.
  • DATA_WAVE: Dictionary with waveform name as key with the
    Pandas DataFrame with the waveform data.
__continuous_processing__(delay=0.25)[source]

Continuous processing.

Parameters:delay (integer in seconds) – Delay in seconds between each attempted processing.
__create_framelist__(byte)[source]

Search for a complete and validated header.

Parameters:byte (byte) – Byte readed from serial raw data.
__create_recordlist__()[source]

Complete the raw header with the correct/full size.

Returns:Full sized DatexHeaderResponse.
Return type:list
__init__(buffer, filter_subrecords=None, filter_waveforms=None)[source]
Parameters:
  • buffer (array reference) – Reference with raw data, the processer will attempt to decoded new data added to this object.
  • filter_subrecords (array, optional) – Sublist with desired subrecords, if empty then will process all available measures.
  • filter_waveforms (array, optional) – List of desired waveforms, if emty then will process all requested waveforms.
__processing__()[source]

Process the input buffer one byte at a time.

Process the input buffer until a header is completed.

clear_buffer()[source]

Clear the processed buffer.

This action brake the synchrony with GEDevice.

clear_data()[source]

Clear the processed data.

process(flag=True, delay=1)[source]

Enable or disable the continuous data processing.

Parameters:
  • flag (bool, True) – Enable or disable the continuous data processing.
  • delay (integer in seconds) – Delay in seconds between each process attempt.
read_shorts(buffer)[source]

Convert an array if bytes from signed 16 bits to integer.

Parameters:buffer (array) – Array with raw bytes, It will be processed in pairs (for complete 16 bits).
read_subrecords(record_list)[source]

Update the DataFrame of subrecords with new decoded data.

Parameters:record_list (array) – Raw DatexHeaderResponse.
read_waveforms(record_list, ignore_missging=False)[source]

Update the dictionary of waveforms with new decoded data.

Parameters:record_list (array) – List of raw headers.
save_as_csv(filename)[source]

Save the decoded data into a set of CSV files.

Parameters:filename (str) – Absolute or realtive path for CSV file.
Returns:A list with filenames generated.
Return type:list
save_as_edf(filename, edf_header=None, annotations=None)[source]

Save the decoded data into a set of EDF+ files.

Parameters:
  • filename (str) – Absolute or realtive path for EDF+ file.
  • edf_header (dict) – Declare the EDF+ patient header.
Returns:

A list with filenames genrated.

Return type:

list

save_as_raw(filename)[source]

Save the decoded data into a RAW file.

Parameters:filename (str) – Absolute or realtive path for RAW file.
Returns:A list with filenames generated.
Return type:list
set_edf_header(**header)[source]

Set the EDF+ patient header.

Parameters:
  • admincode (str) – Sets the admincode.
  • birthdate (date object from datetime) – Sets the birthdate.
  • equipment (str) – Describes the measurement equpipment.
  • gender (int) – Sets the gender, 1 is male, 0 is female.
  • patientcode (str) – Sets the patient code.
  • patientname (str) – Sets the patient name.
  • patient_additional (str) – Sets the additional patient info.
  • recording_additional (str) – Sets the additional recordinginfo.
  • startdate (datetime object) – Sets the recording start Time.
  • technician (str) – Sets the technicians name.