Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts to address datapaper3 revision #56

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
plot with subplots
ferponcem committed May 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 24d22d867364750e9d6502784365c98eff5ab2d3
29 changes: 24 additions & 5 deletions papers_scripts/scidata2023/from_revision/framewise_displacement.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def create_df_for_plotting(all_FD, PTS, grouped_tasks):
return df

# %%
def plot_subs_FD_distribution(df_plot, PTS, tasks, out_dir=''):
def plot_subs_FD_distribution(df_plot, out_dir=''):
"""Plot the distribution of framewise displacement for all subjects."""

#plt.figure(figsize=(10, 7))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't keep commented lines in your scripts.

@@ -78,8 +78,23 @@ def plot_subs_FD_distribution(df_plot, PTS, tasks, out_dir=''):

plt.tight_layout()
#plt.savefig(os.path.join(out_dir, f'FD.png'), dpi=300)
plt.savefig(os.path.join(out_dir, f'FD_hor.png'), dpi=300)

plt.savefig(os.path.join(out_dir, 'FD_hor.png'), dpi=300)
# %%
def subplot_task_FD(df_to_plot, out_dir=''):

fig, axes = plt.subplots(4, 1, figsize=(9, 12), sharey=True)
axes = axes.flatten()
for i, task in enumerate(df_to_plot['Task'].unique()):
task_data = df_to_plot[df_to_plot['Task'] == task]
sns.boxplot(data=task_data, x='Subject', y='FD', ax=axes[i],
hue='Subject', palette='Set1', legend=False)
axes[i].set_title(task)
axes[i].set_xlabel(None)
axes[i].set_ylabel('Framewise Displacement [mm]')
axes[i].set_ylim(0, 1.0)
plt.tight_layout()
plt.savefig(os.path.join(out_dir, 'FD_subplot.png'), dpi=300)

# %%
if __name__ == '__main__':
# ########################### INPUTS #####################################
@@ -114,6 +129,10 @@ def plot_subs_FD_distribution(df_plot, PTS, tasks, out_dir=''):

# %%
df_to_plot = create_df_for_plotting(all_FD, PTS, grouped_tasks)
plot_subs_FD_distribution(df_to_plot, PTS, grouped_tasks)

# %%
# plot all the data in a single plot
# plot_subs_FD_distribution(df_to_plot, out_dir=cache)

# plot each task as subplots
subplot_task_FD(df_to_plot, out_dir=cache)
# %%