Tag: neuronvisio

Packaging Neuronvisio for conda

New Neuronvisio website

New Neuronvisio website

Neuronvisio is a software that I wrote quite long time ago to visualize computational models of neurons in 3D.  At the point in time when I was actively developing it, few services and software were not existing:

  1. conda was not available (kickass package manager able to deal also with binary dependencies)
  2. read the docs were not avaiable (auto-updated docs on each commit)
  3. github pages didn’t have nice themes available (it was there, but you had to do all the heavy lifting, and I was hosting there the docs, which were updated manually.)

To be able to have a smooth way to release and use the software, I was using Paver as a management library for the package, which served very well until it broke, making Neuronvisio not installable via pip anymore. Therefore I’ve promised to myself that, as soon I had a little bit of time, I was going to restructure the thing and make Neuronvisio installable via conda, automatically pulling all the dependencies needed to have a proper environment working out of the box. Because it will be nice.

Read the docs and github pages

This one was relatevely easy. Neuronvisio docs were always built using sphinx, so host them on read the docs was going to be trivial. Therefore the idea was to point neuronvisio.org to the neuronvisio.rtfd.org and job was done.

Not so fast!

So in the classic yak shaving, which you can read here, or watch the gif below:

View post on imgur.com


Yak shaving: recursively solving problems, with the classic case where your last problem is miles away from where you have started.

It turns out that apex domains cannot point to subdomain (foo.com cannot resolve to zap.blah.com), because DNS protocol does not like it and the internet will burn (or email will get lost, which is pretty much the same problem), so you can only point a subdomain (zip.foo.com) to a subdomain (zap.blah.com).

Therefore my original idea, to use the sphinx generated website as entry point was not a possibility. I could still point neuronvisio.org to whatever I was hosting on the gh branch of the neuronvisio repo. It couldn’t be the docs, because I wanted them automatically updated, so I had to design some kind of presentation website for the software. As I said, Github Pages is now sporting some cool themes, so I’ve picked up one, and just used some bits from the intro page.

At the end of this, I had a readthedocs hook which was recreating the docs on the fly at each commit, without manual intervention required; a presentation website written in Markdown using githubpages infrastructure, everything hosted and responsive with the proper domain set in place. Note that I even didn’t start on the package. Yeah \o/.

Creating the package

To create the conda package for Neuronvisio I had to create the meta.yaml and the build.sh. It was pretty easy to create given the fact Neuronvisio is a python package, and it was already using setup.py. The docs are good, and googling around, with a lot of test and try, I’ve got the package done in no (too much) time.

Solving the dependencies

Neuronvisio has a lots of dependencies, but most of them were already packaged for conda. The only big dependencies I was missing was the NEURON package and the Interview library. So I created a PR on the community maintained  conda-recipes repository. As you can see from the PR and the commit, this was not easy at all and it was super complicated.

It turned out to be impossible to make a proper package for neuron which works out of the box. What we’ve got so far is the support for python and interview out of the box, however not the hoc support. This is due to the way NEURON figures out the prefix of the hoc file at compilation time, and due to the re-location done by conda when the package is installed, this tend to differ and it’s not easy to be patched.

Anyway, there is a workaround, which is to export $NEURONHOME environment variable and you are good to go.

After all this a new shiny release of Neuronvisio is available (0.9.1), which it’s goal is to make the installation a bit easier, and get all the dependencies ready to go with one command.

Happy installing.

How to use Neuronvisio to select particular sections of a NEURON based multi-compartment model

Displaying and visualizing selected sections in multi-compartmental models in 3D it’s quite an hard task, however the info and the clarity that is possible to achieve is worth the effort.

Let’s say you have your multi-compartiment model ready in NEURON and you are interested to show in 3D selected sections of the model with arbitrary colors (for example, to show where certain stimuli are applied), like I did in my Medium Spiny Neuron model to show which spines get stimulated:

spiny MSN with stimulated with different trains in selected spines

spiny MSN with stimulated with different trains in selected spines

Neuronvisio offers a nice API, from the visio module, accessible as controls.visio.select_sections(secs_list, scalar_value), which makes this operation easy.

For example, let’s take the pyramidal neuron model that comes as an example with Neuronvisio.

Let’s say that we want to select the soma, the iseg and the first section of the myelin, and we want to give them arbitrary colors.

To achieve that we can easily run:

controls.visio.select_sections([“soma”, “iseg”, “myelin[0]”], [1, 0.5, 0.2]), obtaining this picture:

Selecting and coloring special sections with Neuronvisio

Selecting and coloring special sections with Neuronvisio

Quite handy and pretty fast, don’t you think?

Some thoughts about NeuroML and standardization

I’m pleased to say that we have released Neuronvisio 0.8.5, which has several small improvements and better documentation. I’m pretty sure that there is always room to improve the documentation.

Anyway, first of all the cerebellum network rendered in Neuronvisio, with the model taken from the NeuroML website

cerebellum_network

Cerebellum Network, taken from the NeuroML example pack

The idea with this release was to demonstrate the ability of Neuronvisio to visualize also Network models which are instantiated in NEURON. To note, this ability has been there from version 0.1.0, but now we are beaming on it.

Neuronvisio is able to import 3 different files: hdf5 structured in Neuronvisio format, hoc files, and NeuroML.

The first file is our way to approach hdf5, which gives us the ability to save all the data of a simulation, plus the model itself in one single file, which can then be reloaded and moved. We do all the work here.

The other two are files format where Neuronvisio does not import directly, but let’s NEURON do the heavy-lifting, to avoid any duplication. The hoc format is classic NEURON interpreted script, while NeuroML is an effort to standardize the way neuronal model are encoded.

In particular I would like to stress the last point: Neuronvisio does not have an ad-hoc NeuroML importer, but re-use the one provided by NEURON. We now just exposing an easy way to load a NeuroML file directly in Neuronvisio with the load method from the Controls class

from neuronvisio.controls import Controls
controls = Controls() # starting the GUI
controls.load('path/to/my_model.xml') #or .h5 or .hoc

or directly launching the program, if you prefer

$ neuronvisio [path/to/my_model.xml] # or .h5 or .hoc

this gives us one powerful interface to simplify the life of a user.

Of course, if your model is in python, you can always run it within Ipython as standard python file

$ neuronvisio
In [1]: run path/to/my_model_in_python

The only problem is the NeuroML importer from NEURON does not handle properly the Network file of NeuroML, and this has been registered as issue #50 on our bug-tracker. This belong more to NEURON then Neuronvisio, but they don’t have a bug-tracker, so we logged on ours tracker and we will link any other place where the discussion will take place. NEURON has an amazing forum with quite instantaneous answers from the NEURON community, including Hines and Carnevale, and we will bring the issue over there.

So, we didn’t write our NeuroML importer, because there is no point to replicate what a software already does. That’s why we are now collaborating with the writing of the libNeuroML library, to have one good library that permits to load any NeuroML model properly, and then give the ability to the developer to map it to its own data-structure.

This is the same approach used in the SBML community, which I think is very powerful.

P.S.: So how did we manage to load the Network in NEURON and visualize it in Neuronvisio, if the NEURON (sorry, NEURON has to be written all capital to be precise…) NeuroML importer is not up to the job yet? We have used the neuroConstruct program, which is able to export a model to NEURON, and used the hoc files to load the model up.

How to push to two different git repositories in one go

Branching illustration

Branching it’s good:
http://git-scm.com/

With the new release of Neuronvisio (0.8.3) we have improved the documentation, gave the software a new home (http://neuronvisio.org) and created a new fork under the NeuralEnsemble orgs.

I think for Python and Neuroscience it would be good to have a website similar to http://pinaxproject.com/ecosystem, to give visibility to the different projects and avoid to re-invent the wheel, however for now using the same space in NeuroEnsemble orgs it’s a good start. I didn’t want to move or transfer my repository there directly,  but I wanted to have a mirror of my repo https://github.com/mattions/neuronvisio in that space, without having to manually update it. I’ve looked how to open a mirror fork on github, but to no avail. So I came up with a possible solution, using the ability of git to push to different repositories.

My solution was to create a new remote point, called all in the local git config (.git/config in your repo) with the following format:

[remote "all"]
url = git@github.com:mattions/neuronvisio.git
url = git@github.com:NeuralEnsemble/neuronvisio.git

This way I can push to both the repos with a single command

git push all

Both the repos will be updated in one go. Neat.

Neuronvisio 0.8.0 out in the wild

pyramidal_3D_change_voltage

A Pyramidal Neuron model visualized with Neuronvisio

We have just released a new version of Neuronvisio, which depends on Mayavi 4.1.x. All the goodies are described in the docs, but I want to highlight an aspect of this release which is pretty important.

When we have ported Neuronvisio, from Mayavi 3.4 to Mayavi 4.1.0, two regression bugs popped out: Issues #32 and Issue #34 .

The good thing about issue #34 was that it was gone in the 4.1.1.dev version of traitsui, therefore we had just to depend on the development snapshot, however the story was different for #32. The bug was difficult to replicate, and it seems to not be deterministic. After investigating the problem, I’ve managed to isolate and set up a Pull Request which actually fixes it https://github.com/enthought/mayavi/pull/23.

While the Pull Request was still to be accepted in the main tree of Mayavi, we wanted to distribute it out there, because Neuronvisio paper is under reviewing, and the Reviewers had several trouble to install the version 0.7.3, which depends on Mayavi 3.4. We managed to package both traitsui and Mayavi and make them as required dependencies of the new Neuronvisio, and using the special version requirement in the pavement, we could make the installation as automatic as possible.

All in all, to install the latest version of Neuronvisio, depending on the latest version of Traitsui and the patched version of Mayavi 4.1.1.dev a user has to run

pip install -U --extra-index-url=http://www.ebi.ac.uk/~mattioni/snapshots/ neuronvisio

which I think it’s pretty neat.

With the new version out, we didn’t want to remove the old docs, ’cause the version are quite different and same information applying to one version in particular. Some of our user may don’t want to update to the latest version, so we have now Neuronvisio docs hosted to the beautiful Read The Docs, at http://readthedocs.org/projects/neuronvisio/ where you can choose the docs according to the version.

Neuronvisio ModelDb plugged in released into the wild

We have just released Neuronvisio 0.7.0.

With this release it is possible to browse the models present on the ModelDb database, and have a look at the readme and at the properties of the Model.

Model Information and properties are presented in a quick way to the user

The Load Model button permits to download, extract, compile and load the model in one click. Sweet.

The other big things is that I didn’t write all this code, but actually 0.7.0 it’s the first release that features a contribution from another person (before was one man band!). Uri wrote the scraper for ModelDb and I’ve hooked it together in the GUI. We developed using the pull-request framework, which github makes very nice and clean.

If you’re interested in computational Neuroscience, and you are using NEURON, give Neuronvisio a go.

Impacts graph on Neuronvisio repo

Lately, github has rolled out a series of graphs to visualize the commit through the time.

An interesting one is the impact graph. This is when everything started

Neuronvisio_impact_start

Neuronvisio started as one man band project, actually as a spin-off of my PhD, when I realized that I was building something that was missing and that could be useful for other people as well. So I just detached the neuronvisio code in is own package, and released online. With time, Neuronvisio started to get some users, and people actually wrote enthusiastically on the ML about it. I was proud. Last August/September Uri decided to contribute to the software, to increase the features of it, in particular to plug it with ModelDB, making easy to browse the database, and to download and load a model directly with one button. I helped on the GUI part, while he took care of the ModelDB representation.

This is the graph of his impact on the software, at later stage.

I really enjoyed the Pull request method, and I have to say that github made the collaboration very easy and nice.It was good fun and I’m looking forward to other contributions.

The new features are not yet released (we’ll do in a bit of time), however if you can’t wait, you can grab the code from github master and give it a go!