def step(n, loop_n, save_path, plot=True): ds.simulate(n) if plot: if save_path is False: ds.plot_neurons(show_nodes=True) else: ds.plot_neurons(show_nodes=False, save_path=save_path)
def step(n, loop_n, plot=True): ds.simulate(n*minute) if plot: ds.plot_neurons(show_nodes=True, show=True)
swc_file = ds.get_simulation_id() # print(swc_file) return swc_file if __name__ == '__main__': num_omp = 1 kernel = { "seeds": np.random.randint(0, 10000, num_omp).tolist(), "num_local_threads": num_omp, "environment_required": False } swc_file = lateral_branching(neuron_params) ds.plot_neurons(show=True) pop = ds.get_neurons() n = pop[0] tree = n.axon.get_tree() tree.show_dendrogram() # ~ import neurom # ~ from neurom import viewer # ~ asym = [] # ~ num_tips = [] # ~ for n in pop: # ~ tree = n.axon.get_tree() # ~ num_tips.append(len(tree.tips)) # ~ nrn = tree.neurom_tree()
def step(n, loop_n, plot=True): ds.simulate(n) if plot: ds.plot_neurons(show_nodes=True, show=False)
# becouse the angle is computed numerically as dy/dx there can # be some spurious elements arround 10^-10, remove them and # all the NO Turning zero with np.where hist_tmp = np.array(hist_tmp) hist_tmp = hist_tmp[~np.isclose(hist_tmp, 0)] # make the histogram ahist, _ = np.histogram(hist_tmp, abins, normed=True) ax.plot(abins[:-1] + 0.5 * (abins[1] - abins[0]), ahist, color=cmap(colors[k]), label="resol: {}".format(resol)) ax.set_yscale("log", nonposy='clip') if show_neurons: ds.plot_neurons(show=False, title=str(resol)) # compute distrib x positions xs = np.concatenate(structure["growth_cones"])[:, 0] print(np.average(xs), np.sum(np.isnan(xs))) count, bins = np.histogram(xs, bins=xbins) ax2.plot(bins[:-1] + 0.5 * np.diff(bins), count, color=cmap(colors[k]), alpha=0.5, label="resol: {}".format(resol)) ''' Make, save and show the figure ''' ax.legend(loc=2, fancybox=True, frameon=True)
neuron_params['growth_cone_model'] = 'default' neuron_params['position'] = np.random.uniform(-10000, 10000, (num_neurons, 2)) gids = ds.create_neurons(n=num_neurons, growth_cone_model='random_walk', params=neuron_params, dendrites_params=dendrite_params, num_neurites=2) ''' Create recorders ''' gids_rec = ds.create_recorders(gids, "length", levels="growth_cone") rec_ngc = ds.create_recorders(gids, "num_growth_cones", levels="neuron") #~ step(6000, 0, True) #~ for i in range(10): #~ print("\nNew step block") #~ step(2000, 0, True) for i in range(10): print("\nNew step block") step(2000, 0, False) ds.plot_neurons(show_nodes=True, show=True) #~ pprint(ds.get_object_properties(gids_rec)) ds.plot_recording(rec_ngc, time_units="minutes")
def step(time, loop_n, plot=True): ds.simulate(time) if plot: ds.plot_neurons(show_nodes=True, show=True)
} gids = ds.create_neurons(n=num_neurons, num_neurites=1, params=params) ds.simulate(800) neurons = ds.structure.NeuronStructure(gids) tips = np.concatenate( [neurons["growth_cones"][i] for i in range(num_neurons)]) contained = shape.areas["default_area"].contains_neurons(tips) fractions.append(np.sum(contained) / float(num_neurons)) lengths.append(neurite_length(gids)) ds.plot_neurons(show=False, title="resol {}".format(resol)) ''' Plot the results ''' fig, ax = plt.subplots() ax.plot(resolutions, fractions, ls="-", color="b", alpha=0.8) # ~ for i, width in enumerate(widths): # ~ ax.plot(resolutions, fractions[i][:, 1], ls="-", color=colors[i], alpha=0.8, label=str(width)) # ~ ax.legend() fig.patch.set_alpha(0.)
params = { "sensing_angle": 70. * deg, # ~ "filopodia_wall_affinity": 10.*np.sqrt(resol), # ~ "filopodia_wall_affinity": 10.*resol, # ~ "filopodia_wall_affinity": 10/np.sqrt(resol), "filopodia_wall_affinity": 10., "proba_down_move": 0.02, "scale_up_move": 1., # ~ "filopodia_wall_affinity": 10./resol, } gids = ds.create_neurons(n=num_neurons, num_neurites=1, params=params) ds.simulate(simtime) ds.plot_neurons(show=False, title="Resolution: {}".format(resol)) lengths.append(neurite_length(gids)) ''' Plot the results ''' fig, ax = plt.subplots() upper, median, lower = [], [], [] for i, data in enumerate(lengths): up, med, low = np.percentile(data, [90, 50, 10]) upper.append(up) median.append(med) lower.append(low)
def step(n, loop_n, save_path, plot=True): ds.simulate(n) if plot: ds.plot_neurons( show_nodes=True, save_path=save_path)