Skip to main content

plots.figure_features_channel_space

plots.figure_features_channel_space(
    pid_df,
    features,
    xy,
    pid,
    fig=None,
    axs=None,
    br=None,
    mapping='Cosmos',
    plot_rect=plot_probe_rect2,
    cmap='viridis',
    scaler=None,
    vmin=None,
    vmax=None,
)

Create a figure displaying electrophysiological features and brain regions along a probe.

This function visualizes multiple features along a probe’s channels in physical space, as well as brain region information. It creates a multi-panel figure where each panel shows a different feature or brain region mapping.

Args: pid_df (pd.DataFrame): Dataframe containing channels and voltage information for a given probe ID (PID). Must contain columns for the specified features and brain region mapping. features (list[str]): List of feature names to display, e.g. [‘rms_lf’, ‘psd_delta’, ‘rms_ap’]. These must be column keys in pid_df. xy (np.ndarray): Matrix of spatial channel positions (in μm), with shape [N_channels x 2]. First column is lateral_um (x) and second column is axial_um (y). pid (str): Probe ID to be displayed in the figure title. fig (matplotlib.figure.Figure, optional): Existing figure to plot on. If None, a new figure is created. axs (np.ndarray, optional): Existing axes to plot on. If None, new axes are created. br (iblatlas.atlas.BrainRegions, optional): BrainRegions object for region color mapping. If None, a new one is created. mapping (str, optional): Brain region mapping to use. The function will look for columns named “{mapping}_id” in pid_df. Defaults to “Cosmos”. plot_rect (callable, optional): Function to use for plotting rectangles. Should accept xy, color, and ax parameters. Defaults to plot_probe_rect2. cmap (str, optional): Colormap name to use for feature visualization. Defaults to “viridis”. scaler (object, optional): Scaling to be applied to feature values before displaying. Should have a transform method (like sklearn.preprocessing.StandardScaler). vmin (float, optional): Minimum value for color normalization. If None, the minimum value in the data is used. vmax (float, optional): Maximum value for color normalization. If None, the maximum value in the data is used.

Returns: tuple: A tuple containing: - fig (matplotlib.figure.Figure): The figure object containing the plots. - axs (np.ndarray): The axes objects for each subplot.

Note: The function creates a multi-panel figure with brain region visualization, feature plots, and probe layout. It automatically handles figure sizing and subplot arrangement for optimal visualization.

Example: # Merge the voltage and channels dataframe df_voltage = pd.merge(df_voltage, df_channels, left_index=True, right_index=True).dropna() # Select a PID and create the single probe dataframe pid = ‘0228bcfd-632e-49bd-acd4-c334cf9213e9’ pid_df = df_voltage[df_voltage.index.get_level_values(0).isin([pid])].copy()