bmtk.analyzer package

Submodules

bmtk.analyzer.cell_vars module

bmtk.analyzer.compartment module

bmtk.analyzer.compartment.plot_traces(config_file=None, report_name=None, population=None, report_path=None, group_by=None, group_excludes=None, nodes_file=None, node_types_file=None, node_ids=None, sections='origin', average=False, times=None, title=None, show_legend=None, show=True, save_as=None, plt_style=None)[source]

Plot compartment variables (eg Membrane Voltage, Calcium conc.) traces from the output of simulation. Will attempt to look in the SONATA simulation configuration json “reports” sections for any matching “membrane_report” outputs with a matching report_name:

plot_traces(config_file='config.json', report_name='membrane_potential')

If the path the the report is different (or missing) than what’s in the SONATA config then use the “report_path” option instead:

plot_traces(report_path='/my/path/to/membrane_potential.h5')

To display the traces of only a select number of nodes you can filter using the node_ids options:

plot_traces(config_file='config.json', node_ids=[10, 20, 30, 40, 50])

The average option will find the mean value of all the traces to display:

plot_traces(config_file='config.json', node_ids=range(50, 100), average=True)

You may also group together different subsets of nodes and display multiple averages based on certain attributes of the network, which can be done using the group_by key. The group_exlcudes option will exclude certain groups. For example if you want to plot the averaged membrane potential across each cortical “layer”, exclude L1:

plot_traces(config_file='config.json', report='membrane_potential', group_by='layer', group_excludes='L1')
Parameters:
  • config_file – path to SONATA simulation configuration.

  • report_name – name of the membrane_report “report” which will be plotted. If only one compartment report in the simulation config then function will find it automatically.

  • population – string. If the report more than one population of nodes, use this to determine which nodes to plot. If only one population exists and population=None then the function will find it by default.

  • report_path – Path to SONATA compartment report file. Do not use with “config_file” and “report_name” options.

  • group_by – Attribute of the “nodes” file used to group and average subsets of nodes.

  • group_excludes – list of strings or None. When using the “group_by”, allows users to exclude certain groupings based on the attribute value.

  • nodes_file – path to nodes hdf5 file containing “population”. By default this will be resolved using the config.

  • node_types_file – path to node-types csv file containing “population”. By default this will be resolved using the config.

  • node_ids – int or list of integers. Individual node to display the variable.

  • sections – ‘origin’, ‘all’, or list of ids, Compartments/elements to display, By default will only show values at the soma.

  • average – If true will display average of “node_ids”. Default: False

  • times – (float, float), start and stop times of simulation. By default will get values from simulation configs “run” section.

  • title – str, adds a title to the plot. If None (default) then name will be automatically generated using the report_name.

  • show_legend – Set True or False to determine if legend should be displayed on the plot. The default (None) function itself will guess if legend should be shown.

  • show – bool to display or not display plot. default True.

  • save_as – None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not save plot.

Returns:

matplotlib figure.Figure object

bmtk.analyzer.ecp module

bmtk.analyzer.ecp.plot_ecp(config_file=None, report_name=None, ecp_path=None, title=None, show=True)[source]

bmtk.analyzer.firing_rates module

bmtk.analyzer.firing_rates.convert_rates(rates_file)[source]
bmtk.analyzer.firing_rates.firing_rates_equal(rates_file1, rates_file2, err=0.0001)[source]
bmtk.analyzer.firing_rates.plot_rates_popnet(cell_models_file, rates_file, model_keys=None, save_as=None, show_plot=True)[source]

Initial method for plotting popnet output

Parameters:
  • cell_models_file

  • rates_file

  • model_keys

  • save_as

  • show_plot

Returns:

bmtk.analyzer.io_tools module

bmtk.analyzer.io_tools.load_config(config)[source]

bmtk.analyzer.spike_trains module

bmtk.analyzer.spike_trains.plot_raster(config_file=None, population=None, with_histogram=True, times=None, title=None, show=True, save_as=None, group_by=None, group_excludes=None, spikes_file=None, nodes_file=None, node_types_file=None, plt_style=None)[source]

Create a raster plot (plus optional histogram) from the results of the simulation.

Will using the SONATA simulation configs “output” section to locate where the spike-trains file was created and display them:

plot_raster(config_file='config.json')

If the path the the report is different (or missing) than what’s in the SONATA config then use the “spikes_file” option instead:

plot_raster(spikes_file='/my/path/to/membrane_potential.h5')

You may also group together different subsets of nodes using specific attributes of the network using the “group_by” option, and the “group_excludes” option to exclude specific subsets. For example to color and label different subsets of nodes based on their cortical “layer”, but exlcude plotting the L1 nodes:

plot_raster(config_file='config.json', groupy_by='layer', group_excludes='L1')
Parameters:
  • config_file – path to SONATA simulation configuration.

  • population – name of the membrane_report “report” which will be plotted. If only one compartment report in the simulation config then function will find it automatically.

  • with_histogram – If True the a histogram will be shown as a small subplot below the scatter plot. Default True.

  • times – (float, float), start and stop times of simulation. By default will get values from simulation configs “run” section.

  • title – str, adds a title to the plot. If None (default) then name will be automatically generated using the report_name.

  • show – bool to display or not display plot. default True.

  • save_as – None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not save plot.

  • group_by – Attribute of the “nodes” file used to group and average subsets of nodes.

  • group_excludes – list of strings or None. When using the “group_by”, allows users to exclude certain groupings based on the attribute value.

  • spikes_file – Path to SONATA spikes file. Do not use with “config_file” options.

  • nodes_file – path to nodes hdf5 file containing “population”. By default this will be resolved using the config.

  • node_types_file – path to node-types csv file containing “population”. By default this will be resolved using the config.

Returns:

matplotlib figure.Figure object

bmtk.analyzer.spike_trains.plot_rates(config_file=None, population=None, smoothing=False, smoothing_params=None, times=None, title=None, show=True, save_as=None, group_by=None, group_excludes=None, spikes_file=None, nodes_file=None, node_types_file=None, plt_style=None)[source]

Calculate and plot the rates of each node recorded during the simulation - averaged across the entirety of the simulation.

Will using the SONATA simulation configs “output” section to locate where the spike-trains file was created and display them:

plot_rates(config_file='config.json')

If the path the the report is different (or missing) than what’s in the SONATA config then use the “spikes_file” option instead:

plot_rates(spikes_file='/my/path/to/membrane_potential.h5')

You may also group together different subsets of nodes using specific attributes of the network using the “group_by” option, and the “group_excludes” option to exclude specific subsets. For example to color and label different subsets of nodes based on their cortical “layer”, but exlcude plotting the L1 nodes:

plot_rates(config_file='config.json', groupy_by='layer', group_excludes='L1')
Parameters:
  • config_file – path to SONATA simulation configuration.

  • population – name of the membrane_report “report” which will be plotted. If only one compartment report in the simulation config then function will find it automatically.

  • smoothing – Bool or function. Used to smooth the data. By default (False) no smoothing will be done. If True will using a moving average smoothing function. Or use a function pointer.

  • smoothing_params – dict, parameters when using a function pointer smoothing value.

  • times – (float, float), start and stop times of simulation. By default will get values from simulation configs “run” section.

  • title – str, adds a title to the plot. If None (default) then name will be automatically generated using the report_name.

  • show – bool to display or not display plot. default True.

  • save_as – None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not save plot.

  • group_by – Attribute of the “nodes” file used to group and average subsets of nodes.

  • group_excludes – list of strings or None. When using the “group_by”, allows users to exclude certain groupings based on the attribute value.

  • spikes_file – Path to SONATA spikes file. Do not use with “config_file” options.

  • nodes_file – Path to nodes hdf5 file containing “population”. By default this will be resolved using the config.

  • node_types_file – Path to node-types csv file containing “population”. By default this will be resolved using the config.

Returns:

matplotlib figure.Figure object

bmtk.analyzer.spike_trains.plot_rates_boxplot(config_file=None, population=None, times=None, title=None, show=True, save_as=None, group_by=None, group_excludes=None, spikes_file=None, nodes_file=None, node_types_file=None, plt_style=None)[source]

Creates a box plot of the firing rates taken from nodes recorded during the simulation.

Will using the SONATA simulation configs “output” section to locate where the spike-trains file was created and display them:

plot_rates_boxplot(config_file='config.json')

If the path the the report is different (or missing) than what’s in the SONATA config then use the “spikes_file” option instead:

plot_rates_boxplot(spikes_file='/my/path/to/membrane_potential.h5')

You may also group together different subsets of nodes using specific attributes of the network using the “group_by” option, and the “group_excludes” option to exclude specific subsets. For example to color and label different subsets of nodes based on their cortical “layer”, but exlcude plotting the L1 nodes:

plot_rates_boxplot(config_file='config.json', groupy_by='layer', group_excludes='L1')
Parameters:
  • config_file – path to SONATA simulation configuration.

  • population – name of the membrane_report “report” which will be plotted. If only one compartment report in the simulation config then function will find it automatically.

  • times – (float, float), start and stop times of simulation. By default will get values from simulation configs “run” section.

  • title – str, adds a title to the plot. If None (default) then name will be automatically generated using the report_name.

  • show – bool to display or not display plot. default True.

  • save_as – None or str: file-name/path to save the plot as a png/jpeg/etc. If None or empty string will not save plot.

  • group_by – Attribute of the “nodes” file used to group and average subsets of nodes.

  • group_excludes – list of strings or None. When using the “group_by”, allows users to exclude certain groupings based on the attribute value.

  • spikes_file – Path to SONATA spikes file. Do not use with “config_file” options.

  • nodes_file – Path to nodes hdf5 file containing “population”. By default this will be resolved using the config.

  • node_types_file – Path to node-types csv file containing “population”. By default this will be resolved using the config.

Returns:

matplotlib figure.Figure object

bmtk.analyzer.spike_trains.spike_statistics(spikes_file, simulation=None, population=None, simulation_time=None, group_by=None, network=None, config_file=None, **filterparams)[source]

Get spike statistics (firing_rate, counts, inter-spike interval) of the nodes.

Parameters:
  • spikes_file – Path to SONATA spikes file. Do not use with “config_file” options.

  • simulation

  • population

  • simulation_time

  • groupby

  • network

  • config_file

  • filterparams

Returns:

pandas dataframe

bmtk.analyzer.spike_trains.to_dataframe(config_file, spikes_file=None, population=None)[source]
Parameters:
  • config_file

  • spikes_file

  • population

Returns:

bmtk.analyzer.spikes_analyzer module

bmtk.analyzer.spikes_analyzer.get_mean_firing_rates(spike_gids, node_ids, tstop_msec)[source]

Compute mean firing rate over the duration of the simulation

Parameters:
  • spike_gids – gids of cells which spiked

  • node_ids – np.array of node_ids

Return mean_firing_rate:

np.array mean firing rates

bmtk.analyzer.spikes_analyzer.spike_files_equal(spikes_txt_1, spikes_txt_2, err=0.0001)[source]
bmtk.analyzer.spikes_analyzer.spikes2dict(spikes_file)[source]
bmtk.analyzer.spikes_analyzer.spikes_equal_in_window(spikes1, spikes2, twindow)[source]

Compare spikes within a time window :param spikes1: dict with “time” and “gid” arrays for raster 1 :param spikes2: dict with “time” and “gid” arrays for raster 2 :param twindow: [tstart,tend] time window

Return boolean:

True if equal, False if different

bmtk.analyzer.spikes_loader module

bmtk.analyzer.spikes_loader.load_spikes(file_name, trial_name=None)[source]

Loads spikes from multiple file formats

Parameters:
  • file_name – name of spike file

  • trian_name – name of a trial within a spike file

Return spikes:

dict with spikes

bmtk.analyzer.spikes_loader.load_spikes_from_h5(file_name)[source]

Load spikes from the hdf5 file

Parameters:
  • file_name – name of spike file

  • trian_name – name of a trial within a spike file

Return spikes:

dict with spikes

bmtk.analyzer.spikes_loader.load_spikes_from_nwb(file_name, trial_name)[source]

Load spikes from the nwb file

Parameters:
  • file_name – name of spike file

  • trian_name – name of a trial within a spike file

Return spikes:

dict with spikes

bmtk.analyzer.spikes_loader.load_spikes_from_txt(file_name)[source]

Load spikes from the txt file

Parameters:
  • file_name – name of spike file

  • trian_name – name of a trial within a spike file

Return spikes:

dict with spikes

bmtk.analyzer.utils module

bmtk.analyzer.utils.listify(files)[source]

Module contents

bmtk.analyzer.node_types_table(node_types_file, population)[source]
bmtk.analyzer.nodes_table(nodes_file, population)[source]
bmtk.analyzer.plot_calcium(cell_vars_h5=None, config_file=None, gids=None, show_plot=True, save=False)[source]
bmtk.analyzer.plot_calcium_hdf5(cell_vars_h5, gids, title='Ca2+ influx', show_plot=True, save_as=None)[source]
bmtk.analyzer.plot_potential(cell_vars_h5=None, config_file=None, gids=None, show_plot=True, save=False)[source]
bmtk.analyzer.plot_potential_hdf5(cell_vars_h5, gids, title='membrane potential', show_plot=True, save_as=None)[source]
bmtk.analyzer.spikes_table(config_file, spikes_file=None)[source]