Skip to content

Commit

Permalink
Introduce output result folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Jan 10, 2024
1 parent 83a1a6f commit 368778e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions data_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 368778e

Please sign in to comment.