brian-team / brian2tools Goto Github PK
View Code? Open in Web Editor NEWTools to use with Brian 2, in particular for visualization
Home Page: https://brian2tools.readthedocs.io
License: Other
Tools to use with Brian 2, in particular for visualization
Home Page: https://brian2tools.readthedocs.io
License: Other
First step for the GSoc 2020 project: represent a NeuronGroup
with all its information as a dictionary.
We should decide how to release/version brian2tools
with respect to brian2
. My original proposal was to have a linked release strategy, i.e. we'll release a new version of brian2tools
whenever we release a version of brian2
. The advantage is that we don't have to check the compatibility across different versions, during the development cycle, brian2tools
would test against the current development version of brian2
so at release time it would be guaranteed to work together. Is this reasonable? The main disadvantages of this approach that I can see:
brian2tools
more often than brian2
(but hopefully we do releases of brian2
more regularly in the future)brian2tools
release without any changes, just because a new brian2
version is outAnother question is whether this linking would be strictly enforced, i.e. should the dependency of brian2tools
on brian2
would use an exact version number?
On the other hand, if we manage to uncouple brian2tools
from brian2
internals as much as possible and manage to keep API breaks in brian2
to a minimum, then all of this is maybe not really an issue. We'll just do brian2tools
releases whenever (and maybe start at a humble 0.1
version or so), and have it always depend on brian2>X
, where X
is the latest release.
Any thoughts on this?
When i want to plot the results with brian_plot(connections['XeAe'].w)
, following error appeared.
Would you please give me some advisers, thanks
`INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage10" as iconphoto: not a photo image
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage19" as iconphoto: not a photo image
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage28" as iconphoto: not a photo image
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage38" as iconphoto: not a photo image
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage47" as iconphoto: not a photo image
ERROR Brian 2 encountered an unexpected error. If you think this is bug in Brian 2, please report this issue either to the mailing list at http://groups.google.com/group/brian-development/, or to the issue tracker at https://github.com/brian-team/brian2/issues. Please include this file with debug information in your report: c:\users\licecv\appdata\local\temp\brian_debug_cvd6ww.log Additionally, you can also include a copy of the script that was run, available at: c:\users\licecv\appdata\local\temp\brian_script_983vzt.py You can also include a copy of the redirected std stream outputs, available at c:\users\licecv\appdata\local\temp\brian_stdout_jransm.log and c:\users\licecv\appdata\local\temp\brian_stderr_duu1ut.log Thanks! [brian2]
Traceback (most recent call last):
File "D:/1-xpj/8-bishe/code/Brian2STDPMNIST/Diehl&Cook_spiking_MNIST_Brian2.py", line 553, in
brian_plot(connections['XeAe'].delay)
File "C:\Anaconda3\envs\py27\lib\site-packages\brian2tools\plotting\base.py", line 154, in brian_plot
'%s' % type(brian_obj))
NotImplementedError: Do not know how to plot object of type <class 'brian2.core.variables.VariableView'>
Process finished with exit code 1`
LaTeX (Nordlie et al. 2009?)
Markdown?
We only allow plotting synaptic variables and check whether the variable's group is a Synapses
object. For delay
, this is no longer the case in recent Brian versions, its group is now the SynapticPathway
.
First reported on the mailing list: https://groups.google.com/d/msg/brian-development/-bdFXNhb7XE/A2nf7a0EBAAJ
From @romainbrette on July 20, 2018 14:19
I just noted this library which deals with neuronal morphology (including swc, hdf5 and (experimental) Neurolucida):
https://github.com/BlueBrain/NeuroM
Useful?
Copied from original issue: brian-team/brian2#983
Synaptic events and run_regularly
operations often use the +=
operator (or -=
). We currently include them in the descriptions and that's of course ok, but they look a bit more like programming language code than a mathematical description. It would be nice to replace something like v_post += w
by "increase v_post by w".
With the polishing
branch, intializations that refer to rand()
or randn()
already look a bit nicer. But I think we could use this as a first example of automatic annotation with additional analysis.
If an expression only contains a single rand()
call, we can use sympy's substitution mechanism and substitute it once with 0 and once with 1, and then use this to display the lower and upper bounds. So if you have an initialization like:
v = El + (V_th - El)*rand()
This would currently be displayed as:
but we could further annotate this with something like
We could probably do something fancy with sympy as well to get the mean and variance of a normal distribution if the expression uses randn()
.
Also represent StateMonitor
, SpikeMonitor
and PopulationRateMonitor
in the structure created as part of #30
We have some model fitting code in the model fitting branch. It uses differential evolution to fit traces. But what we could do is a general API, which would work with any optimization function. The user simply defines the criterion to be calculated, and passes the optimization function to use. This could work for any gradient-free algorithm.
What we need to add is a callback for initializing the models, and maybe a few other things.
Then we might be able to use gradient-based algorithms by using automatic differentiation tools such as Autograd. To calculate dE/dp, where E is an error criterion and p is a parameter, we need to be able to calculate dVm/dp. We get this by differentiating the membrane equation with respect to p, and then integrating. We see that we actually need to calculate dXi/dp for every state variable i. We use autograd to calculate the RHS. The main question is whether this can be easily vectorized across neurons.
One of the things I sometimes do when working on a new model is have a sort of 'scientific test suite' which automatically plots the output of each stage of the model and then dumps them into a pdf file. Maybe it would be good to have a tool that automates this, e.g. you would write calibrated_run(100*ms)
instead of run(100*ms)
. Or even simpler, you would create a cal = CalibrationPlotter('filename.pdf')
that would be a BrianObject
and would do some stuff in the before and after run slots. So for example, it would plot a graph of the network, and for each object it would call brian_plot
on it. For NeuronGroup
it would also create a SpikeMonitor
and StateMonitor
(which would only record a handful of neurons to save memory).
I'm not sure how widely useful this would be. Perhaps it's too specific a use case, but it feels like something that a lot of people would benefit from doing but don't because it's effort and time taken from doing the actual modelling work, but if it was made trivially easy to do so then they might.
PoissonGroup
SpikeGeneratorGroup
This summer I would be working on "Importing morphologies into Brian from a NeuroML file" as part of the Gsoc 2018. I would be using this thread for keeping track of the milestones and the upcoming work.
Also I would like to use this thread to discuss issues/ suggestions or to gain any other information.
Milestones to be achieved:
After this I will start working on "accessing other information like ion channel from nml file"
After this we will compare result from Brian, Neuron and other simulators. nml file exported from NEURON will be imported and tested in Brian. detailed milestones will be added later.
@mstimberg
For GSoC 2020: a new device (similar to LemsDevice
) to generate a general representation of a Brian model.
At the moment, plotting a StateMonitor with multiple variables gives an error. It would be nice to plot multiple state variables to a figure with multiple axes (with shared x-axis so zooming in on one zooms on all). You could also imagine having a syntax that allows you to choose which axes are re-used and which are new, e.g. show_variables=[('v', 'vt'), ('I',)]
would show v and vt on one axis, and I on another. It could automatically select the correct number of subplots to use to fill the figure.
The problem with this is that at the moment you can specify an axis to plot to, and this would have to allow plotting to multiple axes.
In the past I've written plotting routines for my own use where you can pass an ax
and fig
argument. If the plotting routine needs multiple axes, you have to pass a fig (or it creates a new one if fig is None). If the plotting routine only needs one axis, you can either pass an ax or fig (if you pass a fig, it will do subplot(111)
on that fig). Maybe this scheme would work here?
At the moment, if you brian_plot(S)
for a large Synapses
you just get a big blue square and you can't see any structure in it. Perhaps we could either have an image rather than scatter plot, or adaptively decide the size of the scatter symbols based on the number of synapses?
In Brian 1 there were functions for electrophysiology models and analysis:
http://brian.readthedocs.io/en/1.4.3/electrophysiology_models.html
http://brian.readthedocs.io/en/1.4.3/electrode_compensation.html
http://brian.readthedocs.io/en/1.4.3/traceanalysis.html
It would be nice to port them, but maybe not in the main Brian. These could co in brian2tools, in a new electrophysiology component.
A while ago I wrote a little GUI thing for exploring the behaviour of models, it's in brian2cookbook. You write a class with certain properties and it automatically generates a GUI that has sliders for the parameters, etc. and displays a plot of the behaviour (in realtime if the model is simple enough to be computed that quickly). Do you think it's worth adding this to brian2tools? It would be quite handy for teaching and demonstration purposes. It would probably need a bit of work to update it to work with the latest changes to brian2, and I was thinking of adding a bit of code to allow it to run using IPython GUI tools as well as Qt. Shouldn't be much work though.
Representing Synapses
in standard dictionary format similar to other supported types
e.g. try plotting c11563.CNG.swc
from neuromorpho.org. It didn't finish after several runs. I think this is because it's doing a lot of work constructing Morphology objects? Not sure. In any case, the following code plots it very quickly and efficiently directly from the swc file so it should be possible to do this from a Morphology object too:
def plot_swc(fname, showtype=(True,)*4):
# Load SWC file directly (Morphology is too slow)
# index, type, x, y, z, radius, parent
i, t, x, y, z, r, p = loadtxt(fname).T
i = array(i, dtype=int)-1 # indices start at 1
t = array(t, dtype=int)-1 # types start at 1
p = array(p, dtype=int)
p[p>0] -= 1 # parent indices too, but -1 is special (root node)
# Create and plot a LineCollection
segs = [((x[i], y[i]), (x[p[i]], y[p[i]])) for i in xrange(len(t)) if p[i]>=0 and showtype[t[i]]]
c = LineCollection(segs, linewidths=1, colors='k', linestyle='solid')
gca().add_collection(c)
gca().autoscale_view(True,True,True)
xticks([])
yticks([])
gca().set_frame_on(False)
gca().set_aspect('equal', 'datalim')
Here's the swc file zipped: c11563.CNG.swc.zip
Currently, using a subgroup only stores its name, but we rather need the name of the source & the start
and stop
attributes.
I want to install the brian2tools package in anaconda. But it failed. The Terminal command as follows:
(snn) hu@brouilly:~$ conda install -c brian-team brian2tools
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
Your python: python=3.7
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
The following specifications were found to be incompatible with your CUDA driver:
Your installed CUDA driver is: 10.2
Is this mean that only python version [version='2.7.|3.5.|3.6.|3.4.'] can use brian2tools ?
Also represent run_regularly
operations in the structure created as part of #30
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.