Skip to content

Refactor InHouseWebBasedGrapher to use MEAPlotter for bar plotting#167

Draft
mandarmp with Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-inhouse-web-based-grapher
Draft

Refactor InHouseWebBasedGrapher to use MEAPlotter for bar plotting#167
mandarmp with Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-inhouse-web-based-grapher

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

NetworkAnalysis/InHouseWebBasedGrapher duplicated bar-chart-with-significance logic that already exists (better) in IPNAnalysis/MEAPlotter. The two separate plot functions also had inconsistent stats (manual per-mean t-test approximation instead of proper t-test / ANOVA+Tukey).

Changes

plot_functions.py

  • Drops plot_activity_graphs and plot_bar_with_p_values (~240 lines of bespoke matplotlib + manual stats)
  • Adds plot_metrics_graphs — single function delegating to MEAPlotter.plot_bars_by_div():
    • seaborn-based grouped bars + scatter, publication-quality styling
    • 2 groups → independent t-test; 3+ groups → one-way ANOVA + Tukey HSD (via MEAPlotter's centralized stats)
    • adds _fig_to_dash_outputs(fig) helper to convert a matplotlib figure into the (html.Img, svg_bytes, png_bytes) tuple Dash expects
  • Keeps plot_activity_graphs / plot_bar_with_p_values as thin backward-compatible aliases
  • plot_isi_graph and min_max_normalize unchanged

app_callbacks.py

  • Replaces the filename-dispatch (if 'activity' in filename … elif 'networks' in filename) with a single plot_metrics_graphs(…) call
  • Updates import accordingly
# Before: two separate implementations + filename-based dispatch
if 'activity' in filename.lower():
    images, svgs, pngs = plot_activity_graphs(df, divs, [metric], genotypes, colors)
elif 'networks' in filename.lower():
    images, svgs, pngs = plot_bar_with_p_values(df, divs, [metric], genotypes, colors)
else:
    raise TypeError("No file of name activity or network found")

# After: unified call regardless of file type
images, svgs, pngs = plot_metrics_graphs(df, divs, [metric], genotypes, colors)

…APlotter.plot_bars_by_div

Agent-Logs-Url: https://github.com/roybens/MEA_Analysis/sessions/33320893-82ab-4a6f-a3e6-d66cd36e89fa

Co-authored-by: mandarmp <33731455+mandarmp@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants