06/07/2007

Interface updates

While trying to tidy up the automatic tracing, primarily by making it simpler and more intuitive to select the correct threshold/Gaussian smoothing, I've also done a bit of an overhaul of the mode system as it had been bugging me for some time.

Originally it made more sense to me to have clearly defined modes, as I didn't see how I could add all the required functionality in an intuitive way without this mechanism. However, after putting most of the functionality of Tree Edit mode into the AutoTrace mode for V1.4.0, it seemed to work quite well.

The first mode (stack manipulation) has become completely redundant as all its functionality was duplicated in every other mode, so it was just an unnecessary distraction. It is now bitten the dust.

The second main change is the merging of the Manual mode and Tree Edit mode - now you can select/edit the position/radius of segments as you add them, without having to change modes.

This leaves two main modes - manual and automatic, which just lets you switch between how you want to add segments to the reconstruction.

A reminder of functionality:
* Edit segment X/Y position - click and drag with left mouse button
* Edit segment radius - hold down CTRL, then click and drag with middle mouse button (I may simplify this in future)
* Edit segment Z position - select segment with left click, move visible slice to correct position and select (Edit->Set Z To Current Slice), or CTRL+C.

To suppress the editing functionality (selecting segments when you left click on them), hold down CTRL+ALT (this is the case for both Manual and Auto modes). This is necessary if you need to add a line that starts where another segment is.

This will all be released shortly as Neuromantic V1.4.1.

NOTE: I've become aware of a bug that can take down the entire application - it's an uncommon error relating to deleting multiple segments. I therefore suggest saving before doing this until I release 1.4.1., where I've surrounded the whole area with exception handling and, hopefully, squashed the underlying bug too.

Labels: , ,

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: , , , ,

20/02/2007

Improving selection ability

Some further updates have just been added based on selecting and editing points.

* Individual segments that overlap in x/y can now be selected much more easily than before in the 2D window - it will now select the closest segment to the cursor, rather than the first one in the list that satisfies a closeness threshold. This should make editing trees significantly simpler.

* Existing segment points can now be dragged about in the 2D window. In Tree Mode, simply hold down the left mouse button and start dragging the point around. In order for the point to start moving the mouse must be dragged over 4 pixels first: this is so that segments are not accidentally dragged when selected.

I also intend to update the bottom scroll bar so that when a stack is not loaded in the scroll bar can be used to drag over the Z range of a loaded reconstruction.

These will be the main updates that will form Neuromantic V1.3.2, along with a few other minor bug fixes.

Labels: ,

15/02/2007

Expansion of functionality in the 3D Window

The 3D Window, accessed by pressing "3D View" on the main GUI, was simply intended to be a way of viewing the reconstruction, rather than interacting with it. However, since V1.3.0, segments can now be selected with the left mouse button and edited in the same way as in the normal 2D slice window (through combinations of CTRL, SHIFT and ALT). Further functionality will be implemented soon, such as the ability to drag points around and edit directly in 3D, as is possible with cvapp.

With this in mind, I thought I would give a quick overview of the controls that allow the selection of desired subtrees.

Holding SHIFT whilst clicking on a segment adds that segment to the current selection. The same applies when holding SHIFT and CTRL.

CTRL is the branch selection option, where holding CTRL and clicking will select all ancestor and descendent segments of the selected one. However, the selection is constrained by any currently selected segments if SHIFT is held too. This means that by selecting the segments around a given subtree the exact desired tree may be efficiently isolated.

Example:

The original zoomed in view of the subtree, achieved by middle clicking on one of the segments and zooming in with the mouse wheel.


Hold down SHIFT and click the desired segments on the periphery of the subtree


Hold down SHIFT and CTRL and click on the segment before the bifurcation to select all the tree. Clicking after the bifurcation would select only one branch.


Press CTRL+I to invert the selection


Press Delete, leaving only the subtree

Labels: ,