snudda.neurons.neuron_morphology

class snudda.neurons.neuron_morphology.NeuronMorphology(name=None, position=<Mock name='mock.zeros()' id='140674829498192'>, rotation=None, swc_filename=None, param_filename=None, param_data=None, mech_filename=None, modulation=None, neuron_path=None, morphology_id=None, parameter_id=None, modulation_id=None, parameter_key=None, morphology_key=None, modulation_key=None, verbose=False, load_morphology=True, hoc=None, colour=None, use_cache=True, pickle_version=-1, logfile=None, virtual_neuron=False, axon_stump_id_flag=False, snudda_data=None)[source]

Neuron morphology object. Also see NeuronPrototype class which handles multiple morphology variations.

cache_exist(cache_file=None)[source]

Checks if cache_file exists

clone(load_morphology=None, position=<Mock name='mock.zeros()' id='140674829498192'>, rotation=None, morphology_id=None, parameter_id=None, modulation_id=None, parameter_key=None, morphology_key=None, modulation_key=None)[source]

Creates a clone copy of a neuron.

Parameters
  • load_morphology (bool) – Load morphology into clone?

  • position (float,float,float) – x,y,z coordinate of clone

  • rotation (rotation matrix) – Rotation matrix for clone

  • morphology_id – Morphology ID for the clone

  • parameter_id – Parameter ID for the clone

  • modulation_id – Neuromodulation parameter ID for the clone

  • parameter_key (str) – Parameter Key for clone

  • morphology_key (str) – Morphology Key for clone

  • modulation_key (str) – Modulation Key for clone

cluster_synapses(sec_id, sec_x, count, distance, rng)[source]

Randomize sec_x for cluster of ‘count’ synapses with centre placed at ‘sec_id’, ‘sec_x’ spread over ‘distance’ (but constrained to current section extent).

Parameters
  • sec_id – Section id of cluster centre

  • sec_x – Section x of cluster centre

  • count – Number of synapses in cluster

  • distance – Maximal spread of cluster along dendrite

  • rng – Numpy random stream

Returns

Section x for cluster synapse coords : Coordinates for synapse (in meters) soma_dist : Distance to soma (in meters)

Return type

cluster_sec_x

compartment_length(comp_type='dend')[source]

Calculates compartment length comp_type (“axon” or “dend”)

dendrite_input_locations(synapse_density, rng, num_locations=None, cluster_size=None, cluster_spread=2e-05)[source]

Randomises input locations on dendrites.

Parameters
  • synapse_density – Synapse density as a function f(d), d=distance from soma

  • rng – Numpy random stream

  • num_locations – Number of input locations (this is average number returned, results vary)

  • cluster_size (int) – Number of synapse clusters to place (None = no clusters, all placed independently)

dendrite_input_locations_helper(synapse_density, rng, num_locations, cluster_size=1, cluster_spread=2e-05)[source]

Helper function. Places num_location clusters, each containing cluster_size synapses. Density is relative, scaled.

Parameters
  • synapse_density – Synapse density as a function f(d), d = distance on dendrite from soma

  • rng – Numpy random stream

  • num_locations (int) – Number of locations

  • cluster_size (int) – Size of synapse clusters

find_radius()[source]

Find finds maximum axon and dendrite radius of neuron.

load_cache(cache_file=None)[source]

Loads morphology from cache_file.

load_neuron_morphology()[source]

Loads neuron morphology from SWC file or from cache file.

load_swc(swc_file=None)[source]

Loads morphology from swc_file

place(rotation=None, position=None)[source]

Placing a neuron and rotating it. Will give a warning if it was previously rotated.

Parameters
  • rotation – 3D rotation matrix

  • position – x,y,z position for neuron

plot_neuron(axis=None, plot_axon=True, plot_dendrite=True, line_style='-', alpha=1.0, plot_origo=None, plot_scale=1.0, axon_colour=None, dend_colour=None, soma_colour=None, show_plot=True)[source]

Plots neuron.

Parameters
  • axis

  • plot_axon

  • plot_dendrite

  • line_style

  • alpha

  • plot_origo

  • plot_scale

  • axon_colour

  • dend_colour

  • soma_colour

  • show_plot

static rand_rotation_matrix(deflection=1.0, rand_nums=None)[source]

Creates a random rotation matrix.

deflection: the magnitude of the rotation. For 0, no rotation; for 1, competely random rotation. Small deflection => small perturbation. rand_nums: 3 random numbers in the range [0, 1]. If None, they will be auto-generated.

save_cache(cache_file=None)[source]

Saves cache_file with morphology

set_axon_voxel_radial_density(density, max_axon_radius)[source]

Sets axon radial density

Parameters
  • density – Axon density f(r), r = radius from soma

  • max_axon_radius – Axon density is calculated within a sphere of radius max_axon_radius

set_axon_voxel_xyz_density(density, axon_density_bounds_xyz)[source]

Sets axon density

Parameters
  • density – Axon density f(x,y,z), x,y,z = SWC coordinates in relative to soma

  • axon_density_bounds_xyz – Bounding box for the axon density in x,y,z

write_log(text, is_error=False)[source]

Write text to log file. Prints on screen if self.verbose or is_error