Enhance Teensy serial handling and refactor code for clarity#330
Open
CeliaBenquet wants to merge 27 commits into
Open
Enhance Teensy serial handling and refactor code for clarity#330CeliaBenquet wants to merge 27 commits into
CeliaBenquet wants to merge 27 commits into
Conversation
Wrap processor initialization in a guarded try/except so partial startup failures trigger cleanup and re-raise as a clear RuntimeError. Add a dedicated stop() method (plus close() alias) to optionally save output and reliably release Teensy, socket connection, and listener resources, reducing leaked serial handles/ports after errors or shutdown.
Implement a dedicated `save()` method in `dlc_inference_w_pd_sync` that persists latency data to a pickle file, supports an optional explicit path, and falls back to `self.save_path` when no file is passed. The change also initializes `save_path` on construction, ensures parent directories are created, and adds warning-based error handling for missing paths or save failures.
Replaced `import datetime` with `from datetime import datetime` in `dlc_processor_socket_pd_sync.py` to align the import with direct `datetime` usage and avoid module/class ambiguity.
Add a `_video_prefix()` helper that derives the base name from discovered video files, falling back to `filename_stem` and then `recording`. Update `_db_compat_base()` to use this prefix instead of the mouse identifier when building the output path, improving alignment with recording/video naming.
…sLab/FreelyMovingVR4Mice into celia/register-processors
…sLab/FreelyMovingVR4Mice into celia/register-processors
…sLab/FreelyMovingVR4Mice into celia/register-processors
…s and updating related file fetching logic
Signed-off-by: Célia Benquet <32598028+CeliaBenquet@users.noreply.github.com>
Base automatically changed from
celia/autocomplete-cameras
to
celia/register-processors
July 24, 2026 11:04
Signed-off-by: Célia Benquet <32598028+CeliaBenquet@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a new developer-facing documentation page that explains the experiment session lifecycle, and makes a series of style and clarity improvements to the DeepLabCut processor code. The documentation addition provides a clear, step-by-step overview of how the two main processes interact during a session, while the code changes focus on improved logging, exception handling, and minor refactoring for readability.
Race-condition fixes
TeensyLatency.close_serial():TeensyLatency+ prevent data-loss fordlc_inference_w_pd_sync#329.ActiveSensingTask.stop() now closes its dlcClient (and joins its thread) so the position-reading socket/thread don't leak across repeated task start/stop cycles in one GUI process.
Documentation Improvements:
docs/software_package/experiment_lifecycle.md, detailing the session lifecycle, process responsibilities, data flow, and failure handling for developers. This is now included in the table of contents (_toc.yml).vr4mice GUI save/close safety (
teensy_experiment.py)_dump_data(): save failures now show an error dialog instead of an uncaught traceback.