Commit c7d3c67d authored by Adrien Dorsaz's avatar Adrien Dorsaz

Use newest sbs2Filter to filter the two bands using only one sbs2Filter object.

parent 73bbdbef
......@@ -3,6 +3,7 @@
MyCallback::MyCallback(QObject *parent) :
Sbs2Callback(parent)
{
filterReady=0;
}
/**
......@@ -17,46 +18,47 @@ void MyCallback::getData(Sbs2Packet *packet)
emit timeTick8();
}
double f3=thisPacket->values["F3"];
double f4=thisPacket->values["F4"];
double af3=thisPacket->values["AF3"];
double af4=thisPacket->values["AF4"];
if(filterReady==0){
initFilter();
}
sbs2DataHandler->filter2bands();
changeBand("alpha");
// alpha band
double f3_alpha=thisPacket->filteredValues["F3"];
double f4_alpha=thisPacket->filteredValues["F4"];
double af3_alpha=thisPacket->filteredValues["AF3"];
double af4_alpha=thisPacket->filteredValues["AF4"];
changeBand("beta");
double f3_beta=thisPacket->filteredValues["F3"];
double f4_beta=thisPacket->filteredValues["F4"];
double af3_beta=thisPacket->filteredValues["AF3"];
double af4_beta=thisPacket->filteredValues["AF4"];
// beta band
double f3_beta=thisPacket->filteredValues2ndBand["F3"];
double f4_beta=thisPacket->filteredValues2ndBand["F4"];
double af3_beta=thisPacket->filteredValues2ndBand["AF3"];
double af4_beta=thisPacket->filteredValues2ndBand["AF4"];
// Goal is to use af3/af4 because they are hairless copmared to f3/f4
// So we'll apply same idea than colorOfMind but we use sensors otherwise
// colorOfMind : double arousal = (f3_alpha/f3_beta + f4_alpha/f4_beta)/2;
double arousal = (af3_alpha/af3_beta + af4_alpha/af4_beta)/2;
// colorOfMind : double valence = ((f4-af4_alpha)/(f4-af4_beta) - (f3-af3_alpha)/(f3-af3_beta));
double valence = ((af4-f4_alpha)/(af4-f4_beta) - (af3-f3_alpha)/(af3-f3_beta));
// colorOfMind : (front beta power)/(front alpha power)
double arousal = (f3_alpha/f3_beta + f4_alpha/f4_beta)/2;
// colorOfMind : Valence = (left beta power)/(left alpha power) – (right beta power)/(right alpha power)
double valence = (f4_alpha/f4_beta - f3_alpha/f3_beta);
//arousal = af3_alpha;
//valence=thisPacket->values["AF3"];
//qDebug()<<"arousal : "<<arousal<<" and valence : "<<valence<<" emited";
emit arousalValence(arousal,valence);
}
void MyCallback::changeBand(QString name)
{
sbs2DataHandler->turnFilterOff();
//qDebug()<<"MyCallBack : change band to "<<name;
if (name.compare("alpha")){
lowFreq = 8;
highFreq = 13;
}else if (name.compare("beta")){
lowFreq = 13;
highFreq = 30;
}
sbs2DataHandler->turnFilterOn(lowFreq, highFreq, 32);
sbs2DataHandler->filter();
void MyCallback::initFilter(){
lowFreq = 8;
highFreq = 13;
lowFreq2nd = 13;
highFreq2nd = 30;
qDebug() << "Mycallback : turn filter on...";
sbs2DataHandler->turnFilterOn2bands(lowFreq, highFreq, 32, lowFreq2nd, highFreq2nd, 32);
qDebug() << "Mycallback : filternow...";
sbs2DataHandler->filter2bands();
qDebug() << "Mycallback : filter activated !";
filterReady=1;
}
......@@ -10,11 +10,14 @@ class MyCallback : public Sbs2Callback
private:
int lowFreq;
int highFreq;
int lowFreq2nd;
int highFreq2nd;
QVector<double>* maxValues;
QVector<double>* minValues;
void changeBand(QString band);
void initFilter();
int filterReady;
public:
explicit MyCallback(QObject *parent = 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment