From: Thomas Pietrzak Date: Thu, 16 Jun 2011 15:43:39 +0000 (+0000) Subject: add threshold and init parameters X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=dffb33b60caf65ddc0f4d20be7e6ba3352507d42;p=tactonexperiment.git add threshold and init parameters git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@36 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/Tactons JND/answer3AFC.cpp b/Tactons JND/answer3AFC.cpp index 34cbc13..88ec83a 100644 --- a/Tactons JND/answer3AFC.cpp +++ b/Tactons JND/answer3AFC.cpp @@ -1,14 +1,14 @@ #include "answer3AFC.h" #include +#include +#include #include #include -#define RESETVAL (3) - Answer3AFC::Answer3AFC(QWidget *parent, Qt::WFlags flags) :QDialog(parent, flags), -_logfile(NULL), _tactonPlayer("COM3"), _defaulttacton(0x0f, 50, 205, 100), +_logfile(NULL), _tactonPlayer("COM3"), _defaulttacton(0x0f, 100, 205, 100), _currenttest(0.0), _goodanswer(-1), _block(0) { //init the window @@ -35,21 +35,31 @@ Answer3AFC::~Answer3AFC() _tactonPlayer.stop(); } -void Answer3AFC::init(QString user, int repetitions, int reversals, double tinc, double finc, int tseries, int fseries, QString experiment, QString gesture) +void Answer3AFC::init(QString user, int repetitions, int reversals, double initval, double tinc, double finc, double threshold, double smalltinc, double smallfinc, int tseries, int fseries, QString experiment, QString gesture) { _user = user; _repetitions = repetitions; _reversals = reversals; + _initval = initval; _tinc = tinc; _finc = finc; + _threshold = threshold; + _smalltinc = smalltinc; + _smallfinc = smallfinc; _tseries = tseries; _fseries = fseries; _experiment = experiment; _gesture = gesture; //create log file - QString logfilename = user + "-" + experiment + "-" + gesture + "-"; - _logfile = fopen(logfilename.toStdString().c_str(), "w"); + QString date = QDate::currentDate().toString("yyyy-MM-dd") + "-" + QTime::currentTime().toString("HH-mm-ss"); + QString logfilename = user + "-" + experiment + "-" + gesture + "-" + date + "-answers"; + if (_logfile = fopen(logfilename.toStdString().c_str(), "w")) + fprintf(_logfile, "TRIAL,VALUE,TESTVALUE,DIFF,GOODANSWER,USERANSWER,NBPRESSED1,NBPRESSED2,NBPRESSED3\n"); + logfilename = user + "-" + experiment + "-" + gesture + "-" + date + "-jnd"; + if (_logfile2 = fopen(logfilename.toStdString().c_str(), "w")) + fprintf(_logfile2, "TRIAL,VALUE,JND\n"); + //load icons FILE *f = fopen((experiment + ".txt").toAscii().data(), "r"); @@ -157,22 +167,33 @@ void Answer3AFC::answer() { if (val) { - if (_tseries == 1 && _currenttest >= _tinc) + if (_tseries == 1) { //change - _currenttest -= _tinc; - nb = 0; + if (_currenttest < _threshold) + { + if (_currenttest > _smalltinc) + { + _currenttest -= _smalltinc; + nb = 0; + } + } + else if (_currenttest > _tinc) + { + _currenttest -= _tinc; + nb = 0; + } } } //wrong answer: increase the gap - else + else if (_fseries == 1)// && _currenttest < _initval) { - if (_fseries == 1)// && _currenttest < RESETVAL) - { - //change + //change + if (_currenttest < _threshold) + _currenttest += _smallfinc; + else _currenttest += _finc; - nb = 0; - } + nb = 0; } } } @@ -184,22 +205,33 @@ void Answer3AFC::answer() //good answer: reduce the gap if (val) { - if (nb >= _tseries && _currenttest >= _tinc) + if (nb >= _tseries) { //change - _currenttest -= _tinc; - nb = 0; + if (_currenttest < _threshold) + { + if (_currenttest > _smalltinc) + { + _currenttest -= _smalltinc; + nb = 0; + } + } + else if (_currenttest > _tinc) + { + _currenttest -= _tinc; + nb = 0; + } } } //wrong answer: increase the gap - else + else if (nb >= _fseries)// && _currenttest < _initval) { - if (nb >= _fseries)// && _currenttest < RESETVAL) - { - //change + //change + if (_currenttest < _threshold) + _currenttest += _smallfinc; + else _currenttest += _finc; - nb = 0; - } + nb = 0; } } lastval = val; @@ -211,14 +243,14 @@ void Answer3AFC::log(int answer) const { if (_logfile == NULL) return; - fprintf(_logfile, "ANSWER,%d,%d,%0.2f,%d,%d,%d,%d,%d\n", _block, _trials[_block], _currenttest, _goodanswer, answer, _tplayed[0], _tplayed[1], _tplayed[2]); + fprintf(_logfile, "%d,%d,%d,%0.2f,%d,%d,%d,%d,%d\n", _block, _trials[_block], testValue(_trials[_block], _currenttest), _currenttest, _goodanswer, answer, _tplayed[0], _tplayed[1], _tplayed[2]); } void Answer3AFC::log2() const { - if (_logfile == NULL) + if (_logfile2 == NULL) return; - fprintf(_logfile, "JND,%d,%d,%0.2f\n", _block, _trials[_block], _jnd[_block]); + fprintf(_logfile2, "%d,%d,%0.2f\n", _block, _trials[_block], _jnd[_block]); } void Answer3AFC::runBlock() @@ -234,7 +266,7 @@ void Answer3AFC::runBlock() label->setText("Finished!"); } - _currenttest = RESETVAL; + _currenttest = _initval; runTrial(); } diff --git a/Tactons JND/answer3AFC.h b/Tactons JND/answer3AFC.h index a7c711f..443846d 100644 --- a/Tactons JND/answer3AFC.h +++ b/Tactons JND/answer3AFC.h @@ -16,7 +16,7 @@ public: Answer3AFC(QWidget *parent = 0, Qt::WFlags flags = 0); ~Answer3AFC(); - void init(QString user, int repetitions, int reversals, double tinc, double finc, int tseries, int fseries, QString experiment, QString gesture); + void init(QString user, int repetitions, int reversals, double initval, double tinc, double finc, double threshold, double smalltinc, double smallfinc, int tseries, int fseries, QString experiment, QString gesture); void setAnswer(bool same); @@ -27,14 +27,14 @@ private: void runBlock(); unsigned int testValue(unsigned int value, double db) const; - FILE *_logfile; + FILE *_logfile, *_logfile2; TactonPlayer _tactonPlayer; Tacton _defaulttacton; //exp parameters QString _user; int _repetitions, _reversals, _tseries, _fseries; - double _tinc, _finc; + double _initval, _tinc, _finc, _threshold, _smalltinc, _smallfinc; QString _experiment; QString _gesture; diff --git a/Tactons JND/tactonsjnd.cpp b/Tactons JND/tactonsjnd.cpp index 7274998..d0736ff 100644 --- a/Tactons JND/tactonsjnd.cpp +++ b/Tactons JND/tactonsjnd.cpp @@ -47,7 +47,8 @@ void TactonsJND::runBlock(void) { this->hide(); w.init(username->text(), repetitions->value(), - reversals->value(), tinc->value(), finc->value(), tseries->value(), fseries->value(), + reversals->value(), initval->value(), tinc->value(), finc->value(), threshold->value(), + smalltinc->value(), smallfinc->value(), tseries->value(), fseries->value(), experiment->currentText(), gesture->currentText()); w.show(); } diff --git a/Tactons JND/tactonsjnd.ui b/Tactons JND/tactonsjnd.ui index 7b97944..16ae61e 100644 --- a/Tactons JND/tactonsjnd.ui +++ b/Tactons JND/tactonsjnd.ui @@ -6,8 +6,8 @@ 0 0 - 231 - 279 + 230 + 357 @@ -21,7 +21,7 @@ - + @@ -72,14 +72,96 @@ - + + + + + + + + + + 1 + + + 20 + + + + + + + 1 + + + 20 + + + + + + + Gesture: + + + + + + + Experiment: + + + + + + + F Series + + + + + + + T Series + + + + + + + Small F inc + + + + + + + Small T inc + + + + + + + Threshold + + + + T Inc - + + + + F Inc + + + + 10.000000000000000 @@ -92,14 +174,7 @@ - - - - F Inc - - - - + 0.000000000000000 @@ -115,60 +190,65 @@ - - - - T Series + + + + 10.000000000000000 - - - - - - F Series + + 0.100000000000000 - - - - Experiment: + + + + 0.100000000000000 - - - - - - Gesture: + + 10.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 - - + + - 1 + 0.100000000000000 - 20 + 10.000000000000000 + + + 0.100000000000000 - - - - 1 + + + + Init val + + + + - 20 + 20.000000000000000 + + + 0.250000000000000 + + + 6.000000000000000 - - - - - -