Spatial Registration Plugin
This document describes the registration plugin architecture and how to create and add a new spatial registration plugin to the MBAT Spatial Registration Workspace.
Architecture
The MBAT Spatial Registration Workspace is one of the MBAT analysis cores and uses a plugin framework. The MBAT Spatial Registration Workspace communicates with the spatial registration plugins using the following input/output model:
- Plugin Input:
- source and template data (derived classes of mbObject)
- a canvas to draw a GUI
- Plugin Output:
- registered data (derived classes of mbObject)
Events
To better understand the interaction between the MBAT spatial registration workspace and its plugin, the events that cause certain plugin methods to be invoked are summarized below:
| Plugin method | Called on event
|
|---|
| layoutPanel() | - Plugin is selected in combobox
|
setSourceObjects() setTemplateObjects() |
- Plugin is selected in combobox
- "Apply" button is clicked by user
|
| getRegisteredObjects() | - "Add to Cart" button is clicked by user
|
SVN repository
For SVN setup, see the
Eclipse SVN Configuration. The key projects for spatial registration plugins are:
-
svn+ssh://svn.loni.ucla.edu/cvs/MouseBIRN/mbRegistration (plugin API)
-
svn+ssh://svn.loni.ucla.edu/cvs/MouseBIRN/mbRegistrationPlugins (sample plugins)
-
svn+ssh://svn.loni.ucla.edu/cvs/MouseBIRN/common (mbObject base classes)
Adding a new plugin
For detailed instructions on how to create and add a plugin to the MBAT source code tree using Eclipse, see
CreatingPlugins.
Once you have created and compiled your plugin, you must archive it and place it in the plugins folder. If you follow the above instructions for Eclipse, the
build.xml will automatically archive and zip the plugin to the correct folder:
- Create a zip file of the plugin.xml and classes/ folder. The zip file should have the following structure:
{root}
classes/
plugin.xml
- Add the .zip file to the plugins folder (
mbat/dist/plugins/mbRegistration)
Creating a new plugin
Creating a spatial registration plugin involves the following steps:
- Create a java class that implements the
RegistrationBase interface. The RegistrationBase interface defines the common interface for all spatial registration plugins. We describe here the major methods of the interface (see RegistrationBase.java for more detailed inline documentation).
public class Landmark implements RegistrationBase {
...
}
- Implement handling of the incoming data for the source and template objects by defining
setSourceObjects(...) and setTemplateObjects(...) methods. All objects passed to the registration plugins will be derived classes of mbObject.
public void setSourceObjects ( Vector<mbObject> vSourceObjects ) throws mbObjectException {
for( mbObject object : vSourceObjects )
{
// handle file
if( object instanceof FileObject ) {
...
}
// handle Image2D
else if( object instanceof Image2D ) {
...
}
}
}
- Implement retrieving of the registered data from the plugin by defining
getRegisteredObjects(). The registration plugin must wrap the data into one of the derived classes of mbObject:
public Vector<mbObject> getRegisteredObjects ()
{
Vector<mbObject> vResults = new Vector<mbObject>();
BufferedImage bufferedImage = this.getBufferedImage();
if( bufferedImage == null ) return vResults;
vResults.add( new BufferedImageObject( bufferedImage, this.getOutputName() ));
return vResults;
}
Note: your plugin GUI is responsible for providing saving functionality to disk if necessary.
- Implement your GUI by overriding the
layoutPanel( JPanel panel ) method. For performance reasons, it is recommended that you avoid instantiating JComponents inside this function; only layout of the JComponents should be done here since layoutPanel() is called everytime the plugin is selected:
public boolean layoutPanel ( JPanel panel ) {
// layout some JComponents in the JPanel
}
- Create plugin.xml. This file is required by the Java Plugin Framework (JPF) and defines the extension point of the plugin. The extension point-id must be specified as
point-id="Registration" to load correctly. For most purposes, you can copy the plugin.xml from the mbRegistrationPlugins project and edit the extension section:
For more detailed information, consult the JPF Tutorial.
Running standalone client
For testing and prototyping purposes, there is a standalone client included in the
mbRegistration project that loads and runs the MBAT Spatial Registration Workspace:
-
net.nbirn.mbat.registration.client.Main
NOTE: When developing and testing your plugin, make sure you update your .zip archive and place it in the plugins folder before running the standalone client!