ALLEN INSTITUTE

# 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)

  Bases: `CompartmentReaderABC`

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

## bmtk.utils.reports.compartment.compartment_report module

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

  Bases: `object`

  static load(report)

## 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)

  Bases: `CompartmentWriterABC`

  add_cell(node_id, element_ids, element_pos, population=None, **element_data)
  close()
  flush()
  initialize()
  merge()
  n_steps(population=None)
  record_cell(node_id, vals, tstep, population=None)
  record_cell_block(node_id, vals, beg_step, end_step, population=None)
  property report_group
  set_dt(val, population=None)
  set_time_trace(val, population=None)
  set_tstart(val, population=None)
  set_tstop(val, population=None)
  set_units(val, population=None)
  set_variable(val, population=None)
  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)

  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)

    Bases: `object`

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

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

    Move data from memory to dataset

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

    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)

    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)
  set_time_trace(val, population=None)
  set_tstart(val, population=None)
  set_tstop(val, population=None)
  set_units(val, population=None)
  set_variable(val, population=None)
  time_trace(population=None)
  tstart(population=None)
  tstop(population=None)
  units(population=None)
  variable(population=None)

## bmtk.utils.reports.compartment.core module

class bmtk.utils.reports.compartment.core.CompartmentReaderABC

  Bases: `object`

  custom_columns(population=None)
  data(node_id=None, population=None, time_window=None, sections='all', **opt_attrs)
  dt(population=None)
  element_ids(node_id=None, population=None)
  element_pos(node_id=None, population=None)
  get_column(column_name, population=None)
  get_node_description(node_id, population=None)
  get_population(population)
  get_report_description(population=None)
  index(population=None)
  n_elements(node_id, population=None)
  n_steps(population=None)
  node_ids(population=None)
  property populations
  time_trace(population=None)
  tstart(population=None)
  tstop(population=None)
  units(population=None)
  validate_file(path, **attrs)
  variable(population=None)

class bmtk.utils.reports.compartment.core.CompartmentWriterABC(path, mode='r', **kwargs)

  Bases: `object`

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

## 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)

  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)

  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)

  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