Page history Edit this page How do I edit this website?

Extending SNT

Implementation and Algorithms

A high-level description of SNT’s algorithms is available on GitHub.

Using SNT in other projects

Currently, the easiest way to improve the code base is by following the guidance of the source-code repository. You will likely need an IDE and some basic familiarity with maven.

To use SNT as a software library in your own project, simply add SNT as a maven dependency in your project’s pom, e.g.:

<!-- https://mvnrepository.com/artifact/org.morphonets/SNT -->
<dependency>
    <groupId>org.morphonets</groupId>
    <artifactId>SNT</artifactId>
    <version>4.2.0</version> <!-- only required if pom-scijava is not being used as parent pom -->
</dependency>

See e.g., this forum thread for a concrete example of SNT being used as a software library.

Tubular Geodesics

The Tubular Geodesics plugins were developed several years ago for Simple Neurite Tracer but remain functional in modern SNT. They can be installed manually as an SNT add-on. Once installed, they allow you to trace on a filtered-version of your image in which neuronal processes (or other tubular structures) are significantly enhanced using ITK segmentation. More details on the following pages:

Tubular geodesics reference: doi:10.1109/cvpr.2012.6247722

TRACES File Format

The .traces files that are saved by SNT are gzipped compressed XML. SNT will also load/save uncompressed XML files, but by default, they are saved in the compressed form.

The XML DTD is included in the DOCTYPE of each file. The root element is always <tracings>, and this can contain the following elements: imagesize, samplespacing, path, and fill

imagesize

: There must be exactly one <imagesize> element present, with attributes that describe the size of the image in terms of number of voxels across, up and down, e.g.:

<imagesize width="520" height="434" depth="117"/>
samplespacing

: There must be exactly one <samplespacing> element present, with attributes that describe the spacing of the samples in the image (voxels) in world-coordinates, e.g.:

<samplespacing x="0.28838738962693633" y="0.28838738962693633" z="1.2" units="micrometers"/>
path

This element can have the following attributes:

id
A non-negative integer ID unique among the paths in this file
startson
If this is present, it gives the ID of the path which the beginning of this path branches off from. If startson is specified, then either the deprecated attribute startsindex or the recommended attributes startsx, startsy startsz must be specified as well
startsx, startsy and startsz
These attributes indicate where on the path specified by startson the branch occurs. If one of these is attributes is specified, all must be specified.
endson
if this is present, it gives the ID of the path which the branch ends on. If endson is specified, then either the deprecated attribute endsindex or the recommended attributes endsx, endsy endsz must be specified as well
endsx, endsy and endsz
These attributes indicate where on the path specified by endson this path ends. If one of these is attributes is specified, all must be specified.
name
A string giving the name of this path
reallength
The length of this path found by summing the Euclidean distance between each consecutive pair of points, in the units specified in samplespacing
fitted
If present, this attribute gives the ID of another path which is a version of this path after the centre-line has been adjusted and radii at each point found. If this attribute is present, the fittedversionof attribute may not be.
fittedversionof
If present, this attribute gives the ID of another path which was the source version for this one. Typically, the path specified does not have radii defined for each point, although this is not always the case. If this attribute is present, the fitted attribute may not be.
usefitted
This attribute must be present if either the fitted or fittedversionof attributes are. This attribute is either “true” or `“false”. It should only be “true” for paths that have a fitted version, when it implies that the user wants the fitted path to be display in favour of this (the unfitted) one. If “false” and this path has a fitted version, it means that this path should not be displayed. It should always be “false” for paths that are fitted versions of other paths.

NB: This is confusing and regrettable; in later versions this will be replaced by attributes with simpler semantics.

swctype
The integer flag defining the type of the path as defined in the latest SWC specification. If not present, the default value is 0.
startsindex
This deprecated attribute used to indicate the 0-based index of the point in the other Path where the branch occurred
endsindex
This deprecated attribute used to indicate the 0-based index of the point in the other Path where this path joins it
point

The <path> element may contain zero or more <point> elements representing a point coordinate in a path. A point element may have the following attributes:

xd, yd, zd
These three attributes give the position of the point in world coordinates. e.g. you can use these coordinates directly to calculate the length of paths
r
If present, this attribute gives the radius of the neuron at that point
tx, ty, tz
If present, these attributes give the tangent vector along the neuron at (xd, yd, zd)
x, y, z
These attributes used to represent the position of the point in image coordinates (i.e. voxel indices) and are now deprecated
fill

This element represents a fill around a path. It contains all the points found in the search starting from points on the path, but those that actually make up the fill are just those below the threshold specified in the attributes. (This is so that the search can be restarted if the fill is reloaded). It can have the following attributes:

id
The ID of the fill, a non-negative integer unique among all the other fill IDs in this file.
frompaths
A comma ( optional space) separated IDs of the paths from which this fill started. e.g. if this attribute is frompaths="2, 0" then there are nodes with distance 0 at each of the points on <path id="2" ... and <path id="0" ... in this fill.
metric
The cost function used during the fill. metric is a bad name for this attribute, but it was kept for backwards compatibility.
threshold
The search threshold. All the points with a “distance” less than this path are considered to be part of the fill.
node

This element can have the following attributes:

id
Each node in the search has a non-negative integer ID which is unique within the enclosing fill
x, y, z
The position of the node in the image stack in image co-ordinates, i.e. 0-based indices in voxels
previousid
If present, this ID gives you previous node on the shortest route from the original paths to this point. It is not present for the points on the original paths, which also have a distance attribute equal to 0
distance
This is the minimum “distance” so far found for any route moving from any point on the original paths to this node. (The complete route can be reconstructed by following previousids)
status
This attribute can either have the value “open” or “closed”, which have their conventional meanings in A* search