Difference between revisions of "Register Virtual Stack Slices"

Line 61: Line 61:
 
== Scripting / PlugIn ==
 
== Scripting / PlugIn ==
  
<p>You can call the plugin in a non-interactive fashion from java code:</p>
+
<p>You can call the plugin in a non-interactive fashion from a jython script:</p>
<source lang="java">
+
<source lang="python">
import ini.trakem2.imaging.Registration;
+
from register_virtual_stack import Register_Virtual_Stack_MT
import register_virtual_stack.Register_Virtual_Stack_Slices;
 
  
[...]
+
source_dir = "/path/to/source/"
 +
target_dir = "/path/to/target/"
  
String source_dir = "/path/to/source/";
+
p = Register_Virtual_Stack_MT.Param()
String target_dir = "/path/to/target/";
+
# The "maximum image size":
// can be PHASE_CORRELATION or SIFT
+
p.sift.maxOctaveSize = 1024
int registration_type = Register_Virtual_Stack_Slices.PHASE_CORRELATION;
+
# The "inlier ratio":
// Can be null if using PHASE_CORRELATION
+
p.minInlierRatio = 0.05
Registration.SIFTParameters sp = new Registration.SIFTParameters();
 
// image scale at which phase-correlation works, for performance
 
float scale = 0.5f;
 
// minimum cross-correlation score to accept phase-correlation results, otherwise try pure cross-correlation
 
// (use as low as 0.4 if images are noisy, or at your discretion)
 
float min_R = 0.7;
 
  
Register_Virtual_Stack_Slices.exec(source_dir, target_dir, registration_type, sp, scale, min_R);
+
Register_Virtual_Stack_MT.exec(source_dir, target_dir, p);
 
 
</source>
 
 
 
<p>The above can of course be called from any scripting language, such as Jython:</p>
 
<source lang="python">
 
from ini.trakem2.imaging import Registration
 
from register_virtual_stack import Register_Virtual_Stack_Slices
 
source_dir = "/path/to/source/"
 
target_dir = "/path/to/target/"
 
registration_type = Register_Virtual_Stack_Slices.PHASE_CORRELATION
 
sp = new Registration.SIFTParameters()
 
scale = 0.5
 
min_R = 0.7
 
Register_Virtual_Stack_Slices.exec(source_dir, target_dir, registration_type, sp, scale, min_R);
 
 
</source>
 
</source>
  
 
== See also ==
 
== See also ==
* [http://www.ini.uzh.ch/~acardona/howto.html#register_virtual_stack Register Virtual Stack] at TrakEM2 website.
+
* [http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=mpicbg.git;a=blob;f=mpicbg/imagefeatures/FloatArray2DSIFT.java;hb=HEAD FloatArray2DSIFT.java] which contains the subclass Param which is the 'sift' member of the Register_Virtual_Stack_Slices.Param subclass.
* [http://www.ini.uzh.ch/~acardona/howto.html#sift_parameters SIFT parameters explained] at TrakEM2 website.
+
* [http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=fiji.git;a=blob;f=src-plugins/register_virtual_stack_slices/register_virtual_stack/Register_Virtual_Stack_MT.java;hb=HEAD Register_Virtual_Stack_MT.java], including the Param subclass.
  
 
[[Category:Plugins]][[Category:Registration]]
 
[[Category:Plugins]][[Category:Registration]]

Revision as of 11:29, 6 June 2009

Register Virtual Stack Slices (Fiji)
Author Albert Cardona (acardona@ini.phys.ethz.ch)
Maintainer Albert Cardona (acardona@ini.phys.ethz.ch)
Source on gitweb (276 lines)
Initial release 2008
Latest version  ?
Development status stable, not active
Category Category:Registration, Category:Plugins



This plugin takes a list of image slices stored in a folder, and delivers a list of registered image slices (with enlarged canvas).

The plugin uses any translation, rigid (translation+rotation), similarity (translation+rotation+isotropic scaling), affine, elastic (via bUnwarpJ with B-splines) or moving least squares transformation model, aided by automatically extracted SIFT features.

Premises:

  • You have a folder with an ordered list of image files in it that ImageJ can open.
  • Each image represents a slice in a sequence.

Images may have different dimensions and be of different type.

Step 1: launch the "Plugins - Registration - Register Virtual Stack Slices" plugin

Step 2: choose the appropriate options:

  • The expected transformation model finding inliers (i.e. correspondences between images) in the feature extraction: translation, rigid, similarity or affine.
  • The image transformation model: translation, rigid, similarity, affine, elastic or moving least squares.
  • The advanced checkbox: whether to see the feature extraction parameters setup dialog, and if elastic, the bUnwarpJ dialog. Otherwise the plugin operates on reasonable, default parameters.

Step 3: choose the source and target folders:

  • Select a source folder containing the slices, at one slice per image file.
  • Select the target folder where resulting registered slices are automatically stored as tif files.

On success, a virtual stack will open showing all the registered images contained in the target folder. The virtual stack can be closed with no ill effect: images are saved in the target folder.

Notes:

  1. The plugin is multithreaded: more CPU cores means faster execution.
  2. The two most relevant parameters in the SIFT feature extraction are:
    • maximum image size, which limits the low-end size of the features (i.e. decrease maximum image size to increase the size of the smallest features to extract.)
    • inlier ratio, which determines when to reject the intersection set of feature correspondences between two images (ratio between correspondent features vs. all extracted features.)
  3. All types of images are accepted (8-bit, 16-bit, 32-bit and RGB), and output images are of the same type as input.


Example

Even this sequence of rather noisy transmission electron microscopy images, with considerable variations from slice to slice, get registered properly:


Raw:Registered:
Stack4.gifStack4-2.gif

Scripting / PlugIn

You can call the plugin in a non-interactive fashion from a jython script:

from register_virtual_stack import Register_Virtual_Stack_MT

source_dir = "/path/to/source/"
target_dir = "/path/to/target/"

p = Register_Virtual_Stack_MT.Param()
# The "maximum image size":
p.sift.maxOctaveSize = 1024
# The "inlier ratio":
p.minInlierRatio = 0.05

Register_Virtual_Stack_MT.exec(source_dir, target_dir, p);

See also