Skip to content

Commit f317bcd

Browse files
authored
Merge pull request #71 from iTrace-Dev/issue-70-idt-huge-fixations
Issue 70 idt huge fixations
2 parents 01574a2 + a3add06 commit f317bcd

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

Options.qml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Popup {
4545
if(algSelection.currentIndex === 0) {
4646
rtn = rtn + "-" + windowSize.text + "-" + radius.text + "-" + peak.text
4747
} else if (algSelection.currentIndex === 1) {
48-
rtn = rtn + "-" + durationWindow.text + "-" + dispersion.text
48+
rtn = rtn + "-" + durationWindow.text + "-" + dispersion.text + "-" + maxGazeSpan.text
4949
} else if (algSelection.currentIndex === 2) {
5050
rtn = rtn + "-" + velocity.text + "-" + duration.text
5151
}
@@ -157,14 +157,14 @@ Popup {
157157

158158
Text {
159159
id: durationWindowLabel
160-
text: qsTr("Duration Window: ")
160+
text: qsTr("Duration Window (ms): ")
161161
}
162162
TextField {
163163
id: durationWindow
164164
Layout.fillWidth: true
165165
//Int validator requires input to be a number >1 and <MAXINT
166166
validator: IntValidator {bottom: 1}
167-
readonly property string defaultVal: "10"
167+
readonly property string defaultVal: "100"
168168
text: defaultVal
169169
}
170170
Text {
@@ -178,6 +178,17 @@ Popup {
178178
readonly property string defaultVal: "125"
179179
text: defaultVal
180180
}
181+
Text {
182+
id: maxGazeSpanLabel
183+
text: qsTr("Maximum Gaze Span (ms): ")
184+
}
185+
TextField {
186+
id: maxGazeSpan
187+
Layout.fillWidth: true
188+
validator: IntValidator{bottom: 1}
189+
readonly property string defaultVal: "1000"
190+
text: defaultVal
191+
}
181192
Item {
182193
// Filler element, fills the rest of the space in the layout to force the above elements to be closer to each other
183194
// rather than equally spaced in the entire layout space
@@ -249,6 +260,7 @@ Popup {
249260
//IDT Algorithm Reset
250261
durationWindow.text = durationWindow.defaultVal
251262
dispersion.text = dispersion.defaultVal
263+
maxGazeSpan.text = maxGazeSpan.defaultVal
252264

253265
//IVT Algorithm Reset
254266
velocity.text = velocity.defaultVal

controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void Controller::generateFixationData(QVector<QString> tasks, QString algSetting
449449
}
450450
else if(settings[0] == "IDT") {
451451
//IDT-10-125 = IDT-duration_window-dispersion
452-
algorithm = new IDTAlgorithm(gazes,settings[duration_window].toInt(),settings[dispersion].toInt());
452+
algorithm = new IDTAlgorithm(gazes,settings[duration_window].toInt(),settings[dispersion].toInt(),settings[max_gaze_span].toInt());
453453
}
454454
else if(settings[0] == "IVT") {
455455
//IVT-50-80 = IVT-velocity-duration

controller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ enum basic {
5151

5252
enum idt {
5353
duration_window = 1,
54-
dispersion
54+
dispersion,
55+
max_gaze_span
5556
};
5657

5758
enum ivt {

idtalgorithm.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,62 @@ double computeGazeDifference(QVector<Gaze> gazes) {
2222
double final = (xmax - xmin) + (ymax - ymin);
2323
return final;
2424
}
25+
long long getLengthOfWindow(QVector<Gaze> gazes) {
26+
if(gazes.size() <= 1) { return 0; }
27+
return gazes[gazes.size() - 1].system_time - gazes[0].system_time;
28+
}
29+
bool isWindowConsistenlySpaced(QVector<Gaze> gazes, int maximum_space) {
30+
for(int i = 0; i < gazes.size() - 1; ++i) {
31+
if(gazes[i+1].system_time - gazes[i].system_time > maximum_space) {
32+
return false;
33+
}
34+
}
35+
return true;
36+
}
2537

26-
IDTAlgorithm::IDTAlgorithm(QVector<Gaze> gazes, int _duration, int _dispersion) : FixationAlgorithm(gazes) {
38+
IDTAlgorithm::IDTAlgorithm(QVector<Gaze> gazes, int _duration, int _dispersion, int _max_gaze_span) : FixationAlgorithm(gazes) {
2739
duration_window = _duration;
2840
dispersion = _dispersion;
41+
max_gaze_span = _max_gaze_span;
2942
}
3043

3144
QVector<Fixation> IDTAlgorithm::generateFixations() {
3245

3346
//This code follows the IDT Algorithm
34-
35-
//Step 1 should already be done
36-
37-
//Step 2 - Calculate velocity between each point and generate Fixations
3847
QVector<Gaze> window;
3948
int i = 0;
4049

41-
while(i < duration_window && i < session_gazes.size()) {
50+
while(getLengthOfWindow(window) < duration_window && i < session_gazes.size()) {
4251
window.push_back(session_gazes[i]);
4352
++i;
4453
}
4554

4655
while(i < session_gazes.size()) {
47-
if((computeGazeDifference(window) <= dispersion) && (window.size() >= duration_window)) {
56+
if((computeGazeDifference(window) <= dispersion) && (getLengthOfWindow(window) >= duration_window)) {
4857
while(computeGazeDifference(window) <= dispersion) {
4958
if(i < session_gazes.size() - 1) {
5059
window.push_back(session_gazes[i]);
5160
++i;
5261
}
5362
else { break; }
5463
}
55-
fixations.push_back(computeFixationEstimate(window));
56-
window.clear();
57-
window.push_back(session_gazes[i]);
58-
++i;
64+
if(isWindowConsistenlySpaced(window,max_gaze_span)) {
65+
fixations.push_back(computeFixationEstimate(window));
66+
window.clear();
67+
window.push_back(session_gazes[i]);
68+
++i;
69+
}
70+
else {
71+
window.pop_front();
72+
}
5973
}
60-
else if(window.size() < duration_window) {
74+
else if(getLengthOfWindow(window) < duration_window) {
6175
window.push_back(session_gazes[i]);
6276
++i;
6377
}
6478
else {
6579
window.pop_front();
66-
if(window.size() < duration_window) {
80+
if(getLengthOfWindow(window) < duration_window) {
6781
window.push_back(session_gazes[i]);
6882
++i;
6983
}
@@ -88,6 +102,6 @@ Fixation IDTAlgorithm::computeFixationEstimate(QVector<Gaze> fixation_points) {
88102
}
89103

90104
QString IDTAlgorithm::generateFixationSettings() {
91-
return "IDT," + QString::number(dispersion) + "," + QString::number(duration_window);
105+
return "IDT," + QString::number(dispersion) + "," + QString::number(duration_window) + "," + QString::number(max_gaze_span);
92106
}
93107

idtalgorithm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class IDTAlgorithm : public FixationAlgorithm{
1818
public:
19-
IDTAlgorithm(QVector<Gaze> gazes, int _duration, int _dispersion);
19+
IDTAlgorithm(QVector<Gaze> gazes, int _duration, int _dispersion, int _max_gaze_span);
2020
~IDTAlgorithm() {};
2121

2222
QVector<Fixation> generateFixations() override;
@@ -27,6 +27,7 @@ class IDTAlgorithm : public FixationAlgorithm{
2727

2828
int duration_window;
2929
int dispersion;
30+
int max_gaze_span;
3031
};
3132

3233
#endif // IDTALGORITHM_H

0 commit comments

Comments
 (0)