29/06/2007

Neuromantic V1.4.0 - How to use it!

Yes, a new version of Neuromantic is *finally* available! Version 1.4.0 performs semi-automatic tracing of neurites by automatically tracing between user-defined beginning and end points. On a basic level, this new version should encompass almost all of the basic functionality of NeuronJ, but with the ability to trace in 3D and improved midline tracking on thicker dendrites.

Although the semi-automatic tracing (particularly the radius estimation) is not quite as well as I'd like yet, I wanted to release a version so that people could see what it will be able to do, especially as there are a number of tweaks that make semi-manual reconstruction easier, too.

I'm pretty happy with the actual tracing process, but I still need to significantly improve the radius estimation algorithm and post-processing, which are both a little rudimentary. It's probably quite useable in most situations, but it may require a bit of cleaning up afterwards where the radius estimation has gone wrong. It should still improve productivity in most cases, though. As such, the radius estimation is off by default, and all segments will be a uniform radius. To apply the radius estimation, select the entire branch (by pressing CTRL+left clicking it in Tree or AutoTrace mode) and press CTRL+R (or select Edit->Restimate Radius from the menu).

Some tips on cleaning up auto-tracings:

* A segment's position may be altered in Tree/AutoTrace mode by left dragging it.
* The radius of a segment may be altered in Neuromantic in the main (non-3D screen) by selecting the segment (either in Tree or Auto mode) and holding down the middle mouse button along the length of the segment and dragging.

Upon entering the application, you should notice that there is a shiny new toolbar button up at the top left that says "AUTO". Clicking this will get you into semi-automatic mode, so do it! The associated right hand panel has a number of twiddle factors for the algorithm (which I promise to clean up and automate for subsequent releases).

Firstly, notice that there's a couple of radio buttons on the panel for either following dark or light dendrites - make sure the correct one of these is selected for your data or odd things will happen. Also, remember that pressing "Invert" on the image processing panel doesn't invert the underlying stack data, so if you're looking at an inverted stack of a Golgi-stained neuron the "Dark dendrites" option should still be selected.

The basic process of semi-automatic tracing is as follows:

* Navigate to the correct slice by auto-focussing on the desired point (middle mouse button click achieves this, as in Tree mode).
* Click and hold the left mouse button: this will begin the tracing.
* Move the mouse roughly down the dendrite - you will see blue boxes pop up (currently of a default size of 128x128 pixels). This shows the area that is currently being image processed and routed. Each box represents (currently) a stack of 11 patches from the current slice - 5 to the current slice + 5.
* As you move the mouse down the dendrite auto-focus on the dendrite by clicking the middle mouse button (I admit this is a little fiddly at the moment, as you need to be pressing the left and middle mouse buttons at once). Also, you can still translate the stack by also holding the right mouse button.
* If a current route has currently been calculated to the position the mouse cursor is at, a line showing the basic trace will be shown. Once a tracing has begun, the application is constantly calculating routing information, so if no route currently exists then waiting for a few moments will help.
* Release the mouse button to complete the tracing.
* If the algorithm won't correctly trace a neurite in one go, segment it in multiple traces - the next trace will automatically connect up to the last as long as the start point is nearby.
* If the trace ends up horribly wrong, just press CTRL+Z to undo it and start again.

The following labelled image captured partway through making a trace should make it clearer:


There are two main twiddle factors to the tracing algorithm - the first is the Neurite Radius slider. This determines which radius of neurite will be detected most effectively (and traced most effectively). If tracing is not working at all, or not working well, this is most likely to be the problem. The slider varies from 1 pixel radius to 30 pixels radius at the moment, although I shall hopefully replace this in future with a more visually intuitive brush size selection tool, a bit like a graphics package.

The second slider is the Neurite Threshold, which determines which pixels will and will not be counted as neurites. The higher (more to the right) the slider is, the less pixels will be considered, and the faster the routing will occur. Turning on the "Show Routing Progress" option will show you which pixels are actually currently being considered, by colouring them in shades of blue (based on the cost function at that point), and thus let you tune this parameter correctly for your data. Hopefully, though, this will be done automatically in future versions. The following image shows what the routing progress looks like when the parameter is set to about the right level:



If the threshold is too high, you might see something like the next image: it is apparent that the algorithm is not considering pixels that should be counted as neurites, as there is not a solid line between the start and end point.


Conversely, if the threshold is too low you may just end up with all the patches filled with blue, in which case the algorithm will work significantly more slowly than it should, so you should put it up a little.

The Segment Length slider bar determines the subsampling rate of the final calculated path. This is by default set to 5 pixels long, but should in general be set high enough that you don't end up with a billion segments but low enough so that you still approximate the shape of the dendrite well.

3D Window


Post-processing is also performed on the Z axis to clean it up using the AutoFocus function (although this can be removed by unticking the Post Processing box on the AutoTrace panel). However, when neurites overlap close to each other you may still get an error where the focussing jumps to another neurite and then back again, creating an error which looks a little like this (the view has been rotated so that the horizontal axis represents the stack images):



In order to get rid of this artifact, select (by left clicking, although the standard CTRL and SHIFT controls for the main window also work in here too) the last correct segment BEFORE the artifact, up until the end of the artifact, like this:



The direction of the dendrite here is going from the top to the bottom of the screen.

Pressing CTRL+W (or Edit->Z Interpolation) will then interpolate the Z values between the beginning and end of the identified artifact.



Other features


Another thing which has been added is a couple of interpolation options for the main window. These can be selected between using the F keys:

F9 - No interpolation
F10 - Bilinear interpolation
F11 - Bicubic intrpolation

As with the rest of the image processing, the interpolation is performed on-the-fly as you zoom in to the image, so it does not add any extra memory burden (take that, ImageJ!). The interpolation can be handy for judging more accurately the midline/edges of neurites.

Also, if you've bothered to read this far, please leave a cheery comment on the blog post so that I know I didn't spend all this time writing it for nothing ;)

Labels: , , , ,