Skip to content

Commit 8987ad7

Browse files
committed
glassesValidator functionality is now included in glassesTools, so remove dependency on glassesValidator and adapt all call sites
1 parent 5661aee commit 8987ad7

File tree

7 files changed

+57
-47
lines changed

7 files changed

+57
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ In this section, a full overview of gazeMapper's settings is given. These settin
663663
|Mapped data export: include 2D fields?|`export_output2D`|`True`|Determines whether gaze positions on the plane in the plane's reference frame are exported when invoking the [`gazeMapper.process.Action.EXPORT_TRIALS` action](#actions). See [the glassesTools manual](https://github.com/dcnieho/glassesTools/blob/master/README.md#world-referenced-gaze-data).|
664664
|Mapped data export: only include marker presence?|`export_only_code_marker_presence`|`True`|If `True`, for each marker only a single column is added to the export created by the [`gazeMapper.process.Action.EXPORT_TRIALS` action](#actions), indicating whether the given marker was detected or not on a given frame. If `False`, marker pose information is included in the export.|
665665
|||||
666-
|glassesValidator: Apply global shift?|`validate_do_global_shift`|`True`|glassesValidator setting: if `True`, for each validation interval the mean position will be removed from the gaze data and the targets, removing any overall shift of the data. This improves the matching of fixations to targets when there is a significant overall offset in the data. It may fail (backfire) if there are data samples far outside the range of the validation targets, or if there is no data for some targets.|
666+
|glassesValidator: Apply global shift?|`validate_do_global_shift`|`True`|glassesValidator setting: if `True`, for each validation interval the median position will be removed from the gaze data and the mean from the targets, removing any overall shift of the data. This improves the matching of fixations to targets when there is a significant overall offset in the data. It may fail (backfire) if there are data samples far outside the range of the validation targets, or if there is no data for some targets.|
667667
|glassesValidator: Maximum distance factor|`validate_max_dist_fac`|`.5`|glassesValidator setting: factor for determining distance limit when assigning fixation points to validation targets. If for a given target the closest fixation point is further away than <factor>*[minimum intertarget distance], then no fixation point will be assigned to this target, i.e., it will not be matched to any fixation point. Set to a large value to essentially disable.|
668668
|glassesValidator: Data quality types|`validate_dq_types`|`None`|glassesValidator setting: selects the types of data quality you would like to calculate for each of the recordings. When none are selected, a good default is used for each recording. When none of the selected types is available, depending on the `validate_allow_dq_fallback` setting, either an error is thrown or that same default is used instead. Whether a data quality type is available depends on what type of gaze information is available for a recording, as well as whether the camera is calibrated. See the [glassesValidator documentation](https://github.com/dcnieho/glassesValidator/blob/master/README.md#advanced-settings) for more information.|
669669
|glassesValidator: Allow fallback data quality type?|`validate_allow_dq_fallback`|`False`|glassesValidator setting: applies if the `validate_dq_types` setting is set. If `False`, an error is raised when the indicated data quality type(s) are not available, if `True`, a sensible default other data type will be used instead.|

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
glassesTools[GUI]==1.15.0 # pulls in various other dependencies such as imgui_bundle, matplotlib, numpy, opencv, pandas, polars
2-
glassesValidator==2.3.0
1+
glassesTools[GUI]>=1.16.0 # pulls in various other dependencies such as imgui_bundle, matplotlib, numpy, opencv, pandas, polars
32
typeguard
43
uvloop ; sys_platform != "win32"
54
watchfiles

src/gazeMapper/GUI/_impl/callbacks.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from imgui_bundle import imgui, imspinner, hello_imgui, icons_fontawesome_6 as ifa6
1010

1111
from glassesTools import annotation, aruco, async_thread, camera_recording, eyetracker, gui as gt_gui, naming as gt_naming, platform, recording, video_utils
12-
from glassesValidator.config import deploy_validation_config, get_validation_setup
13-
from glassesValidator import process as gv_process
12+
from glassesTools.validation import config as val_config, DataQualityType, export, get_DataQualityType_explanation
1413

1514
from . import colors, utils
1615
from ... import config, marker, naming, plane, process, session
@@ -150,10 +149,10 @@ def glasses_validator_plane_check_config(study_config: config.Study, pl: plane.D
150149
# check if there are already are validation setup files
151150
working_dir = config.guess_config_dir(study_config.working_directory)/pl.name
152151
try:
153-
get_validation_setup(working_dir)
152+
val_config.get_validation_setup(working_dir)
154153
except:
155154
# no config file, deploy
156-
deploy_validation_config(working_dir)
155+
val_config.deploy_validation_config(working_dir)
157156
else:
158157
# already exists, nothing to do
159158
pass
@@ -347,7 +346,7 @@ def show_export_config(g, path: str|pathlib.Path, sessions: list[str]):
347346

348347
dq_df, dq_set = None, None
349348
if rec_dirs:
350-
dq_df, default_dq_type, dq_targets = gv_process.collect_data_quality(rec_dirs, {p:f'{naming.validation_prefix}{p}_data_quality.tsv' for p in g.study_config.planes_per_episode[annotation.Event.Validate]}, col_for_parent='session')
349+
dq_df, default_dq_type, dq_targets = export.collect_data_quality(rec_dirs, {p:f'{naming.validation_prefix}{p}_data_quality.tsv' for p in g.study_config.planes_per_episode[annotation.Event.Validate]}, col_for_parent='session')
351350
if dq_df is None:
352351
to_export.pop('validation', None)
353352
else:
@@ -357,7 +356,7 @@ def show_export_config(g, path: str|pathlib.Path, sessions: list[str]):
357356
# data quality type
358357
type_idx = dq_df.index.names.index('type')
359358
dq_set['dq_types'] = {k:False for k in sorted(list(dq_df.index.levels[type_idx]), key=lambda dq: dq.value)}
360-
for dq in gv_process.DataQualityType:
359+
for dq in DataQualityType:
361360
if g.study_config.validate_dq_types is not None and dq in g.study_config.validate_dq_types and dq in dq_set['dq_types']:
362361
dq_set['dq_types'][dq] = True
363362
if not any(dq_set['dq_types'].values()):
@@ -402,7 +401,7 @@ def set_export_config_popup():
402401
imgui.table_next_row()
403402
imgui.table_next_column()
404403
imgui.align_text_to_frame_padding()
405-
t,ht = gv_process.get_DataQualityType_explanation(dq)
404+
t,ht = get_DataQualityType_explanation(dq)
406405
imgui.text(t)
407406
gt_gui.utils.draw_hover_text(ht, text="")
408407
imgui.table_next_column()
@@ -467,7 +466,7 @@ def launch_export():
467466
if 'validation' in to_export and to_export['validation']:
468467
dq_types = [dq for dq in dq_set['dq_types'] if dq_set['dq_types'][dq]]
469468
targets = [t for t in dq_set['targets'] if dq_set['targets'][t]]
470-
gv_process.summarize_and_store_data_quality(dq_df, path/'data_quality.tsv', dq_types, targets, dq_set['targets_avg'], dq_set['include_data_loss'])
469+
export.summarize_and_store_data_quality(dq_df, path/'data_quality.tsv', dq_types, targets, dq_set['targets_avg'], dq_set['include_data_loss'])
471470

472471
buttons = {
473472
ifa6.ICON_FA_CHECK+f" Continue": launch_export,

src/gazeMapper/GUI/_impl/gui.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import glassesTools
2121
from glassesTools import annotation, gui as gt_gui, naming as gt_naming, plane as gt_plane, platform as gt_platform
22-
import glassesValidator
2322

2423
from ... import config, marker, plane, process, project_watcher, session, type_utils, version
2524
from .. import async_thread
@@ -1569,7 +1568,6 @@ def popup_content():
15691568
imgui.text("Made by Diederick C. Niehorster")
15701569
imgui.text("")
15711570
imgui_md.render(f"[glassesTools {glassesTools.version.__version__}](https://github.com/dcnieho/glassesTools)")
1572-
imgui_md.render(f"[glassesValidator {glassesValidator.version.__version__}](https://github.com/dcnieho/glassesValidator)")
15731571
imgui.text(f"Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
15741572
imgui.text(f"OpenGL {'.'.join(str(gl.glGetInteger(num)) for num in (gl.GL_MAJOR_VERSION, gl.GL_MINOR_VERSION))}, PyOpenGL {OpenGL.__version__}")
15751573
imgui.text(f"GLFW {'.'.join(str(num) for num in glfw.get_version())}, pyGLFW {glfw.__version__}")

src/gazeMapper/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import Any, Literal
99

1010
from glassesTools import annotation, gaze_worldref, utils
11-
from glassesValidator import process as gv_process
11+
from glassesTools.validation import DataQualityType, get_DataQualityType_explanation
1212

1313
from . import marker, plane, session, typed_dict_defaults, type_utils
1414

@@ -89,7 +89,7 @@ def __init__(self,
8989

9090
validate_do_global_shift : bool = True,
9191
validate_max_dist_fac : float = .5,
92-
validate_dq_types : set[gv_process.DataQualityType]|None = None,
92+
validate_dq_types : set[DataQualityType]|None = None,
9393
validate_allow_dq_fallback : bool = False,
9494
validate_include_data_loss : bool = False,
9595
validate_I2MC_settings : I2MCSettings|None = None,
@@ -549,8 +549,8 @@ def load_from_json(path: str | pathlib.Path, strict_check: bool=True) -> 'Study'
549549
_params = inspect.signature(Study.__init__).parameters
550550
study_defaults = {k:d for k in _params if (d:=_params[k].default)!=inspect._empty}
551551
study_parameter_types = {k:_params[k].annotation for k in _params if k not in ['self','strict_check']}
552-
def _get_gv_data_quality_type_doc(dq: gv_process.DataQualityType):
553-
t,doc = gv_process.get_DataQualityType_explanation(dq)
552+
def _get_gv_data_quality_type_doc(dq: DataQualityType):
553+
t,doc = get_DataQualityType_explanation(dq)
554554
return (dq, type_utils.GUIDocInfo(t,doc))
555555
def _get_annotation_event_doc(a: annotation.Event):
556556
t = annotation.tooltip_map[a]
@@ -619,11 +619,11 @@ def _get_annotation_event_doc(a: annotation.Event):
619619
'export_output3D': type_utils.GUIDocInfo('Mapped data export: include 3D fields', 'Determines whether gaze positions on the plane in the scene camera reference frame are exported when invoking the Export Trials action.'),
620620
'export_output2D': type_utils.GUIDocInfo('Mapped data export: include 2D fields', 'Determines whether gaze positions on the plane in the plane\'s reference frame are exported when invoking the Export Trials action.'),
621621
'export_only_code_marker_presence': type_utils.GUIDocInfo('Mapped data export: only include marker presence?', 'If enabled, for each marker only a single column is added to the export created by the Export Trials action, indicating whether the given marker was detected or not on a given frame. If not enabled, marker pose information is included in the export.'),
622-
'validate_do_global_shift': type_utils.GUIDocInfo('glassesValidator: Apply global shift?', 'If enabled, for each validation interval the mean position will be removed from the gaze data and the targets, removing any overall shift of the data. This improves the matching of fixations to targets when there is a significant overall offset in the data. It may fail (backfire) if there are data samples far outside the range of the validation targets, or if there is no data for some targets.'),
622+
'validate_do_global_shift': type_utils.GUIDocInfo('glassesValidator: Apply global shift?', 'If enabled, for each validation interval the median position will be removed from the gaze data and the mean from the targets, removing any overall shift of the data. This improves the matching of fixations to targets when there is a significant overall offset in the data. It may fail (backfire) if there are data samples far outside the range of the validation targets, or if there is no data for some targets.'),
623623
'validate_max_dist_fac': type_utils.GUIDocInfo('glassesValidator: Maximum distance factor', 'Factor for determining distance limit when assigning fixation points to validation targets. If for a given target the closest fixation point is further away than <factor>*[minimum intertarget distance], then no fixation point will be assigned to this target, i.e., it will not be matched to any fixation point. Set to a large value to essentially disable.'),
624624
'validate_dq_types': type_utils.GUIDocInfo('glassesValidator: Data quality types', 'Selects the types of data quality you would like to calculate for each of the recordings. When none are selected, a good default is used for each recording. When none of the selected types is available, depending on the `validate_allow_dq_fallback` setting, either an error is thrown or that same default is used instead. Whether a data quality type is available depends on what type of gaze information is available for a recording, as well as whether the camera is calibrated.',{
625625
None: # None indicates the doc specification applies to the contained values
626-
dict([_get_gv_data_quality_type_doc(dq) for dq in gv_process.DataQualityType])
626+
dict([_get_gv_data_quality_type_doc(dq) for dq in DataQualityType])
627627
}),
628628
'validate_allow_dq_fallback': type_utils.GUIDocInfo('glassesValidator: Allow fallback data quality type?', 'If not enabled, an error is raised when the data quality type(s) indicated in "glassesValidator: Data quality types" are not available. If enabled, a sensible default other data type will be used instead. Does not apply if the "glassesValidator: Data quality types" is not set.'),
629629
'validate_include_data_loss': type_utils.GUIDocInfo('glassesValidator: Include data loss?', 'If enabled, the data quality report will include data loss during the episode selected for each target on the validation poster. This is NOT the data loss of the whole recording and thus not what you want to report in your paper.'),

src/gazeMapper/plane.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import typing
88

99
from glassesTools import plane, utils
10-
from glassesValidator.config import get_validation_setup
11-
from glassesValidator.config.poster import Poster
10+
from glassesTools.validation.config import get_validation_setup
11+
from glassesTools.validation.config.plane import ValidationPlane
1212

1313
from . import type_utils
1414

@@ -136,7 +136,7 @@ def make(p_type: Type, name: str, path: pathlib.Path|None, **kwargs) -> Definiti
136136
if 'use_default' in kwargs and not kwargs['use_default']:
137137
validator_config_dir = path
138138
validation_setup = get_validation_setup(validator_config_dir)
139-
kwargs['aruco_dict'] = Poster.default_aruco_dict
139+
kwargs['aruco_dict'] = ValidationPlane.default_aruco_dict
140140
kwargs['marker_border_bits'] = validation_setup['markerBorderBits']
141141
kwargs['min_num_markers'] = validation_setup['minNumMarkers']
142142
kwargs['ref_image_size'] = validation_setup['referencePosterSize']
@@ -183,8 +183,8 @@ def get_plane_from_definition(plane_def: Definition, path: str | pathlib.Path) -
183183
validator_config_dir = None # use glassesValidator built-in/default
184184
if not plane_def.use_default:
185185
validator_config_dir = path
186-
validation_setup = get_validation_setup(validator_config_dir)
187-
return Poster(validator_config_dir, validation_setup, ref_image_store_path=path / plane.Plane.default_ref_image_name)
186+
validation_config = get_validation_setup(validator_config_dir)
187+
return ValidationPlane(validator_config_dir, validation_config, ref_image_store_path=path / plane.Plane.default_ref_image_name)
188188
else:
189189
pl = plane.Plane(
190190
markers = path / plane_def.marker_file,

0 commit comments

Comments
 (0)