speed-analyzer 3.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Laboratorio di Scienze Cognitive e del Comportamento
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: speed-analyzer
3
+ Version: 3.6.0
4
+ Summary: A package for processing and extracting eye-tracking data.
5
+ Home-page: https://github.com/danielelozzi/SPEED
6
+ Author: Daniele Lozzi, LabSCoC
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: pandas
14
+ Requires-Dist: numpy
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: opencv-python
17
+ Requires-Dist: scipy
18
+ Requires-Dist: tqdm
19
+ Requires-Dist: moviepy
20
+ Requires-Dist: ultralytics
21
+ Dynamic: author
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ # SPEED v3.6 - Desktop App & Analysis Package
32
+
33
+ *An Advanced Eye-Tracking Data Analysis Software*
34
+
35
+ SPEED is a Python-based project for processing, analyzing, and visualizing eye-tracking data. Version 3.6 introduces a major restructuring, offering two distinct components:
36
+
37
+ 1. **SPEED Desktop App**: A user-friendly GUI application for running a full analysis pipeline, designed for end-users and researchers.
38
+ 2. **`speed-analyzer`**: A programmatic Python package for developers who want to integrate the analysis logic into their own scripts.
39
+
40
+ This version also supports GPU acceleration for YOLO analysis.
41
+
42
+ ---
43
+
44
+ ## 1. SPEED Desktop Application (For End Users)
45
+
46
+ An application with a graphical user interface (GUI) for a complete, visually-driven analysis workflow.
47
+
48
+ ### How to Use the Application
49
+ 1. **Download the latest version**: Go to the [Releases page](https://github.com/danielelozzi/SPEED/releases) and download the `.zip` file for your operating system (Windows or macOS).
50
+ 2. **Extract and Run**: Unzip the file and run the `SpeedApp` executable.
51
+ 3. **Follow the Instructions**: Use the interface to select your data folders (RAW, Un-enriched, etc.), manage events with the interactive editors, and run the analysis.
52
+
53
+ ---
54
+
55
+ ## 2. `speed-analyzer` (Python Package for Developers)
56
+
57
+ The core analysis engine of SPEED, now available as a reusable package. It's designed for automation and integration into custom data pipelines.
58
+
59
+ ### Installation from PyPI
60
+ You can install the package directly from the Python Package Index (PyPI) using pip:
61
+ ```bash
62
+ pip install speed-analyzer
63
+ ```
64
+ ### How to Use the Package
65
+ The package exposes a main function, `run_full_analysis`, that takes paths and options as arguments. See the `example_usage.py` file for a complete demonstration.
66
+
67
+ Here is a basic snippet:
68
+
69
+ ```python
70
+ import pandas as pd
71
+ from speed_analyzer import run_full_analysis
72
+
73
+ # 1. Define paths and parameters
74
+ raw_path = "./data/raw"
75
+ unenriched_path = "./data/unenriched"
76
+ output_path = "./analysis_results"
77
+
78
+ # 2. Create an events DataFrame
79
+ events_df = pd.DataFrame({
80
+ 'name': ['Task_Start', 'Task_End'],
81
+ 'timestamp [ns]': [1672531201000000000, 1672531215000000000]
82
+ })
83
+
84
+ # 3. Run the full analysis programmatically
85
+ run_full_analysis(
86
+ raw_data_path=raw_path,
87
+ unenriched_data_path=unenriched_path,
88
+ output_path=output_path,
89
+ subject_name="participant_01",
90
+ events_df=events_df,
91
+ run_yolo=True,
92
+ yolo_model_path="yolov8n.pt"
93
+ )
94
+ ```
95
+
96
+ ---
97
+
98
+ ## The Modular Workflow (GUI)
99
+ SPEED v3.6 operates on a two-step workflow designed to save time and computational resources.
100
+
101
+ ### Step 1: Run Core Analysis
102
+ This is the main data processing stage. You run this step only once per participant for a given set of events. The software will:
103
+
104
+ - Load all necessary files from the specified input folders (RAW, Un-enriched, Enriched).
105
+ - Dynamically load events from `events.csv` into the GUI, allowing you to select which events to analyze.
106
+ - Segment the data based on your selection.
107
+ - Calculate all relevant statistics for each selected segment.
108
+ - Optionally run YOLO object detection on the video frames, saving the results to a cache to speed up future runs.
109
+ - Save the processed data (e.g., filtered dataframes for each event) and summary statistics into the output folder.
110
+
111
+ This step creates a `processed_data` directory containing intermediate files. Once this is complete, you do not need to run it again unless you want to analyze a different combination of events.
112
+
113
+ ### Step 2: Generate Outputs On-Demand
114
+ After the core analysis is complete, you can use the dedicated tabs in the GUI to generate as many plots and videos as you need, with any combination of settings, without re-processing the raw data.
115
+
116
+ - **Generate Plots**: Select which categories of plots you want to create.
117
+ - **Generate Videos**: Compose highly customized videos with various overlays.
118
+ - **View YOLO Results**: Load and view the quantitative results from the object detection.
119
+
120
+ ---
121
+
122
+ ## Environment Setup (For Development) ⚙️
123
+ To run the project from source or contribute to development, you'll need Python 3 and several libraries.
124
+
125
+ 1. **Install Anaconda**: [Link](https://www.anaconda.com/)
126
+ 2. *(Optional)* Install CUDA Toolkit: For GPU acceleration with NVIDIA. [Link](https://developer.nvidia.com/cuda-downloads)
127
+ 3. **Create a virtual environment**:
128
+ ```bash
129
+ conda create --name speed
130
+ conda activate speed
131
+ conda install pip
132
+ ```
133
+ 4. **Install the required libraries**:
134
+ ```bash
135
+ pip install -r requirements.txt
136
+ ```
137
+
138
+ ---
139
+
140
+ ## How to Use the Application from Source 🚀
141
+ ### Launch the GUI:
142
+ ```bash
143
+ # Navigate to the desktop_app folder
144
+ cd desktop_app
145
+ python GUI.py
146
+ ```
147
+ ### Setup and Analysis:
148
+ - Fill in the Participant Name and select the Output Folder.
149
+ - Select the required Input Folders: RAW and Un-enriched.
150
+ - Use the Advanced Event Management section to load and edit events using the table or interactive video editor.
151
+ - Click **"RUN CORE ANALYSIS"**.
152
+ - Use the other tabs to generate plots, videos, and view YOLO results.
153
+
154
+ ---
155
+
156
+ ## 🧪 Synthetic Data Generator (`generate_synthetic_data.py`)
157
+ Included in this project is a utility script to create a full set of dummy eye-tracking data. This is extremely useful for testing the SPEED software without needing Pupil Labs hardware or actual recordings.
158
+
159
+ ### How to Use
160
+ Run the script from your terminal:
161
+ ```bash
162
+ python generate_synthetic_data.py
163
+ ```
164
+ The script will create a new folder named `synthetic_data_output` in the current directory.
165
+
166
+ This folder will contain all the necessary files (`gaze.csv`, `fixations.csv`, `external.mp4`, etc.), ready to be used as input for the GUI application or the `speed-analyzer` package.
167
+
168
+ ---
169
+
170
+ ## ✍️ Authors & Citation
171
+ This tool is developed by the Cognitive and Behavioral Science Lab (LabSCoC), University of L'Aquila and Dr. Daniele Lozzi.
172
+
173
+ If you use this script in your research or work, please cite the following publications:
174
+
175
+ - Lozzi, D.; Di Pompeo, I.; Marcaccio, M.; Ademaj, M.; Migliore, S.; Curcio, G. SPEED: A Graphical User Interface Software for Processing Eye Tracking Data. NeuroSci 2025, 6, 35. https://doi.org/10.3390/neurosci6020035
176
+ - Lozzi, D.; Di Pompeo, I.; Marcaccio, M.; Alemanno, M.; Krüger, M.; Curcio, G.; Migliore, S. AI-Powered Analysis of Eye Tracker Data in Basketball Game. Sensors 2025, 25, 3572. https://doi.org/10.3390/s25113572
177
+
178
+ It is also requested to cite Pupil Labs publication, as requested on their website https://docs.pupil-labs.com/neon/data-collection/publication-and-citation/
179
+
180
+ - Baumann, C., & Dierkes, K. (2023). Neon accuracy test report. Pupil Labs, 10. https://doi.org/10.5281/zenodo.10420388
181
+
182
+ If you also use the Computer Vision YOLO-based feature, please cite the following publication:
183
+
184
+ - Redmon, J., Divvala, S., Girshick, R., & Farhadi, A. (2016). You only look once: Unified, real-time object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 779-788). https://doi.org/10.1109/CVPR.2016.91
185
+
186
+ ---
187
+
188
+ ## 💻 Artificial Intelligence disclosure
189
+ This code is partially written using Google Gemini 2.5 Pro
@@ -0,0 +1,159 @@
1
+ # SPEED v3.6 - Desktop App & Analysis Package
2
+
3
+ *An Advanced Eye-Tracking Data Analysis Software*
4
+
5
+ SPEED is a Python-based project for processing, analyzing, and visualizing eye-tracking data. Version 3.6 introduces a major restructuring, offering two distinct components:
6
+
7
+ 1. **SPEED Desktop App**: A user-friendly GUI application for running a full analysis pipeline, designed for end-users and researchers.
8
+ 2. **`speed-analyzer`**: A programmatic Python package for developers who want to integrate the analysis logic into their own scripts.
9
+
10
+ This version also supports GPU acceleration for YOLO analysis.
11
+
12
+ ---
13
+
14
+ ## 1. SPEED Desktop Application (For End Users)
15
+
16
+ An application with a graphical user interface (GUI) for a complete, visually-driven analysis workflow.
17
+
18
+ ### How to Use the Application
19
+ 1. **Download the latest version**: Go to the [Releases page](https://github.com/danielelozzi/SPEED/releases) and download the `.zip` file for your operating system (Windows or macOS).
20
+ 2. **Extract and Run**: Unzip the file and run the `SpeedApp` executable.
21
+ 3. **Follow the Instructions**: Use the interface to select your data folders (RAW, Un-enriched, etc.), manage events with the interactive editors, and run the analysis.
22
+
23
+ ---
24
+
25
+ ## 2. `speed-analyzer` (Python Package for Developers)
26
+
27
+ The core analysis engine of SPEED, now available as a reusable package. It's designed for automation and integration into custom data pipelines.
28
+
29
+ ### Installation from PyPI
30
+ You can install the package directly from the Python Package Index (PyPI) using pip:
31
+ ```bash
32
+ pip install speed-analyzer
33
+ ```
34
+ ### How to Use the Package
35
+ The package exposes a main function, `run_full_analysis`, that takes paths and options as arguments. See the `example_usage.py` file for a complete demonstration.
36
+
37
+ Here is a basic snippet:
38
+
39
+ ```python
40
+ import pandas as pd
41
+ from speed_analyzer import run_full_analysis
42
+
43
+ # 1. Define paths and parameters
44
+ raw_path = "./data/raw"
45
+ unenriched_path = "./data/unenriched"
46
+ output_path = "./analysis_results"
47
+
48
+ # 2. Create an events DataFrame
49
+ events_df = pd.DataFrame({
50
+ 'name': ['Task_Start', 'Task_End'],
51
+ 'timestamp [ns]': [1672531201000000000, 1672531215000000000]
52
+ })
53
+
54
+ # 3. Run the full analysis programmatically
55
+ run_full_analysis(
56
+ raw_data_path=raw_path,
57
+ unenriched_data_path=unenriched_path,
58
+ output_path=output_path,
59
+ subject_name="participant_01",
60
+ events_df=events_df,
61
+ run_yolo=True,
62
+ yolo_model_path="yolov8n.pt"
63
+ )
64
+ ```
65
+
66
+ ---
67
+
68
+ ## The Modular Workflow (GUI)
69
+ SPEED v3.6 operates on a two-step workflow designed to save time and computational resources.
70
+
71
+ ### Step 1: Run Core Analysis
72
+ This is the main data processing stage. You run this step only once per participant for a given set of events. The software will:
73
+
74
+ - Load all necessary files from the specified input folders (RAW, Un-enriched, Enriched).
75
+ - Dynamically load events from `events.csv` into the GUI, allowing you to select which events to analyze.
76
+ - Segment the data based on your selection.
77
+ - Calculate all relevant statistics for each selected segment.
78
+ - Optionally run YOLO object detection on the video frames, saving the results to a cache to speed up future runs.
79
+ - Save the processed data (e.g., filtered dataframes for each event) and summary statistics into the output folder.
80
+
81
+ This step creates a `processed_data` directory containing intermediate files. Once this is complete, you do not need to run it again unless you want to analyze a different combination of events.
82
+
83
+ ### Step 2: Generate Outputs On-Demand
84
+ After the core analysis is complete, you can use the dedicated tabs in the GUI to generate as many plots and videos as you need, with any combination of settings, without re-processing the raw data.
85
+
86
+ - **Generate Plots**: Select which categories of plots you want to create.
87
+ - **Generate Videos**: Compose highly customized videos with various overlays.
88
+ - **View YOLO Results**: Load and view the quantitative results from the object detection.
89
+
90
+ ---
91
+
92
+ ## Environment Setup (For Development) ⚙️
93
+ To run the project from source or contribute to development, you'll need Python 3 and several libraries.
94
+
95
+ 1. **Install Anaconda**: [Link](https://www.anaconda.com/)
96
+ 2. *(Optional)* Install CUDA Toolkit: For GPU acceleration with NVIDIA. [Link](https://developer.nvidia.com/cuda-downloads)
97
+ 3. **Create a virtual environment**:
98
+ ```bash
99
+ conda create --name speed
100
+ conda activate speed
101
+ conda install pip
102
+ ```
103
+ 4. **Install the required libraries**:
104
+ ```bash
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ ---
109
+
110
+ ## How to Use the Application from Source 🚀
111
+ ### Launch the GUI:
112
+ ```bash
113
+ # Navigate to the desktop_app folder
114
+ cd desktop_app
115
+ python GUI.py
116
+ ```
117
+ ### Setup and Analysis:
118
+ - Fill in the Participant Name and select the Output Folder.
119
+ - Select the required Input Folders: RAW and Un-enriched.
120
+ - Use the Advanced Event Management section to load and edit events using the table or interactive video editor.
121
+ - Click **"RUN CORE ANALYSIS"**.
122
+ - Use the other tabs to generate plots, videos, and view YOLO results.
123
+
124
+ ---
125
+
126
+ ## 🧪 Synthetic Data Generator (`generate_synthetic_data.py`)
127
+ Included in this project is a utility script to create a full set of dummy eye-tracking data. This is extremely useful for testing the SPEED software without needing Pupil Labs hardware or actual recordings.
128
+
129
+ ### How to Use
130
+ Run the script from your terminal:
131
+ ```bash
132
+ python generate_synthetic_data.py
133
+ ```
134
+ The script will create a new folder named `synthetic_data_output` in the current directory.
135
+
136
+ This folder will contain all the necessary files (`gaze.csv`, `fixations.csv`, `external.mp4`, etc.), ready to be used as input for the GUI application or the `speed-analyzer` package.
137
+
138
+ ---
139
+
140
+ ## ✍️ Authors & Citation
141
+ This tool is developed by the Cognitive and Behavioral Science Lab (LabSCoC), University of L'Aquila and Dr. Daniele Lozzi.
142
+
143
+ If you use this script in your research or work, please cite the following publications:
144
+
145
+ - Lozzi, D.; Di Pompeo, I.; Marcaccio, M.; Ademaj, M.; Migliore, S.; Curcio, G. SPEED: A Graphical User Interface Software for Processing Eye Tracking Data. NeuroSci 2025, 6, 35. https://doi.org/10.3390/neurosci6020035
146
+ - Lozzi, D.; Di Pompeo, I.; Marcaccio, M.; Alemanno, M.; Krüger, M.; Curcio, G.; Migliore, S. AI-Powered Analysis of Eye Tracker Data in Basketball Game. Sensors 2025, 25, 3572. https://doi.org/10.3390/s25113572
147
+
148
+ It is also requested to cite Pupil Labs publication, as requested on their website https://docs.pupil-labs.com/neon/data-collection/publication-and-citation/
149
+
150
+ - Baumann, C., & Dierkes, K. (2023). Neon accuracy test report. Pupil Labs, 10. https://doi.org/10.5281/zenodo.10420388
151
+
152
+ If you also use the Computer Vision YOLO-based feature, please cite the following publication:
153
+
154
+ - Redmon, J., Divvala, S., Girshick, R., & Farhadi, A. (2016). You only look once: Unified, real-time object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 779-788). https://doi.org/10.1109/CVPR.2016.91
155
+
156
+ ---
157
+
158
+ ## 💻 Artificial Intelligence disclosure
159
+ This code is partially written using Google Gemini 2.5 Pro
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,30 @@
1
+ # setup.py
2
+ from setuptools import setup, find_packages
3
+
4
+ setup(
5
+ name="speed-analyzer",
6
+ version="3.6.0",
7
+ author="Daniele Lozzi, LabSCoC",
8
+ description="A package for processing and extracting eye-tracking data.",
9
+ long_description=open('README.md').read(),
10
+ long_description_content_type="text/markdown",
11
+ url="https://github.com/danielelozzi/SPEED", # Sostituisci con l'URL del tuo repo
12
+ package_dir={"": "src"},
13
+ packages=find_packages(where="src"),
14
+ classifiers=[
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ],
19
+ python_requires='>=3.10',
20
+ install_requires=[
21
+ "pandas",
22
+ "numpy",
23
+ "matplotlib",
24
+ "opencv-python",
25
+ "scipy",
26
+ "tqdm",
27
+ "moviepy",
28
+ "ultralytics"
29
+ ]
30
+ )
@@ -0,0 +1,112 @@
1
+ # src/speed_analyzer/__init__.py
2
+ import pandas as pd
3
+ from pathlib import Path
4
+ import json
5
+ import shutil
6
+ import logging
7
+ from typing import Optional, Dict
8
+
9
+ # Importa i moduli di analisi dalla sottocartella
10
+ from .analysis_modules import speed_script_events
11
+ from .analysis_modules import yolo_analyzer
12
+ from .analysis_modules import video_generator
13
+
14
+ # Esporta la funzione principale per renderla accessibile con "from speed_analyzer import run_full_analysis"
15
+ __all__ = ["run_full_analysis"]
16
+
17
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
18
+
19
+ def _prepare_working_directory(output_dir: Path, raw_dir: Path, unenriched_dir: Path, enriched_dir: Optional[Path], events_df: pd.DataFrame):
20
+ working_dir = output_dir / 'eyetracking_files'
21
+ working_dir.mkdir(parents=True, exist_ok=True)
22
+ logging.info(f"Preparing working directory at: {working_dir}")
23
+ try:
24
+ external_video_path = next(unenriched_dir.glob('*.mp4'))
25
+ except StopIteration:
26
+ raise FileNotFoundError(f"No .mp4 file found in {unenriched_dir}")
27
+ file_map = {
28
+ 'internal.mp4': raw_dir / 'Neon Sensor Module v1 ps1.mp4',
29
+ 'external.mp4': external_video_path,
30
+ 'fixations.csv': unenriched_dir / 'fixations.csv',
31
+ 'gaze.csv': unenriched_dir / 'gaze.csv',
32
+ 'blinks.csv': unenriched_dir / 'blinks.csv',
33
+ 'saccades.csv': unenriched_dir / 'saccades.csv',
34
+ '3d_eye_states.csv': unenriched_dir / '3d_eye_states.csv',
35
+ 'world_timestamps.csv': unenriched_dir / 'world_timestamps.csv',
36
+ }
37
+ if enriched_dir:
38
+ file_map.update({
39
+ 'surface_positions.csv': enriched_dir / 'surface_positions.csv',
40
+ 'gaze_enriched.csv': enriched_dir / 'gaze.csv',
41
+ 'fixations_enriched.csv': enriched_dir / 'fixations.csv',
42
+ })
43
+ for dest, source in file_map.items():
44
+ if source and source.exists():
45
+ shutil.copy(source, working_dir / dest)
46
+ else:
47
+ logging.warning(f"Optional file not found and not copied: {source}")
48
+ if not events_df.empty:
49
+ events_df.to_csv(working_dir / 'events.csv', index=False)
50
+ return working_dir
51
+
52
+ def run_full_analysis(
53
+ raw_data_path: str, unenriched_data_path: str, output_path: str, subject_name: str,
54
+ enriched_data_path: Optional[str] = None, events_df: Optional[pd.DataFrame] = None,
55
+ run_yolo: bool = False, yolo_model_path: str = 'yolov8n.pt',
56
+ generate_plots: bool = True, plot_selections: Optional[Dict[str, bool]] = None,
57
+ generate_video: bool = True, video_options: Optional[Dict] = None
58
+ ) -> Path:
59
+ raw_dir = Path(raw_data_path)
60
+ unenriched_dir = Path(unenriched_data_path)
61
+ output_dir = Path(output_path)
62
+ enriched_dir = Path(enriched_data_path) if enriched_data_path else None
63
+ output_dir.mkdir(parents=True, exist_ok=True)
64
+ un_enriched_mode = enriched_dir is None
65
+
66
+ if events_df is None:
67
+ logging.info("No events DataFrame provided, loading 'events.csv' from un-enriched folder.")
68
+ events_file = unenriched_dir / 'events.csv'
69
+ events_df = pd.read_csv(events_file) if events_file.exists() else pd.DataFrame()
70
+
71
+ working_dir = _prepare_working_directory(output_dir, raw_dir, unenriched_dir, enriched_dir, events_df)
72
+ selected_event_names = events_df['name'].tolist() if not events_df.empty else []
73
+
74
+ logging.info(f"--- STARTING CORE ANALYSIS FOR {subject_name} ---")
75
+ speed_script_events.run_analysis(
76
+ subj_name=subject_name, data_dir_str=str(working_dir), output_dir_str=str(output_dir),
77
+ un_enriched_mode=un_enriched_mode, selected_events=selected_event_names
78
+ )
79
+ logging.info("--- CORE ANALYSIS COMPLETE ---")
80
+
81
+ if run_yolo:
82
+ logging.info("--- STARTING YOLO ANALYSIS ---")
83
+ yolo_analyzer.run_yolo_analysis(
84
+ data_dir=working_dir, output_dir=output_dir, subj_name=subject_name, model_path=yolo_model_path
85
+ )
86
+ logging.info("--- YOLO ANALYSIS COMPLETE ---")
87
+
88
+ if generate_plots:
89
+ logging.info("--- STARTING PLOT GENERATION ---")
90
+ if plot_selections is None:
91
+ plot_selections = { "path_plots": True, "heatmaps": True, "histograms": True, "pupillometry": True, "advanced_timeseries": True, "fragmentation": True }
92
+ config = {"unenriched_mode": un_enriched_mode, "source_folders": {"unenriched": str(unenriched_dir)}}
93
+ with open(output_dir / 'config.json', 'w') as f: json.dump(config, f)
94
+ speed_script_events.generate_plots_on_demand(
95
+ output_dir_str=str(output_dir), subj_name=subject_name,
96
+ plot_selections=plot_selections, un_enriched_mode=un_enriched_mode
97
+ )
98
+ logging.info("--- PLOT GENERATION COMPLETE ---")
99
+
100
+ if generate_video:
101
+ logging.info("--- STARTING VIDEO GENERATION ---")
102
+ if video_options is None:
103
+ video_options = { "output_filename": f"video_output_{subject_name}.mp4", "overlay_gaze": True, "overlay_event_text": True }
104
+ video_generator.create_custom_video(
105
+ data_dir=working_dir, output_dir=output_dir, subj_name=subject_name,
106
+ options=video_options, un_enriched_mode=un_enriched_mode,
107
+ selected_events=selected_event_names
108
+ )
109
+ logging.info("--- VIDEO GENERATION COMPLETE ---")
110
+
111
+ logging.info(f"Analysis complete. Results saved in: {output_dir.resolve()}")
112
+ return output_dir