I believe we've identified sources of some, maybe all, the problems I've encountered. I've succeeded in generating a .hoc file containing the morphology reconstructed in Neurolucida, with minor differences. Some errors remain during the conversion process, but I believe they can be ignored. I believe there are some bugs and hope we can continue to address these. However, I think at this point it is worth describing the process that seems to work sufficiently well. This was tested in Neurolucida v9.14 (on 2P image stacks) and NEURON 7.1:
How to reconstruct a neuron in Neurolucida and generate a HOC file containing its morphology:
In Neurolucida:
1. Begin the reconstruction in "contour mode" and reconstruct the soma as a series of closed loop contours. I created a closed loop at successive z-levels. It is important to proceed monotonically in z, e.g. start superficial and proceed steadily deeper. Save the reconstruction so you can return to this point if the next steps fail.
2. Switch to selection mode. Right-click and choose "Select contours only". Drag the selection cursor to select all the contours at once. Right-click on a contour (between points) and choose "Set to Cell Body".
3. Switch to manual neuron tracing mode. Trace the remaining processes, taking care to select the appropriate type (dendrite, apical dendrite, axon). I chose to begin each process just within the boundary of the soma volume - I believe the important thing is to start close to the soma (whether inside or outside is not critical).
4. Save the reconstruction in the standard Neurolucida format, e.g. as a .dat file. This is useful if you need to return to make any modifications.
5. Save as an MBF ASCII file, with the .asc extension. This is a text file format that can be read by NEURON. Note: Do NOT use the "export tracing" menu command, instead you should choose "Save as" and select the .asc format there.
In NEURON:
6. Start the NEURON gui, then Tools->Miscellaneous->Import3D.
7. Choose a file, namely the .asc file generated in step 5.
8. You may see an error dialog that says "file translation problems. See the messages on the terminal." Continue / close this message dialog.
9. Inspect the messages at the terminal. You will likely see some lines showing Principle values and Principle axes data - this reflects NEURON's process of converting the soma contours from Neurolucida into the standard NEURON geometry type. Below this you will likely see a list of problems. In my experience, there is one such problem reported for every root process (e.g. the axon, apical dendrite and any basal dendrites), indicating that the root of a process is outside the bounding box of the soma. The messages also indicate that a "logical connection to center of nearest soma" is made. This means that the electrical connectivity (the topology) is established from soma to process, even though there is some geometrical gap. If you see any other problems reported, there may be issues with the reconstruction that were not automatically fixed, i.e. you may need to investigate the problems further. In my case there was an additional dialog window titled "Possible root branch errors". It lists the same "problems" as were shown on the terminal, with checkboxes next to each. Do NOT check any of these - I believe the statements at the terminal confirm that these connections were automatically fixed. Furthermore, in my case as soon as I checked any one of these checkboxes an error occurred and NEURON needed to be restarted. Close this "possible root branch errors" window.
10. The Import3D gui should show you the shape of your imported reconstruction. Optionally, deselect "Show Points" and zoom in/rotate to visually inspect the soma shape. Note that some of the root processes may look like they are hanging disconnected from the soma - geometrically this may be so, but topologically they should be properly connected per the points discussed in #9 above.
11. In Import3D, select "Export" then "CellBuilder". A CellBuild[0] windows should appear. Select the "Management" tab. Select the "Export" button. Deselect the "Membrane" option but keep "Topology", "Subsets", "Geometry" selected. Then click "Export to file" and save as appropriate. The resulting .hoc file contains the morphology of your reconstruction. If you wish, you can of course use the CellBuilder to add passive or active membrane properties for e.g. testing purposes.
12. At this point, I recommend closing NEURON, restarting and then loading the .hoc file via File->load hoc. You can then type
at the terminal to see a schematic diagram of the sections and their connections. You likely will want to confirm that the soma is connected to all the expected main branches.
13. It is recommended that you check your model for any morphological problems. For example, if the diameter is too small at some point the electrical flow may effectively be blocked. The following code executed at the terminal is useful, but won't catch the case of a tiny (but non-zero) diameter:
Code: Select all
forall { for(x,0) { if (diam(x) <=0) print secname(), diam(x) } }
14. You should also check for any sections of zero length:
Code: Select all
forall { if (L<=0) print secname(), L }
15. Finally, I recommend adding passive membrane properties, an IClamp point process at the soma, injecting a current step, and measuring whether the resulting somatic change in membrane potential reaches all the distal processes by displaying a shape plot with the display range scaled appropriately. The Tools->Impedance menu provides a number of more sophisticated ways to analyze / inspect the reconstruction's electrical signal transfer.
Remaining issues:
A. I'd prefer if the default conversion of the soma contours resulted in a soma shape where the "0" end and the "1" end define a line roughly parallel to the y-axis. At present, in my case, the resulting line from "0" to "1" end of the soma is roughly parallel to the z-axis. I'd like to connect the apical dendrite at the narrow end of the "egg", the axon at the opposing blunt end of the "egg", and the basal dendrites in the middle. I don't think this is currently possible in my case, due to z-parallel orientation of the primary axis.
B. The "possible root branch errors" dialog window seems to be broken, and it seems to duplicate the errors shown in the terminal and conflict with them (the terminals says they were automatically fixed, the dialog says the user should select the ones to be fixed). Note that checking any of these results in errors at the terminal and breaks the ability to export to CellBuilder.
C. I'd prefer if Import3D printed info to the terminal indicating what type of file was recognized (i.e. "Neurolucida v3"), and also what types of elements were identified (e.g. "Contours: 1 soma; Tracings: 1 axon, 1 apical dendrite, 14 basal dendrites").
D. Turns out that the Neurolucida "Export tracing->ASC v2" command generates files whose header reads "version 3", but which are not "v3" files. Furthermore, these files are not the same as the ones generated by "Save as -> ASCII 2 .asc2". The latter are identified as "v3" by NEURON, the former as older versions. I'm waiting for some clarification from Neurolucida on these different formats and will report what I learn - for now, the key is to use "Save as->ASC".
E. For Neurolucida users: if you wish to reconstruct the soma as a tracing (i.e. sequence of tapered cylinder sections) instead of as contours, you may need to take the following approach: First reconstruct the soma as contours, the rest of the cell as tracings, as detailed above. Generate a .hoc file from this. Then start a new reconstruction, tell NL that you are tracing a "dendrite" in manual tracing mode, reconstruct just the soma in this way, then generate a soma.hoc file from this. Open soma.hoc, change "dend" to "soma", copy the geometry definition and then modify the initial, full .hoc file such as to replace the original "contour based" soma geometry with this simpler fragment. You will also need to update some of .hoc code at the end of the file since there will be just one soma section, rather than multiple (one for each contour). Why this roundabout technique? When I tried to trace a "Cell Body" in "manual tracing mode", it first seemed to work fine in Neurolucida, but in NeuroExplorer it was shown as if I had been defining points in a contour, and similarly in Import3D.
Your mileage may vary ...