freeman-lab/thunder — pull request #74 by freeman-lab (2014-12-21 23:21:53+00:00)
Title: Refactored registration

Significant refactoring of registration methods based on offline discussions with @broxtronix and @poolio and Noah (@d-v-b might be interested as well).

The key change is to separate the application and estimation of registration parameters through a new `RegisterModel` class. Performing registration will return an instantiation of this class, and it has a `transform` method for applying the transformations to an `Images` object. This makes it simple to compute parameters on one data set and apply them to another, which was previously difficult.

Other features for improved modularity and extensibility
- Support simple saving / loading of registration models to / from JSON
- Separate particular registration implementations into modules within an `imgprocessing.regmethods` package
- Provide simpler constructor interface through a `Register` class that is separate from the base class `RegisterMethod`
- A new `run` method on registration methods combines the `fit` and `transform` into a single step, which can be more efficient, and matches the old behavior, but does not expose the transformation parameters directly

Example usage
- Compute parameters on one data set and apply to another
```
from thunder import Register

images1 = tsc.loadExample('fish-images')
images2 = images1.medianFilter(2)
ref = images2.first()[1]

model = Register('crosscorr').fit(images2, ref)
alginedimages = model.transform(images1)
```
- Perform registration in one step
```
from thunder import Register

images1 = tsc.loadExample('fish-images')
ref = images1.first()[1]

alignedimages = Register('crosscorr').run(images1, ref)
```
- Save registration model to JSON
```
from thunder import Register

images1 = tsc.loadExample('fish-images')
ref = images1.first()[1]

model = Register('crosscorr').fit(images1, ref)
model.save('/tmp/file.json')

model = Register.load('/tmp/file.json')
```