processing module

This module contains functions that process databases generated by NeuroDevSim simulations.

processing.nds_plot(db_name, pdf_out=True, max_cycle=- 1, neurons=[], wire=False, azim=- 60, elev=30, box=False, no_axis=False, scale_axis=False, axis_ticks=True, soma_black=True, color_scheme=0, color_data=None, neuron_colors=None, prefix='', postfix='', show_retracted=False, verbose=1)

Generate a 3D plot and save it to a pdf file.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • Optional

  • axis_ticks (boolean : show axis ticks, default True.) –

  • azim (float : azimuth in degrees of camera, default -60.) –

  • box (box format [[left, front, bottom], [right, back, top]] to plot, allows to zoom in, default full sim_volume.) –

  • color_scheme (integer -1 - 3 : controls how colors change: 0: every neuron has a different color; 1: neurons of same type have same color, different types have different colors; 2: different branches in a neuron have different colors, based on branch_name; 3: color set by front attribute as defined in color_data, -1: use colors defined in neuron_colors, default 0.) –

  • color_data (list : [front attribute name, min value, max value], data necessary for color_scheme 3, default None.) –

  • elev (float : elevation in degrees of camera, default 30.) –

  • max_cycle (integer : stop plotting at this cycle (inclusive), default -1: plot till end of simulation.) –

  • neuron_colors (string : name of text file containing dictionary info by neuron name that specifies color to use, use nds_get_color_dict to obtain a valid file and then edit it, default None.) –

  • neurons (list of string : only plot the neurons with names (wildcard) listed, default: empty list (plot all).) –

  • no_axis (boolean : suppress drawing of axes, default False.) –

  • pdf_out (boolean : ,save plot as a pdf file, if False plot is shown in a window, default True.) –

  • prefix (string : attach string before database name to specify a directory in name of pdf file, default ''.) –

  • postfix (string : attach string after database name in name of pdf file, default ''.) –

  • scale_axis (boolean or list of 3 floats: list as [1.0,1.0,1.0] decrease one or more values to change relative scaling of axes, value for one axis should always be 1.0; default False.) –

  • show_retracted (boolean : if True retracted dendrites are drawn in black, if False they are not drawn, default False.) –

  • soma_black (boolean : all somata are black for increased contrast, default True.) –

  • verbose (integer 0-1 : print information about all fronts plotted (1), default 1.) –

  • wire (boolean : if True all fronts have same small radius, default False.) –

processing.nds_movie(db_name, min_cycle=- 1, max_cycle=- 1, neurons=[], wire=False, azim=- 60.0, elev=30.0, box=False, no_axis=False, scale_axis=False, axis_ticks=True, soma_black=True, color_scheme=0, color_data=None, neuron_colors=None, prefix='', postfix='', show_retraction=True, verbose=1, dpi=300)

Generate a 3D movie and save it to a mp4 file.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • Optional

  • axis_ticks (boolean : show axis ticks, default True.) –

  • azim (float : azimuth in degrees of camera, default -60.) –

  • box (box format [[left, front, bottom], [right, back, top]] to plot, allows to zoom in, default full sim_volume.) –

  • color_scheme (integer -1 - 3 : controls how colors change: 0: every neuron has a different color; 1: neurons of same type have same color, different types have different colors; 2: different branches in a neuron have different colors, based on branch_name; 3: color set by front attribute as defined in color_data, -1: use colors defined in neuron_colors, default 0.) –

  • color_data (list : [front attribute name, min value, max value], data necessary for color_scheme 3, default None.) –

  • dpi (integer : resolution of movie frames, default 300.) –

  • elev (float : elevation in degrees of camera, default 30.) –

  • max_cycle (integer : stop plotting at this cycle (inclusive), default -1: plot till end of simulation.) –

  • min_cycle (integer : start plotting at this cycle, default -1: plot from begin of simulation.) –

  • neuron_colors (string : name of text file containing dictionary info by neuron name that specifies color to use, use nds_get_color_dict to obtain a valid file and then edit it, default None.) –

  • neurons (list of string : only plot the neurons with names (wildcard) listed, default: empty list (plot all).) –

  • no_axis (boolean : suppress drawing of axes, default False.) –

  • pdf_out (boolean : ,save plot as a pdf file, if False plot is shown in a window, default True.) –

  • prefix (string : attach string before database name to specify a directory in name of pdf file, default ''.) –

  • postfix (string : attach string after database name in name of pdf file.) –

  • scale_axis (boolean or list of 3 floats: list as [1.0,1.0,1.0] decrease one or more values to change relative scaling of axes, value for one axis should always be 1.0; default False.) –

  • show_retraction (boolean : retracted dendrites will disappear, they are intially drawn in black, default True.) –

  • soma_black (boolean : all somata are black for increased contrast, default True.) –

  • verbose (integer 0-1 : print information about all fronts plotted (1), default 1.) –

  • wire (boolean : if True all fronts have same small radius, default False.) –

processing.nds_interact(db_name, neuron_id, front_id, cycle, focus=10, azim=- 60, elev=30, radius_scale=2.0, sphere_scale=1.0, verbose=0)

Make a notebook plot of a NeuroDevSim database in an interactive session.

Standard use is to focus on a small cube around a provided reference front which will be colored red. If the front information is not provided (neuron_id==0 and front_id==0) the entire simulation is shown.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • neuron_id (integer : neuron_id value of a reference front present in db_name.) –

  • front_id (integer : front_id value of a reference front present in db_name.) –

  • cycle (integer : plot till this cycle.) –

  • Optional

  • focus (float : distance in µm to plot around reference front, default 10 µm.) –

  • azim (float : azimuth in degrees of camera, default -60.) –

  • elev (float : elevation in degrees of camera, default 30.) –

  • radius_scale (float : increase radius of all cylindrical fronts to improve visibility, default 2.) –

  • sphere_scale (float : change radius of all spherical fronts to improve visibility, default 1.) –

  • verbose (integer 0-1 : print information about all fronts plotted (1), default 0.) –

Returns

ax

Return type

subplot object

processing.nds_get_color_dict(db_name, file_name, max_cycle=- 1, neurons=[], color_scheme=0, verbose=1)

Save the color table by neuron name to a text file.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • file_name (string : name of output text file.) –

  • Optional

  • color_scheme (integer 0 - 1 : controls how colors change: 0: every neuron has a different color; 1: neurons of same type have same color, different types have different colors, default 0.) –

  • verbose (integer 0-1 : print information about all fronts plotted (1), default 1.) –

processing.nds_plot_data(db_name, attribute, num_plots=- 1, select=[], min_cycle=0, max_cycle=- 1)

Generate a line plot of an attribute versus time.

To select plotting of specific subsets use the select optional parameter. Data about available neurons and fronts can be obtained with the nds_list_data method. Alternatively, the num_plots optional parameter can be used to restrict the number of fronts plotted.

To restrict the range of cycles plotted use the min_cycle and max_cycle optional parameters.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • attribute (string : name of attribute to plot.) –

  • Optional

  • max_cycle (integer -1 or >0 : stop plotting at this cycle, default -1: plot till end of simulation.) –

  • min_cycle (integer >0 : start plotting at this cycle, default 0: plot from beginning.) –

  • num_plots (integer -1 or >0 or [integer,integer]: restrict number of plots to value indicated. When a list is used it is interpreted as a range. Default: -1, plot all data.) –

  • select ([DataID,] : list of neurons or fronts to plot defined by their DataID, default []: plot all entries in database table.) –

processing.nds_compare_files(db_name1, db_name2, max_cycle=- 1, swc_types=[], verbose=1, print_all=True)

Compare two NeuroDevSim databases to each other.

Outputs a list of all differences between the two files. Does not check branch names or shape. Present version ignores soma migration.

Parameters
  • db_name1 (string : name of NeuroDevSim database file.) –

  • db_name2 (string : name of NeuroDevSim database file.) –

  • Optional

  • max_cycle (integer > 0 : stop output at this cycle, default: all cycles (-1).) –

  • swc_types (list of integer : only analyze differences for specified swc_types, default: all swc_types.) –

  • verbose (integer 0-2 : control output, default 1: print output filename.) –

  • print_all (boolean : print all differences between fronts or only first difference, default True.) –

processing.nds_summary(db_name)

Prints summary of available neuron data from a NeuroDevSim simulation database.

Parameters

db_name (string : name of raw SQL NeuroDevSim output database file.) –

processing.nds_cycles(db_name, max_cycle=- 1, by_type=False)

Prints summary of how many fronts were made each cycle from a NeuroDevSim simulation database.

Parameters
  • db_name (string : name of raw SQL NeuroDevSim output database file.) –

  • Optional

  • by_type (boolean : split totals by neuron_type, default False.) –

  • max_cycle (integer > 0 : last cycle to print data for, default -1 (all cycles).) –

processing.nds_neuron(db_name, neuron_name, by_swc_type=False, front_ids=False, sizes=False)

Prints information about a single neuron from a NeuroDevSim simulation database.

By default prints database neuron_id and number of fronts, which can be sorted by swc_type. Can also print all front_ids.

Parameters
  • db_name (string : name of raw SQL NeuroDevSim output database file.) –

  • neuron_name (string : name of a neuron in the database, can be a wildcard.) –

  • Optional

  • by_swc_type (boolean : print number of fronts for each swc_type, default False.) –

  • front_ids (boolean : print also all front ids with swc type and birth/death, default False.) –

  • sizes (boolean : print also front sizes, requires front_ids=True, default False.) –

processing.nds_stats(data, max_range, leader='      ', mean=True, histo=True, ranges=True, bins=20, min_range=0, plot=False, title='')

Prints or plots statistics for data list.

By default prints mean +/- std and a histogram with 10 bins for given range.

Parameters
  • data (list : list of data (integer or float).) –

  • max_range (integer > 0 : maximum of range to be used for histogram.) –

  • Optional

  • leader (string : printed first for every line, default: " ".) –

  • mean (boolean : print mean and standard deviation, default True.) –

  • histo (boolean : print histogram with step_size, default True.) –

  • ranges (boolean : print above histogram, default True.) –

  • bins (integer > 0 : number of bins to be used for histogram, default 20.) –

  • min_range (integer > 0 : minimum of range to be used for histogram, default 0.) –

  • plot (boolean : plot instead of print, default False.) –

  • title (string : title of plot (if plot==True), default "".) –

processing.nds_children(db_name, max_children=2, verbose=1)

Checks whether any front except a soma has too many children in NeuroDevSim simulation database. Default is maximum 2 children.

Parameters
  • db_name (string : name of raw SQL NeuroDevSim output database file.) –

  • Optional

  • max_children (integer > 0 : maximum children allowed, default 2.) –

  • verbose (0 or 1 : print summary (0) or all problem fronts (1), default 1.) –

processing.nds_front_id(db_name, front_id, sizes=False)

Prints information about a single front from a NeuroDevSim simulation database.

By default prints database neuron_id and number of fronts. Can also print all front_ids.

Parameters
  • db_name (string : name of raw SQL NeuroDevSim output database file.) –

  • front_id (integer : front_id of a front in the database.) –

  • Optional

  • sizes (boolean : print also front sizes, default False.) –

processing.nds_list_data(db_name, attribute, num_data=- 1)

Prints summary of data available for attribute in a NeuroDevSim database.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • attribute (string : name of attribute to report on.) –

  • Optional

  • num_data (integer -1 or >0 or [integer,integer]: restrict number of fronts listed to value indicated. When a list is used it is interpreted as a range. Default: -1, output all fronts.) –

processing.nds_swc_files(db_name, postfix='', max_cycle=- 1, verbose=1)

Generate swc files from a NeuroDevSim database.

The swc file format is defined in Cannon et al. J. Neurosci. Methods 84, 49–54 (1998).

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • Optional

  • postfix (string : attach string after database name in name of pdf file.) –

  • max_cycle (integer > 0 : stop output at this cycle, default: all cycles (-1).) –

  • verbose (integer 0-2 : control output, default 1: print output filename.) –

processing.nds_output_sizes(db_name, neuron_name='', number_fronts=False, number_swc_type=False, length=True)

Outputs a list containing specific sizes from a NeuroDevSim database.

Four output options are available: - default : length of all fronts is returned as a list. - neuron_name specified : data is printed and returned for all fronts of a single neuron. - number_fronts : total number of fronts is printed for each neuron. - number_swc_type : total number of fronts of each swc_type is printed for each neuron.

Parameters
  • db_name (string : name of raw SQL NeuroDevSim output database file.) –

  • Optional

  • neuron_name (string : name of a neuron in the database, can be a wildcard, print and return only data for this neuron, default not specified (all neurons).) –

  • number_fronts (boolean : print only total number of fronts for each neuron, default False.) –

  • number_swc_type (boolean : print only total number of fronts of each swc_type for each neuron, default False.) –

  • length (boolean : return front lengths (True) or radii (False), default True.) –

Returns

list of lengths or radii

Return type

[float, ]

processing.nds_output_data(db_name, front_id, attribute, min_cycle=0, max_cycle=- 1)

Output values of an attribute versus time for a front or neuron.

At present only attributes stored with admin.attrib_to_db can be selected. To restrict the range of cycles plotted use the min_cycle and max_cycle optional parameters.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • front_id (dataID : selects which front to plot, can also be neuron_id) –

  • attribute (string : name of attribute to output.) –

  • Optional

  • max_cycle (integer -1 or >0 : stop plotting at this cycle, default -1: plot till end of simulation.) –

  • min_cycle (integer >0 : start plotting at this cycle, default 0: plot from beginning.) –

  • Returns

  • (cycle (list of) –

  • attribute_value) (list) –

processing.nds_output_neurons(db_name, neuron_type)

Output information about all neurons of a specific type.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • neuron_type (integer : index into neuron_types list provided to Admin_agent.) –

  • Returns

  • neuron_id (dictionary by) –

processing.nds_output_migration(db_name, last_pos=False)

Output migration history for each migrating somata in database.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • Optional

  • last_pos (boolean : output only final position, default: False.) –

  • Returns

  • neuron_id (dictionary by) –

processing.nds_dict_to_list(d, index)

Extracts data from a dictionary.

Parameters
  • dict (string : name of NeuroDevSim dictionary produced by nds_output_neurons or nds_output_migration.) –

  • index (integer >= 0 : index in list for which data should be returned.) –

  • Returns (list) –

processing.check_collision(db_name, verbose=1)

Checks whether any undetected collisions are present in a NeuroDevSim database.

Parameters
  • db_name (string : name of NeuroDevSim database file.) –

  • Optional

  • verbose (integer 0-3 : control output, default 1.) –

processing.strip_db_name(db_name)

removes directories and ‘.db’ from NeuroDevSim database name.

Parameters

db_name (string : name of NeuroDevSim database file.) –

Returns

name

Return type

string

processing.point_in_volume(point, volume)

Returns whether point*` is inside the given *volume (including its borders).

Parameters
  • point (Point object.) –

  • volume (list of 2 lists: coordinates specifying volume in µm as: [[left, front, bottom], [right, back, top]]) –

Returns

is inside volume

Return type

boolean.