Closed vsrivas closed 1 year ago
Hi @vsrivas
Once you've exported the morphology, you'll see your new segments/segment groups in the NeuroML representation. To complete the cell, you need to now add the various biophysics to it. (Continue from the "# Other cell properties" bit in the OLM cell example)
So, for example:
mycell = .... # something that reads swc and exports to NeuroML
mycell.summary() # will show you how many segments and segment groups the cell has
mycell.add_channel_density(....group_id="some segment group id") # add this channel to this segment group
and so on. You need to know the ids of the segments/segment groups here---you can either just directly look at the NeuroML XML file, or you can use the python object model:
for sg in cell.morphology.segment_groups:
print(f"** {sg.id} **")
print(cell.get_all_segments_in_group(sg.id))
print() # add blank line
will show you all the segment groups and their segments.
I hope this helps, please let us know how you go and we can discuss this further.
Hi Ankur,
Thanks for your reply. I am trying to understand your suggestions. Meanwhile, I am enclosing my understanding and proposed solution. Please advise if it is correct.
from neuroml.loaders import SWCLoader def get_morph(fname): return SWCLoader.load_swc_single(fname).to_neuroml_morphology("pyr_morph")
morpho = get_morph("AA0995.CNG.swc")
def create_olm_cell(): nml_cell_doc = component_factory("NeuroMLDocument", id="oml_cell") cell = nml_cell_doc.add("Cell", id="olm", neuro_lex_id="NLXCELL:AA0995") # type neuroml.Cell nml_cell_file = cell.id + ".cell.nml"
cell.add_unbranched_segment_group("soma_0") soma_0 = cell.add_segment( prox=[morpho.segments[0].proximal.x, morpho.segments[0].proximal.y, morpho.segments[0].proximal.z, morpho.segments[0].proximal.diameter], dist=[morpho.segments[0].proximal.x, morpho.segments[0].proximal.y, morpho.segments[0].proximal.z, morpho.segments[0].proximal.diameter], name="Seg0_soma_0", group_id="soma_0", seg_type="soma" )
A snapshot of the .swc is attached with this email. Is this approach correct? Also, I could not figure out how to access the "type" of the morphology from the "morpho" file. When I do morpho.segments[1].id, it gives me the index of the segment, not the type (1, 2, or 3). Please advise.
Thanks for your help
I think the SWCLoader class is meant to be deprecated. I see a comment there that says so:
https://github.com/NeuralEnsemble/libNeuroML/blob/development/neuroml/loaders.py#L96
Loading morphologies is usually tricky because a morphology that was reconstructed from experiments may not contain the information necessary for modelling. So one has to make lots of manual tweaks to ensure it's a valid morphology for modelling. Take a look at this page for some information on this:
https://docs.neuroml.org/Userdocs/ImportingMorphologyFiles.html
Currently, the preferred way is to use something like NEURON as a first step to import swc files into a modelling representation, fix it up, and then export from neuron to NeuroML. So, we'd use the Neuron Import3D method to export the morphology to a hoc file, and then use the export_to_neuroml2 to generate the NeuroML from it. That'll give you a NeuroML Cell with the morphologies (segments/segment groups) already set. Then, we follow the OLM tutorial to add the necessary biophysics. Here's an example script:
Using neuroConstruct is another, probably simpler way. It also does lots of checks etc. to ensure the generated morphology is appropriate for modelling.
A "native" swc to neuroml converter is in the works, but it's not quite ready yet. See this issue:
Yes @vsrivas, do try out loading the swc into neuroContruct. The advantage there is you can clearly see the 3D structure and any strange connectivity at the soma.
You can edit the morphology in nC (it's a bit clunky, but you see what you change in 3D) and then export it to NML2.
@sanjayankur31 @pgleeson : Thank you. This solved my problem.
@vsrivas that's great to hear. Please do let us know if we can help in any other way too.
Hi, I have just started using NeuroML2 and trying to re-work with the "Interactive multi-compartment OLM cell example". I have to use the morphology from a .swc file. I have converted the .swc file to neuroml morphology. I am stuck on how to use this morphology file in the OLM example.
I understand that I have to replace the description of soma, axon, and dendrite but can't figure out how these values can be replaced from a file.
Any help is greatly appreciated. Thanks