clustering.py

Clustering Figure

This script contains classes and functions for implementing synaptic clustering in the build step of the simulation.

class L5NeuronSimulation.clustering.Cell(n_syns)[source]

A class used to an input cell within a functional group.

n_syns

number of synapses from the cell

Type

int

syn_segs

list of Segments where the cell’s synapses should be placed

Type

list

num_set

number of synapses that the build step has already created. Functions as a way to iterate through synapses.

Type

int

add_syn(seg: pandas.Series)[source]

Adds the given segment to syn_segs

get_seg()[source]

Returns the next synapse to set

add_syn(seg)[source]

Adds the given segment to syn_segs

Parameters

seg (pandas.Series) – represents the segment to added to syn_segs

get_seg()[source]

Returns the next Segment where a synapses should be created with this cell as the presynaptic cell.

class L5NeuronSimulation.clustering.Cluster(center, clustering_func, group_segs)[source]

A class used to represent a cluster of synapses within a functional group.

center

the segment that the cluster is centered around

Type

pd.Series

n_syns

number of synapses attached to the cluster

Type

int

cluster_segs

contains the segments that are within the cluster

Type

pd.DataFrame

random_seg() pd.Series[source]

Returns a random segment in cluster_segs

random_seg()[source]

Returns a random segment in cluster_segs and increases the count of synapses in the cluster

class L5NeuronSimulation.clustering.FunctionalGroup(seg_list, center, num_cells, num_clusters, name, start_id, grouping_func, clustering_func, syn_per_cell=[2, 8])[source]

A class used to represent a functional group of input cells. Each functional group has some number of clusters that it places its cells’ synapses into.

center

the segment that the functional group is centered around

Type

pd.Series

n_cells

number of cells

Type

int

syn_per_cell

list of length two that contains the lower and upper boundary for the number of synapses from each cell. [low, high]

Type

list

n_clusters

number of clusters

Type

int

name

the name associated with the group. Used in the build step of the simulation for proper assignment.

Type

str

start_id

the node_id that is associated with the first cell in the cells list

Type

int

clustering_func

how segments are chosen for the clusters (formatted like make_seg_sphere above)

Type

func

group_segs

DataFrame of segments that fall within the group

Type

pd.DataFrame

cells

list of Cell objects that belong to the group

Type

list

clusters

list of Cluster objects that belong to the group

Type

list

make_clusters()[source]

Creates the group’s clusters

create_cells()[source]

Creates the group’s cells

create_cells()[source]

Creates the group’s cells. Gives each cell and random number of synapses within syn_per_cell. Distributes each cell’s synapses onto the clusters.

make_clusters()[source]

Initializes the clusters of the group. Cluster centers are randomly selected (uniquely) from group_segs.

class L5NeuronSimulation.clustering.Segment(bmtk_id, x)[source]

Simple class that represents a single segment in BMTK.

bmtk_id

the id that BMTK associates with the section (not the section id)

Type

int

x

distance along the section

Type

float

L5NeuronSimulation.clustering.calc_dist(p1, p2)[source]

Returns the distance between two points.

Parameters
  • p1 (list) – [x, y, z] representation of the first coordinate

  • p2 (list) – [x, y, z] representation of the second coordinate

Returns

The distance between the two given points

Return type

float

L5NeuronSimulation.clustering.make_seg_sphere(segments, center, radius=50)[source]

Returns segments within a sphere of the given radius centered at the given center.

Parameters
  • segments (pandas.DataFrame) – DataFrame with each row representing a segment that can be in the sphere

  • center (pandas.Series) – Series representing the segment that is the center of the created sphere

  • radius (int, optional) – The radius of sphere to be made in um (default is 50)

Returns

DataFrame contiaining the subset of segments that is within the sphere

Return type

pandas.DataFrame

L5NeuronSimulation.clustering.plot_group(segs, group, ax, psoma=[0, 0, 0])[source]

Plots the given group’s center, cells, and clusters on the given plt axes.

Parameters
  • segs (pd.DataFrame) – all segments that can possibly be plotted

  • group (FunctionalGroup) – the group to be plotted

  • ax (Axes3d) – what to plot on

  • psoma (list, optional) – used to shift the coordinates of the segments to match the morphology plot. formatted as [x, y, z] (default is [0, 0, 0])