diff --git a/AudioGameGUI.pro b/AudioGameGUI.pro index 0b55513..63227a5 100644 --- a/AudioGameGUI.pro +++ b/AudioGameGUI.pro @@ -7,6 +7,7 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +CONFIG += c++11 TARGET = AudioGameGUI TEMPLATE = app @@ -14,11 +15,13 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ - timerdialog.cpp + timerdialog.cpp \ + StateMachineController.cpp HEADERS += mainwindow.h \ helpers.h \ - timerdialog.h + timerdialog.h \ + StateMachineController.h FORMS += mainwindow.ui \ timerdialog.ui diff --git a/AudioGameGUI.pro.user b/AudioGameGUI.pro.user index 307c907..441184a 100644 --- a/AudioGameGUI.pro.user +++ b/AudioGameGUI.pro.user @@ -1,11 +1,7 @@ - + - - EnvironmentId - {08b675bc-35b5-4c97-917b-a3d8beca82ed} - ProjectExplorer.Project.ActiveTarget 0 @@ -33,14 +29,10 @@ false 4 false - 80 - true true 1 true - false 0 - true true 0 8 @@ -59,25 +51,24 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.7.0 clang 64bit - Desktop Qt 5.7.0 clang 64bit - qt.57.clang_64_kit + Desktop + Desktop + {2a550e7b-41ba-4c4c-9b90-d18a4be629c4} 0 0 0 - /Users/davidunzue/Projects/build-AudioGameGUI-Desktop_Qt_5_7_0_clang_64bit-Debug + /home/kretschmerf/projectsbuild-AudioGameGUI-Desktop-Debug true qmake QtProjectManager.QMakeBuildStep - true + false + true false - false - false true @@ -126,7 +117,7 @@ true - /Users/davidunzue/Projects/build-AudioGameGUI-Desktop_Qt_5_7_0_clang_64bit-Release + /home/kretschmerf/projectsbuild-AudioGameGUI-Desktop-Release true @@ -134,10 +125,9 @@ QtProjectManager.QMakeBuildStep false + true false - false - false true @@ -185,67 +175,7 @@ 0 true - - /Users/davidunzue/Projects/build-AudioGameGUI-Desktop_Qt_5_7_0_clang_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 + 2 0 @@ -261,59 +191,19 @@ 1 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 2 AudioGameGUI - Qt4ProjectManager.Qt4RunConfiguration:/Users/davidunzue/Projects/AudioGameGUI/AudioGameGUI.pro - true + Qt4ProjectManager.Qt4RunConfiguration:/storage/scic/Data/External/Developer/AudioGameGUI/AudioGameGUI.pro AudioGameGUI.pro false + false - /Users/davidunzue/Projects/build-AudioGameGUI-Desktop_Qt_5_7_0_clang_64bit-Debug/AudioGameGUI.app/Contents/MacOS 3768 - false - true + true + false false false true @@ -326,11 +216,11 @@ 1 - ProjectExplorer.Project.Updater.FileVersion - 18 + ProjectExplorer.Project.Updater.EnvironmentId + {2ed301e3-4f04-4cfb-b8ea-e4f5caa11dd8} - Version - 18 + ProjectExplorer.Project.Updater.FileVersion + 15 diff --git a/helpers.h b/helpers.h index caaef19..27a49ca 100644 --- a/helpers.h +++ b/helpers.h @@ -15,4 +15,84 @@ double randomMinMax (double min, double max) { return dist(rng); } + + +QVector generateTrialSequence(int sorting, int repeatPositive, int repeatNegative) +{ + QVector trialSequence; + int currentRepeatPositive; + int currentRepeatNegative; + + switch(sorting){ + case ORDERED: + currentRepeatPositive = 1; + currentRepeatNegative = 1; + while(currentRepeatPositive <= repeatPositive || currentRepeatNegative <= repeatNegative) { + if(currentRepeatPositive <= repeatPositive) { + trialSequence.append(1); + currentRepeatPositive++; + } + if(currentRepeatNegative <= repeatNegative) { + trialSequence.append(0); + currentRepeatNegative++; + } + } + break; + case SORTED: + for (currentRepeatPositive = 1; currentRepeatPositive <= repeatPositive; ++currentRepeatPositive) { + trialSequence.append(1); + } + for (currentRepeatNegative = 1; currentRepeatNegative <= repeatNegative; ++currentRepeatNegative) { + trialSequence.append(0); + } + break; + case SHUFFLED: + for (currentRepeatPositive = 1; currentRepeatPositive <= repeatPositive; ++currentRepeatPositive) { + trialSequence.append(1); + } + for (currentRepeatNegative = 1; currentRepeatNegative <= repeatNegative; ++currentRepeatNegative) { + trialSequence.append(0); + } + // shuffle trial sequence + std::random_shuffle(trialSequence.begin(), trialSequence.end(), randomGenerator); + break; + default: + for (currentRepeatPositive = 1; currentRepeatPositive <= repeatPositive; ++currentRepeatPositive) { + trialSequence.append(1); + for (currentRepeatNegative = 1; currentRepeatNegative <= repeatNegative; ++currentRepeatNegative) { + trialSequence.append(0); + } + } + } + //qDebug() << trialSequence; + return trialSequence; + +} + +QVector generateItiSequence(double userReaction, QString itiList, double preImaq, int repeatPositive, int repeatNegative) +{ + QVector itiSequence; + int itiSequenceLength = repeatPositive + repeatNegative; + + if(!itiList.isEmpty()) { + if(itiList.contains(',')) { + QStringList iti_range = itiList.split(','); + double itiValueMin = iti_range.first().toDouble() - userReaction - preImaq; + double itiValueMax = iti_range.last().toDouble() - userReaction - preImaq; + for (int itiSequenceElement = 0; itiSequenceElement < itiSequenceLength; ++itiSequenceElement) { + itiSequence.append(randomMinMax(itiValueMin, itiValueMax)); + } + } else { + double itiValue = itiList.toDouble() - userReaction - preImaq; + for (int itiSequenceElement = 0; itiSequenceElement < itiSequenceLength; ++itiSequenceElement) { + itiSequence.append(itiValue); + } + } + } + + return itiSequence; +} + + + #endif // HELPERS_H