neurochat.nc_plot module¶
This module implements plotting functions for NeuroChaT analyses.
@author: Md Nurul Islam; islammn at tcd dot ie
-
neurochat.nc_plot.angular_velocity(angVel_data)[source]¶ Plot the angular head velocity of the animal vs spike rate.
Parameters: angVel_data (dict) – Graphical data from the unit firing to angular head velocity correlation Returns: fig1 (matplotlib.pyplot.Figure) – Scatter plot of angular velocity vs spike-rate superimposed with fitted rate
-
neurochat.nc_plot.border(border_data)[source]¶ Plot the analysis resulting from border analysis.
Parameters: border_data (dict) – Graphical data from border analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Histogram of taxicab distance of active pixels
- fig2 (matplotlib.pyplot.Figure) – Angular distance of pixels vs active pixel count
- fig3 (matplotlib.pyplot.Figure) – Distance from border vs spike rate
- fig4 (matplotlib.pyplot.Figure) – Mean distance distance from border vs firing-rate percentage
-
neurochat.nc_plot.dist_rate(dist_data)[source]¶ Plot the firing rate vs distance from border.
Parameters: dist_data (dict) – Graphical data from border and gradient analysis Returns: fig1 (matplotlib.pyplot.Figure) – Distance from border vs spike rate
-
neurochat.nc_plot.gradient(gradient_data)[source]¶ Plot the result from gradient cell analysis.
Parameters: border_data (dict) – Graphical data from border analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Distance from border vs spike rate
- fig2 (matplotlib.pyplot.Figure) – Differential firing rate vs distance from border
- fig3 (matplotlib.pyplot.Figure) – Mean distance distance from border vs firing-rate percentage
-
neurochat.nc_plot.grid(grid_data, **kwargs)[source]¶ Plot the result from grid analysis.
Parameters: - grid_data (dict) – Graphical data from border analysis
- kwargs – Keyword arguments passed to loc_auto_corr
Returns: - fig1 (matplotlib.pyplot.Figure) – Autocorrelation of firing rate map, superimposed with central peaks
- fig2 (matplotlib.pyplot.Figure) – Rotational correlation of autocorrelation map
-
neurochat.nc_plot.hd_firing(hd_data, **kwargs)[source]¶ Plot the analysis of head directional correlation to spike-rate.
Parameters: - hd_data (dict) – Graphical data from the unit firing to head-directional correlation
- kwargs (keyword arguments) –
- show_predicted : bool
- Whether to show predicted head direction
Returns: - fig1 (matplotlib.pyplot.Figure) – Polar plot of head-direction during spiking-events
- fig2 (matplotlib.pyplot.Figure) – Polar plot of head-direction vs spike-rate. Predicted firing rate is also plotted.
-
neurochat.nc_plot.hd_rate(hd_data, ax=None, **kwargs)[source]¶ Plot head direction vs spike rate.
Parameters: - hd_data (dict) – Graphical data from the unit firing to head-direction correlation
- ax (matplotlib.axes.Axes) – Polar Axes object. If specified, the figure is plotted in this axes.
- kwargs (keyword arguments) –
- title : str
- default “Head directional firing rate”
- do_ticks : bool
- default False Show ticks on the plot.
Returns: ax (matplotlib.axes.Axes) – Axes of the polar plot of head-direction vs spike-rate.
-
neurochat.nc_plot.hd_rate_ccw(hd_data)[source]¶ Plot head directional correlation to spike-rate by turning direction.
This is split into counterclockwise and clockwise head-movements.
Parameters: hd_data (dict) – Graphical data from the unit firing to head-direction correlation Returns: fig1 (matplotlib.pyplot.Figure) – Polar plot of head-direction vs spike-rate in clockwise and counterclockwise head movements
-
neurochat.nc_plot.hd_rate_pred(hd_data, ax=None, **kwargs)[source]¶ Plot predicted and actual head direction from the positional data.
Parameters: - hd_data (dict) – Graphical data from the unit firing to head-direction correlation
- ax (matplotlib.axes.Axes) – Polar Axes object. If specified, the figure is plotted in this axes.
- kwargs (title - str, default "Head directional firing rate") –
Returns: ax (matplotlib.axes.Axes) – Axes of the polar plot of actual (blue) and expected (green) head-direction vs spike-rate.
-
neurochat.nc_plot.hd_rate_time_lapse(hd_data)[source]¶ Plot the analysis outcome of head directional time-lapse analysis.
Parameters: hd_data (dict) – Graphical data from head-directional time-lapsed anlaysis Returns: fig (list of matplotlib.pyplot.Figure) – Time-lapsed head-drectional firing rate plot
-
neurochat.nc_plot.hd_shuffle(hd_shuffle_data)[source]¶ Plot the analysis outcome of head directional shuffling analysis.
Parameters: hd_shuffle_data (dict) – Graphical data from head-directional shuffling analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Distribution of Rayleigh Z statistics
- fig2 (matplotlib.pyplot.Figure) – Distribution of Von Mises concentration parameter Kappa
-
neurochat.nc_plot.hd_spike(hd_data, ax=None)[source]¶ Plot the head-direction of the animal at the time of spiking-events.
This is presented in a polar scatter plot.
Parameters: - hd_data (dict) – Graphical data from the unit firing to head-direction correlation
- ax (matplotlib.pyplot.axis) – Axis object. If specified, the figure is plotted in this axis.
Returns: ax (matplotlib.pyplot.Axis) – Axis of the polar plot of head-direction during spiking events.
-
neurochat.nc_plot.hd_spike_time_lapse(hd_data)[source]¶ Plot the analysis outcome of head directional time-lapse analysis.
Parameters: hd_data (dict) – Graphical data from head-directional time-lapsed anlaysis Returns: fig (list of matplotlib.pyplot.Figure) – Time-lapsed spike-plots
-
neurochat.nc_plot.hd_time_shift(hd_shift_data)[source]¶ Plot the analysis outcome of head directional time-shift analysis.
Parameters: hd_shift_data (dict) – Graphical data from head-directional time-shift anlaysis Returns: - fig1 (matplotlib.pyplot.Figure) – Skaggs information content of head directional firing in shifted time of spiking events
- fig2 (matplotlib.pyplot.Figure) – Peak firing rate of head directional firing in shifted time of spiking events
- fig3 (matplotlib.pyplot.Figure) – Skaggs information content of head directional firing in shifted time of spiking events
-
neurochat.nc_plot.isi(isi_data, axes=[None, None, None], **kwargs)[source]¶ Plot Interspike interval histogram.
Also plots scatter plots of interval-before vs interval-after.
Parameters: isi_data (dict) – Graphical data from the ISI analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Histogram of ISI
- fig2 (matplotlib.pyplot.Figure) – Scatter plot of ISI-before vs ISI-after in loglog scale
- fig3 (matplotlib.pyplot.Figure) – 2D histogram of the ISI-before vs ISI-after in log-log scale
-
neurochat.nc_plot.isi_corr(isi_corr_data, ax=None, **kwargs)[source]¶ Plot ISI correlation.
Parameters: - isi_corr_data (dict) – Graphical data from the ISI correlation
- ax (matplotlib.axes.Axes) – Optional axes object to plot to.
- kwargs – title : str
Returns: fig (matplotlib.pyplot.Figure) – ISI correlation histogram
-
neurochat.nc_plot.largest_waveform(wave_data, ax=None)[source]¶ Plot the largest waveform in electrode groups.
Parameters: - wave_data (dict) – Graphical data form the Waveform analysis
- ax (matplotlib.axes.Axes) – Optional axes to plot to
Returns: matplotlib.pyplot.Figure – The figure plotted to, or None if an axes is provided
-
neurochat.nc_plot.lfp_spectrum(plot_data, ax=None, color=None, style='Solid')[source]¶ Plot LFP spectrum analysis data.
Parameters: - plot_data (dict) – Graphical data from the ISI correlation
- ax (matplotlib Axes) – Optional axes to plot into. Makes a new figure if this is None
- color (matplotlib supported color) – Default is None, the color of the plot line
- style (str) –
- options are:
- Solid - A thin flat line Dashed - A thicker dashed line
Returns: fig1 (matplotlib.pyplot.Figure) – Line plot of LFP spectrum using Welch’s method
-
neurochat.nc_plot.lfp_spectrum_tr(plot_data, ax=None, **kwargs)[source]¶ Plot time-resolved LFP spectrum analysis data.
Parameters: - plot_data (dict) – Graphical data from the ISI correlation
- ax (matplotlib axis) – An optional matplotlib axis object to plot to.
- kwargs –
- colormap : str
- The colormap to use. Defaults to “magma”.
Returns: fig1 (matplotlib.pyplot.Figure) – 3D plot of short-term FFT of the LFP signal
-
neurochat.nc_plot.loc_auto_corr(locAuto_data, **kwargs)[source]¶ Plot the analysis outcome of locational firing rate autocorrelation.
By default, colormap=”coolwarm”, style=”contour”. However, the old NC style was colormap=”default”, style=”digitized”. The old style produces very nice maps, but not colorblind.
Parameters: - locAuto_data (dict) – Graphical data from spatial correlation of firing map
- kwargs –
- colormap : str
- coolwarm is used if not specified “default” uses the standard red green intensity colours but these are bad for colorblindness.
- style : str
- What kind of map to plot - can be “contour”, “digitized” or “interpolated”
- levels : int
- The number of levels in the contour plot Defaults to 8
Returns: fig1 (matplotlib.pyplot.Figure) – Spatial correlation map
-
neurochat.nc_plot.loc_firing(place_data, **kwargs)[source]¶ Plot the analysis of locational correlation to spike-rate.
Parameters: place_data (dict) – Graphical data from the unit firing to head-directional correlation Returns: fig (matplotlib.pyplot.Figure) – Spike-plot and firing rate map in two subplots respectively
-
neurochat.nc_plot.loc_firing_and_place(place_data, smooth=True, **kwargs)[source]¶ Plot locational correlation to spike-rate with a place map.
The place map indicates groups of neighbouring bins with high firing rate.
Parameters: - place_data (dict) – Graphical data from the unit firing to head-directional correlation
- smooth (bool) – Whether to smooth the firing rate map plot.
- kwargs (keyword arguments) – Passed to loc_spike, loc_rate and loc_place_field.
Returns: fig (matplotlib.pyplot.Figure) – Spike-plot and firing rate map and place field in three subplots respectively
-
neurochat.nc_plot.loc_place_centroid(place_data, centroid)[source]¶ Plot firing map with the centroid of the highest firing place field.
The path of the animal in the arena is also returned.
Parameters: - place_data (dict) – Graphical data from the unit firing to head-directional correlation
- centroid (ndarray) – The centroid of the place field
Returns: fig (matplotlib.pyplot.Figure) – Spike-plot and firing rate map in two subplots respectively
-
neurochat.nc_plot.loc_place_field(place_data, ax=None)[source]¶ Plot the location of the place field(s) of the unit.
The place map indicates groups of neighbouring bins with high firing rate.
Parameters: - place_data (dict) – Graphical data from the correlation of unit firing to location of the animal
- ax (matplotlib.pyplot.axis) – Axis object. If specified, the figure is plotted in this axis.
Returns: ax (matplotlib.pyplot.Axis) – Axis of the spike-plot
-
neurochat.nc_plot.loc_rate(place_data, ax=None, smooth=True, **kwargs)[source]¶ Plot location vs spike rate.
By default, colormap=”viridis”, style=”contour”. However, the old NC style was colormap=”default”, style=”digitized”. The old style produces very nice maps, but not colorblind friendly.
Parameters: - place_data (dict) – Graphical data from the unit firing to locational correlation
- ax (matplotlib.pyplot.axis) – Axis object. If specified, the figure is plotted in this axis.
- kwargs –
- colormap : str
- viridis is used if not specified “default” uses the standard red green intensity colours but these are bad for colorblindness.
- style : str
- What kind of map to plot - can be “contour”, “digitized” or “interpolated”
- levels : int
- Number of contour regions.
Returns: ax (matplotlib.pyplot.Axis) – Axis of the firing rate map
-
neurochat.nc_plot.loc_rate_time_lapse(place_data, **kwargs)[source]¶ Plot the analysis outcome of locational time-lapse analysis.
Parameters: - place_data (dict) – Graphical data from locational time-lapsed anlaysis
- kwargs – keyword arguments passed to loc_rate
Returns: fig (list of matplotlib.pyplot.Figure) – Time-lapsed firing-rate map
-
neurochat.nc_plot.loc_shuffle(loc_shuffle_data)[source]¶ Plot the analysis outcome of locational shuffling analysis.
Parameters: loc_shuffle_data (dict) – Graphical data from head-directional shuffling anlaysis Returns: fig1 (matplotlib.pyplot.Figure) – Distribution of Skaggs IC, sparsity and spatial coherecne in three subplots
-
neurochat.nc_plot.loc_spike(place_data, ax=None, **kwargs)[source]¶ Plot the location of spiking-events (spike-plot) with trace of animal.
Parameters: - place_data (dict) – Graphical data from the correlation of unit firing to location of the animal
- ax (matplotlib.pyplot.axis) – Axis object. If specified, the figure is plotted in this axis.
- kwargs –
- color : matplotlib colour
- default red
- point_size : float
- default 2
Returns: ax (matplotlib.pyplot.Axis) – Axis of the spike-plot
-
neurochat.nc_plot.loc_spike_time_lapse(place_data)[source]¶ Plot the analysis outcome of locational time-lapse analysis.
Parameters: place_data (dict) – Graphical data from locational time-lapsed anlaysis Returns: fig (list of matplotlib.pyplot.Figure) – Time-lapsed spike-plots
-
neurochat.nc_plot.loc_time_shift(loc_shift_data)[source]¶ Plot the analysis outcome of locational time-shift analysis.
Parameters: loc_shift_data (dict) – Graphical data from head-directional time-shift anlaysis Returns: - fig1 (matplotlib.pyplot.Figure) – Skaggs information content of locational firing in shifted time of spiking events
- fig2 (matplotlib.pyplot.Figure) – Sparsity of locational firing in shifted time of spiking events
- fig3 (matplotlib.pyplot.Figure) – Coherence of locational firing in shifted time of spiking events
-
neurochat.nc_plot.multiple_regression(mra_data)[source]¶ Plot the result of multiple regression analysis.
Parameters: mra_data (dict) – Graphical data from multiple regression analysis Returns: fig1 (matplotlib.pyplot.Figure) – Bar plot of multiple regression analysis result
-
neurochat.nc_plot.plot_angle_between_points(points, xlim, ylim, ax=None)[source]¶ Plot the angle between three points.
Parameters: - points (list) – The list of points to plot the angle between
- xlim (float) – The upper xlimit of the graph
- ylim (float) – The upper ylimit of the graph
- ax (matplotlib.axes.Axes) – Optional axis to plot into
Returns: fig (matplotlib.pyplot.Figure) – The angle between the points
-
neurochat.nc_plot.plv(plv_data)[source]¶ Plot the analysis of Phase-locking value (PLV).
Parameters: plv_data (dict) – Graphical data from the PLV analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Plot of spike-triggered average (STA)
- fig2 (matplotlib.pyplot.Figure) – Plot of FFT of STA (fSTA), average power spectrum of spike-triggered LFP signals (STP), spike-field coherence and PLV in four subplots
-
neurochat.nc_plot.plv_bs(plv_data)[source]¶ Plot the analysis of bootstrapped Phase-locking value (PLV).
Parameters: plv_data (dict) – Graphical data from the time-resolved PLV analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Plot of fSTA
- fig2 (matplotlib.pyplot.Figure) – Plot of STP
- fig3 (matplotlib.pyplot.Figure) – Plot of SFC
-
neurochat.nc_plot.plv_tr(plv_data, **kwargs)[source]¶ Plot the analysis of time-resolved Phase-locking value (PLV).
Parameters: - plv_data (dict) – Graphical data from the time-resolved PLV analysis
- kwargs (keyword arguments) –
- colormap : str
- magma is used if not specified “default” uses the standard red green intensity colours but these are bad for colorblindness.
Returns: - fig1 (matplotlib.pyplot.Figure) – Plot of fSTA
- fig2 (matplotlib.pyplot.Figure) – Plot of STP
- fig3 (matplotlib.pyplot.Figure) – Plot of SFC
-
neurochat.nc_plot.print_place_cells(rows, cols=7, size_multiplier=4, wspace=0.3, hspace=0.3, placedata=None, wavedata=None, graphdata=None, isidata=None, headdata=None, thetadata=None, point_size=10, units=None, output=['Wave', 'Path', 'Place', 'HD', 'LowISI', 'Theta', 'HighISI'], fixed_color=None, burst_ms=5, color_isi=True, one_by_one=False, raster=True, hd_predict=True)[source]¶ Plot a summary plot useful for investigating place and spatial properties.
Data is entered for multiple cells in one go. This is a num_cells by num_plots gridded figure, unless one_by_one is True.
Parameters: - rows (int) – The number of rows in the plot. (number of cells)
- cols (int, optional) – The number of columns in the plot. Defaults to 7.
- size_multiplier (float, optional) – The size each extra row or column adds to the plot. Defaults to 4.
- wspace (float, optional) – The fraction of the horizontal spacing between plots. See matplotlib GridSpec. Defaults to 0.3.
- hspace (float, optional) – The fraction of the vertical spacing between plots. See matplotlib GridSpec. Defaults to 0.3.
- placedata (list of dict, optional) – The result of NData.place() for each cell
- wavedata (list of dict, optional) – The result of NData.wave_property() for each cell
- graphdata (list of dict, optional) – The result of NData.isi_cor() for each cell
- isidata (list of dict, optional) – The result of NData.isi() for each cell
- headdata (list of dict, optional) – The result of NData.hd_rate() for each cell
- thetadata (list of dict, optional) – The result of NData.theta_index() for each cell
- point_size (float) – The size of the dots of the spikes in the path map. Defaults to 10.
- units (list of int, optional) – The unit number of each cell entered
- output (list of str, optional) – What data to include in the final plot. The input should be a permutation and or subset of [“Wave”, “Path”, “Place”, “HD”, “LowISI”, “Theta”, “HighISI”]
- fixed_color (matplotlib compatible color, optional) – If provided, all cells are plotted with this color. By default, the cells are colored automatically differently.
- burst_ms (float, optional) – How long a burst is considered to be in milliseconds. Defaults to 5.
- color_isi (bool, optional) – Whether the output ISI graph should be blue (True) or black (False). Defaults to True.
- one_by_one (bool, optional) – Whether to return all the cells plots as one large grid figure or a list of figures, with one figure for each cell. Defaults to False.
- raster (bool, optional) – Whether to raster the individual plot elements. Defaults to True.
- hd_predict (bool, optional) – Whether to plot the predicted head directional firing or just regular. Defaults to False.
Returns: list of figs or Figure object – if one_by_one is True, returns a list of figures if one_by_one is False, returns a figure.
-
neurochat.nc_plot.rot_corr(plot_data)[source]¶ Plot rotational correlation of spatial autocorrelation map.
Parameters: plot_data (dict) – Graphical data from spatial correlation of firing map Returns: fig1 (matplotlib.pyplot.Figure) – Rotational correlation plot
-
neurochat.nc_plot.scatterplot_matrix(_data, names=[], **kwargs)[source]¶ Plot a scatterplot matrix of subplots.
Each row of “_data” is plotted against other rows, resulting in an nrows by nrows grid of subplots with the diagonal subplots labeled with “names”.
Additional keyword arguments are passed on to matplotlib’s “plot” command.
Returns the matplotlib figure object containing the subplot grid.
Parameters: - _data (np.ndarray) – 2D square data array to plot. Shape is (numvars, numvars)
- names (list of str) – Names to label the scatter plots with on the diagonal.
- **kwargs (keyword arguments) – Keyword args passed to matplotlib plot
Returns: matplotlib.pyplot.Figure
-
neurochat.nc_plot.set_backend(backend)[source]¶ Set the backend of Matplotlib.
Parameters: backend (str) – The new backend for Matplotlib Returns: None See also
matplotlib.pyplot.switch_backend()
-
neurochat.nc_plot.speed(speed_data)[source]¶ Plot the speed of the animal vs spike rate.
Parameters: speed_data (dict) – Graphical data from the unit firing to speed correlation Returns: fig1 (matplotlib.pyplot.Figure) – Scatter plot of speed vs spike-rate superimposed with fitted rate
-
neurochat.nc_plot.spike_phase(phase_data)[source]¶ Plot the analysis of spike-LFP phase locking.
Parameters: phase_data (dict) – Graphical data from the spike-LFP phase locking analysis Returns: - fig1 (matplotlib.pyplot.Figure) – Phase histogram
- fig2 (matplotlib.pyplot.Figure) – Phase distribution in circular plot
- fig3 (matplotlib.pyplot.Figure) – Phase-raster in one subplot, phase histogram in another
-
neurochat.nc_plot.spike_raster(events, xlim=None, colors=[0, 0, 0], ax=None, **kwargs)[source]¶ Plot the spike raster for a number of units.
Parameters: - events (list) – The positions of the events
- xlim (tuple) – Optional start and end of raster plot
- colors – Optional list of colours, or single colour - default black
- ax (matplotlib.axes.Axes) – Optional axis to plot into
- **kwargs – A set of keyword arguments to change graph appearance
Returns: fig (matplotlib.pyplot.Figure) – The spike raster
-
neurochat.nc_plot.stair_plot(dist_data)[source]¶ Plot the stairs of mean distance vs firing-rate bands.
Parameters: dist_data (dict) – Graphical data from border and gradient analysis Returns: fig1 (matplotlib.pyplot.Figure) – Mean distance distance from border vs firing-rate percentage
-
neurochat.nc_plot.theta_cell(plot_data, ax=None, **kwargs)[source]¶ Plot theta-modulated cell and theta-skipping cell analysis data.
Parameters: - plot_data (dict) – Graphical data from the theta-modulated cell
- ax (matplotlib.axes.Axes) – Optional axes object to plot to.
- kwargs – title : str
Returns: matplotlib.pyplot.Figure – ISI correlation histogram superimposed with fitted sinusoidal curve.
-
neurochat.nc_plot.wave_property(wave_data, plots=[2, 2])[source]¶ Plot mean +/-std of waveforms in electrode groups.
Parameters: - wave_data (dict) – Graphical data from the Waveform analysis
- plots (list) – Subplot shape. [2, 2] for tetrode setup
Returns: matplotlib.pyplot.Figure – Matlab figure object