API Reference
This section provides detailed API documentation for figpack.
Core Modules
figpack - A Python package for creating shareable, interactive visualizations in the browser
- class figpack.ExtensionRegistry[source]
Bases:
object
Singleton registry for managing figpack extensions
- get_all_extensions() Dict[str, FigpackExtension] [source]
Get all registered extensions
- Returns:
Dictionary mapping extension names to extension objects
- get_extension(name: str) FigpackExtension | None [source]
Get an extension by name
- Parameters:
name – Name of the extension to retrieve
- Returns:
The extension if found, None otherwise
- classmethod get_instance() ExtensionRegistry [source]
Get the singleton instance of the extension registry
- classmethod register(extension: FigpackExtension) None [source]
Register an extension with the global registry
- Parameters:
extension – The extension to register
- class figpack.ExtensionView(*, extension_name: str)[source]
Bases:
FigpackView
Base class for views that are rendered by figpack extensions
- class figpack.FigpackExtension(*, name: str, javascript_code: str, additional_files: Dict[str, str] | None = None, version: str = '1.0.0')[source]
Bases:
object
Base class for figpack extensions that provide custom view components
- class figpack.FigpackView[source]
Bases:
object
Base class for all figpack visualization components
- save(output_path: str, *, title: str) None [source]
Save as figure either to a folder or to a .tar.gz file :param output_path: Output path (destination folder or .tar.gz file path)
- show(*, title: str, description: str | None = None, port: int | None = None, open_in_browser: bool | None = None, upload: bool | None = None, inline: bool | None = None, inline_height: int = 600, ephemeral: bool | None = None, allow_origin: str | None = None, wait_for_input: bool | None = None, _dev: bool | None = None)[source]
Display a figpack view component with intelligent environment detection and flexible display options. See https://flatironinstitute.github.io/figpack/show_function.html for complete documentation.
Automatically adapts behavior based on context (Jupyter, Colab, JupyterHub, standalone). Display modes include local browser, inline notebook, and remote upload with ephemeral options. Environment variables (FIGPACK_UPLOAD, FIGPACK_INLINE, FIGPACK_OPEN_IN_BROWSER) can control default behaviors.
- Parameters:
title – Title for browser tab and figure (required)
description – Description text with markdown support (optional)
port – Local server port, random if None
open_in_browser – Auto-open in browser, auto-detects by environment
upload – Upload figure to figpack servers, auto-detects by environment
ephemeral – Use temporary figure for cloud notebooks, auto-detects
inline – Display inline in notebook, auto-detects by environment
inline_height – Height in pixels for inline display (default: 600)
allow_origin – CORS allow-origin header for local server
wait_for_input – Wait for Enter before continuing, auto-detects
_dev – Developer mode for figpack development
Views
Core Views
Spike Sorting Views
Spike sorting views for figpack
- class figpack.spike_sorting.views.AutocorrelogramItem(*, unit_id: str | int, bin_edges_sec: ndarray, bin_counts: ndarray)[source]
Bases:
object
Represents a single autocorrelogram for a unit
- class figpack.spike_sorting.views.Autocorrelograms(*, autocorrelograms: List[AutocorrelogramItem])[source]
Bases:
FigpackView
A view that displays multiple autocorrelograms for spike sorting analysis
- class figpack.spike_sorting.views.AverageWaveforms(*, average_waveforms: List[AverageWaveformItem])[source]
Bases:
FigpackView
A view that displays multiple average waveforms for spike sorting analysis
- class figpack.spike_sorting.views.CrossCorrelogramItem(*, unit_id1: str | int, unit_id2: str | int, bin_edges_sec: ndarray, bin_counts: ndarray)[source]
Bases:
object
Represents a single cross-correlogram between two units
- class figpack.spike_sorting.views.CrossCorrelograms(*, cross_correlograms: List[CrossCorrelogramItem], hide_unit_selector: bool | None = False)[source]
Bases:
FigpackView
A view that displays multiple cross-correlograms for spike sorting analysis
- class figpack.spike_sorting.views.RasterPlot(*, start_time_sec: float, end_time_sec: float, plots: List[RasterPlotItem])[source]
Bases:
FigpackView
A view that displays multiple raster plots for spike sorting analysis
- class figpack.spike_sorting.views.RasterPlotItem(*, unit_id: str | int, spike_times_sec: ndarray)[source]
Bases:
object
Represents spike times for a single unit in a raster plot
- class figpack.spike_sorting.views.SpikeAmplitudes(*, start_time_sec: float, end_time_sec: float, plots: List[SpikeAmplitudesItem])[source]
Bases:
FigpackView
A view that displays spike amplitudes over time for multiple units
- class figpack.spike_sorting.views.SpikeAmplitudesItem(*, unit_id: str | int, spike_times_sec: ndarray, spike_amplitudes: ndarray)[source]
Bases:
object
Represents spike amplitudes for a single unit
- class figpack.spike_sorting.views.UnitMetricsGraph(*, units: List[UnitMetricsGraphUnit], metrics: List[UnitMetricsGraphMetric], height: int | None = None)[source]
Bases:
FigpackView
A view that displays unit metrics in a graph format
- class figpack.spike_sorting.views.UnitMetricsGraphMetric(*, key: str, label: str, dtype: str)[source]
Bases:
object
Defines a metric with key, label, and data type
- class figpack.spike_sorting.views.UnitMetricsGraphUnit(*, unit_id: str | int, values: Dict[str, int | float])[source]
Bases:
object
Represents a unit with its metric values
- class figpack.spike_sorting.views.UnitSimilarityScore(*, unit_id1: str | int, unit_id2: str | int, similarity: float)[source]
Bases:
object
Represents a similarity score between two units
- class figpack.spike_sorting.views.UnitsTable(*, columns: List[UnitsTableColumn], rows: List[UnitsTableRow], similarity_scores: List[UnitSimilarityScore] | None = None, height: int | None = 600)[source]
Bases:
FigpackView
A view that displays a table of units with their properties and optional similarity scores
Franklab Views
Franklab views for figpack
- class figpack.franklab.views.TrackAnimation(*, bin_height: float, bin_width: float, frame_bounds: ndarray, locations: ndarray, values: ndarray, xcount: int, ycount: int, xmin: float, ymin: float, head_direction: ndarray, positions: ndarray, timestamps: ndarray, track_bin_corners: ndarray, sampling_frequency_hz: float, timestamp_start: float, total_recording_frame_length: int, track_bin_height: float, track_bin_width: float, xmax: float, ymax: float)[source]
Bases:
FigpackView
A track animation visualization component for displaying animal tracking data
Core Functionality
The core functionality includes the essential show()
function used to display and share visualizations. For detailed documentation of this crucial function and all its configuration options, see the show() function reference.
- class figpack.core.ExtensionRegistry[source]
Bases:
object
Singleton registry for managing figpack extensions
- get_all_extensions() Dict[str, FigpackExtension] [source]
Get all registered extensions
- Returns:
Dictionary mapping extension names to extension objects
- get_extension(name: str) FigpackExtension | None [source]
Get an extension by name
- Parameters:
name – Name of the extension to retrieve
- Returns:
The extension if found, None otherwise
- classmethod get_instance() ExtensionRegistry [source]
Get the singleton instance of the extension registry
- classmethod register(extension: FigpackExtension) None [source]
Register an extension with the global registry
- Parameters:
extension – The extension to register
- class figpack.core.ExtensionView(*, extension_name: str)[source]
Bases:
FigpackView
Base class for views that are rendered by figpack extensions
- class figpack.core.FigpackExtension(*, name: str, javascript_code: str, additional_files: Dict[str, str] | None = None, version: str = '1.0.0')[source]
Bases:
object
Base class for figpack extensions that provide custom view components
- class figpack.core.FigpackView[source]
Bases:
object
Base class for all figpack visualization components
- save(output_path: str, *, title: str) None [source]
Save as figure either to a folder or to a .tar.gz file :param output_path: Output path (destination folder or .tar.gz file path)
- show(*, title: str, description: str | None = None, port: int | None = None, open_in_browser: bool | None = None, upload: bool | None = None, inline: bool | None = None, inline_height: int = 600, ephemeral: bool | None = None, allow_origin: str | None = None, wait_for_input: bool | None = None, _dev: bool | None = None)[source]
Display a figpack view component with intelligent environment detection and flexible display options. See https://flatironinstitute.github.io/figpack/show_function.html for complete documentation.
Automatically adapts behavior based on context (Jupyter, Colab, JupyterHub, standalone). Display modes include local browser, inline notebook, and remote upload with ephemeral options. Environment variables (FIGPACK_UPLOAD, FIGPACK_INLINE, FIGPACK_OPEN_IN_BROWSER) can control default behaviors.
- Parameters:
title – Title for browser tab and figure (required)
description – Description text with markdown support (optional)
port – Local server port, random if None
open_in_browser – Auto-open in browser, auto-detects by environment
upload – Upload figure to figpack servers, auto-detects by environment
ephemeral – Use temporary figure for cloud notebooks, auto-detects
inline – Display inline in notebook, auto-detects by environment
inline_height – Height in pixels for inline display (default: 600)
allow_origin – CORS allow-origin header for local server
wait_for_input – Wait for Enter before continuing, auto-detects
_dev – Developer mode for figpack development
Command Line Interface
Command-line interface for figpack
- figpack.cli.download_figure(figure_url: str, dest_path: str) None [source]
Download a figure from a figpack URL and save as tar.gz
- Parameters:
figure_url – The figpack URL
dest_path – Destination path for the tar.gz file
- figpack.cli.download_file(base_url: str, file_info: Dict, temp_dir: Path) Tuple[str, bool] [source]
Download a single file from the figure
- Parameters:
base_url – The base URL for the figure
file_info – Dictionary with ‘path’ and ‘size’ keys
temp_dir – Temporary directory to download to
- Returns:
Tuple of (file_path, success)
Individual View Classes
For detailed documentation of specific view classes, see the source code and docstrings in the respective modules:
figpack.views
- Core visualization componentsfigpack.spike_sorting.views
- Spike sorting specific viewsfigpack.franklab.views
- Franklab specific views
Usage Examples
For practical examples of using the API, see the Examples section.