src.canns.analyzer.plotting.spatial¶
Spatial visualization functions for neural firing field heatmaps.
This module provides plotting utilities for visualizing spatial firing patterns of neural populations, particularly for grid cells, place cells, and band cells.
Functions¶
|
Plot a single spatial firing field heatmap. |
Module Contents¶
- src.canns.analyzer.plotting.spatial.plot_firing_field_heatmap(heatmap, config=None, figsize=(5, 5), cmap='jet', interpolation='nearest', origin='lower', show=True, save_path=None, **kwargs)[source]¶
Plot a single spatial firing field heatmap.
This function creates a publication-quality heatmap visualization of neural spatial firing patterns. It supports both modern PlotConfig-based configuration and legacy keyword arguments for backward compatibility.
- Parameters:
heatmap (np.ndarray) – 2D array of shape (M, K) representing spatial firing rates in each bin.
config (PlotConfig | None) – Unified configuration object. If None, uses backward compatibility parameters.
figsize (tuple[int, int]) – Figure size (width, height) in inches. Defaults to (5, 5).
cmap (str) – Colormap name for the heatmap. Defaults to ‘jet’.
interpolation (str) – Interpolation method for imshow. Defaults to ‘nearest’.
origin (str) – Origin position for imshow (‘lower’ or ‘upper’). Defaults to ‘lower’.
show (bool) – Whether to display the plot. Defaults to True.
save_path (str | None) – Path to save the figure. If None, figure is not saved.
**kwargs – Additional keyword arguments passed to plt.imshow().
- Returns:
The figure and axis objects for further customization.
- Return type:
tuple[plt.Figure, plt.Axes]
Example
>>> from canns.analyzer.spatial import compute_firing_field >>> from canns.analyzer.plotting import plot_firing_field_heatmap, PlotConfig >>> # Compute firing field >>> heatmaps = compute_firing_field(activity, positions, 5.0, 5.0, 50, 50) >>> # Plot single neuron with PlotConfig >>> config = PlotConfig(figsize=(6, 6), save_path='neuron_0.png', show=False) >>> fig, ax = plot_firing_field_heatmap(heatmaps[0], config=config) >>> # Plot with legacy parameters >>> fig, ax = plot_firing_field_heatmap(heatmaps[1], cmap='viridis', save_path='neuron_1.png')