.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/02_add_visual_interface/3_output_system.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_02_add_visual_interface_3_output_system.py: ============================================== Part 3: Output System ============================================== This implementation demonstrates the creation of an **Output System** for the Virtual Hand Interface. It processes predictions (classification or regression) and communicates them to the visual interface. Steps: -------------- 1. **Step 1: Class Initialization and Validation** - Ensures the correct visual interface is selected and initializes helper objects. 2. **Step 2: Processing Predictions** - Converts classification and regression predictions into an appropriate format. 3. **Step 3: Sending Predictions** - Sends processed predictions to the visual interface via output signals. 4. **Step 4: Handling Close Events** - Cleans up resources and handles the exit process gracefully. .. GENERATED FROM PYTHON SOURCE LINES 27-32 ------------------------------------------------- Predefined Mapping for Classification Predictions ------------------------------------------------- This dictionary maps classification labels to their respective predefined output strings for the Virtual Hand Interface. .. GENERATED FROM PYTHON SOURCE LINES 32-45 .. code-block:: Python PREDICTION2INTERFACE_MAP = { -1: "Rejected Sample", 0: "[0, 0, 0, 0, 0, 0, 0, 0, 0]", 1: "[0, 0, 1, 0, 0, 0, 0, 0, 0]", 2: "[1, 0, 0, 0, 0, 0, 0, 0, 0]", 3: "[0, 0, 0, 1, 0, 0, 0, 0, 0]", 4: "[0, 0, 0, 0, 1, 0, 0, 0, 0]", 5: "[0, 0, 0, 0, 0, 1, 0, 0, 0]", 6: "[0.67, 1, 1, 1, 1, 1, 0, 0, 0]", 7: "[0.45, 1, 0.6, 0, 0, 0, 0, 0, 0]", 8: "[0.55, 1, 0.65, 0.65, 0, 0, 0, 0, 0]", } .. GENERATED FROM PYTHON SOURCE LINES 46-57 ------------------------------------------------- Step 1: Class Initialization ------------------------------------------------- This step ensures that the selected visual interface is the Virtual Hand Interface. It also establishes the connection for outgoing signals using the main window. .. literalinclude:: /../../myogestic/gui/widgets/visual_interfaces/virtual_hand_interface/output_interface.py :language: python :lineno-match: :lines: 1-55 :caption: Output System Initialization .. GENERATED FROM PYTHON SOURCE LINES 59-76 ------------------------------------------------- Step 2: Processing Predictions ------------------------------------------------- This step defines how predictions (either classification or regression) are processed into the appropriate format that can be used by the Virtual Hand Interface. .. literalinclude:: /../../myogestic/gui/widgets/visual_interfaces/virtual_hand_interface/output_interface.py :language: python :lineno-match: :pyobject: VirtualHandInterface_OutputSystem._process_prediction__classification :caption: Processing Classification Predictions - Convert classification predictions into the required format to send them to the visual interface. .. literalinclude:: /../../myogestic/gui/widgets/visual_interfaces/virtual_hand_interface/output_interface.py :language: python :lineno-match: :pyobject: VirtualHandInterface_OutputSystem._process_prediction__regression :caption: Processing Regression Predictions - Convert regression predictions into the required format to send them to the visual interface. .. GENERATED FROM PYTHON SOURCE LINES 78-89 ------------------------------------------------- Step 3: Sending Predictions ------------------------------------------------- This step sends the processed predictions (after formatting them into bytes) to the connected visual interface via the outgoing signal. .. literalinclude:: /../../myogestic/gui/widgets/visual_interfaces/virtual_hand_interface/output_interface.py :language: python :lineno-match: :pyobject: VirtualHandInterface_OutputSystem.send_prediction :caption: Sending Predictions - Send the processed prediction to the visual interface. .. GENERATED FROM PYTHON SOURCE LINES 91-102 ------------------------------------------------- Step 4: Handling Close Events ------------------------------------------------- This step handles the cleanup process when the Output System is closed. It logs the closure and ensures that resources are properly released. .. literalinclude:: /../../myogestic/gui/widgets/visual_interfaces/virtual_hand_interface/output_interface.py :language: python :lineno-match: :pyobject: VirtualHandInterface_OutputSystem.close_event :caption: Handling Close Events - Clean up resources and handle the exit process gracefully. If needed, this method can be extended to include additional cleanup steps. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.115 seconds) **Estimated memory usage:** 570 MB .. _sphx_glr_download_auto_examples_02_add_visual_interface_3_output_system.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 3_output_system.ipynb <3_output_system.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 3_output_system.py <3_output_system.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 3_output_system.zip <3_output_system.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_