utils
helpers
Here are some simple Numpy functions or torch functions that help to achieve simulation or assimilation.
- utils.helpers.load_if_exist(func, *args, **kwargs)[source]
Load npy if exist else generate it by
func.
pretty_print
sample
- utils.sample.sample(aal_region, neurons_per_population_base, populations_id, specified_info=None, num_sample_voxel_per_region=1, num_neurons_per_voxel=300)[source]
sample neurons from the
simulationobject according requirement.In simulation object simulation, it’s required to set neuron sample before
simulation.run.- Parameters:
aal_region (ndarrau) – indicate the brain regions label of each voxel.
neurons_per_population_base (ndarray) – The accumulated number of neurons for each population , corresponding to the population_id.
populations_id (ndarray) – The population id. Due to the routing algorithm, the population id may be disordered and repeated. The population id of neurons distributed between consecutive cards may be duplicated, because the neurons of this population may not be completely divided into one card.
num_sample_voxel_per_region (int, default=1) – the sample number of voxels in each region.
num_neurons_per_voxel (int, default=300) – the sample number of neurons in each voxel .
specified_info (ndarray) – according the specified_info info , we can randomly sample neurons which are from given voxel id.
- Returns:
ndarray which contain sample information
—————-|——————
0 th column | neuron id
1 th column | voxel id
2 th column | population id
3 th column | region id
—————-|——————
- utils.sample.specified_sample_column(aal_region, neurons_per_population_base, specified_info=None, num_sample_voxel_per_region=1, num_neurons_per_voxel=300)[source]
more convenient version to sample neurons for
simulationobject.neurons_per_population_base is read from
population_base.npywhich is generated during generation of connection table.- Parameters:
aal_region (ndarrau) – indicate the brain regions label of each voxel.
neurons_per_population_base (ndarray) – The accumulated number of neurons for each population , corresponding to the population_id. corresponding to [0, 1, 2, 3, 4,… 227029]
num_sample_voxel_per_region (int, default=1) – the sample number of voxels in each region.
num_neurons_per_voxel (int, default=300) – the sample number of neurons in each voxel .
specified_info (ndarray) – according the specified_info info , we can randomly sample neurons which are from given voxel id.
- Returns:
ndarray which contain sample information
—————-|——————
0 th column | neuron id
1 th column | voxel id
2 th column | population id
3 th column | region id
—————-|——————