OpenVIBE ovpCEDFAsciFileReader

Making & changing box plugins and external apps
Post Reply
ThinkEEG
Posts: 4
Joined: Tue Jan 04, 2011 12:18 am

OpenVIBE ovpCEDFAsciFileReader

Post by ThinkEEG »

Background:
I am trying to learn how to develop an OpenVIBE plugin, starting with a csv Reader. Reference (viewtopic.php?f=10&t=417). I am hoping that others who have experience can help and hopefully the codes here will reach a state that makes it less effort for the OpenVIBE developers to incorporate into the standard distribution.

Motivation:
The binary EDF files exported by Emotiv can be converted into text format using edf2ascii.exe http://www.teuniz.net/edf2ascii/index.html. To bring the signal data and channel information into OpenVIBE, I need two of the generated files:

a) edfFileName_signals.txt (Information on channels, if 16 channels, each line starts with a channel name)

b) edfFileName_data.txt (signal data in csv format, if there are 16 channels, then each line is 16 signal data delimited by ",")
EDFConvert.jpg
EDFConvert.jpg (13.58 KiB) Viewed 3887 times
Justifications:
(1)The format is very simple and it will help others to convert a proprietory binary format into ascii format for import into OpenVIBE especially when there is no such binary reader exist yet in OpenVIBE.

(2) Many BCI EEG hardware and softwares generate and use binary EDF format. However, the challenge is always how consistent is the binary EDF format. E.g. Emotiv binary EDF format can not be imported into the EDF browser. Therefore, there is an urgent need to have a more robust and more consistent way to convert EDF files from different sources into one that is simple for import into OpenVIBE. The EDFascii seems to be a good option.

Requirements for writing a OpenVIBE Reader:
Step1: Determine the minimum template.h and template.cpp needed for an OpenVIBE Reader.

I am using VS2008, it is straight forwards to generate VS projects using the downloaded 0.9 OpenVIBE source

The project directory needed to write OpenVIBE Reader is in plugins-file-io-dynamic

Guildlines for writing plugin
http://openvibe.inria.fr/documentation/ ... lugin.html


Composition of a plugin
PluginDevelopemernt1.jpg
PluginDevelopemernt1.jpg (148.97 KiB) Viewed 3884 times
Generate Template using openvibe-skeleton-generator.cmd

Code: Select all

#ifndef __OpenViBEPlugins_file_io_CEDFAcsiiFileReader_H__
#define __OpenViBEPlugins_file_io_CEDFAcsiiFileReader_H__

#include "ovp_defines.h"
#include <openvibe/ov_all.h>
#include <openvibe-toolkit/ovtk_all.h>
#include <ebml/TWriterCallbackProxy.h>
#include <ebml/IWriter.h>

#include <vector>
#include <string>
#include <sstream>
#include <fstream>

namespace OpenViBEPlugins
{
	namespace FileIO
	{

		class CEDFAcsiiFileReader : public OpenViBEToolkit::TBoxAlgorithm<OpenViBE::Plugins::IBoxAlgorithm>
		{

			public:
			CEDFAcsiiFileReader();
			virtual void release(void) { delete this; }
			virtual OpenViBE::boolean initialize();
			virtual OpenViBE::boolean uninitialize();
			virtual OpenViBE::boolean process();
			virtual OpenViBE::boolean processClock(OpenViBE::CMessageClock& rMessageClock);
			virtual OpenViBE::uint64 getClockFrequency(){ return m_ui64ClockFrequency; }

			public:
			void writeSignalInformation();
			virtual void writeSignalOutput(const void* pBuffer, const EBML::uint64 ui64BufferSize);
			virtual void writeStimulationOutput(const void* pBuffer, const EBML::uint64 ui64BufferSize);            
			_IsDerivedFromClass_Final_( OpenViBE::Plugins::  IBoxAlgorithm, OVP_ClassId_CEDFAcsiiFileReader )
	};
};
#endif
(ongoing)
Additional references
viewtopic.php?f=3&t=166

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVIBE ovpCEDFAsciFileReader

Post by yrenard »

Dear ThinkEEG,

thank you for this contribution !

If you want a clean base of file reader, I suggest that you look at the Brainamp File Reader box / algorithm. This code is clean & up to date.

I also suggest that you avoid using EBMLReaderCallback and EBMLReaderCallbackProxy. Boxes and algorithms based on those classes are deprecated. The produced code is hard to write, hard to read and hard to maintain so please, use algorithms, they are much more powerful and reusable.

Last thing is that a CSV File Reader is currently being developed by Baptiste. It is almost finished already. If you are interested in testing it, please move to the wip-bpayan-csv-reader of the file-io project.

Hope that helps,
Yann

Post Reply