Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw data exporter: Add option to not export low confidence values #2210

Merged
merged 6 commits into from
Nov 19, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 44 additions & 1 deletion pupil_src/shared_modules/raw_data_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def __init__(
should_export_pupil_positions=True,
should_export_field_info=True,
should_export_gaze_positions=True,
should_include_low_confidence_data=True,
):
super().__init__(g_pool)

Expand All @@ -127,6 +128,15 @@ def __init__(
self.should_export_pupil_positions = should_export_pupil_positions
self.should_export_field_info = should_export_field_info
self.should_export_gaze_positions = should_export_gaze_positions
self.should_include_low_confidence_data = should_include_low_confidence_data

def get_init_dict(self):
return {
"should_export_pupil_positions": self.should_export_pupil_positions,
"should_export_field_info": self.should_export_field_info,
"should_export_gaze_positions": self.should_export_gaze_positions,
"should_include_low_confidence_data": self.should_include_low_confidence_data,
}

@property
def _is_pupil_producer_avaiable(self) -> bool:
Expand Down Expand Up @@ -161,6 +171,22 @@ def init_ui(self):
"should_export_gaze_positions", self, label="Export Gaze Positions"
)
)
self.menu.append(
ui.Info_Text(
'Pupil Core software assigns "confidence" values to its pupil '
"detections and gaze estimations. They indicate the quality of the "
"measurement. Disable the option below to only export data above the"
'"Minimum data confidence" threshold. It can be adjusted in the '
papr marked this conversation as resolved.
Show resolved Hide resolved
"general settings menu."
)
)
self.menu.append(
ui.Switch(
"should_include_low_confidence_data",
self,
label="Include low confidence data",
)
)
self.menu.append(
ui.Info_Text("Press the export button or type 'e' to start the export.")
)
Expand All @@ -180,6 +206,11 @@ def export_data(self, export_window, export_dir):
timestamps=self.g_pool.timestamps,
export_window=export_window,
export_dir=export_dir,
min_confidence_threshold=(
0.0
if self.should_include_low_confidence_data
else self.g_pool.min_data_confidence
),
)

if self.should_export_gaze_positions:
Expand All @@ -189,6 +220,11 @@ def export_data(self, export_window, export_dir):
timestamps=self.g_pool.timestamps,
export_window=export_window,
export_dir=export_dir,
min_confidence_threshold=(
0.0
if self.should_include_low_confidence_data
else self.g_pool.min_data_confidence
),
)

if self.should_export_field_info:
Expand Down Expand Up @@ -217,7 +253,12 @@ def dict_export(
pass

def csv_export_write(
self, positions_bisector, timestamps, export_window, export_dir
self,
positions_bisector,
timestamps,
export_window,
export_dir,
min_confidence_threshold=0.0,
):
export_file = type(self).csv_export_filename()
export_path = os.path.join(export_dir, export_file)
Expand All @@ -231,6 +272,8 @@ def csv_export_write(
dict_writer.writeheader()

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

Expand Down