cerebellum.analysis package¶
Module contents¶
Analysis and plotting tools for cerebellar cortex reconstructions.
- class cerebellar_models.analysis.BSBReport(scaffold: str | Scaffold, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
ReportClass interfacing a list of matplotlib plots for analysis of BSB reconstructions.
- Parameters:
cell_types_info (List[PlotTypeInfo])
- property cell_names¶
List of the name of the elements to plot.
- property labelled_abbreviations¶
- property labelled_cell_names¶
- class cerebellar_models.analysis.BasicSimulationReport(scaffold: str | Scaffold, simulation_name: str, folder_nio: str, time_from: float = 0, time_to: float = None, ignored_ct=None, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
SpikeSimulationReportSimulation report of the spike activity containing:
a plot with the raster and PSTH for each cell type,
a table plot storing the mean firing rate and ISI value for each cell type,
an instantaneous firing rate plot for each cell type,
an inter-spike interval histogram plot for each cell type,
a frequency spectrum plot for each cell type,
a legend plot
- Parameters:
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- class cerebellar_models.analysis.CellPlacement3D(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, ignored_ct=None, **kwargs)¶
Bases:
ScaffoldPlotPlot the position of the cells in the scaffold in 3D space.
- ignored_ct¶
List of cell type names to ignore in the plot.
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- static set_axes_equal(ax)¶
Make axes of 3D plot have equal scale so that spheres appear as spheres, cubes as cubes, etc.
- Parameters:
ax – a matplotlib axis, e.g., as output from plt.gca().
- class cerebellar_models.analysis.ConnectivityTable(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, dict_abv=None, **kwargs)¶
Bases:
TablePlot,ScaffoldPlotTable plot of the results of the connectivity for BSB Scaffold. This includes for each pair of connected cell types:
the number of synapses formed
the number of synapses per unique pair of cell.
the convergence ratio defined as the mean number of afferent connections created with a single postsynaptic cell
the divergence ratio defined as the mean number of efferent connections created with a single presynaptic cell
- dict_abv¶
Dictionary of abbreviations for cell types
- extract_strat_name(ps: ConnectivitySet)¶
Convert the name of a connection into its abbreviation. Connection strategy name is assumed to be in the form A_B, where A is the presynaptic type name and B is the postsynaptic type name.
- Parameters:
ps (ConnectivitySet)
- get_convergences()¶
Return a dictionary which gives for each connection name the divergence number of each unique postsynaptic cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_divergences()¶
Return a dictionary which gives for each connection name the divergence number of each unique presynaptic cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_nb_synapse_per_pair()¶
Return a dictionary which gives for each connection name the number of synapses per unique pair of cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_synapse_counts()¶
Return a dictionary which gives for each connection name the number of synapses formed. The plot needs to be updated.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.FiringRatesPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, kernel=None, dict_colors: dict = None, **kwargs)¶
Bases:
Spike2ColumnsInstantaneous firing rate plot for each cell type based on a time kernel. A firing rate signal is computed as the mean of the convolution of spike times for each neuron with the time kernel.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- kernel¶
Elephant kernel to filter the spike trains
- plot(relative_time=False, **kwargs)¶
Plot or replot the figure Calls the update function if needed.
- Parameters:
relative_time (bool) – If True, the x-axis values will be relative to the time interval.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.FrequencyPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, kernel=None, dict_colors: dict = None, **kwargs)¶
Bases:
FiringRatesPlotPlot of the frequency distribution analysis of the instantaneous firing rate signal.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- plot(max_freq=30.0, plot_bands=True, **kwargs)¶
Plot or replot the figure Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.ISIPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 50, dict_colors: dict = None, **kwargs)¶
Bases:
Spike2ColumnsInter-spike interval histogram plot for each cell type. For each neuron type, one mean inter-spike interval value is computed for each of its neuron.
- Parameters:
- nb_bins¶
Number of bins of the histogram.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- class cerebellar_models.analysis.Legend(fig_size: Tuple[float, float], nb_cols: int = 1, dict_colors: dict = None, dict_abbreviations: dict = None, dict_legend=None, **kwargs)¶
Bases:
PlotPatch Legend plot
- Parameters:
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- class cerebellar_models.analysis.PlacementTable(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, dict_abv=None, **kwargs)¶
Bases:
TablePlot,ScaffoldPlotTable plot of the results of the placement for BSB Scaffold. This includes the counts and density of each cell type.
- dict_abv¶
Dictionary of abbreviations for cell types
- extract_ct_name(ct: CellType)¶
Convert the name of a cell type to its abbreviation.
- Parameters:
ct (CellType)
- get_counts()¶
Return a dictionary which gives for each cell type the number placed in the Scaffold. The plot needs to be updated.
- get_densities()¶
- get_volumes()¶
Return a dictionary which gives for each cell type the volume occupied by its cells in the Scaffold. The plot needs to be updated.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.Plot(fig_size: Tuple[float, float] | ndarray, nb_rows: int = 1, nb_cols: int = 1, dict_colors=None, **kwargs)¶
Bases:
ABCMatplotlib plot class interface.
- axes¶
Matplotlib Axes of the plot
- clear()¶
Clear the figure axes
- dict_colors¶
Dictionary of element name to their color
- fig_size¶
Tuple size of the figure in inches.
- figure¶
Matplotlib Figure of the plot.
- get_axes()¶
Return figure axes as a flat list.
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- is_initialized¶
Flag to indicate if this plot figure has been initialized.
- is_plotted¶
Flag to indicate if this plot figure has been plotted.
- is_updated¶
Flag to indicate if this plot data has been updated.
- nb_cols¶
Number of sub-panel columns in the plot.
- nb_rows¶
Number of sub-panel rows in the plot.
- plot(*args, **kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- set_axis_off(axes=None)¶
Removes the borders of the provided axes. If none are provided, all axes’ borders will be removed.
- Parameters:
axes – List of matplotlib axes
- set_color(key: str, color: ndarray[float])¶
Set the color dictionary for a given key. Colors must be an array of type RGB or RGBA.
- show()¶
Show the figure. The figure will be plotted if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.PlotTypeInfo(name: str, color, abbreviation: str = None)¶
Bases:
objectClass storing information about element plotted, usually cell types or fibers.
- abbreviation¶
Abbreviation of the element to print in the plot.
- color¶
Color of the element.
- name¶
Name of the element.
- class cerebellar_models.analysis.RasterPSTHPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 30, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlotCombined raster plot and PSTH plot of the spiking activity results for each neuron type. The subplots are split in two columns.
- Parameters:
- clear()¶
Clear the figure axes
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- nb_bins¶
Number of bins for the PSTH subplot.
- class cerebellar_models.analysis.Report(cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
objectClass interfacing a list of matplotlib plots to save in an external file.
- Parameters:
cell_types_info (List[PlotTypeInfo])
- property abbreviations¶
Dictionary from the name of the elements to plot to its abbreviation.
- cell_types_info¶
List of PlotTypeInfo for each element to plot.
- property colors¶
Dictionary from the name of the elements to plot to its color.
- plots¶
Dictionary mapping the report’s plots’ name to their instance
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- print_report(output_name: str, dpi: int = 200, pad: int = 0, **kwargs)¶
Print the report and export it in a pdf file.
- save_plot(plot_name: str, output_name: str, dpi: int = 200, pad: int = 0, **kwargs)¶
Save one of the report’s plots as a separate figure.
- set_color(key: str, color: ndarray[float])¶
Set a color for an element to plot. Colors must be an array of type RGB or RGBA.
- set_plot_colors(plot: Plot)¶
Set the plot color dictionary according to the report’s
- Parameters:
plot (Plot)
- show()¶
Show all report’s plots one by one.
- show_plot(plot_name)¶
Show one of the report’s plots.
- class cerebellar_models.analysis.RunStructureReport(*args, _parent=None, _key=None, **kwargs)¶
Bases:
AfterConnectivityHookBSB postprocessing node to generate a scaffold structural report after running the connectivity jobs.
- get_node_name()¶
- postprocess()¶
- class cerebellar_models.analysis.ScaffoldPlot(fig_size: Tuple[float, float], scaffold: Scaffold, nb_rows: int = 1, nb_cols: int = 1, dict_colors: dict = None, **kwargs)¶
Bases:
PlotMatplotlib plot interface for BSB Scaffold.
- Parameters:
- static get_labelled_ct_name(ct_name, labels)¶
- static get_unique_labels(ps)¶
Get unique labels sets for a provided placement set Provide the default placement set label sets if the placement set is empty.
- property labelled_dict_colors¶
- set_scaffold(scaffold)¶
Set the scaffold of the plot.
- class cerebellar_models.analysis.SimResultsTable(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, dict_abv=None, **kwargs)¶
-
Table of the firing rates and inter-spike intervals for each cell type. The firing rate value of a cell type corresponds to the mean number of spike over the time interval, while its inter-spike interval corresponds to the mean of all mean inter-spike interval values computed for each of its neuron.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- dict_abv¶
Dictionary of abbreviations for cell types
- get_firing_rates()¶
Return a dictionary which gives for each cell type the firing rate of each neuron spiking. The plot needs to be updated.
- get_isis_values()¶
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.SortedPSTH(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 50, sample_size: int = 100, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlot- Parameters:
- nb_bins¶
Number of bins for the PSTH.
- plot()¶
Plot or replot the figure. Calls the update function if needed.
- sample_size¶
Maximum number of neurons to subsample for each population.
- class cerebellar_models.analysis.Spike2Columns(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlotUtility class to plot simulation results for each neuron type in a 2 columns fashion.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- class cerebellar_models.analysis.SpikeCorrelationPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, bin_size: float = array(5.) * ms, dict_colors: dict = None, dict_abv=None, **kwargs)¶
Bases:
SpikePlotSpike cross-correlation matrix plot for each cell type. Spike trains will be time binned before computing the pairwise Pearson’s correlation coefficients.
- Parameters:
- bin_size¶
Size of the time bins used to group spikes before computing correlation coefficients.
- dict_abv¶
Dictionary of abbreviations for cell types
- plot()¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.SpikePlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, **kwargs)¶
Bases:
ScaffoldPlotAbstract class for plotting the spiking simulation results of a BSB scaffold.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- property dt¶
- property filt_spikes¶
- property nb_neurons¶
- property populations¶
- spiking_results¶
Loaded spiking results.
- property time_from¶
- property time_to¶
- class cerebellar_models.analysis.SpikeSimulationReport(scaffold: str | Scaffold, simulation_name: str, folder_nio: str, time_from: float = 0, time_to: float = None, ignored_ct=None, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
BSBReportAbstract class for reports of simulation results of BSB scaffold.
- Parameters:
- property dt¶
- property filt_spikes¶
Filter the spike events for the time of the analysis.
- Returns:
Sliced List of SpikeTrain.
- Return type:
List[neo.core.SpikeTrain]
- property nb_neurons¶
- property populations¶
- property time_from¶
- property time_to¶
- class cerebellar_models.analysis.SpikingResults(scaffold: Scaffold, simulation_name, time_from: float, time_to: float, folder_nio: str, ignored_ct: list[str])¶
Bases:
objectClass used to load the results of the NEST simulations produced from a BSB scaffold.
- Parameters:
- property dt¶
Time step of the simulation in ms
- property filt_spikes: List[SpikeTrain]¶
Filter the spike events for the time of the analysis.
- Returns:
List of time-sliced SpikeTrain.
- Return type:
List[neo.core.SpikeTrain]
- property folder_nio¶
- ignored_ct¶
List of ignored cell type names
- load_spikes()¶
Load the spike trains from nio files.
- Returns:
Boolean numpy array of shape (N*M) storing spike events for each time step. N corresponds to the number of time steps, M to the number of neuron. Neurons are sorted by type.
List of number of unique neuron per type.
List of cell type names.
- Return type:
Tuple[List[neo.core.SpikeTrain], numpy.ndarray[int], List[str]]
- property scaffold¶
BSB Scaffold used as reference for simulation results.
- property simulation_name¶
Name of the simulation as defined in the scaffold configuration.
- property time_from¶
Start time of the analysis
- property time_to¶
End time of the analysis. By default, this corresponds to the simulation duration.
- class cerebellar_models.analysis.StructureReport(scaffold: str | Scaffold, cell_type_info: List[PlotTypeInfo] = None)¶
Bases:
BSBReportReport of the scaffold neural network structure containing:
a table listing the number and density of each cell type placed.
a table listing the number, convergence and divergence of connections for each connected cell type pair
a 3D plot showing the soma location of each cell in the circuit.
a legend plot
- Parameters:
cell_type_info (List[PlotTypeInfo])
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- class cerebellar_models.analysis.TablePlot¶
Bases:
objectMixin for plotting tables with matplotlib
- columns = []¶
Names of the table’s columns
- plot_table(**kwargs)¶
Plot the table in the Figure.
- reset_table()¶
Update the values of the table.
- rows = []¶
Names of the table’s rows
- table_values = []¶
List of list of string values to put in the table
- cerebellar_models.analysis.extract_isis(spikes, dt)¶
Extract inter-spike intervals from a SpikeTrain object. One mean inter-spike interval value is computed for each neuron.
- Parameters:
spikes (neo.core.SpikeTrain) – population SpikeTrain object
dt (float) – time step
- Returns:
list of inter-spike intervals
- Return type:
List[float]
- cerebellar_models.analysis.get_correlation_coefficients(spiking_results, bin_size)¶
Get the spike cross-correlation matrix for each cell type. Spike trains will be time binned before computing the pairwise Pearson’s correlation coefficients.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
bin_size (float) – size of time bin
- Returns:
numpy array 2D matrix storing the Pearson correlation coefficients between each neuron population.
- Return type:
- cerebellar_models.analysis.get_firing_rates(spiking_results: SpikingResults, kernel=None) ndarray¶
Get the instantaneous firing rate for each cell type from SpikingResults based on a time kernel.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
kernel – Elephant kernel to filter the spike trains
- Returns:
numpy array storing instantaneous firing rates for each population, for each time step.
- Return type:
- cerebellar_models.analysis.get_frequencies(spiking_results, firing_rates)¶
Get the Fast Fourier Transform on instantaneous firing rates signal.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
firing_rates – numpy array storing instantaneous firing rates for each population, for each time step.
- Returns:
Tuple of lists of frequencies and their corresponding FFT powers.
- Return type:
Tuple[numpy.ndarray[float], numpy.ndarray[float]]
Submodules¶
cerebellar_models.analysis.plots module¶
Module for abstract classes interfacing matplotlib plots.
- class cerebellar_models.analysis.plots.Legend(fig_size: Tuple[float, float], nb_cols: int = 1, dict_colors: dict = None, dict_abbreviations: dict = None, dict_legend=None, **kwargs)¶
Bases:
PlotPatch Legend plot
- Parameters:
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- class cerebellar_models.analysis.plots.Plot(fig_size: Tuple[float, float] | ndarray, nb_rows: int = 1, nb_cols: int = 1, dict_colors=None, **kwargs)¶
Bases:
ABCMatplotlib plot class interface.
- axes¶
Matplotlib Axes of the plot
- clear()¶
Clear the figure axes
- dict_colors¶
Dictionary of element name to their color
- fig_size¶
Tuple size of the figure in inches.
- figure¶
Matplotlib Figure of the plot.
- get_axes()¶
Return figure axes as a flat list.
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- is_initialized¶
Flag to indicate if this plot figure has been initialized.
- is_plotted¶
Flag to indicate if this plot figure has been plotted.
- is_updated¶
Flag to indicate if this plot data has been updated.
- nb_cols¶
Number of sub-panel columns in the plot.
- nb_rows¶
Number of sub-panel rows in the plot.
- plot(*args, **kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- set_axis_off(axes=None)¶
Removes the borders of the provided axes. If none are provided, all axes’ borders will be removed.
- Parameters:
axes – List of matplotlib axes
- set_color(key: str, color: ndarray[float])¶
Set the color dictionary for a given key. Colors must be an array of type RGB or RGBA.
- show()¶
Show the figure. The figure will be plotted if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.plots.ScaffoldPlot(fig_size: Tuple[float, float], scaffold: Scaffold, nb_rows: int = 1, nb_cols: int = 1, dict_colors: dict = None, **kwargs)¶
Bases:
PlotMatplotlib plot interface for BSB Scaffold.
- Parameters:
- static get_labelled_ct_name(ct_name, labels)¶
- static get_unique_labels(ps)¶
Get unique labels sets for a provided placement set Provide the default placement set label sets if the placement set is empty.
- property labelled_dict_colors¶
- set_scaffold(scaffold)¶
Set the scaffold of the plot.
cerebellar_models.analysis.report module¶
Module for the Report class.
- class cerebellar_models.analysis.report.BSBReport(scaffold: str | Scaffold, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
ReportClass interfacing a list of matplotlib plots for analysis of BSB reconstructions.
- Parameters:
cell_types_info (List[PlotTypeInfo])
- property cell_names¶
List of the name of the elements to plot.
- property labelled_abbreviations¶
- property labelled_cell_names¶
- cerebellar_models.analysis.report.LIST_CT_INFO = [<cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>, <cerebellar_models.analysis.report.PlotTypeInfo object>]¶
Cell and fiber information for plotting cerebellum BSB circuit.
- class cerebellar_models.analysis.report.PlotTypeInfo(name: str, color, abbreviation: str = None)¶
Bases:
objectClass storing information about element plotted, usually cell types or fibers.
- abbreviation¶
Abbreviation of the element to print in the plot.
- color¶
Color of the element.
- name¶
Name of the element.
- class cerebellar_models.analysis.report.Report(cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
objectClass interfacing a list of matplotlib plots to save in an external file.
- Parameters:
cell_types_info (List[PlotTypeInfo])
- property abbreviations¶
Dictionary from the name of the elements to plot to its abbreviation.
- cell_types_info¶
List of PlotTypeInfo for each element to plot.
- property colors¶
Dictionary from the name of the elements to plot to its color.
- plots¶
Dictionary mapping the report’s plots’ name to their instance
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- print_report(output_name: str, dpi: int = 200, pad: int = 0, **kwargs)¶
Print the report and export it in a pdf file.
- save_plot(plot_name: str, output_name: str, dpi: int = 200, pad: int = 0, **kwargs)¶
Save one of the report’s plots as a separate figure.
- set_color(key: str, color: ndarray[float])¶
Set a color for an element to plot. Colors must be an array of type RGB or RGBA.
- set_plot_colors(plot: Plot)¶
Set the plot color dictionary according to the report’s
- Parameters:
plot (Plot)
- show()¶
Show all report’s plots one by one.
- show_plot(plot_name)¶
Show one of the report’s plots.
cerebellar_models.analysis.structure_analysis module¶
Module for the plots and reports related to the structural analysis of BSB scaffold.
- class cerebellar_models.analysis.structure_analysis.AdjacencyMatrix(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, ignored_ct=None, dict_abv=None, **kwargs)¶
Bases:
ScaffoldPlotPlot showing the cell-type adjacency matrix of a scaffold.
- adjacency_matrix¶
Cell to cell adjacency matrix.
- dict_abv¶
Dictionary of abbreviations for cell types
- grouped_matrix¶
Cell type population to cell type population adjacency matrix.
- ignored_ct¶
List of cell type names to ignore in the plot.
- normalize()¶
Normalization function for resulting the adjacency matrix.
- plot(log_scale=True, **kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.structure_analysis.CellPlacement3D(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, ignored_ct=None, **kwargs)¶
Bases:
ScaffoldPlotPlot the position of the cells in the scaffold in 3D space.
- ignored_ct¶
List of cell type names to ignore in the plot.
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- static set_axes_equal(ax)¶
Make axes of 3D plot have equal scale so that spheres appear as spheres, cubes as cubes, etc.
- Parameters:
ax – a matplotlib axis, e.g., as output from plt.gca().
- class cerebellar_models.analysis.structure_analysis.ConnectivityTable(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, dict_abv=None, **kwargs)¶
Bases:
TablePlot,ScaffoldPlotTable plot of the results of the connectivity for BSB Scaffold. This includes for each pair of connected cell types:
the number of synapses formed
the number of synapses per unique pair of cell.
the convergence ratio defined as the mean number of afferent connections created with a single postsynaptic cell
the divergence ratio defined as the mean number of efferent connections created with a single presynaptic cell
- dict_abv¶
Dictionary of abbreviations for cell types
- extract_strat_name(ps: ConnectivitySet)¶
Convert the name of a connection into its abbreviation. Connection strategy name is assumed to be in the form A_B, where A is the presynaptic type name and B is the postsynaptic type name.
- Parameters:
ps (ConnectivitySet)
- get_convergences()¶
Return a dictionary which gives for each connection name the divergence number of each unique postsynaptic cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_divergences()¶
Return a dictionary which gives for each connection name the divergence number of each unique presynaptic cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_nb_synapse_per_pair()¶
Return a dictionary which gives for each connection name the number of synapses per unique pair of cell. The plot needs to be updated.
- Return type:
Dict[str, numpy.ndarray[int]]
- get_synapse_counts()¶
Return a dictionary which gives for each connection name the number of synapses formed. The plot needs to be updated.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.structure_analysis.PlacementTable(fig_size: Tuple[float, float], scaffold: Scaffold = None, dict_colors=None, dict_abv=None, **kwargs)¶
Bases:
TablePlot,ScaffoldPlotTable plot of the results of the placement for BSB Scaffold. This includes the counts and density of each cell type.
- dict_abv¶
Dictionary of abbreviations for cell types
- extract_ct_name(ct: CellType)¶
Convert the name of a cell type to its abbreviation.
- Parameters:
ct (CellType)
- get_counts()¶
Return a dictionary which gives for each cell type the number placed in the Scaffold. The plot needs to be updated.
- get_densities()¶
- get_volumes()¶
Return a dictionary which gives for each cell type the volume occupied by its cells in the Scaffold. The plot needs to be updated.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.structure_analysis.RunStructureReport(*args, _parent=None, _key=None, **kwargs)¶
Bases:
AfterConnectivityHookBSB postprocessing node to generate a scaffold structural report after running the connectivity jobs.
- get_node_name()¶
- postprocess()¶
- class cerebellar_models.analysis.structure_analysis.StructureReport(scaffold: str | Scaffold, cell_type_info: List[PlotTypeInfo] = None)¶
Bases:
BSBReportReport of the scaffold neural network structure containing:
a table listing the number and density of each cell type placed.
a table listing the number, convergence and divergence of connections for each connected cell type pair
a 3D plot showing the soma location of each cell in the circuit.
a legend plot
- Parameters:
cell_type_info (List[PlotTypeInfo])
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- class cerebellar_models.analysis.structure_analysis.TablePlot¶
Bases:
objectMixin for plotting tables with matplotlib
- columns = []¶
Names of the table’s columns
- plot_table(**kwargs)¶
Plot the table in the Figure.
- reset_table()¶
Update the values of the table.
- rows = []¶
Names of the table’s rows
- table_values = []¶
List of list of string values to put in the table
cerebellar_models.analysis.spike_plots module¶
Module for the plots and reports related to the simulation analysis of BSB scaffold.
- class cerebellar_models.analysis.spike_plots.BasicSimulationReport(scaffold: str | Scaffold, simulation_name: str, folder_nio: str, time_from: float = 0, time_to: float = None, ignored_ct=None, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
SpikeSimulationReportSimulation report of the spike activity containing:
a plot with the raster and PSTH for each cell type,
a table plot storing the mean firing rate and ISI value for each cell type,
an instantaneous firing rate plot for each cell type,
an inter-spike interval histogram plot for each cell type,
a frequency spectrum plot for each cell type,
a legend plot
- Parameters:
- preprocessing()¶
Function to apply modifications to the report’s plots after the plotting is done.
- class cerebellar_models.analysis.spike_plots.FiringRatesPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, kernel=None, dict_colors: dict = None, **kwargs)¶
Bases:
Spike2ColumnsInstantaneous firing rate plot for each cell type based on a time kernel. A firing rate signal is computed as the mean of the convolution of spike times for each neuron with the time kernel.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- kernel¶
Elephant kernel to filter the spike trains
- plot(relative_time=False, **kwargs)¶
Plot or replot the figure Calls the update function if needed.
- Parameters:
relative_time (bool) – If True, the x-axis values will be relative to the time interval.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.spike_plots.FrequencyPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, kernel=None, dict_colors: dict = None, **kwargs)¶
Bases:
FiringRatesPlotPlot of the frequency distribution analysis of the instantaneous firing rate signal.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- plot(max_freq=30.0, plot_bands=True, **kwargs)¶
Plot or replot the figure Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.spike_plots.ISIPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 50, dict_colors: dict = None, **kwargs)¶
Bases:
Spike2ColumnsInter-spike interval histogram plot for each cell type. For each neuron type, one mean inter-spike interval value is computed for each of its neuron.
- Parameters:
- nb_bins¶
Number of bins of the histogram.
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- class cerebellar_models.analysis.spike_plots.RasterPSTHPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 30, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlotCombined raster plot and PSTH plot of the spiking activity results for each neuron type. The subplots are split in two columns.
- Parameters:
- clear()¶
Clear the figure axes
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- nb_bins¶
Number of bins for the PSTH subplot.
- class cerebellar_models.analysis.spike_plots.SimResultsTable(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, dict_abv=None, **kwargs)¶
-
Table of the firing rates and inter-spike intervals for each cell type. The firing rate value of a cell type corresponds to the mean number of spike over the time interval, while its inter-spike interval corresponds to the mean of all mean inter-spike interval values computed for each of its neuron.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- dict_abv¶
Dictionary of abbreviations for cell types
- get_firing_rates()¶
Return a dictionary which gives for each cell type the firing rate of each neuron spiking. The plot needs to be updated.
- get_isis_values()¶
- plot(**kwargs)¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.spike_plots.SortedPSTH(fig_size: Tuple[float, float], spiking_results: SpikingResults, nb_bins: int = 50, sample_size: int = 100, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlot- Parameters:
- nb_bins¶
Number of bins for the PSTH.
- plot()¶
Plot or replot the figure. Calls the update function if needed.
- sample_size¶
Maximum number of neurons to subsample for each population.
- class cerebellar_models.analysis.spike_plots.Spike2Columns(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, **kwargs)¶
Bases:
SpikePlotUtility class to plot simulation results for each neuron type in a 2 columns fashion.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- init_plot(**kwargs)¶
Initialize the plot and return figure and axes.
- class cerebellar_models.analysis.spike_plots.SpikeCorrelationPlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, bin_size: float = array(5.) * ms, dict_colors: dict = None, dict_abv=None, **kwargs)¶
Bases:
SpikePlotSpike cross-correlation matrix plot for each cell type. Spike trains will be time binned before computing the pairwise Pearson’s correlation coefficients.
- Parameters:
- bin_size¶
Size of the time bins used to group spikes before computing correlation coefficients.
- dict_abv¶
Dictionary of abbreviations for cell types
- plot()¶
Plot or replot the figure. Calls the update function if needed.
- update()¶
Update function to prepare the data before plotting.
- class cerebellar_models.analysis.spike_plots.SpikePlot(fig_size: Tuple[float, float], spiking_results: SpikingResults, dict_colors: dict = None, **kwargs)¶
Bases:
ScaffoldPlotAbstract class for plotting the spiking simulation results of a BSB scaffold.
- Parameters:
spiking_results (SpikingResults)
dict_colors (dict)
- property dt¶
- property filt_spikes¶
- property nb_neurons¶
- property populations¶
- spiking_results¶
Loaded spiking results.
- property time_from¶
- property time_to¶
- class cerebellar_models.analysis.spike_plots.SpikeSimulationReport(scaffold: str | Scaffold, simulation_name: str, folder_nio: str, time_from: float = 0, time_to: float = None, ignored_ct=None, cell_types_info: List[PlotTypeInfo] = None)¶
Bases:
BSBReportAbstract class for reports of simulation results of BSB scaffold.
- Parameters:
- property dt¶
- property filt_spikes¶
Filter the spike events for the time of the analysis.
- Returns:
Sliced List of SpikeTrain.
- Return type:
List[neo.core.SpikeTrain]
- property nb_neurons¶
- property populations¶
- property time_from¶
- property time_to¶
cerebellar_models.analysis.spiking_results module¶
Module for loading spiking results from BSB-NEST simulations and analysing them with Elephant.
- class cerebellar_models.analysis.spiking_results.SpikingResults(scaffold: Scaffold, simulation_name, time_from: float, time_to: float, folder_nio: str, ignored_ct: list[str])¶
Bases:
objectClass used to load the results of the NEST simulations produced from a BSB scaffold.
- Parameters:
- property dt¶
Time step of the simulation in ms
- property filt_spikes: List[SpikeTrain]¶
Filter the spike events for the time of the analysis.
- Returns:
List of time-sliced SpikeTrain.
- Return type:
List[neo.core.SpikeTrain]
- property folder_nio¶
- ignored_ct¶
List of ignored cell type names
- load_spikes()¶
Load the spike trains from nio files.
- Returns:
Boolean numpy array of shape (N*M) storing spike events for each time step. N corresponds to the number of time steps, M to the number of neuron. Neurons are sorted by type.
List of number of unique neuron per type.
List of cell type names.
- Return type:
Tuple[List[neo.core.SpikeTrain], numpy.ndarray[int], List[str]]
- property scaffold¶
BSB Scaffold used as reference for simulation results.
- property simulation_name¶
Name of the simulation as defined in the scaffold configuration.
- property time_from¶
Start time of the analysis
- property time_to¶
End time of the analysis. By default, this corresponds to the simulation duration.
- cerebellar_models.analysis.spiking_results.extract_isis(spikes, dt)¶
Extract inter-spike intervals from a SpikeTrain object. One mean inter-spike interval value is computed for each neuron.
- Parameters:
spikes (neo.core.SpikeTrain) – population SpikeTrain object
dt (float) – time step
- Returns:
list of inter-spike intervals
- Return type:
List[float]
- cerebellar_models.analysis.spiking_results.get_correlation_coefficients(spiking_results, bin_size)¶
Get the spike cross-correlation matrix for each cell type. Spike trains will be time binned before computing the pairwise Pearson’s correlation coefficients.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
bin_size (float) – size of time bin
- Returns:
numpy array 2D matrix storing the Pearson correlation coefficients between each neuron population.
- Return type:
- cerebellar_models.analysis.spiking_results.get_firing_rates(spiking_results: SpikingResults, kernel=None) ndarray¶
Get the instantaneous firing rate for each cell type from SpikingResults based on a time kernel.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
kernel – Elephant kernel to filter the spike trains
- Returns:
numpy array storing instantaneous firing rates for each population, for each time step.
- Return type:
- cerebellar_models.analysis.spiking_results.get_frequencies(spiking_results, firing_rates)¶
Get the Fast Fourier Transform on instantaneous firing rates signal.
- Parameters:
spiking_results (SpikingResults) – simulation spike results
firing_rates – numpy array storing instantaneous firing rates for each population, for each time step.
- Returns:
Tuple of lists of frequencies and their corresponding FFT powers.
- Return type:
Tuple[numpy.ndarray[float], numpy.ndarray[float]]
- cerebellar_models.analysis.spiking_results.get_spike_matrix(spikes, dt)¶
Extract the 2D boolean matrix of the spiking activity for each neuron in the SpikeTrain object. Neurons are sorted according to their NEST id.
- Parameters:
spikes (neo.core.SpikeTrain) – population SpikeTrain object
dt (float) – time step
- Returns:
numpy array 2D boolean matrix storing spike events for each neuron, for each time step.
- Return type: