bmtk.utils.reports.compartment package

Submodules

bmtk.utils.reports.compartment.compartment_reader module

class bmtk.utils.reports.compartment.compartment_reader.CompartmentReaderVer01(filename, mode='r', **params)[source]

Bases: CompartmentReaderABC

custom_columns(population=None)[source]
data(node_id=None, population=None, time_window=None, sections='all', **opt_attrs)[source]
property default_population
dt(population=None)[source]
element_ids(node_id=None, population=None)[source]
element_pos(node_id=None, population=None)[source]
get_column(column_name, population=None)[source]
get_node_description(node_id, population=None)[source]
get_population(population, default=None)[source]
get_report_description(population=None)[source]
n_elements(node_id=None, population=None)[source]
node_ids(population=None)[source]
property populations
time_trace(population=None)[source]
tstart(population=None)[source]
tstop(population=None)[source]
units(population=None)[source]
variable(population=None)[source]

bmtk.utils.reports.compartment.compartment_report module

class bmtk.utils.reports.compartment.compartment_report.CompartmentReport(path, mode='r', adaptor=None, *args, **kwargs)[source]

Bases: object

static load(report)[source]

bmtk.utils.reports.compartment.compartment_writer module

class bmtk.utils.reports.compartment.compartment_writer.CompartmentWriterv01(file_path, mode='w', default_population=None, cache_dir=None, variable=None, units=None, buffer_size=0, tstart=0.0, tstop=0.0, dt=0.0, n_steps=None, **kwargs)[source]

Bases: CompartmentWriterABC

add_cell(node_id, element_ids, element_pos, population=None, **element_data)[source]
close()[source]
flush()[source]
initialize()[source]
merge()[source]
n_steps(population=None)[source]
record_cell(node_id, vals, tstep, population=None)[source]
record_cell_block(node_id, vals, beg_step, end_step, population=None)[source]
property report_group
set_dt(val, population=None)[source]
set_time_trace(val, population=None)[source]
set_tstart(val, population=None)[source]
set_tstop(val, population=None)[source]
set_units(val, population=None)[source]
set_variable(val, population=None)[source]
property temp_files
class bmtk.utils.reports.compartment.compartment_writer.PopulationWriterv01(parent, population, variable=None, units=None, tstart=0.0, tstop=1.0, dt=0.01, n_steps=None, buffer_size=0, **kwargs)[source]

Bases: CompartmentWriterABC, CompartmentReaderVer01

Used to save cell membrane variables (V, Ca2+, etc) to the described hdf5 format.

For parallel simulations this class will write to a seperate tmp file on each rank, then use the merge method to combine the results. This is less efficent, but doesn’t require the user to install mpi4py and build h5py in parallel mode. For better performance use the CellVarRecorderParrallel class instead.

class DataTable(var_name)[source]

Bases: object

A small struct to keep track of different data (and buffer) tables

add_cell(node_id, element_ids, element_pos, **map_attrs)[source]
close()[source]
dt(population=None)[source]
flush()[source]

Move data from memory to dataset

property h5_base
initialize(**kwargs)[source]
merge()[source]
n_steps(population=None)[source]
record_cell(node_id, vals, tstep, population=None)[source]

Record cell parameters.

Parameters:
  • gid – gid of cell.

  • var_name – name of variable being recorded.

  • seg_vals – list of all segment values

  • tstep – time step

record_cell_block(node_id, vals, beg_step, end_step, population=None)[source]

Save cell parameters one block at a time

Parameters:
  • gid – gid of cell.

  • var_name – name of variable being recorded.

  • seg_vals – A vector/matrix of values being recorded

set_dt(val, population=None)[source]
set_time_trace(val, population=None)[source]
set_tstart(val, population=None)[source]
set_tstop(val, population=None)[source]
set_units(val, population=None)[source]
set_variable(val, population=None)[source]
time_trace(population=None)[source]
tstart(population=None)[source]
tstop(population=None)[source]
units(population=None)[source]
variable(population=None)[source]
bmtk.utils.reports.compartment.compartment_writer.barrier()

Comm.Barrier(self) -> None

Barrier synchronization

bmtk.utils.reports.compartment.core module

class bmtk.utils.reports.compartment.core.CompartmentReaderABC[source]

Bases: object

custom_columns(population=None)[source]
data(node_id=None, population=None, time_window=None, sections='all', **opt_attrs)[source]
dt(population=None)[source]
element_ids(node_id=None, population=None)[source]
element_pos(node_id=None, population=None)[source]
get_column(column_name, population=None)[source]
get_node_description(node_id, population=None)[source]
get_population(population)[source]
get_report_description(population=None)[source]
index(population=None)[source]
n_elements(node_id, population=None)[source]
n_steps(population=None)[source]
node_ids(population=None)[source]
property populations
time_trace(population=None)[source]
tstart(population=None)[source]
tstop(population=None)[source]
units(population=None)[source]
validate_file(path, **attrs)[source]
variable(population=None)[source]
class bmtk.utils.reports.compartment.core.CompartmentWriterABC(path, mode='r', **kwargs)[source]

Bases: object

add_cell(node_id, element_ids, element_pos, population=None, **attrs)[source]
close()[source]
flush()[source]
initialize(**kwargs)[source]
merge()[source]
record_cell(node_id, values, tstep, population=None)[source]
record_cell_block(node_id, values, tbegin, tend, population=None)[source]
set_dt(val, population=None)[source]
set_time_trace(val, population=None)[source]
set_tstart(val, population=None)[source]
set_tstop(val, population=None)[source]
set_units(val, population=None)[source]
set_variable(val, population=None)[source]

bmtk.utils.reports.compartment.plotting module

bmtk.utils.reports.compartment.plotting.plot_traces(report, population=None, node_ids=None, sections='origin', average=False, node_groups=None, times=None, title=None, show_legend=None, show=True, save_as=None, plt_style=None)[source]

Displays the time trace of one or more nodes from a SONATA CompartmentReport file.

To plot a group of individual variable traces (based on their soma):

plot_traces('/path/to/report.h5', node_ids=[0, 10, 20, ...])

If node_ids=None (default) then all nodes in the report will be displayed. For large networks then can become difficult to visualize so it’s recommended you use average=True:

plot_traces('/path/to/report.h5', average=True)

Users also have the option of taking the averages of multiple subsets of nodes using the “node_groups” options. “node_groups” should be a list of dictionary, each dict with a ‘node_ids’: [list of ids], and optionally a ‘label’ and ‘c’ (color). For example support nodes [0, 70) are excitatory cells, nodes [70, 100) are inhibitory, and we want display excitatory and inhibitory averages and blue and red, respectivly:

plot_traces('/path/to/report.h5',
            node_groups=[{'node_ids': range(0, 70), 'label': 'exc', 'c': 'b'},
                         {'node_ids': range(70, 100), 'label': 'inh', 'c': 'r'}])
Parameters:
  • report – Path to SONATA report file or CompartmentReport object

  • 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.

  • node_ids – int or list of ints. 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 take the averages of all/selected nodes. Default False

  • node_groups – None or list of dicts. Used to group sets of nodes by labels and color. Each grouping should be a dictionary with a ‘node_ids’ key with a list of the ids. You can also add ‘label’ and ‘c’ keys for label and color. If None all nodes will be labeled and colored the same.

  • times – (float, float), start and stop times of simulation

  • title – str, adds a title to the plot

  • 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.utils.reports.compartment.plotting.plot_traces_averaged(report, population=None, sections='origin', node_groups=None, times=None, title=None, show_background=True, show_legend=None, show=True, save_as=None)[source]

Used to plot averages across multiple nodes in a SONATA Compartment Report file.

Recommended that you use “plot_traces” function.

To plot multiple averages use the “node_groups” options. “node_groups” should be a list of dictionary, each dict with a ‘node_ids’: [list of ids], and optionally a ‘label’ and ‘c’ (color). For example support nodes [0, 70) are excitatory cells, nodes [70, 100) are inhibitory, and we want display excitatory and inhibitory averages and blue and red, respectively:

plot_traces('/path/to/report.h5',
            node_groups=[{'node_ids': range(0, 70), 'label': 'exc', 'c': 'b'},
                         {'node_ids': range(70, 100), 'label': 'inh', 'c': 'r'}])
Parameters:
  • report – Path to SONATA report file or CompartmentReport object.

  • 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.

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

  • node_groups – None or list of dicts. Used to group sets of nodes by labels and color. Each grouping should be a dictionary with a ‘node_ids’ key with a list of the ids. You can also add ‘label’ and ‘c’ keys for label and color. If None all nodes will be labeled and colored the same.

  • times – (float, float), start and stop times of simulation.

  • title – str, adds a title to the plot.

  • show_background – shows all the individual traces greyed in the background.

  • 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.utils.reports.compartment.plotting.plot_traces_individual(report, population=None, node_ids=None, sections='origin', times=None, title=None, show_legend=None, show=True, save_as=None)[source]

Used the plot time traces of individual nodes from a SONATA compartment report file.

Recommended use plot_traces instead, which will call this function if necessarcy.

Parameters:
  • report – Path to SONATA report file or CompartmentReport object.

  • 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.

  • node_ids – int or list of ints. 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.

  • times – (float, float), start and stop times of simulation.

  • title – str, adds a title to the plot.

  • 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

Module contents