From 368778eb7a898c94e0121463f2c6a18ca7debb23 Mon Sep 17 00:00:00 2001 From: jcohenadad Date: Tue, 9 Jan 2024 22:59:57 -0500 Subject: [PATCH] Introduce output result folder --- data_processing.ipynb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/data_processing.ipynb b/data_processing.ipynb index 69f8608..6ee1def 100644 --- a/data_processing.ipynb +++ b/data_processing.ipynb @@ -127,7 +127,11 @@ "# shim_modes = [\"CP\", \"CoV\"] # debugging\n", "print(f\"shim_modes: {shim_modes}\")\n", "subjects = sorted(glob.glob(\"sub-*\"))\n", - "print(f\"subjects: {subjects}\")" + "print(f\"subjects: {subjects}\")\n", + "\n", + "# Create output folder\n", + "path_results = os.path.join(path_data, 'derivatives', 'results')\n", + "os.makedirs(path_results, exist_ok=True)" ] }, { @@ -413,14 +417,14 @@ { "cell_type": "code", "execution_count": null, - "id": "a66be786", + "id": "95ab4e6d", "metadata": {}, "outputs": [], "source": [ "# Create tables and perform statistics\n", "\n", "# Go back to root data folder\n", - "os.chdir(os.path.join(path_data))\n", + "os.chdir(path_data)\n", "\n", "# Data storage\n", "data_summary = []\n", @@ -441,11 +445,11 @@ "\n", "# Convert to DataFrame and save to CSV\n", "df_summary = pd.DataFrame(data_summary, columns=['Subject', 'Shim_Mode', 'Average', 'Standard_Deviation'])\n", - "df_summary.to_csv('subject_shim_mode_summary.csv', index=False)\n", + "df_summary.to_csv(os.path.join(path_results, 'subject_shim_mode_summary.csv'), index=False)\n", "\n", "# Step 3: Compute statistics across subjects\n", "df_grouped = df_summary.groupby('Shim_Mode').agg({'Average': 'mean', 'Standard_Deviation': 'mean'}).reset_index()\n", - "df_grouped.to_csv('average_across_subjects.csv', index=False)\n", + "df_grouped.to_csv(os.path.join(path_results, 'average_across_subjects.csv'), index=False)\n", "\n", "# Step 4: ANOVA and Posthoc Tests\n", "anova_result = f_oneway(*[group[\"Average\"].values for name, group in df_summary.groupby(\"Shim_Mode\")])\n",