snudda.utils.load¶
- class snudda.utils.load.SnuddaLoad(network_file, snudda_data=None, load_synapses=True, verbose=False)[source]¶
Load data from network-neuron-positions.hdf5 or network-neuron-synapses.hdf5 into python dictionary
Constructor
- Parameters:
network_file (str) – Data file to load
snudda_data (str, optional) – Snudda Data path, if you want to override the one specified in the hdf5 file
load_synapses (bool, optional) – Whether to read synapses into memory, or keep them on disk (this keeps file open)
verbose (bool, optional) – Print more info during execution
- count_synapses_per_type(pre_neuron_type=None, post_neuron_type=None, connection_matrix=None)[source]¶
- Parameters:
pre_neuron_type (list) – List of neuron types
post_neuron_type (list) – List of neuron types, e.g. [“dSPN”, “iSPN”]
connection_matrix
- static extract_neurons(hdf5_file)[source]¶
Helper function to extract neuron data from hdf5 file and put it in a dictionary.
- Parameters:
hdf5_file – hdf5 file object
- Returns:
List containing neurons as dictionary elements.
- find_gap_junctions(neuron_id, n_max=1000000, return_index=False)[source]¶
Find gap junctions associated with neuron_id
- Parameters:
neuron_id (int) – Neuron with gap junction (can also be a list)
n_max (int) – Maximum number of gap junctions to return
return_index (bool) – Should third return value index be present
- Returns:
Subset of gap junction matrix, gap junction coordinates
- find_synapses(pre_id=None, post_id=None, silent=True, return_index=False)[source]¶
Returns subset of synapses.
- Parameters:
pre_id (int) – Pre-synaptic neuron ID
post_id (int) – Post-synaptic neuron ID
silent (bool) – Work quietly or verbosely
- Returns:
Subset of synapse matrix.
- find_synapses_slow(pre_id, n_max=1000000)[source]¶
Returns subset of synapses.
- Parameters:
pre_id (int) – Pre-synaptic neuron ID (can also be a list)
n_max (int) – Maximum number of synapses to return
- Returns:
Subset of synapse matrix, synapse coordinates
- gap_junction_iterator(chunk_size=1000000)[source]¶
Iterates through all gap junctions in chunks (default 1e6 gap junctions).
- Parameters:
chunk_size (int) – Number of gap junctions per chunk
- Returns:
Iterator over the gap junctions
- get_centre_neurons_iterator(n_neurons=None, neuron_type=None, neuron_name=None, centre_point=None, max_distance=None, return_distance=True, include_virtual=False)[source]¶
Return neuron id:s, starting from the centre most and moving outwards
- Parameters:
n_neurons (int) – Number of neurons to return, None = all available
neuron_type (str) – Type of neurons to return, None = all available
centre_point (np.array) – x,y,z of centre position, None = auto detect centre
- get_neuron_id(include_virtual=True)[source]¶
Returns all neuron_id, if include_virtual is set (default) virtual neurons are also included.
- get_neuron_id_of_type(neuron_type, num_neurons=None, random_permute=False, volume=None, include_virtual=True, population_unit_id=None)[source]¶
Find all neuron ID of a specific neuron type.
- Parameters:
neuron_type (string) – Neuron type (e.g. “FS”)
num_neurons (int) – Maximum number of neurons to return
random_permute (bool) – Shuffle the resulting neuron IDs?
volume (string) – volume_id containing neurons (default None – all neurons of type)
- Returns:
List of neuron ID of specified neuron type
- get_neuron_id_with_name(neuron_name, include_virtual=True)[source]¶
Find neuron ID of neurons with a given name.
- Parameters:
neuron_name (str) – Name of neurons (e.g. “dSPN_0”)
include_virtual (bool) – Should virtual neurons also be included?
- Returns:
List of neuron ID
- get_population_unit_members(population_unit, num_neurons=None, random_permute=False)[source]¶
Returns neuron ID of neurons belonging to a specific population unit.
- Parameters:
population_unit (int) – Population unit ID
num_neurons (int) – Number of neurons to return (None = all hits)
random_permute (bool) – Randomly shuffle neuron IDs?
- Returns:
List of neuron ID belonging to population unit.
- load_hdf5(network_file, load_synapses=True, load_morph=False)[source]¶
Load data from hdf5 file.
- Args:
network_file (str) : Network file to load data from load_synapses (bool) : Load synapses into memory, or read on demand from file (keeps file open) load_morph
- Returns:
data (dictionary) : Dictionary with data.
Data format. The top level of the data hierarchy are “meta”, “morphologies”, “network”.
- “meta” hierarchy:
“slurm_id” (int) : Run ID of Slurm job “axon_stump_id_flag” (bool) : Should axon be replaced by a axon stump “config” : Config data “config_file” : Config file “connectivity_distributions” : Information about connections allowed, including pruning information “hyper_voxel_ids” : List of all hyper voxels IDs “hyper_voxel_size” (int, int, int): Number of hyper voxels along each dimension x, y, z “hyper_voxel_width” (float, float, float) : Size of hypervoxel in meters (x,y,z) “num_hyper_voxels” (int) : Number of hyper voxels “position_file” : Neuron position file “simulation_origo” (float, float, float) : Simulation origo (x, y, z) in SI-units (m) “voxel_size” (float) : Voxel size in meters
- “morphologies” heirarchy:
List of neuron names, contains the location of the morphologies (either SWC file or directory with multiple SWC files)
- “network” hierarchy:
“gap_junctions” : Gap junction data matrix (see below for format) “num_gap_junctions” (int) : Number of gap junctions “num_synapses” (int) : Number of synapses “neurons” : Neuron data structure (see below for format) “synapses” : Synapse data matrix (see below for format)
Neuron data format:
Synapse data format (column within parenthesis):
0: source_cell_id, 1: dest_cell_id, 2: voxel_x, 3: voxel_y, 4: voxel_z, 5: hyper_voxel_id, 6: channel_model_id, 7: source_axon_soma_dist (not SI scaled 1e6, micrometers), 8: dest_dend_soma_dist (not SI scalled 1e6, micrometers) 9: dest_seg_id, 10: dest_seg_x (int 0 - 1000, SONATA wants float 0.0-1.0) 11: conductance (int, not SI scaled 1e12, in pS) 12: parameterID
Note on parameterID:
If there are n parameter sets for the particular synapse type, then the ID to use is parameterID % n, this way we can reuse connectivity if we add more synapse parameter sets later.
Gap junction format (column in parentheses):
0: source_cell_id, 1: dest_cell_id, 2: source_seg_id, 3: dest_seg_id, 4: source_seg_x, 5: dest_seg_x, 6: voxel_x, 7: voxel_y, 8: voxel_z, 9: hyper_voxel_id, 10: conductance (integer, in pS)
- load_neuron(neuron_id)[source]¶
Loads a specific neuron. Returns a NeuronMorphology object.
- Parameters:
neuron_id (int) – Neuron ID
- Returns:
NeuronMorphology object.