Open din14970 opened 1 year ago
The bias correction step indeed still seems to be missing. Let $$N[\psi]:=\frac12\sum{i=1}^{n}\int\Omega\lVert\phi_i(\psi(x))-x\rVert^2\mathrm{d}x.$$ To compute the minimizing $\phi$, we do a gradient flow of $N$ with respect to $\psi$. This needs the first variation $$\langle N'[\psi,\phi_1,\ldots,\phin],\zeta\rangle=\sum{i=1}^{n}\int_\Omega (D\phi_i)(\psi(x))^T(\phi_i(\psi(x))-x)\cdot\zeta\mathrm{d}x.$$ This is very similar to how the registration itself is done. This just doesn't have a regularizer and includes all deformations, not just one.
Note $N$ can be seen as sum of data terms typical for registration. Let $x_1$ and $x_2$ denote the components of $x$, i.e. $x=(x_1,x_2)$. Furthermore, denote the components of $\phi_i(x)$ with $\phii(x)=(\phi{i,1}(x),\phi{i,2}(x))$. Then, $$N[\psi]=\frac12\sum{i=1}^{n}\sum{j=1}^2\int\Omega(\phi_{i,j}(\psi(x))-x_j)^2\mathrm{d}x.$$ and $$\langle N'[\psi,\phi_1,\ldots,\phin],\zeta\rangle=\sum{i=1}^{n}\sum{j=1}^2\int\Omega(\phi_{i,j}(\psi(x))-xj)\nabla\phi{i,j}(\psi(x)) \cdot\zeta.$$ Using this, you should be able to implement this using the data term and its gradient you implemented for the registration. There the images would be $\phi_{i,j}$ and $x_j$. The C++ code uses the interpretation above, but reusing your existing registration should work as well and take less effort.
BTW: I'm very happy to see that you made a lot of progress on this!
FYI, the C++ code handles the bias correction in SeriesMatching::reduceDeformations
in projects/electronMicroscopy/matchSeries.h
. I don't think that though this is very helpful as reference.
After more than a year I finally found a bit of spare time to work on this project a bit more. I have taken your implementation @berkels and made some improvements in terms of:
What still needs to happen:
implementation/implementation.py
, in theJNNR
class, support writing intermediate results to a file.JNNR.run
. Some help here would be appreciated.@berkels I would really appreciate if you could skim over this if/when you find time and comment on: