From d79fad909ca6f47dde8b0685dc38b83e64684899 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 22 Jan 2026 18:39:33 +0100 Subject: [PATCH] changed script for combined feature creation min duration for blink is now configurable in __main__ --- dataset_creation/combined_feature_creation.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dataset_creation/combined_feature_creation.py b/dataset_creation/combined_feature_creation.py index b1fc341..ad8fec4 100644 --- a/dataset_creation/combined_feature_creation.py +++ b/dataset_creation/combined_feature_creation.py @@ -11,11 +11,12 @@ from pygazeanalyser.detectors import fixation_detection, saccade_detection # KONFIGURATION ############################################################################## INPUT_DIR = Path(r"/home/jovyan/data-paulusjafahrsimulator-gpu/both_mod_parquet_files") -OUTPUT_FILE = Path(r"/home/jovyan/data-paulusjafahrsimulator-gpu/new_datasets/combined_dataset_25hz.parquet") +OUTPUT_FILE = Path(r"/home/jovyan/data-paulusjafahrsimulator-gpu/new_datasets/fix_blink_combined_dataset_25hz.parquet") WINDOW_SIZE_SAMPLES = 1250 # 50s bei 25Hz STEP_SIZE_SAMPLES = 125 # 5s bei 25Hz SAMPLING_RATE = 25 # Hz +MIN_DUR_BLINKS = 2 # x * 40ms ############################################################################## @@ -115,7 +116,7 @@ def compute_IPA(pupil, fs=25): return np.sum(Pxx[hf_band]) -def extract_eye_features_window(df_eye_window, fs=25): +def extract_eye_features_window(df_eye_window, fs=25, min_dur_blinks=2): """ Extrahiert Eye-Tracking Features für ein einzelnes Window. Gibt Dictionary mit allen Eye-Features zurück. @@ -160,7 +161,7 @@ def extract_eye_features_window(df_eye_window, fs=25): # ---------------------------- # BLINKS # ---------------------------- - blinks = detect_blinks(pupil_validity) + blinks = detect_blinks(pupil_validity, min_duration=min_dur_blinks) blink_durations = [(b[1] - b[0]) / fs for b in blinks] # ---------------------------- @@ -197,7 +198,7 @@ def extract_eye_features_window(df_eye_window, fs=25): # KOMBINIERTE FEATURE-EXTRAKTION ############################################################################## -def process_combined_features(input_dir, output_file, window_size, step_size, fs=25): +def process_combined_features(input_dir, output_file, window_size, step_size, fs=25,min_duration_blinks=2): """ Verarbeitet Parquet-Dateien mit FACE_AU und EYE Spalten. Extrahiert beide Feature-Sets und kombiniert sie. @@ -285,7 +286,7 @@ def process_combined_features(input_dir, output_file, window_size, step_size, fs # Eye-Tracking Features if has_eye: try: - eye_features = extract_eye_features_window(window_df[eye_columns], fs=fs) + eye_features = extract_eye_features_window(window_df[eye_columns], fs=fs,min_dur_blinks=min_duration_blinks) result.update(eye_features) except Exception as e: print(f" WARNUNG: Eye-Features fehlgeschlagen: {str(e)}") @@ -358,7 +359,8 @@ def main(): output_file=OUTPUT_FILE, window_size=WINDOW_SIZE_SAMPLES, step_size=STEP_SIZE_SAMPLES, - fs=SAMPLING_RATE + fs=SAMPLING_RATE, + min_duration_blinks=MIN_DUR_BLINKS ) if result is not None: