libNeuroML
libNeuroML copied to clipboard
NEURON compatible morphologies from ArrayMorphology.
Allows to do something like
fname = 'Morphologies/pyr/MouseLight_Final/CNG version/AA0995.CNG.swc'
SWCLoader.load_swc_single(fname).to_neuroml_morphology("pyr_morph")
and use successfully this morphology in NEURON simulations. Tested with https://neuromorpho.org/neuron_info.jsp?neuron_name=AA0995 . If you like it you can merge it; if you'd prefer not to merge right away, you can wait. I'll continue to use this code with other morphologies for a project of mine so I'll push fixes if this does not work with other morphologies.
I attached the generated morphology, for reference. The biophys is rubbish (they are the same as for the tutorial on the OLM cell), but the morphology seems reasonable to me.
Hi @christian-oreilly , thanks for that. Could you rebase that against the development branch please? The master branch is "stable, released code", so all new features/fixes go into development. We then merge development into master when we make a release.
The development branch has a number of new cell builder methods and so on which could perhaps make this easier for you too:
https://libneuroml.readthedocs.io/en/development/userdocs/coreclasses.html#cell
For example, this may help:
https://libneuroml.readthedocs.io/en/development/userdocs/coreclasses.html#neuroml.nml.nml.Cell.add_unbranched_segments
Very nice to know, @sanjayankur31. I am used to the master being the "development version" and releases being flagged as such, so I did not think of looking for a bleeding-edge branch. This is very good to know! I'll look at the development code and edit the PR accordingly.
@sanjayankur31 Sorry for taking so long to get around to do that but this PR is now rebased onto development.
Well, @sanjayankur31, that is somewhat counterproductive guys (and a failure in communication) if you ask me to rebased this PR and the next day that I rebase, you put a runtime error to deprecate the method that this PR is relying on ( https://github.com/NeuralEnsemble/libNeuroML/commit/c2f829f7f29ae388162d836a19f31f5e5b82a793 ). Anyway, I'll just fork this converter out of libneuroml and provide it as a standalone if you are not interested in maintaining this as part of libneuroml as your doc https://docs.neuroml.org/Userdocs/ImportingMorphologyFiles.html do not point to any viable Python option for import SWC, as far as I can tell.
Ah, sorry about that @christian-oreilly. I hadn't looked at this PR in a while and I missed that the code was being used here. I'll revert that change to mark it for deprecation in a future release.
This rather naive coverter is not really complete/tested. For example, it runs none of the checks listed in our documentation to ensure that the generated NeuroML file is viable for modelling. A user will need to do all of these checks themselves. A full SWC converter is being worked on here:
https://github.com/NeuroML/pyNeuroML/issues/89
https://github.com/WardDPeeters/Morphologies
The plan is to include this in pyneuroml to create an interactive converter, hopefully in the new year.
Until then, the suggested method is to use neuroConstruct, which runs all the necessary checks already provides an interactive UI for the user to make tweaks where required. If your files are NEURON files, this is another pythonic way of doing it:
https://github.com/sanjayankur31/Human-L2-3-Cortical-Microcircuit/blob/feat/neuroml/NeuroML2/cellmorph2nml.py
Error softened to warning: https://github.com/NeuralEnsemble/libNeuroML/commit/f4415dcb9fde4afbf8ed3467b777be1f6c57ec88
Thanks for the info, @sanjayankur31. It is much appreciated and useful. I'll look at these different options. Your conversion from NEURON seems interesting. Do you have anything going on about converting mod files? I started a while back to work on that (based on the work of others using the domain-specific language converter textx). At the time, I could not find anything public doing a satisfying job, but I'd be very interested to know if you are working on something for that under the radar. I don't want to lose time on that if there is a more "official" solution to that already being developped.
There's no completely automated way to convert mod files that I'm aware of, primarily because they can contain equations and so on in them that need a human to go over and convert into a declarative form that NeuroML requires. We have helper tools though. They're noted here:
https://docs.neuroml.org/Userdocs/CreatingNeuroMLModels.html?highlight=chananalysis#b-convert-channels-to-neuroml
In short:
- pyneuroml includes the
export_mod_to_neuroml2method which will try to fill in as much information as it can manage into a NeuroML channel file: https://pyneuroml.readthedocs.io/en/development/pyneuroml.neuron.html#pyneuroml.neuron.export_mod_to_neuroml2
Then, a human must go over the mod file and fill in the rest. To help with this there are:
- pynml-modchananlyis: generates info plots about the activation variables listed in the mod files
- pynml-channelanalysis: generates info plots about the activation variables used in the NeuroML
So the idea is to complete the neuroml channel file iteratively until the plots from pynml-channelanalysis match the ones that pynml-modchananalysis.
I think neuroConstruct does have lots of these utilities built in too, but I haven't used it much so i can't be sure. (I find it easiest to find existing NeuroML channel files and tweak them. The ones in the L5bPyrCellHayetal repo tend to cover quite a few and there should be more on NeuroML-DB. channelpedia also provides NeuroMLv1 exports of channels, and these can be converted to NeuroML using the pynml-channelml2nml tool.)