Skip to content

Commit a3add06

Browse files
committed
Fix IDT issue by switching to a minimum gaze time-span instead of minum # of gazes. Additionally add a new parameter to IDT that determines the maximum gap between any two gazes in the window
1 parent beee0d2 commit a3add06

File tree

5 files changed

+64
-61
lines changed

5 files changed

+64
-61
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: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,78 +22,67 @@ 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
47+
QVector<Gaze> window;
48+
int i = 0;
3449

35-
//QVector<Gaze> window;
36-
while(session_gazes.size() != 0) { // While there are still points
37-
// Initialize the window over the first points to not cover the duration threshold
38-
QVector<Gaze> window;
39-
int i = 0;
40-
while(window.size() != duration_window && session_gazes.size() != 0) {
41-
window.push_back(session_gazes[i]);
42-
++i;
43-
}
50+
while(getLengthOfWindow(window) < duration_window && i < session_gazes.size()) {
51+
window.push_back(session_gazes[i]);
52+
++i;
53+
}
4454

45-
// If dispersion of window points <= threshold
46-
if(computeGazeDifference(window) <= dispersion) {
47-
// Add additional points to the window until dispersion > threshold
48-
while(computeGazeDifference(window) <= dispersion && i < session_gazes.size()) {
55+
while(i < session_gazes.size()) {
56+
if((computeGazeDifference(window) <= dispersion) && (getLengthOfWindow(window) >= duration_window)) {
57+
while(computeGazeDifference(window) <= dispersion) {
58+
if(i < session_gazes.size() - 1) {
59+
window.push_back(session_gazes[i]);
60+
++i;
61+
}
62+
else { break; }
63+
}
64+
if(isWindowConsistenlySpaced(window,max_gaze_span)) {
65+
fixations.push_back(computeFixationEstimate(window));
66+
window.clear();
4967
window.push_back(session_gazes[i]);
5068
++i;
5169
}
52-
// Not a fixation ant the centroid of the windows points
53-
fixations.push_back(computeFixationEstimate(window));
54-
// Remove window points from points
55-
for(int x = 0; x < window.size(); ++x) {
56-
session_gazes.pop_front();
70+
else {
71+
window.pop_front();
5772
}
5873
}
74+
else if(getLengthOfWindow(window) < duration_window) {
75+
window.push_back(session_gazes[i]);
76+
++i;
77+
}
5978
else {
60-
session_gazes.pop_front();
79+
window.pop_front();
80+
if(getLengthOfWindow(window) < duration_window) {
81+
window.push_back(session_gazes[i]);
82+
++i;
83+
}
6184
}
6285
}
63-
// QVector<Gaze> window;
64-
// int i = 0;
65-
66-
// while(i < duration_window && i < session_gazes.size()) {
67-
// window.push_back(session_gazes[i]);
68-
// ++i;
69-
// }
70-
71-
// while(i < session_gazes.size()) {
72-
// if((computeGazeDifference(window) <= dispersion) && (window.size() >= duration_window)) {
73-
// while(computeGazeDifference(window) <= dispersion) {
74-
// if(i < session_gazes.size() - 1) {
75-
// window.push_back(session_gazes[i]);
76-
// ++i;
77-
// }
78-
// else { break; }
79-
// }
80-
// fixations.push_back(computeFixationEstimate(window));
81-
// window.clear();
82-
// window.push_back(session_gazes[i]);
83-
// ++i;
84-
// }
85-
// else if(window.size() < duration_window) {
86-
// window.push_back(session_gazes[i]);
87-
// ++i;
88-
// }
89-
// else {
90-
// window.pop_front();
91-
// if(window.size() < duration_window) {
92-
// window.push_back(session_gazes[i]);
93-
// ++i;
94-
// }
95-
// }
96-
// }
9786

9887
return fixations;
9988
}
@@ -113,6 +102,6 @@ Fixation IDTAlgorithm::computeFixationEstimate(QVector<Gaze> fixation_points) {
113102
}
114103

115104
QString IDTAlgorithm::generateFixationSettings() {
116-
return "IDT," + QString::number(dispersion) + "," + QString::number(duration_window);
105+
return "IDT," + QString::number(dispersion) + "," + QString::number(duration_window) + "," + QString::number(max_gaze_span);
117106
}
118107

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)