From 0c07bddbc821aef8defd2ae7a2c57340c3243937 Mon Sep 17 00:00:00 2001 From: mnystrom Date: Thu, 29 Feb 2024 09:11:53 +0100 Subject: [PATCH] clean-up --- demo_analyses/extract_trial_data.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/demo_analyses/extract_trial_data.py b/demo_analyses/extract_trial_data.py index 6996a88..c2904b2 100644 --- a/demo_analyses/extract_trial_data.py +++ b/demo_analyses/extract_trial_data.py @@ -79,20 +79,14 @@ def extract_trial_data(df_et_data, df_msg, msg_onset, msg_offset): # Create a folder to put the trials path = Path.cwd() / 'trials' / pid - try: - path.mkdir(parents=True, exist_ok=False) - except FileExistsError: - print("Folder is already there") - else: - print("Folder was created") + path.mkdir(parents=True, exist_ok=True) # Extract relevant trial data and save in format required by I2MC for t in trial_msg: df_trial = extract_trial_data(df_gaze, df_msg, t[0], t[1]) - df_trial.reset_index(inplace=True) filename = t[0].split('_', 1)[1] + '.tsv' - df_trial.to_csv(str(path) + os.sep + filename, sep='\t') + df_trial.to_csv(str(path) + os.sep + filename, sep='\t', index=False) print('Trial ' + filename + " written to folder ", path)