added clean eye df call to combined feature creation

bug fix, was missing in combined feature creation script
This commit is contained in:
Michael Weig 2026-01-26 17:53:54 +01:00
parent 38e9354c42
commit eee173dc0b

View File

@ -11,7 +11,7 @@ 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/blink_fix_dataset.parquet")
OUTPUT_FILE = Path(r"/home/jovyan/data-paulusjafahrsimulator-gpu/new_datasets/50s_25Hz_dataset.parquet")
WINDOW_SIZE_SAMPLES = 25*50 # 50s bei 25Hz
STEP_SIZE_SAMPLES = 125 # 5s bei 25Hz
@ -26,6 +26,7 @@ MIN_DUR_BLINKS = 2 # x * 40ms
def clean_eye_df(df):
"""Extrahiert nur Eye-Tracking Spalten und entfernt leere Zeilen."""
eye_cols = [c for c in df.columns if c.startswith("EYE_")]
if not eye_cols:
return pd.DataFrame()
@ -56,13 +57,14 @@ def extract_gaze_signal(df):
gx_R[~val_R] = np.nan
gy_R[~val_R] = np.nan
# Mittelwert beider Augen
gx = np.mean(np.column_stack([gx_L, gx_R]), axis=1)
gy = np.mean(np.column_stack([gy_L, gy_R]), axis=1)
# Interpolation
gx = pd.Series(gx).interpolate(limit=50, limit_direction="both").bfill().ffill()
gy = pd.Series(gy).interpolate(limit=50, limit_direction="both").bfill().ffill()
gx = pd.Series(gx).interpolate(limit=None, limit_direction="both").bfill().ffill()
gy = pd.Series(gy).interpolate(limit=None, limit_direction="both").bfill().ffill()
# MinMax Skalierung
xscaler = MinMaxScaler()
@ -227,6 +229,7 @@ def process_combined_features(input_dir, output_file, window_size, step_size, fs
df = pd.read_parquet(parquet_file)
print(f" Einträge: {len(df)}")
# Identifiziere Spalten
au_columns = [col for col in df.columns if col.startswith('FACE_AU')]
eye_columns = [col for col in df.columns if col.startswith('EYE_')]
@ -286,6 +289,9 @@ def process_combined_features(input_dir, output_file, window_size, step_size, fs
# Eye-Tracking Features
if has_eye:
try:
# clean dataframe from all nan rows
window_df= clean_eye_df(window_df)
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: