senec-initiative / dense Goto Github PK
View Code? Open in Web Editor NEWSimulator for the Development of Neurons in Spatial Environments
Home Page: https://dense.readthedocs.io/en/latest/
License: GNU General Public License v2.0
Simulator for the Development of Neurons in Spatial Environments
Home Page: https://dense.readthedocs.io/en/latest/
License: GNU General Public License v2.0
Hi Tanguy,
I'm reinstalling the latest master on a fully updated system (Debian); Dense installs but I cannot run my code any longer, because of some issue with Pint
self._areas = {
Traceback (most recent call last):
File "/home/bottani/2021_Arches_fig/arches2_figure/Temp_RIGHT/temp.py", line 161, in <module>
pos = culture.seed_neurons(neurons=num_neurons,
File "/home/bottani/.local/lib/python3.9/site-packages/dense-0.1.0-py3.9-linux-x86_64.egg/dense/environment/shape.py", line 848, in seed_neurons
raise RuntimeError("`return_quantity` requested but Pint is "
RuntimeError: `return_quantity` requested but Pint is not available. Please install it first.
Of ourse 'Pint' is installed
In [1]: import pint
In [2]: print(pint.__version__)
0.18
There are also many warning concerning Shapely
when shapely objects are used, as
self._geom_type = 'Polygon'
/home/bottani/.local/lib/python3.9/site-packages/dense-0.1.0-py3.9-linux-x86_64.egg/dense/environment/shape.py:418: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
Having I think upgraded all requirements and packages I am at a loss here.
Thank you
Samuel
Hi Tanguy,
Following my remarks on the compilation of the doc, I made a clean fresh install of all the required python libraries.
I got no more complain with a babel.core. But still the doc does not compile.
Here is the log after the make install:
Une exception a été levée :
File "/home/ele/.local/lib/python3.8/site-packages/breathe/directives.py", line 2, in <module>
from .finder.core import FinderFactory
ModuleNotFoundError: No module named 'breathe.finder.core'
Le traceback complet a été sauvé dans /tmp/sphinx-err-lyt4nhcz.log, au cas où vous souhaiteriez signaler le problème aux développeurs.
Merci de rapporter ceci s'il s'agit d'une erreur utilisateur, afin d'améliorer le message d'erreur à l'avenir.
Un rapport d'erreur peut être déposé dans le système de tickets à <https://github.com/sphinx-doc/sphinx/issues>. Merci !
CMake Error at docs/cmake_install.cmake:60 (file):
file INSTALL cannot find "/home/ele/Documents/WORK/DENSE/build/docs/html":
No such file or directory.
Call Stack (most recent call first):
cmake_install.cmake:43 (include)
Best
Samuel
Hi Tanguy,
I'm finalyy running on the lastest master version... well, actually not. I cannot resolve issues with units in my codes and examples that load environments. Issues risen concern units and Pint. I definitively have the latest pint, reinstalled indeed all the required libraries.
Apparently some commands seed.neurons() now require explicit indication of the unit (implies we have to correct all the exmaple files !) but this is not enough.
See for instance the output of the example
python circular_simple.py
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:172: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._parent = None
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:173: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._unit = unit
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:174: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._geom_type = g_type
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:175: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._return_quantity = False
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1053: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._parent = None
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1054: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._unit = unit
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1055: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._geom_type = g_type
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1057: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._area = None
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1058: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj.height = height
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1059: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj.name = name
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1060: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._prop = _PDict(
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:1062: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._return_quantity = False
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:176: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
obj._areas = {
/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py:317: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
disk.radius = radius
Traceback (most recent call last):
File "/home/ele/Documents/WORK/DENSE/examples/space_embedding/circular/circular_simple.py", line 132, in <module>
neuron_params['position'] = culture.seed_neurons(
File "/home/ele/.local/lib/python3.10/site-packages/dense-0.1.0-py3.10-linux-x86_64.egg/dense/environment/shape.py", line 827, in seed_neurons
raise RuntimeError("`return_quantity` requested but Pint is "
RuntimeError: `return_quantity` requested but Pint is not available. Please install it first.
I do not understand also the new argument 'return_quantity', when I change the code to set it to false set to False, the issue is with
reate_neurons()
Creating neurons
Traceback (most recent call last):
File "/home/ele/Documents/WORK/20210507/Improving_density_plot/arches-work.py", line 158, in <module>
gids = ds.create_neurons(n=num_neurons,
File "_pygrowth.pyx", line 327, in dense._pygrowth.create_neurons
File "_pygrowth.pyx", line 1796, in dense._pygrowth._create_neurons
File "_pygrowth.pyx", line 2289, in dense._pygrowth._set_vector_status
AssertionError: Positions must have units.
Well I stuck and cannot even revert to previous versions...
Thank you for your suggestions
Samuel
Hi again Tanguy, last issue for the moment -promised-
Using the latest compiled version from freshly pulled SENeC-Initiative master, the create_neurites()
method doesn't work as newly expected and documented in the doc.
To be sure of no conflict of version I even removed dense-0.1.0-py3.8-linux-x86_64.egg
for /python3.8/site-package
before compiling.
See example below:
My input
In [2]: from dense.units import *
In [3]: neuron = ds.create_neurons(params={"position": (0., 0.)*um})
In [4]: neuron.create_neurites(num_neurites=3,neurite_angles= {"axon": 15, "dendrite_1": 60, "dendrite_2": 180})
Output
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-8e85eed7398b> in <module>
----> 1 neuron.create_neurites(num_neurites=3,neurite_angles= {"axon": 15, "dendrite_1": 60, "dendrite_2": 180})
TypeError: create_neurites() got an unexpected keyword argument 'neurite_angles'
Hi Tanguy,
The parameter random_rotation_angles parameter in create_neurons()
should prevent random global rotation of neurite angles created with relative angles between them. It does not work.
Run the example below, relative angle between 1 dendrite and 1 axon is respected, but each neuron orients the pair differently and randomly.
# -*- coding: utf-8 -*-
import os
import shutil
import time
import numpy as np
import matplotlib.pyplot as plt
import nngt
import dense as ds
from dense.units import *
def CleanFolder(tmp_dir, make=True):
if os.path.isdir(tmp_dir):
shutil.rmtree(tmp_dir)
if make:
os.mkdir(tmp_dir)
return tmp_dir
current_dir = os.path.abspath(os.path.dirname(__file__))
main_dir = current_dir[:current_dir.rfind("/")]
'''
Main parameters
'''
soma_radius = 8.
num_neurons = 10
#~ gc_model = 'persistent_random_walk'
gc_model = 'run-and-tumble'
use_uniform_branching = False
use_vp = True
use_run_tumble = False
neuron_params = {
"axon_diameter": 4. * um,
"dendrite_diameter": 2.*um,
"soma_radius": soma_radius * um,
}
axon_params = {
"growth_cone_model": gc_model,
"use_uniform_branching": use_uniform_branching,
"use_van_pelt": use_vp ,
"sensing_angle": 45.*deg,
"speed_growth_cone": 0.025 * um / minute, #0.15
"filopodia_wall_affinity": 100.,
"filopodia_finger_length": 7. * um,
"filopodia_min_number": 30,
"persistence_length": 300. * um,
"taper_rate": 1./4000.,
'B': 3. * cpm,
'T': 1000. * minute,
'E': 1.,
}
dendrite_params = {
"use_van_pelt": use_vp,
"growth_cone_model": gc_model,
"speed_growth_cone": 0.01 * um / minute,
"filopodia_wall_affinity": 10. ,
"persistence_length" : 200. * um,
"taper_rate": 3./250.,
"B": 6. * cpm,
"T": 1000. * minute,
'E': 1.,
}
neurite_params = {"axon": axon_params, "dendrite": dendrite_params}
'''
Simulation
'''
def step(n, loop_n, plot=True):
ds.simulate(n)
if plot:
ds.plot.plot_neurons(show_nodes=True, show=True)
if __name__ == '__main__':
num_omp = 10
kernel = {
"seeds": range(10, 10+num_omp),
"num_local_threads": num_omp,
"resolution": 10. * minute,
"adaptive_timestep": -1.,
"environment_required": True,
"interactions": True
}
ds.set_kernel_status(kernel, simulation_id="ID")
gids, culture = None, None
culture_file = current_dir + "/box.svg"
min_x = 0 # Choice of the coordinates associated to
max_x = 1800 # the x axis of the imported environment image
# the y coodirnated will be automatically determined
# by scaling from the image
# using Inkscape for the bix.svg the y coordinated will be
min_y = -707
max_y = +707
y_margin = (max_y-min_y)/num_neurons # choice of margin not to seed neurons closer to the border
if kernel["environment_required"]:
culture = ds.set_environment(culture_file, min_x=0, max_x=1800)
# neuron_params['position'] = [(900., 0.),(900., 100.)] *um
positions = []
for y in np.linspace(min_y+y_margin,
max_y-y_margin, num_neurons):
positions.append((900, y))
neuron_params['position'] = positions *um
print("Creating neurons")
# gids = ds.create_neurons(n=num_neurons,
# params=neuron_params,
# num_neurites=0)
gids = ds.create_neurons(n=num_neurons,
params=neuron_params,
num_neurites=2,
random_rotation_angles=False,
neurite_angles={"axon": 0.*deg,
"dendrite_1": 180.*deg})
Hi again,
This issue concerns the recorder in the example file of previous issue #33 : file
python ds.plot.plot_recording(rec, show=False)
gives
_pygrowth.pyx in dense._pygrowth._get_recorder_data()
OverflowError: cannot convert float infinity to integer
whatever the recorder type tries.
I am just starting looking at recorders, so I may not ot it or have latest syntax, sorry.
Best
Samuel
Hi again Tanguy,
Other annoying issue : I am not able to reload any simulated morphology file in a program for further analysis.
The i/o module documentation is not very helpful and most examples (that do not run) seem outdated (couldn't find any working).
I am updating the doc and docstrings with more help. But need yours to progress !
Several questions
info.json
?What is in the info.json
file generated by dense.io.save_json_info()
? The doc says simulation data. What kind of data ? The generated files seem quite empty. Here is an example from a simulation with 15 neurons. Appear only the names of the kernel parameters, and names of the neurons.
{"kernel": ["max_allowed_resolution", "resolution", "num_mpi_processes", "adaptive_timestep", "record_enabled", "version", "max_synaptic_distance", "environment_initialized", "environment_required", "num_local_threads", "num_virtual_processes", "interactions", "seeds", "time"], "neurons": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"]}
I suspect an issue with the generation of this file.
From the documentation I understand tthe instruction is.
pop = ds.io.load_swc(swc_folder="my_swc_folder", swc_file="my_swc_file.swc")
It is not very happy
In [6]: pop = ds.io.load_swc(swc_file="2chambers_test.swc")
import neuron from swc file
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-91c75af034b2> in <module>
----> 1 pop = ds.io.load_swc(swc_file="2chambers_test.swc")
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/io/data_swc.py in load_swc(swc_folder, swc_file, info)
84 """
85 if swc_file is not None:
---> 86 return Population.from_swc(
87 NeuronFromSwcFile(swc_file, info))
88 if swc_folder is not None:
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/elements.py in from_swc(cls, population, info)
859 else:
860 ensemble = cls(info=population['info'])
--> 861 ensemble._add_swc_population(population['neurons'])
862 ensemble.sort()
863 ensemble._idx = {} # converter from gid to idx
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/elements.py in _add_swc_population(self, neurons)
996 axon, dendrites = _get_swc_struct(neuron=neurons[neuron]['data'])
997 try:
--> 998 position = self.info["neurons"][str(
999 neurons[neuron]['gid'])]['position']
1000 except KeyError:
TypeError: 'NoneType' object is not subscriptable
And if I put the swc file in a folder, then we get
In [7]: pop = ds.io.load_swc(swc_folder="2culture_swc",swc_file="2chambers_test.swc")
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-62cd3b497c6a> in <module>
----> 1 pop = ds.io.load_swc(swc_folder="2culture_swc",swc_file="2chambers_test.swc")
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/io/data_swc.py in load_swc(swc_folder, swc_file, info)
84 """
85 if swc_file is not None:
---> 86 return Population.from_swc(
87 NeuronFromSwcFile(swc_file, info))
88 if swc_folder is not None:
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/elements.py in from_swc(cls, population, info)
859 else:
860 ensemble = cls(info=population['info'])
--> 861 ensemble._add_swc_population(population['neurons'])
862 ensemble.sort()
863 ensemble._idx = {} # converter from gid to idx
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/elements.py in _add_swc_population(self, neurons)
994 for neuron in neurons:
995 gid = neurons[neuron]['gid']
--> 996 axon, dendrites = _get_swc_struct(neuron=neurons[neuron]['data'])
997 try:
998 position = self.info["neurons"][str(
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/io/data_swc.py in GetSWCStructure(neuron, plot, neuron_gid, axon_ID, dendrite_ID)
293
294 else:
--> 295 import btmorph2
296 if isinstance(neuron, btmorph2.NeuronMorphology):
297 if plot:
ModuleNotFoundError: No module named 'btmorph2'
(Alas btmorph2 is in Python2 and I could install it to check what happened with it)
Alternatively, some examples show to import a morphology the following coed:
from dense.elements import Population
pop = Population.from_swc("my_swc_file.swc")
But if I'm not wrong this is deprecated syntax, and anyway it does not work.
pop = Population.from_swc("2chambers_test.swc")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-3e1b26e8106c> in <module>
----> 1 pop = Population.from_swc("2chambers_test.swc")
~/.local/lib/python3.8/site-packages/dense-0.1.0-py3.8-linux-x86_64.egg/dense/elements.py in from_swc(cls, population, info)
858 ensemble = cls(info=population['info'])
859 else:
--> 860 ensemble = cls(info=population['info'])
861 ensemble._add_swc_population(population['neurons'])
862 ensemble.sort()
TypeError: string indices must be integers
I'm quite at a loss here. Thank you in advance
Samuel
Hi Tanguy,
I'm having trouble with the graph generation from a grown morphology.
There are apparently two way for doing it :
dense.morphology.generate_network()
Right ? Are there differences ?
Anyway, dense.morphology.generate_network()
seems to work (see below), but I cannot get the generated graph to be displayed, so there might be an issue.
Here is how the graph is generated than attempted display in the first approach producing an error :
# graph generation from the network structure in DENsE
structure = ds.morphology.NeuronStructure()
graph = ds.morphology.generate_network(structure=structure)
graph.to_file("connections_graph.el")
# display through nngt
nngt.plot.draw_network(graph, show=True)
Which results in the error at the display command:
In [12]: nngt.plot.draw_network(graph,show=True)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-12-b5ae5d06ab97> in <module>
----> 1 nngt.plot.draw_network(graph,show=True)
~/.local/lib/python3.8/site-packages/nngt/plot/plt_networks.py in draw_network(network, nsize, ncolor, nshape, nborder_color, nborder_width, esize, ecolor, ealpha, max_nsize, max_esize, curved_edges, threshold, decimate_connections, spatial, restrict_sources, restrict_targets, restrict_nodes, show_environment, fast, size, xlims, ylims, dpi, axis, colorbar, show, **kwargs)
420 else:
421 for i, ci in enumerate(c):
--> 422 m = MarkerStyle(nshape[i]).get_path()
423 transform = Affine2D().scale(0.5*nsize[i]).translate(pos[i][0], pos[i][1])
424 patch = PathPatch(m.transformed(transform), facecolor=ci,
IndexError: string index out of range
On another hand the following code to generate the graph through nngt the the same display comand works well:
population = nngt.NeuralPop(with_models=False)
population.create_group(range(num_neurons), "All_neurons")
nngt.Graph.make_network(graph, population)
graph.to_file("connections_graph.el")
nngt.plot.draw_network(graph,
show_environment=False,
colorbar=False, show=True)
I attach here a file that illustrates.
Best,
Samuel
polygons.zip
Hi,
It seems both axon and dendrite type neurites' properties have no diameter !
Or are axon_diameter
and dendrite_diameter
properties of a neuron ?
Confusing. Anyway, here what makes me believe axons and dendrites have no diameters :
With neuron
created by create_neurons()
ds.set_neurite_properties(neuron,neuron.dendrites["dendrite_1"],
params={ "dendrite_diameter": 3. * um})
one gets
KeyError Traceback (most recent call last)
<ipython-input-20-f4ea6ce20f95> in <module>
----> 1 ds.set_neurite_properties(neuron,neuron.dendrites["dendrite_1"],params={ "dendrite_diameter": 3. * um})
_pygrowth.pyx in dense._pygrowth.set_neurite_properties()
_pygrowth.pyx in dense._pygrowth._check_params()
KeyError: "Unknown parameter 'dendrite_diameter' for `neurite`."
In [3]: neuron = ds.create_neurons(params={"position": (0., 0.)*um}, num_neurites=0)
In [4]: neuron.create_neurites(num_neurites=1,neurite_types="axon")
In [5]: neuron.create_neurites(num_neurites=1,neurite_types="dendrite")
In [6]: neuron.neurites
In [7]: dd=neuron.dendrites
In [8]: dd
Out[8]: { 'dendrite_1': Neurite<dendrite_1 of neuron 0> }
In [9]: d1=dd["dendrite_1"]
zero-dimensional arrays cannot be concatenated
dendrite.xy: dendrite_1 missing
In [10]: d1.get_properties()
Out[10]:
{
'critical_pull' : 4.0,
'affinity_dendrite_soma_other_neuron' : 0.0,
'affinity_dendrite_soma_same_neuron' : nan,
'affinity_dendrite_axon_same_neuron' : nan,
'affinity_dendrite_dendrite_same_neuron' : nan,
'duration_of_retraction' : 4.0 minute,
'proba_down_move' : 0.008,
'sensing_angle' : 69.99825383113267 degree,
'taper_rate' : 0.002,
'retraction_probability' : 0.001,
'filopodia_min_number' : 24,
'observables' : [
'angle',
'length',
'num_growth_cones',
'num_tumbles',
'retraction_time',
'speed',
'status',
'stepping_probability'
],
'neurite_type' : 'dendrite',
'filopodia_wall_affinity' : 2.0,
'diameter_fraction_lb' : 0.8,
'persistence_length' : 500.0 micrometer,
'diameter_ratio_avg' : 1.0,
'use_van_pelt' : False,
'gc_split_angle_mean' : 97.95031817647606 degree,
'max_sensing_angle' : 89.95437383553924 degree,
'max_gc_number' : 500,
'diameter_ratio_std' : 0.02,
'gc_split_angle_std' : 9.994930426171027 degree,
'affinity_dendrite_axon_other_neuron' : 5.0,
'lateral_branching_angle_std' : 0.9994930426171028 degree,
'affinity_dendrite_self' : nan,
'lateral_branching_angle_mean' : 59.969582557026165 degree,
'max_arbor_length' : 5000.0 micrometer,
'active' : True,
'diameter_eta_exp' : 2.67,
'speed_decay_factor' : 0.0,
'min_branching_distance' : 20.0 micrometer,
'use_uniform_branching' : False,
'use_flpl_branching' : False,
'speed_growth_cone' : 0.05 micrometer / minute,
'use_uniform_split' : False,
'scale_up_move' : 20.0 micrometer,
'growth_cone_model' : 'constant_pull-only_run-and-tumble',
'affinity_dendrite_dendrite_other_neuron': 2.0,
'filopodia_finger_length' : 12.0 micrometer
}
no dendrite_diameter above
Hi Tanguy,
There's again an issue with setting initial neurite angles.
ValueError Traceback (most recent call last)
~/Documents/WORK/DENSE/examples/space_embedding/ordered_neurons/neurons_ordred_in_a_box.py in <module>
151 # num_neurites=0)
152
--> 153 gids = ds.create_neurons(n=num_neurons,
154 params=neuron_params,
155 neurite_params=neurite_params,
_pygrowth.pyx in dense._pygrowth.create_neurons()
_pygrowth.pyx in dense._pygrowth._create_neurons()
ValueError: InvalidParameter @init_status in /home/ele/Documents/WORK/DENSE/src/elements/Neuron.cpp:200
`neurite_angles` contain invalid neurite names.
I'm sure it worked not long ago after your update.
Here's the code to reproduce
# -*- coding: utf-8 -*-
#
# polygons.py
#
# This file is part of DeNSE.
#
# Copyright (C) 2019 SeNEC Initiative
#
# DeNSE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# DeNSE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with DeNSE. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import time
import numpy as np
import matplotlib.pyplot as plt
import nngt
import dense as ds
from dense.units import *
def CleanFolder(tmp_dir, make=True):
if os.path.isdir(tmp_dir):
shutil.rmtree(tmp_dir)
if make:
os.mkdir(tmp_dir)
return tmp_dir
current_dir = os.path.abspath(os.path.dirname(__file__))
main_dir = current_dir[:current_dir.rfind("/")]
'''
Main parameters
'''
soma_radius = 8.
num_neurons = 10
#~ gc_model = 'persistent_random_walk'
gc_model = 'run-and-tumble'
use_uniform_branching = False
use_vp = True
use_run_tumble = False
neuron_params = {
"axon_diameter": 4. * um,
"dendrite_diameter": 2.*um,
"soma_radius": soma_radius * um,
"random_rotation_angles": False,
"neurite_names": ["axon", "dendrite_1"], # this I just added to see if explicit naming would help
"neurite_angles": {"axon": 0.*deg, "dendrite_1": 180.*deg},
}
axon_params = {
"growth_cone_model": gc_model,
"use_uniform_branching": use_uniform_branching,
"use_van_pelt": use_vp ,
"sensing_angle": 45.*deg,
"speed_growth_cone": 0.025 * um / minute, #0.15
"filopodia_wall_affinity": 100.,
"filopodia_finger_length": 7. * um,
"filopodia_min_number": 30,
"persistence_length": 300. * um,
"taper_rate": 1./4000.,
'B': 3. * cpm,
'T': 1000. * minute,
'E': 1.,
}
dendrite_params = {
"use_van_pelt": use_vp,
"growth_cone_model": gc_model,
"speed_growth_cone": 0.01 * um / minute,
"filopodia_wall_affinity": 10.,
"persistence_length": 200. * um,
"taper_rate": 3./250.,
"B": 6. * cpm,
"T": 1000. * minute,
'E': 1.,
}
neurite_params = {"axon": axon_params, "dendrite": dendrite_params}
'''
Simulation
'''
def step(n, loop_n, plot=True):
ds.simulate(n)
if plot:
ds.plot.plot_neurons(show_nodes=True, show=True)
if __name__ == '__main__':
num_omp = 10
kernel = {
# For random simulations each time
# "seeds": np.random.randint(0, 100, num_omp),
"seeds": range(10, 10+num_omp),
"num_local_threads": num_omp,
"resolution": 10. * minute,
"adaptive_timestep": -1.,
"environment_required": True,
"interactions": True
}
ds.set_kernel_status(kernel, simulation_id="ID")
gids, culture = None, None
culture_file = current_dir + "/box.svg"
min_x = 0 # Choice of the coordinates associated to
max_x = 1800 # the x axis of the imported environment image
# the y coodirnated will be automatically determined
# by scaling from the image
# using Inkscape for the bix.svg the y coordinated will be
min_y = -707
max_y = +707
y_margin = (max_y-min_y)/num_neurons # choice of margin not to seed neurons closer to the border
if kernel["environment_required"]:
culture = ds.set_environment(culture_file, min_x=0, max_x=1800)
# neuron_params['position'] = [(900., 0.),(900., 100.)] *um
positions = []
for y in np.linspace(min_y+y_margin,
max_y-y_margin, num_neurons):
positions.append((900, y))
neuron_params['position'] = positions *um
print("Creating neurons")
gids = ds.create_neurons(n=num_neurons,
params=neuron_params,
neurite_params=neurite_params,
num_neurites=2)
start = time.time()
for i in range(3):
step(2 * day, 0, True)
duration = time.time() - start
plt.show(block=True)
print("SIMULATION ENDED")
Hi,
Install scripts pip install pyneuroml
.
Examples withimport neurom
where not working.
I had to pip install --user neurom
instead to have it work
Should install script be updated ?
Best
For some reason it is not possible to compile DeNSE with the new Cython 3 version.
Compilation fails with:
Dans le fichier inclus depuis /usr/include/python3.11/Python.h:11,
depuis DeNSE/src/pymodule/dense/_pygrowth.cpp:60:
DeNSE/src/pymodule/dense/_pygrowth.cpp: Dans la fonction « int __pyx_import_star_set(PyObject*, PyObject*, char*) »:
/usr/include/python3.11/patchlevel.h:19:33: erreur: l-valeur exigée comme opérande de gauche de l'affectation
19 | #define PY_MAJOR_VERSION 3
| ^
DeNSE/src/pymodule/dense/_pygrowth.cpp:52624:3: note: dans l'expansion de la macro « PY_MAJOR_VERSION »
52624 | PY_MAJOR_VERSION = __Pyx_PyInt_As_int(o); if (unlikely((PY_MAJOR_VERSION == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 203, __pyx_L2_error)
| ^~~~~~~~~~~~~~~~
/usr/include/python3.11/pyport.h:132:27: erreur: l-valeur exigée comme opérande de gauche de l'affectation
132 | # define PY_SSIZE_T_MAX SSIZE_MAX
| ^~~~~~~~~
DeNSE/src/pymodule/dense/_pygrowth.cpp:52627:3: note: dans l'expansion de la macro « PY_SSIZE_T_MAX »
52627 | PY_SSIZE_T_MAX = __Pyx_PyIndex_AsSsize_t(o); if (unlikely((PY_SSIZE_T_MAX == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 63, __pyx_L2_error)
| ^~~~~~~~~~~~~~
error: command '/usr/bin/gcc' failed with exit code 1
A new issue when updating neurite parameters with dense.set_object_properties()
, occuring possibly only with environment enabled (example program worked fine on april 9th):
Continuing the simulation after parameter update leads to segmentation fault.
# Two successive simulation runs : ok
ds.simulate(1*day)
ds.simulate(1*day)
# Now update of parameters (error persist even if neurite_parameters unchanged)
dense.set_object_properties(gids, neurite_params=neurite_params)
# Addition simulation run
ds.simulate(1*day) # leads to segmentation fault
m
Repeating simulation steps without calling dense.set_object_properties() works
for i in range(3):
ds.simulate(1*day)
Example code:
import os
import shutil
import time
import numpy as np
import matplotlib.pyplot as plt
import nngt
import dense as ds
from dense.units import *
current_dir = os.path.abspath(os.path.dirname(__file__))
main_dir = current_dir[:current_dir.rfind("/")]
def CleanFolder(tmp_dir, make=True):
if os.path.isdir(tmp_dir):
shutil.rmtree(tmp_dir)
if make:
os.mkdir(tmp_dir)
return tmp_dir
def step(n, loop_n, plot=True):
print("simulating", n)
ds.simulate(n)
print("done")
if plot:
_, ax = plt.subplots()
ds.plot.plot_neurons(mode='mixed', subsample=1, axis=ax,
show_nodes=True, show_neuron_id=True, show=True)
'''
Main parameters
'''
np.random.seed(0)
soma_radius = 5.
num_neurons = 10
gc_model = 'cst_po_nwa'
use_vp = True
neuron_params = {
"soma_radius": soma_radius * um,
}
dendrite_params = {
"use_van_pelt": True,
"growth_cone_model": gc_model,
"speed_growth_cone": 0.06 * um / minute,
"filopodia_wall_affinity": 0.01,
"persistence_length": 200. * um,
"B": 6. * cph,
"T": 1000. * minute,
"E": 1.,
}
axon_params = {
"growth_cone_model": gc_model,
"use_uniform_branching": False,
"sensing_angle": 70.*deg,
"speed_growth_cone": 0.1 * um / minute,
"filopodia_wall_affinity": 10.,
"filopodia_finger_length": 10. * um,
"filopodia_min_number": 30,
"affinity_axon_axon_other_neuron": 100.,
"persistence_length": 500.*um,
"taper_rate": 1./400.,
"diameter_ratio_avg": 0.5,
# branching
"use_van_pelt": True,
"use_uniform_branching": False,
"filopodia_wall_affinity": 10.
}
neurite_params = {
"axon": axon_params,
"dendrites": dendrite_params
}
'''
Simulation
'''
if __name__ == '__main__':
num_omp = 10
kernel = {
"seeds": range(num_omp),
"num_local_threads": num_omp,
"environment_required": True,
"resolution": 5. * minute,
"interactions": True}
np.random.seed(118239) # seeds for the neuron positions
ds.set_kernel_status(kernel, simulation_id="ID")
gids, culture = None, None
if kernel["environment_required"]:
shape = ds.environment.Shape.disk(300.)
culture = ds.set_environment(shape)
# generate the neurons inside the left chamber
# pos_left = culture.seed_neurons(
# neurons=100, xmax=540, soma_radius=soma_radius)
neuron_params['position'] = culture.seed_neurons(
neurons=num_neurons, soma_radius=soma_radius)
else:
neuron_params['position'] = \
np.random.uniform(-1000, 1000, (num_neurons, 2))*um
print("\nCreating neurons\n")
gids = ds.create_neurons(n=num_neurons,
culture=culture,
params=neuron_params,
neurite_params=neurite_params,
num_neurites=3)
rec = ds.create_recorders(gids, "num_growth_cones")
start = time.time()
for i in range(3):
step(1 * day, 0, True)
# dendrite_params.update({"speed_growth_cone": 0.04 * um / minute,
# "use_van_pelt": False})
# axon_params.update({"speed_growth_cone": 0.1 * um / minute,
# "use_van_pelt": False,
# "use_uniform_branching": True,
# "uniform_branching_rate": 0.1 * cph,})
# NB dictionary neurite_params is updated
print("update parameters")
ds.set_object_properties(gids, neurite_params=neurite_params)
print("parameters updated")
print("extension run")
step(1 * day, 0, True)
print("extension run done")
duration = time.time() - start
print(ds.get_kernel_status("time"))
plt.show(block=True)
print("SIMULATION ENDED")
Something may have changed with respect to the resource-based implementation because the current models lead to biologically-irrelevant dynamics where most of the neurites die out.
when installing DeNSE from a fresh version of Linux Mint
./install_debian.sh
install works well up until
Collecting breathe
Using cached https://files.pythonhosted.org/packages/2b/4a/bc1bdf34b258e64d9d65869820da927a8995ed9b6edce933b4e11b35848f/breathe-4.19.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-QeRQ8u/breathe/setup.py", line 11, in
import breathe
File "breathe/init.py", line 10
def setup(app: Sphinx):
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-QeRQ8u/breathe/
DeNSE seems like it works despite this
Hi Tanguy,
I'm at last playing with the critical resources models. Namely growth cone model res_po_rt
.
I am facing the issue that the model runs ony over one simulation step. If you launch a second simulation step after a first one, it remains stucked.
i.e.
> ds.simulate(12000 * minute)
works, but not
> ds.simulate(6000 * minute)
> ds.simulate(6000 * minute)
See attached code.
See you
Samuel
At some point, branching method was changed regarding the way new cones are positioned with respect to either themselves or to the previous polygon and this leads to issues when interactions are on (new growth cones must interact with one another or the previous polygon) which leads to their pruning.
Currently, kernel parameters passed via set_kernel_status
are not checked, which can lead to very problematic errors, especially if "resolution"
is an integer, leading to its value being set to zero.
If one of the first two growth cones after the first branching dies, then plot_dendrogram
is not able to handle the fact that there are two nodes with a single child.
Add links to source files in docs/user/tutorial.rst
using the :source:
role.
See here.
Using the shapely _geom
pointer directly causes too many issues, use WKT to pass geometries back and forth between Python and C++
We need a page which groups all parameters by "common feature" (e.g. lateral branching). gives a one line explanation as to what they do, and refers to a section containing all the details about this feature and the associated model.
Hi,
Nothing critical, just wanted to tell there's still a warning concerning boost:
/usr/include/boost/detail/no_exceptions_support.hpp:17:1: note: ‘#pragma message: This header is deprecated. Use <boost/core/no_exceptions_support.hpp> instead.’
17 | BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
Repeated many times during compilation.
Best
Following multiple splitting events, the diameter decreases discontinuously which is a problem when all sibling cones die.
To solve this one would probably have to handle intermediate node removal but even with this feature, no obvious solution comes to mind except for some kind of dynamical diameter implementation (maybe associated to competition for the resource-based model)
Won't fix for now.
The script:
import dense as ds
pop = ds.create_neurons(10, num_neurites=1)
pop.get_properties()
Leads to the following error:
~/.local/lib/python3.9/site-packages/dense-0.1.0-py3.9-linux-x86_64.egg/dense/elements.py in __getitem__(self, key)
1031 return pop
1032 else:
-> 1033 return super(Population, self).__getitem__(self._idx[key])
1034
1035 @property
KeyError: 0
This flag:
'-Dwith-debug=ON'
in
function( CGROWTH_PROCESS_WITH_DEBUG )
if ( with-debug )
if ( with-debug STREQUAL "ON" )
if (NOT MSVC)
set( with-debug "-g" )
endif ()
set( CMAKE_BUILD_TYPE "Debug" PARENT_SCOPE )
else ()
foreach ( flag ${with-debug} )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE )
endforeach ()
endif ()
else ()
set( CMAKE_BUILD_TYPE "Release" PARENT_SCOPE )
endif ()
endfunction()
overrides the standard flag CMAKE_BUILD_TYPE
To prevent issues on older machines, installation should check:
If a growth cone is the only child of a node and it retracts back to this node, then should the node be removed and the growth cone be able to retract further back?
node growth cone
===o====> becomes ===o=> then ===> then =>
Neuron
creation within Population
does not use new __init__
method.
Hi again,
Using the new neurite parameter dictionary
neurite_params = {"axon": axon_params, "dendrite": dendrite_params}
when attempting to use create_neurites() on neurons to create an axon and neurites, the "axon" entry in the neurite parameters is not recognized:
# Here neurons created
gids = ds.create_neurons(n=num_neurons, params=neuron_params, num_neurites=0)
# Now for each neuron, creation of neurites
for neuron in gids:
neuron.create_neurites(num_neurites=2, params=neurite_params)
Here are the definition of the parameters
neuron_params = {
"axon_diameter": 4. * um,
"dendrite_diameter": 2.*um,
"soma_radius": soma_radius * um,
}
axon_params = {
"growth_cone_model": gc_model,
"use_uniform_branching": use_uniform_branching,
"use_van_pelt": use_vp ,
"sensing_angle": 45.*deg,
"speed_growth_cone": 0.025 * um / minute, #0.15
"filopodia_wall_affinity": 100.,
"filopodia_finger_length": 7. * um,
"filopodia_min_number": 30,
"persistence_length": 300. * um,
"taper_rate": 1./4000.,
'B': 3. * cpm,
'T': 1000. * minute,
'E': 1.,
}
dendrite_params = {
"use_van_pelt": use_vp,
"growth_cone_model": gc_model,
"speed_growth_cone": 0.01 * um / minute,
"filopodia_wall_affinity": 10. ,
"persistence_length" : 200. * um,
"taper_rate": 3./250.,
"B": 6. * cpm,
"T": 1000. * minute,
'E': 1.,
}
neurite_params = {"axon": axon_params, "dendrite": dendrite_params}
in /src/pymodule/dense/io/data_swc.py
method load_swc()
has aberrant behvior:
Currently if swc_file
is given, the code assumes the file contains only one neuron !
If both swc_folder
and swc_file
are given, it assumes the file contains only one neuron.
If the swc file
contains more than one neuron, it requires only the swc_folder
path.
Rather confusing
Hi Tanguy,
I'm resuming testing the installation on macosx (10.15.7)
Problems by building.
BOOST following warning repeated many times :
/usr/local/include/boost/geometry/geometry.hpp:27:138: note: #pragma message: CAUTION: Boost.Geometry in Boost 1.73 deprecates support for C++03 and will require C++14 from Boost 1.75 onwards. BOOST_PRAGMA_MESSAGE("CAUTION: Boost.Geometry in Boost 1.73 deprecates support for C++03 and will require C++14 from Boost 1.75 onwards.") ^ /usr/local/include/boost/geometry/geometry.hpp:28:110: note: #pragma message: CAUTION: Define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING to suppress this message. BOOST_PRAGMA_MESSAGE("CAUTION: Define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING to suppress this message.")
But make concludes with
'
make[2]: *** [src/kernel/CMakeFiles/kernel.dir/space_manager.cpp.o] Error 1
make[1]: *** [src/kernel/CMakeFiles/kernel.dir/all] Error 2
make: *** [all] Error 2
'
Problem also with the doc
`Scanning dependencies of target doc
[100%] Compiling documentation...
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sphinx/config.py", line 319, in eval_config_file
execfile_(filename, namespace)
File "/usr/local/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 89, in execfile_
exec(code, _globals)
File "/Users/ele/Documents/DeNSE/build/docs/conf.py", line 113, in
gen_autosum(f, target, module, 'summary')
File "/Users/ele/Documents/DeNSE/build/docs/conf.py", line 68, in gen_autosum
mod = importlib.import_module(module)
File "/usr/local/Cellar/[email protected]/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 961, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'dense'
make[3]: *** [docs/CMakeFiles/doc] Error 2
make[2]: *** [docs/CMakeFiles/doc.dir/all] Error 2
make[1]: *** [docs/CMakeFil`
Here is the config
'- Check for working CXX compiler: /usr/local/bin/g++-8 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Host triple: x86_64-apple-darwin
-- Target triple: x86_64-apple-darwin
-- Found PythonInterp: /usr/local/opt/[email protected]/bin/python3 (found suitable version "3.8.6", minimum required is "3")
-- Found PythonLibs: /usr/local/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib (found version "3.8.6")
-- Found PythonInterp: /usr/local/opt/[email protected]/bin/python3 (found version "3.8.6")
-- Found Cython: /usr/local/bin/cython (found version "0.29.21")
-- Found GEOS: /usr/local/Cellar/geos/3.8.1_1/lib/libgeos_c.dylib (3.8.1)
-- Boost 1.62 found.
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.20") found components: doxygen dot
-- Found breathe: Yes
-- Found Sphinx: /usr/local/bin/sphinx-build
Build type : Release
Target System : Darwin
Cross Compiling : FALSE
C compiler : /usr/local/bin/gcc-8
C compiler flags : -fopenmp -fdiagnostics-color=auto
C++ compiler : /usr/local/bin/g++-8
C++ compiler flags : -std=c++11 -fopenmp -fdiagnostics-color=auto
GEOS library : Yes
Includes : /usr/local/include
Libraries : /usr/local/Cellar/geos/3.8.1_1/lib/libgeos_c.dylib
BOOST headers : Yes 1.73.0
Includes :
Python bindings : Yes (Python 3.8: /usr/local/opt/[email protected]/bin/python3)
Includes : /usr/local/Frameworks/Python.framework/Versions/3.8/include/python3.8
Libraries : /usr/local/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib
Cython bindings : Yes (Cython 0.29.21: /usr/local/bin/cython)
Use threading : Yes (OpenMP: -fopenmp)
Use doxygen : Yes (/usr/local/bin/doxygen)
Use Sphinx : Yes (/usr/local/bin/sphinx-build) => -Dwith-docs=ON
can be used
Use Breathe : Yes
Use MPI : No
Python bindings will be installed to:
/Users/ele/Library/Python/3.8/lib/python/site-packages
Libraries will be installed to:
/Users/ele/Library/Python/3.8/lib
Binaries will be installed to:
/Users/ele/Library/Python/3.8/bin
`
No more showing of a neurite dendogram of branchings by using object syntax. Eg.
not working:
tree = n.axon.get_tree()
tree.show_dendrogram()
working instead:
ds.plot.plot_dendrogram(n.axon)
See for instance /examples/neurons.chandelier-cell.py
at the very end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.