Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 438d6215 authored by Alison Cellard's avatar Alison Cellard
Browse files

Hilbert : Added channel name (label) for clearer

visualization.
PLV Algo : Cleaned up code and added label for visualization.
Connectivity measure box : Handle all selection, fixed bug on selection
of invalid channel, handle second input.
parent 30e6cf13
No related branches found
No related tags found
No related merge requests found
......@@ -52,8 +52,7 @@ boolean CAlgorithmHilbertTransform::process(void)
{
if( l_pInputMatrix->getDimensionCount() != 2)
{
this->getLogManager() << LogLevel_Error << "The input matrix must have 2 dimensions, here the dimension is ";
std::cout<<l_pInputMatrix->getDimensionCount()<<std::endl;
this->getLogManager() << LogLevel_Error << "The input matrix must have 2 dimensions, here the dimension is "<<l_pInputMatrix->getDimensionCount()<<"\n";
return false;
}
......@@ -71,6 +70,13 @@ boolean CAlgorithmHilbertTransform::process(void)
l_pOutputPhaseMatrix->setDimensionSize(0,l_ui32ChannelCount);
l_pOutputPhaseMatrix->setDimensionSize(1,l_ui32SamplesPerChannel);
for(uint32 i=0; i<l_ui32ChannelCount;i++)
{
l_pOutputHilbertMatrix->setDimensionLabel(0,i,l_pInputMatrix->getDimensionLabel(0,i));
l_pOutputEnvelopeMatrix->setDimensionLabel(0,i,l_pInputMatrix->getDimensionLabel(0,i));
l_pOutputPhaseMatrix->setDimensionLabel(0,i,l_pInputMatrix->getDimensionLabel(0,i));
}
}
if(this->isInputTriggerActive(OVP_Algorithm_HilbertTransform_InputTriggerId_Process))
......
......@@ -7,6 +7,8 @@
#include <unsupported/Eigen/FFT>
#include <system/Memory.h>
#include <iostream>
#include <sstream>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
......@@ -58,39 +60,30 @@ boolean CAlgorithmSingleTrialPhaseLockingValue::uninitialize(void) {
boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
{
std::complex <double> iComplex(0.0,1.0);
IMatrix* l_pInputMatrix1;
IMatrix* l_pInputMatrix2;
IMatrix* l_pChannelPairs;
IMatrix* l_pOutputMatrix;
const std::complex <double> iComplex(0.0,1.0);
MatrixXd l_pChannelToCompare;
IMatrix* l_pInputMatrix1 = ip_pSignal1;
IMatrix* l_pInputMatrix2 = ip_pSignal2;
uint32 l_ui32ChannelCount1;
uint32 l_ui32SamplesPerChannel1;
IMatrix* l_pChannelPairs = ip_pChannelPairs;
IMatrix* l_pOutputMatrix = op_pMatrix;
uint32 l_ui32ChannelCount2;
uint32 l_ui32SamplesPerChannel2;
uint32 l_ui32ChannelCount1 = l_pInputMatrix1->getDimensionSize(0);
uint32 l_ui32SamplesPerChannel1 = l_pInputMatrix1->getDimensionSize(1);
uint32 l_ui32PairsCount;
uint32 l_ui32ChannelCount2 = l_pInputMatrix2->getDimensionSize(0);
uint32 l_ui32SamplesPerChannel2 = l_pInputMatrix2->getDimensionSize(1);
l_pInputMatrix1 = ip_pSignal1;
l_pInputMatrix2 = ip_pSignal2;
uint32 l_ui32PairsCount = ip_pChannelPairs->getDimensionSize(0)/2;
l_pOutputMatrix = op_pMatrix;
MatrixXd l_pChannelToCompare = MatrixXd::Zero(ip_pChannelPairs->getDimensionSize(0),l_ui32SamplesPerChannel1);
l_ui32ChannelCount1 = l_pInputMatrix1->getDimensionSize(0);
l_ui32SamplesPerChannel1 = l_pInputMatrix1->getDimensionSize(1);
float64* l_ipMatrixBuffer1 = l_pInputMatrix1->getBuffer();
float64* l_ipMatrixBuffer2 = l_pInputMatrix2->getBuffer();
float64* l_opMatrixBuffer = l_pOutputMatrix->getBuffer();
l_ui32ChannelCount2 = l_pInputMatrix2->getDimensionSize(0);
l_ui32SamplesPerChannel2 = l_pInputMatrix2->getDimensionSize(1);
l_pChannelPairs = ip_pChannelPairs;
l_ui32PairsCount = ip_pChannelPairs->getDimensionSize(0)/2;
l_pChannelToCompare = MatrixXd::Zero(l_ui32ChannelCount1,l_ui32SamplesPerChannel1);
float64* l_pHilberInputBuffer = ip_pHilbertInput->getBuffer();
float64* l_pInstPhaseBuffer = op_pInstantaneousPhase->getBuffer();
if(this->isInputTriggerActive(OVTK_Algorithm_Connectivity_InputTriggerId_Initialize))
......@@ -114,6 +107,19 @@ boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
l_pOutputMatrix->setDimensionSize(0,l_ui32PairsCount); //
l_pOutputMatrix->setDimensionSize(1,1);//
// Setting name of output channels for visualization
CString l_name1, l_name2, l_name;
uint32 l_ui32Index;
for(uint32 i=0;i<l_ui32PairsCount;i++)
{
l_ui32Index=2*i;
l_name1 = l_pInputMatrix1->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index]);
l_name2 = l_pInputMatrix2->getDimensionLabel(0,l_pChannelPairs->getBuffer()[l_ui32Index+1]);
l_name = l_name1+l_name2;
l_pOutputMatrix->setDimensionLabel(0,i,l_name);
}
//
ip_pHilbertInput->setDimensionCount(2);
ip_pHilbertInput->setDimensionSize(0,1);
ip_pHilbertInput->setDimensionSize(1,l_ui32SamplesPerChannel1);
......@@ -127,84 +133,66 @@ boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
VectorXd l_vecXdPhase1;
VectorXd l_vecXdPhase2;
std::complex <double> l_sum(0.0,0.0);
// std::cout<<"Channel pairs = "<<l_pChannelPairs->getBuffer() <<std::endl;
//_______________________________________________________________________________________
//
// Form pairs with the lookup matrix given
// Compute S-PLV for each pairs
//_______________________________________________________________________________________
//
for(uint32 i=0; i<l_ui32PairsCount*2; i++)
{
if(l_pChannelPairs->getBuffer()[i] < l_ui32ChannelCount1)
{
for(uint32 sample = 0; sample<l_ui32SamplesPerChannel1; sample++)
{
l_pChannelToCompare(i,sample) = l_pInputMatrix1->getBuffer()[sample+(uint32)l_pChannelPairs->getBuffer()[i]*l_ui32SamplesPerChannel1];
// std::cout<<"Input matrix 1 = "<<l_pInputMatrix1->getBuffer()[sample+(uint32)l_pChannelPairs->getBuffer()[i]*l_ui32SamplesPerChannel1]<<std::endl;
}
}
}
/* for(uint32 i=1; i<l_pChannelPairs->getDimensionSize(0); i=i+2)
{
if(l_pChannelPairs->getBuffer()[i] < l_pInputMatrix2->getDimensionSize(0))
{
System::Memory::copy(l_pChannelToCompare->getBuffer()+i*l_ui32SamplesPerChannel2, l_pInputMatrix2->getBuffer()+(uint32)l_pChannelPairs->getBuffer()[i]*l_ui32SamplesPerChannel2,
l_ui32SamplesPerChannel2*sizeof(float64));
}
}*/
//Compute S-PLV for each pairs
for(uint32 channel = 0; channel < l_ui32PairsCount; channel = channel+1)
for(uint32 channel = 0; channel < l_ui32PairsCount; channel++)
{
l_vecXdChannelToCompare1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
l_vecXdChannelToCompare2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
l_vecXdPhase1 = VectorXd::Zero(l_ui32SamplesPerChannel1);
l_vecXdPhase2 = VectorXd::Zero(l_ui32SamplesPerChannel2);
l_sum = (0.0,0.0);
// std::cout<<"channel to compare = "<<l_pChannelToCompare<<std::endl;
for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
{
l_vecXdChannelToCompare1(i) = l_pChannelToCompare(channel,i);
l_vecXdChannelToCompare2(i) = l_pChannelToCompare(channel+1,i);
uint32 l_channelIndex = 2*channel; //Index on single channel
//_______________________________________________________________________________________
//
// Form pairs with the lookup matrix given
//_______________________________________________________________________________________
//
// std::cout<<"channel to compare = "<<l_pChannelToCompare<<std::endl;
for(uint32 sample = 0; sample < l_ui32SamplesPerChannel1; sample++)
{
if(l_pChannelPairs->getBuffer()[sample] < l_ui32ChannelCount1)
{
l_pChannelToCompare(l_channelIndex,sample) = l_ipMatrixBuffer1[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex]*l_ui32SamplesPerChannel1];
l_pChannelToCompare(l_channelIndex+1,sample) = l_ipMatrixBuffer2[sample+(uint32)l_pChannelPairs->getBuffer()[l_channelIndex+1]*l_ui32SamplesPerChannel2];
}
}
// std::cout<<"channel to compare 1 = "<<l_vecXdChannelToCompare1.transpose()<<std::endl;
// std::cout<<"channel to compare 2 = "<<l_vecXdChannelToCompare2.transpose()<<std::endl;
for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
// Retrieve the 2 channel to compare
l_vecXdChannelToCompare1 = l_pChannelToCompare.row(l_channelIndex);
l_vecXdChannelToCompare2 = l_pChannelToCompare.row(l_channelIndex+1);
// Apply Hilbert transform to each channel to compute instantaneous phase
// Channel 1
for(uint32 sample = 0; sample<l_ui32SamplesPerChannel1; sample++)
{
ip_pHilbertInput->getBuffer()[i] = l_vecXdChannelToCompare1(i);
l_pHilberInputBuffer[sample] = l_vecXdChannelToCompare1(sample);
}
m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize);
m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);
// std::cout<<"N1 = "<<l_ui32SamplesPerChannel1<<"\n"<<std::endl;
// Channel 2
for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
{
l_vecXdPhase1(i) = op_pInstantaneousPhase->getBuffer()[i];
ip_pHilbertInput->getBuffer()[i] = (float64)l_vecXdChannelToCompare2(i);
l_pHilberInputBuffer[i] = l_vecXdChannelToCompare2(i);
}
// std::cout<<"Phase 1 = "<<l_vecXdPhase1.transpose()<<"\n"<<std::endl;
m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Initialize);
m_pHilbertTransform->process(OVP_Algorithm_HilbertTransform_InputTriggerId_Process);
// Compute S-PLV and store it in l_opMatrixBuffer for each pair
for(uint32 i=0; i<l_ui32SamplesPerChannel1; i++)
{
l_vecXdPhase2(i) = op_pInstantaneousPhase->getBuffer()[i];
......@@ -212,18 +200,12 @@ boolean CAlgorithmSingleTrialPhaseLockingValue::process(void)
l_sum += exp(iComplex*(l_vecXdPhase1(i)-l_vecXdPhase2(i)));
}
// std::cout<<"Phase 2 = "<<l_vecXdPhase2.transpose()<<"\n"<<std::endl;
// std::cout<<"N2 = "<<l_ui32SamplesPerChannel1<<"\n"<<std::endl;
l_pOutputMatrix->getBuffer()[channel] = abs(l_sum)/l_ui32SamplesPerChannel1;
// std::cout<<"sum2 = "<<abs(l_sum)<<"\n"<<std::endl;
l_opMatrixBuffer[channel] = abs(l_sum)/l_ui32SamplesPerChannel1;
}
this->activateOutputTrigger(OVTK_Algorithm_Connectivity_OutputTriggerId_ProcessDone, true);
}
}
return true;
}
......
//#if defined(TARGET_HAS_ThirdPartyEIGEN)
#include "ovpCBoxAlgorithmConnectivityMeasure.h"
#include <system/Memory.h>
#include <cstdio>
#include <iostream>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
......@@ -25,7 +24,6 @@ namespace
inline uint32 _find_channel_(const IMatrix& rMatrix, const CString& rChannel, const CIdentifier& rMatchMethodIdentifier, uint32 uiStart=0)
{
uint32 i, l_ui32Result=uint32(-1);
unsigned int value;
if(rMatchMethodIdentifier==OVP_TypeId_MatchMethod_Name)
{
......@@ -39,27 +37,20 @@ namespace
}
else if(rMatchMethodIdentifier==OVP_TypeId_MatchMethod_Index)
{
unsigned int value;
if(::sscanf(rChannel.toASCIIString(), "%u", &value)==1)
{
value--; // => makes it 0-indexed !
//cout<<"value = "<<value<<endl;
if(uiStart <= uint32(value) && uint32(value) < rMatrix.getDimensionSize(1))
if(uiStart <= uint32(value) && uint32(value) < rMatrix.getDimensionSize(0))
{
l_ui32Result=uint32(value);
}
}
}
else if(rMatchMethodIdentifier==OVP_TypeId_MatchMethod_Smart)
{
if(l_ui32Result==uint32(-1)) l_ui32Result=_find_channel_(rMatrix, rChannel, OVP_TypeId_MatchMethod_Name, uiStart);
if(l_ui32Result==uint32(-1)) l_ui32Result=_find_channel_(rMatrix, rChannel, OVP_TypeId_MatchMethod_Index, uiStart);
}
return l_ui32Result;
......@@ -107,13 +98,12 @@ boolean CBoxAlgorithmConnectivityMeasure::initialize(void)
m_oAlgo2_SignalDecoder.initialize(*this);
}
// The box can't process more than two input
else if(m_ui32InputCount !=1 && m_ui32InputCount !=2)
else if(m_ui32InputCount > 2)
{
this->getLogManager() << LogLevel_ImportantWarning << "Incorrect number of input";
return false;
}
ip_pChannelTable->setDimensionCount(2);
ip_pChannelTable->setDimensionSize(1,1);
......@@ -146,18 +136,49 @@ boolean CBoxAlgorithmConnectivityMeasure::uninitialize(void)
m_oAlgo0_SignalDecoder.uninitialize();
m_oAlgo1_SignalEncoder.uninitialize();
// if a second decoder algorithm was created
if(m_ui32InputCount==2)
{
m_oAlgo2_SignalDecoder.uninitialize();
}
return true;
}
boolean CBoxAlgorithmConnectivityMeasure::processInput(uint32 ui32InputIndex)
{
// some pre-processing code if needed...
IBox& l_rStaticBoxContext=this->getStaticBoxContext();
IDynamicBoxContext& l_rDynamicBoxContext=this->getDynamicBoxContext();
if(l_rDynamicBoxContext.getInputChunkCount(0) == 0)
{
return true;
}
uint64 l_ui64StartTime=l_rDynamicBoxContext.getInputChunkStartTime(0, 0);
uint64 l_ui64EndTime=l_rDynamicBoxContext.getInputChunkEndTime(0, 0);
for(uint32 i=1; i<l_rStaticBoxContext.getInputCount(); i++)
{
if(l_rDynamicBoxContext.getInputChunkCount(i)==0)
{
return true;
}
else
{
boolean l_bValidDates=true;
if(l_ui64StartTime!=l_rDynamicBoxContext.getInputChunkStartTime(i, 0)) { l_bValidDates=false; }
if(l_ui64EndTime!=l_rDynamicBoxContext.getInputChunkEndTime(i, 0)) { l_bValidDates=false; }
if(!l_bValidDates)
{
this->getLogManager() << LogLevel_Warning << "Chunk dates mismatch, check stream structure or parameters\n";
return l_bValidDates;
}
}
}
// ready to process !
getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
......@@ -174,25 +195,47 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
// the dynamic box context describes the current state of the box inputs and outputs (i.e. the chunks)
IBoxIO& l_rDynamicBoxContext=this->getDynamicBoxContext();
boolean l_bHeaderReceived = false;
boolean l_bBufferReceived = false;
boolean l_bEndReceived = false;
// we decode the input signal chunks
for(uint32 i=0; i<l_rDynamicBoxContext.getInputChunkCount(0); i++)
{
m_oAlgo0_SignalDecoder.decode(0,i);
// if(m_ui32InputCount==2){m_oAlgo2_SignalDecoder.decode(1,i);};
m_oAlgo0_SignalDecoder.decode(0,i);
// If header is received
if(m_oAlgo0_SignalDecoder.isHeaderReceived())
if(m_ui32InputCount==2)
{
m_oAlgo2_SignalDecoder.decode(1,i);
/* m_pConnectivityMethod->process(OVTK_Algorithm_Connectivity_InputTriggerId_Initialize);
// Make sure the algo initialization was successful
if(!m_pConnectivityMethod->process(OVTK_Algorithm_Connectivity_InputTriggerId_Initialize))
if(m_oAlgo0_SignalDecoder.isHeaderReceived() && m_oAlgo2_SignalDecoder.isHeaderReceived())
{
this->getLogManager() << LogLevel_Trace << "initialization was unsuccessful";
return false;
}*/
l_bHeaderReceived = true;
}
if(m_oAlgo0_SignalDecoder.isBufferReceived() && m_oAlgo2_SignalDecoder.isBufferReceived())
{
l_bBufferReceived = true;
}
if(m_oAlgo0_SignalDecoder.isEndReceived() && m_oAlgo2_SignalDecoder.isEndReceived())
{
l_bEndReceived = true;
}
}
else
{
if(m_oAlgo0_SignalDecoder.isHeaderReceived()){l_bHeaderReceived = true;}
if(m_oAlgo0_SignalDecoder.isBufferReceived()){l_bBufferReceived = true;}
if(m_oAlgo0_SignalDecoder.isEndReceived()){l_bEndReceived = true;}
}
// If header is received
if(l_bHeaderReceived)
{
//______________________________________________________________________________________________________________________________________
//
......@@ -201,8 +244,8 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
//
// Retrieve string setting giving channel pairs
CString l_sChannelList=FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
uint64 l_ui64MatchMethodIdentifier=FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2);
CString l_sChannelList = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
uint64 l_ui64MatchMethodIdentifier = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 2);
m_vChannelTable.clear();
......@@ -224,52 +267,55 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
uint32 range1 = Tools::String::split(l_sChannel[chan], OpenViBEToolkit::Tools::String::TSplitCallback < std::vector < CString > >(l_sSubChannel), OV_Value_RangeStringSeparator);
uint32 range2 = Tools::String::split(l_sChannel[chan+1], OpenViBEToolkit::Tools::String::TSplitCallback < std::vector < CString > >(l_sSubChannel2), OV_Value_RangeStringSeparator);
uint32 l_ui32RangeStartIndex=::_find_channel_(*ip_pMatrix1, l_sSubChannel[0], OVP_TypeId_MatchMethod_Index);
uint32 l_ui32RangeEndIndex=::_find_channel_(*ip_pMatrix1, l_sSubChannel[range1-1], OVP_TypeId_MatchMethod_Index);
uint32 l_ui32RangeStartIndex = uint32(-1);
uint32 l_ui32RangeEndIndex = uint32(-1);
uint32 l_ui32RangeStartIndex2 = uint32(-1);
uint32 l_ui32RangeEndIndex2 = uint32(-1);
if (Tools::String::isAlmostEqual(l_sSubChannel[0], "*", false)) // If all channels selected
{
// Select all the channels
l_ui32RangeStartIndex = 0;
l_ui32RangeEndIndex = ip_pMatrix1->getDimensionSize(0)-1;
}
else // Else find channels selected
{
l_ui32RangeStartIndex=::_find_channel_(*ip_pMatrix1, l_sSubChannel[0], l_ui64MatchMethodIdentifier);
l_ui32RangeEndIndex=::_find_channel_(*ip_pMatrix1, l_sSubChannel[range1-1], l_ui64MatchMethodIdentifier);
}
uint32 l_ui32RangeStartIndex2 =::_find_channel_(*ip_pMatrix1, l_sSubChannel2[0], OVP_TypeId_MatchMethod_Index);
uint32 l_ui32RangeEndIndex2=::_find_channel_(*ip_pMatrix1, l_sSubChannel2[range2-1], OVP_TypeId_MatchMethod_Index);
if (Tools::String::isAlmostEqual(l_sSubChannel2[0], "*", false))
{
//Select all the channels
l_ui32RangeStartIndex2 = 0;
l_ui32RangeEndIndex = ip_pMatrix1->getDimensionSize(0)-1;
}
else
{
l_ui32RangeStartIndex2 =::_find_channel_(*ip_pMatrix1, l_sSubChannel2[0], l_ui64MatchMethodIdentifier);
l_ui32RangeEndIndex2=::_find_channel_(*ip_pMatrix1, l_sSubChannel2[range2-1], l_ui64MatchMethodIdentifier);
}
// When first or second part is not found but associated token is empty, don't consider this as an error
if(l_ui32RangeStartIndex==uint32(-1) && l_sSubChannel[0]==CString("")) l_ui32RangeStartIndex=0;
if(l_ui32RangeEndIndex ==uint32(-1) && l_sSubChannel[range1-1]==CString("")) l_ui32RangeEndIndex=ip_pMatrix1->getDimensionSize(0)-1;
if(l_ui32RangeStartIndex == uint32(-1) && l_sSubChannel[0] == CString("")) l_ui32RangeStartIndex = 0;
if(l_ui32RangeEndIndex == uint32(-1) && l_sSubChannel[range1-1] == CString("")) l_ui32RangeEndIndex = ip_pMatrix1->getDimensionSize(0)-1;
if(l_ui32RangeStartIndex2==uint32(-1) && l_sSubChannel2[0]==CString("")) l_ui32RangeStartIndex2=0;
if(l_ui32RangeEndIndex2 ==uint32(-1) && l_sSubChannel2[range2-1]==CString("")) l_ui32RangeEndIndex2=ip_pMatrix1->getDimensionSize(0)-1;
if(l_ui32RangeStartIndex2 == uint32(-1) && l_sSubChannel2[0] == CString("")) l_ui32RangeStartIndex2 = 0;
if(l_ui32RangeEndIndex2 == uint32(-1) && l_sSubChannel2[range2-1] == CString("")) l_ui32RangeEndIndex2 = ip_pMatrix1->getDimensionSize(0)-1;
// After these corrections, if either first or second token were not found, or if start index is greater than start index, consider this an error and invalid range
if(l_ui32RangeStartIndex==uint32(-1) || l_ui32RangeEndIndex ==uint32(-1) || l_ui32RangeStartIndex>l_ui32RangeEndIndex)
if(l_ui32RangeStartIndex == uint32(-1) || l_ui32RangeEndIndex == uint32(-1) || l_ui32RangeStartIndex > l_ui32RangeEndIndex)
{
this->getLogManager() << LogLevel_Warning << "Invalid channel range [" << l_sChannel[chan] << "] - splitted as [" << l_sSubChannel[0] << "][" << l_sSubChannel[1] << "]\n";
this->getLogManager() << LogLevel_Warning << "Invalid channel or range [" << l_sChannel[chan] << "]\n";
}
else if(l_ui32RangeStartIndex2==uint32(-1) || l_ui32RangeEndIndex2 ==uint32(-1) || l_ui32RangeStartIndex2>l_ui32RangeEndIndex2)
else if(l_ui32RangeStartIndex2 == uint32(-1) || l_ui32RangeEndIndex2 == uint32(-1) || l_ui32RangeStartIndex2 > l_ui32RangeEndIndex2)
{
this->getLogManager() << LogLevel_Warning << "Invalid channel range [" << l_sChannel[chan+1] << "] - splitted as [" << l_sSubChannel2[0] << "][" << l_sSubChannel2[1] << "]\n";
this->getLogManager() << LogLevel_Warning << "Invalid channel or range [" << l_sChannel[chan+1] << "]\n";
}
else
{
// The ranges are valid so selects all the channels in those range
/* uint32 l_bFound=false;
uint32 l_ui32Index=uint32(-1);
// Looks for all the channels with this name
while((l_ui32Index=::_find_channel_(*m_pInputMatrix, l_sToken[j], l_ui64MatchMethodIdentifier, l_ui32Index+1))!=uint32(-1))
{
l_bFound=true;
m_vLookup.push_back(l_ui32Index);
this->getLogManager() << LogLevel_Trace << "Selected channel [" << l_ui32Index+1 << "]\n";
}
// When no channel was found, consider it a missing channel
if(!l_bFound)
{
this->getLogManager() << LogLevel_Warning << "Invalid channel [" << l_sToken[j] << "]\n";
m_vLookup.push_back(uint32(-1));
}*/
// The ranges are valid so selects all the channels in those range
this->getLogManager() << LogLevel_Trace << "For range [" << l_sChannel[chan] << "] :\n";
for(uint32 k=l_ui32RangeStartIndex; k<=l_ui32RangeEndIndex; k++)
{
......@@ -279,14 +325,13 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
m_vChannelTable.push_back(j);
this->getLogManager() << LogLevel_Info << " Selected channels [" << k+1 << ","<< j+1 <<"]\n";
//std::cout<< "Selected channel [" << k+1 << ","<< j+1 << "]\n"<<std::endl;
}
}
}
}
}
// Parsing chain to identify channel name or index
ip_pChannelTable->setDimensionSize(0,m_vChannelTable.size());
......@@ -294,7 +339,6 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
for(uint32 cpt=0;cpt<m_vChannelTable.size();cpt++)
{
ip_pChannelTable->getBuffer()[cpt] = m_vChannelTable[cpt];
//cout<<"channel table"<<ip_pChannelTable->getBuffer()[cpt]<<endl;
}
// Make sure the algo initialization was successful
......@@ -307,17 +351,11 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
// Pass the header to the next boxes, by encoding a header on the output 0:
m_oAlgo1_SignalEncoder.encodeHeader(0);
// if(m_ui32InputCount==2){m_oAlgo2_SignalDecoder.encodeHeader(0);};
// send the output chunk containing the header. The dates are the same as the input chunk:
l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i));
}
if(m_oAlgo0_SignalDecoder.isBufferReceived())
if(l_bBufferReceived)
{
// Buffer received. For example the signal values
// Access to the buffer can be done thanks to :
// IMatrix* l_pMatrix = m_oAlgo0_SignalDecoder.getOutputMatrix(); // the StreamedMatrix of samples.
// uint64 l_uiSamplingFrequency = m_oAlgo0_SignalDecoder.getOutputSamplingRate(); // the sampling rate of the signal
m_pConnectivityMethod->process(OVTK_Algorithm_Connectivity_InputTriggerId_Process);
......@@ -330,10 +368,11 @@ boolean CBoxAlgorithmConnectivityMeasure::process(void)
}
}
if(m_oAlgo0_SignalDecoder.isEndReceived())
if(l_bEndReceived)
{
// End of stream received. This happens only once when pressing "stop". Just pass it to the next boxes so they receive the message :
m_oAlgo1_SignalEncoder.encodeEnd(0);
l_rDynamicBoxContext.markOutputAsReadyToSend(0, l_rDynamicBoxContext.getInputChunkStartTime(0, i), l_rDynamicBoxContext.getInputChunkEndTime(0, i));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment