I have some neuron traces exported from NeuroLucida where some branches have been traced as separate trees and not connected to the main tree with the soma. Now when I try to join such a separated branch by connecting a node to the nearest node of the main tree, SNT connects the other end of the branch.
I suspect this is because the branch was traced with the node at the other end as the root. If so, does SNT have a shortcut to set any node as the root and reorder the tree without resorting to scripting?
Welcome to the forum @subhacom!
You may need to use scripting. It really depends on how the paths are defined. Can you please share the traces file? (you may need to append a “.txt” extension or similar to post it here in the forum).
Thanks for the prompt response. Here is the traces file.12-14-2010.traces.txt (75.2 KB).
It has two separate paths.
I can export them to SWC and join them back after reordering the tree in a script, but it will be handy for non-programmers to be able to fix ordering in the GUI. For example NeuroLucida provides such a facility, and it helps when one wants to jump between working on different parts of a complex neuronal morphology instead of going sequentially from the soma.
@subhacom, it is not obvious which is the path associated with the soma and which merging operations need to occur. Which path ids are problematic? And which path ids should be merged to which path? Having a simpler use case (or a smaller subset of paths) would help to troubleshoot this better.
I tried this with a minimal made-up example with the attached SWC file. Now I am not sure why this is varying from one trial to another, but now sometimes SNT creates the correct path (figurestest_multi_tree.swc.txt (484 Bytes) , but at other times it connects the distal node.
Ideally one would like to connect exactly the nodes I am specifying for connecting, and let SNT take care of reordering of the tree.
There are two trees here which are actually a single path split in the middle, so nodes 1 and 4 are roots:
To connect the nodes, which operation are you using? The merge operation in the right-click menu of the tracer canvas (only accessible when in edit mode), or the “Merge Primary Path(s) into shared root…” command in the Path Manager UI edit menu?
In the tracer canvas right-click menu, there is the option “Set active node as Tree root” which will re-order the edge directions of the Tree based on the new root. Also, it may be done via scripting. As a general toy example in python,
tree = Tree('/path/to/reconstruction')
graph = tree.getGraph()
# picking a random node for demonstration purposes...
newRoot = graph.vertexSet().iterator().next()
modifiedTree = graph.getTree()
Thank you so much for the tip. That should solve my problem.
I am using edit mode(shift+E) to connect (keyboard shortcut C) the selected nodes as described in the last part of the Advanced Path Editing screencast here .
But @arshadic’s suggestion is excellent! The Edit → Merge Primary Path(s) into Shared root… should solve the issue on your initial Neurolucida file (I would think!?):
Make the paths to be merged into a common soma “Primary” (Edit → Make Primary)
Then, select the primary paths to be merged, and run Merge Primary Path(s) into Shared root…
The “problem” I foresee here is that 1. only accepts one path at the time, so it may be a tad cumbersome to use from the GUI. That restriction is in place only because it is an invasive operation. But if that works for you (seems a more expedite way than the approach you are using), we could try to find a way around that limitation.
Thank you for your input. Does Edit → Merge Primary Path(s) into Shared root assume that all the branches arise from soma? That is not the case in the traces I am using.
When I try that in the Path Manager I get some long straight lines (incorrect) connecting the branches. So manually selecting the closest nodes and connecting them in the edit mode seems to work best for now.
Yes. it assumes they branch-off from a common node.
Hmmm, so we still need to find why the merge is being erratic. A couple of pointers:
the sensitivity of the merge will depend on the zoom level, and the precise location of the cursor. E.g.,: I find it hard to use a trackpad for this. A physical mouse is preferred.
With 3D images, it is important to have the node’s plane active to ensure out-of-focus nodes are not selected. Disabling cursor snapping and/or enabling Only nodes within nearby Z-slices (Main tab) may be beneficial
The two nodes to be merged should be highlighted by a larger crosshair at both source and destination. Isn’t it the case?
I just checked again, and that indeed is the case.
I can reproduce the issue reliably with the dummy example posted above. Specifically,
I start “Edit” mode with the upper (longer) tree.
Select its lowest node.
Then switch selection to the lower (short) tree so it becomes green (the lowest node in the upper tree now has big magenta cross-hair).
Hover mouse cursor over its top node so that there is a large green circle over it.
This results in the lowest node of the top tree getting connected to the lowest node (instead of the top node) of the bottom tree.
The problem is fixed when I use “Set active node as Tree root” on the lowest node of the upper tree as suggested by @arshadic.
I am using SNT 3.2.2 on Fiji with ImageJ 1.53d and Java 1.8.0_172.
As an aside, I am working on invertebrate neurons, which do not follow the simple rule of all major branches emanating from the soma. In invertebrates, including Drosophila, often a single neurite comes out of the soma and then splits into multiple arbors in different regions of the brain. Therefore it is quite useful to be able to connect these side arbors to the main neurite in this way.
Unfortunately, I haven’t been able to reproduce this. The only thing that comes to mind would be if the “Enable snapping within XY Z” checkbox is enabled (as @tferr suggested above), then the active editing node could jump to a node on a brighter pixel right before pressing “C”, resulting in the unexpected merge point. But if it is disabled, then I’m not sure what might be causing it at the moment.