Plotter Module

Defines plotting functions used for analyzing data.

See examples/analysis for examples of how to use.

src.core.plotter.heatmaps(*facetdata, data=None, ax=None, **kwargs)

Create heatmap for a single axis using the _HeatmapPlotter class.

To create a single heatmap, call the class directly Use a Seaborn FacetGrid to create multiple heatmaps in one figure, using the FacetGrid.map() method. Note that data cannot be aggregated across n_sims (e.g., each call of heatmaps() must recieve only one threshold per fiber).

Parameters:
  • facetdata – Recieves data from FacetGrid if using to plot an array.

  • data – DataFrame to plot, used if manually passing data.

  • ax – Axis to plot on.

  • kwargs – Arguments to be passed to _HeatmapPlotter class constructor.

Returns:

Plotting axis.

class src.core.plotter._HeatmapPlotter(data, mode: str = 'fibers', sample_object=None, sim_object=None, missing_color='red', suprathresh_color='blue', subthresh_color='green', cutoff_thresh=None, cmap=None, colorbar=True, min_max_ticks=False, cuff_orientation=False, plot_outers=False, cbar_kws=None, scatter_kws=None, line_kws=None, min_thresh=None, max_thresh=None, color=None)

Class used to contruct heatmap plots.

This class should not be called directly by the user. Rather, the user should call the heatmaps() function, which will pass any keyword arguments to this class’s constructor.

__init__(data, mode: str = 'fibers', sample_object=None, sim_object=None, missing_color='red', suprathresh_color='blue', subthresh_color='green', cutoff_thresh=None, cmap=None, colorbar=True, min_max_ticks=False, cuff_orientation=False, plot_outers=False, cbar_kws=None, scatter_kws=None, line_kws=None, min_thresh=None, max_thresh=None, color=None)

Initialize heatmap plotter.

Parameters:
  • data – DataFrame containing data to plot.

  • mode

    Plotting mode. There are multiple options:

    • 'fibers': Plot a point for each fiber, using a heatmap of thresholds for color.

    • 'fibers_on_off': Plot a point for each fiber. If the fiber threshold is above cutoff_thresh, suprathresh_color is used. Otherwise, subthresh_color is used.

    • 'inners': Plot each inner as filled in, using a heatmap of thresholds for color. The mean threshold for that inner is used, thus if only one fiber is present per inner, that threshold is used.

    • 'inners_on_off': Plot each inner as filled in. If the mean inner threshold is above cutoff_thresh, suprathresh_color is used. Otherwise, subthresh_color is used.

  • sample_object – Sample object to use for plotting. Automatically loaded if not provided.

  • sim_object – Simulation object to use for plotting. Automatically loaded if not provided.

  • missing_color – Color to use for missing data.

  • suprathresh_color – Color to use for suprathresh data.

  • subthresh_color – Color to use for subthresh data.

  • cutoff_thresh – Threshold to use for plotting on_off modes.

  • cmap – Color map to override default.

  • colorbar – Whether to add a colorbar.

  • min_max_ticks – Whether to add only the minimum and maximum ticks to the colorbar.

  • cuff_orientation – Whether to plot a point for the cuff orientation.

  • plot_outers – Whether to plot the fascicle outers.

  • cbar_kws – Keyword arguments to pass to matplotlib.colorbar.Colorbar.

  • scatter_kws – Keyword arguments to pass to matplotlib.pyplot.scatter.

  • line_kws – Keyword arguments to pass to matplotlib.pyplot.plot.

  • min_thresh – Minimum threshold to use for plotting. Use this to override the default minimum.

  • max_thresh – Maximum threshold to use for plotting. Use this to override the default maximum.

  • color – Color passed in by seaborn when using FacetGrid. Not used.

plot(ax)

Make heatmap plot.

Parameters:

ax – Axis to plot on.

Returns:

Plotting axis.

plot_inners_fibers(ax)

Plot inners and fibers using the colors determined in determine_colors().

Parameters:

ax – axis to plot on

create_cmap()

Create color map and mappable for assigning colorbar and ticks.

static set_ax(ax)

Remove axis elements.

Parameters:

ax – axis to plot on

determine_colors(threshdf)

Determine colors for inners and fibers based on user selected mode.

Parameters:

threshdf – DataFrame of thresholds.

add_colorbar(ax)

Add colorbar to heatmap plot.

Parameters:

ax – axis to plot on

get_objects()

Get sample and sim objects for plotting.

validate(data)

Check that data is valid for plotting.

Parameters:

data – DataFrame of thresholds.

plot_cuff_orientation(ax)

Plot the orientation of the cuff.

Parameters:

ax – axis to plot on

src.core.plotter.ap_loctime(query_object: Query, n_sim_filter: List[int] | None = None, plot: bool = False, plot_distribution: bool = False, n_sim_label_override: str | None = None, model_labels: List[str] | None = None, save: bool = False, subplots=False, nodes_only=False, amp=0)

Plot time and location of action potential initiation.

Parameters:
  • query_object – Query object to use for plotting.

  • n_sim_filter – List of n_sim values to plot.

  • plot – Whether to plot the ap location node for each fiber.

  • plot_distribution – Whether to plot action potential initiation node distribution.

  • n_sim_label_override – Label to use for n_sim.

  • model_labels – Labels to use for models.

  • save – Whether to save the plot.

  • subplots – Whether to plot in subplots.

  • nodes_only – Whether to plot only nodes.

  • amp – Amplitude of action potential.