From 629fc338c99c885907d96c2e120284ac35fc0edc Mon Sep 17 00:00:00 2001 From: Dan Handwerker <7406227+handwerkerd@users.noreply.github.com> Date: Mon, 8 Apr 2024 14:56:23 -0400 Subject: [PATCH] Fix dynamic reports with bokeh 3.4.0 problems (#1068) * fixed crash * hopefully solved --- pyproject.toml | 2 +- tedana/reporting/dynamic_figures.py | 37 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8c7cb4d1f..50216a592 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ license = {file = "LICENSE"} requires-python = ">=3.8" dependencies = [ - "bokeh", + "bokeh>=1.0.0,<=3.4.0", "mapca>=0.0.4,<=0.0.5", "matplotlib", "nibabel>=2.5.1,<=5.2.1", diff --git a/tedana/reporting/dynamic_figures.py b/tedana/reporting/dynamic_figures.py index ae52863f8..95ac95edb 100644 --- a/tedana/reporting/dynamic_figures.py +++ b/tedana/reporting/dynamic_figures.py @@ -162,15 +162,20 @@ def _create_kr_plt(comptable_cds, kappa_elbow=None, rho_elbow=None): ("Tags", "@classtag"), ] ) + fig = plotting.figure( width=400, height=400, - tools=["tap,wheel_zoom,reset,pan,crosshair,save", kr_hovertool], + tools=[ + "wheel_zoom,reset,pan,crosshair,save", + models.TapTool(mode="replace"), + kr_hovertool, + ], title="Kappa / Rho Plot", ) diagonal = models.Slope(gradient=1, y_intercept=0, line_color="#D3D3D3") fig.add_layout(diagonal) - fig.circle( + fig.scatter( "kappa", "rho", size="size", @@ -279,7 +284,7 @@ def _create_sorted_plt( fig = plotting.figure( width=400, height=400, - tools=["tap,wheel_zoom,reset,pan,crosshair,save", hovertool], + tools=["wheel_zoom,reset,pan,crosshair,save", models.TapTool(mode="replace"), hovertool], title=title, ) fig.line( @@ -287,7 +292,7 @@ def _create_sorted_plt( y=comptable_cds.data[y_var].sort_values(ascending=False).values, color="black", ) - fig.circle(x_var, y_var, source=comptable_cds, size=5, color="color", alpha=0.7) + fig.scatter(x_var, y_var, source=comptable_cds, size=5, color="color", alpha=0.7) fig.xaxis.axis_label = x_label fig.yaxis.axis_label = y_label fig.x_range = models.Range1d(-1, n_comps + 1) @@ -319,18 +324,22 @@ def _create_sorted_plt( def _create_varexp_pie_plt(comptable_cds): - fig = plotting.figure( - width=400, - height=400, - title="Variance Explained View", - tools=["hover,tap,save"], + + pie_hovertool = models.HoverTool( tooltips=[ - ("Component ID", " @component"), + ("Component ID", "@component"), ("Kappa", "@kappa{0.00}"), ("Rho", "@rho{0.00}"), - ("Var. Exp.", "@varexp{0.00}%"), + ("Var. Expl.", "@varexp{0.00}%"), ("Tags", "@classtag"), - ], + ] + ) + + fig = plotting.figure( + width=400, + height=400, + title="Variance Explained View", + tools=[pie_hovertool, models.TapTool(mode="replace"), "save"], ) fig.wedge( x=0, @@ -347,7 +356,9 @@ def _create_varexp_pie_plt(comptable_cds): fig.grid.visible = False fig.toolbar.logo = None - circle = models.Circle(x=0, y=1, size=150, fill_color="white", line_color="white") + circle = models.Scatter( + x=0, y=1, size=150, marker="circle", fill_color="white", line_color="white" + ) fig.add_glyph(circle) return fig