Skip to content

Commit b8fd82c

Browse files
authored
Merge pull request #2210 from pupil-labs/filter_low_conf_raw_data
Raw data exporter: Add option to not export low confidence values
2 parents b3acbb7 + f20d700 commit b8fd82c

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

pupil_src/shared_modules/raw_data_exporter.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def __init__(
117117
should_export_pupil_positions=True,
118118
should_export_field_info=True,
119119
should_export_gaze_positions=True,
120+
should_include_low_confidence_data=True,
120121
):
121122
super().__init__(g_pool)
122123

@@ -127,6 +128,15 @@ def __init__(
127128
self.should_export_pupil_positions = should_export_pupil_positions
128129
self.should_export_field_info = should_export_field_info
129130
self.should_export_gaze_positions = should_export_gaze_positions
131+
self.should_include_low_confidence_data = should_include_low_confidence_data
132+
133+
def get_init_dict(self):
134+
return {
135+
"should_export_pupil_positions": self.should_export_pupil_positions,
136+
"should_export_field_info": self.should_export_field_info,
137+
"should_export_gaze_positions": self.should_export_gaze_positions,
138+
"should_include_low_confidence_data": self.should_include_low_confidence_data,
139+
}
130140

131141
@property
132142
def _is_pupil_producer_avaiable(self) -> bool:
@@ -161,6 +171,22 @@ def init_ui(self):
161171
"should_export_gaze_positions", self, label="Export Gaze Positions"
162172
)
163173
)
174+
self.menu.append(
175+
ui.Info_Text(
176+
'Pupil Core software assigns "confidence" values to its pupil '
177+
"detections and gaze estimations. They indicate the quality of the "
178+
"measurement. Disable the option below to only export data above the"
179+
'"Minimum data confidence" threshold. This threshold can be adjusted in the '
180+
"general settings menu."
181+
)
182+
)
183+
self.menu.append(
184+
ui.Switch(
185+
"should_include_low_confidence_data",
186+
self,
187+
label="Include low confidence data",
188+
)
189+
)
164190
self.menu.append(
165191
ui.Info_Text("Press the export button or type 'e' to start the export.")
166192
)
@@ -180,6 +206,11 @@ def export_data(self, export_window, export_dir):
180206
timestamps=self.g_pool.timestamps,
181207
export_window=export_window,
182208
export_dir=export_dir,
209+
min_confidence_threshold=(
210+
0.0
211+
if self.should_include_low_confidence_data
212+
else self.g_pool.min_data_confidence
213+
),
183214
)
184215

185216
if self.should_export_gaze_positions:
@@ -189,6 +220,11 @@ def export_data(self, export_window, export_dir):
189220
timestamps=self.g_pool.timestamps,
190221
export_window=export_window,
191222
export_dir=export_dir,
223+
min_confidence_threshold=(
224+
0.0
225+
if self.should_include_low_confidence_data
226+
else self.g_pool.min_data_confidence
227+
),
192228
)
193229

194230
if self.should_export_field_info:
@@ -217,7 +253,12 @@ def dict_export(
217253
pass
218254

219255
def csv_export_write(
220-
self, positions_bisector, timestamps, export_window, export_dir
256+
self,
257+
positions_bisector,
258+
timestamps,
259+
export_window,
260+
export_dir,
261+
min_confidence_threshold=0.0,
221262
):
222263
export_file = type(self).csv_export_filename()
223264
export_path = os.path.join(export_dir, export_file)
@@ -231,6 +272,8 @@ def csv_export_write(
231272
dict_writer.writeheader()
232273

233274
for g, idx in zip(export_section["data"], export_world_idc):
275+
if g["confidence"] < min_confidence_threshold:
276+
continue
234277
dict_row = type(self).dict_export(raw_value=g, world_index=idx)
235278
dict_writer.writerow(dict_row)
236279

0 commit comments

Comments
 (0)