Hi all,

I am working with the descriptor based registration from @StephanPreibisch plugin and would like to reapply a model to a set of 3D positions using an external code but can’t figure out the right operation.

To be more specific, my user has already analyzed a large population of cells but has only realized later that there is a shrinking effect between his 2 rounds of imaging, unfortunately his final analysis requires a perfect overlap of the 2 rounds of images and the spots he extracted from them. He could redo the whole analysis after registering the images, but I wonder if we could still do the registration of the images and apply the model to the lists of spots he already extracted from the unregistered images.

To test this I have used the plugin to register pairs of images and kept the alignment log results, so I have the 3d-affine model 12 parameters provided in the log and a control of the expected result. Based on linear algebra, I understand that these parameters should be used in the form of a 4x4 matrix with this format:

M =

i00, i01, i02, i03

i04, i05, i06, i07

i08, i09, i10, i11

0, 0, 0, 1

and to register the spots the equation should be:

v’ = Mv with the original spot position v=(x,y,z,1) and v’ the registered spot position.

However, this doesn’t seem to work in the test sample I have (1 image analyzed before and after registration). I have coded a small script in MATLAB since this is the language they have been using so far in the lab and can only obtain this kind of result.

- alignment log: Log of alignment for comparison.txt (638 Bytes)
- spot list before registration: Gaussian_fit_mRNA_beforealign.mat (57.1 KB)
- spot list after registration (control): Gaussian_fit_mRNA_afteralign_noCroop.mat (202.5 KB)
- 3D display after registering the unregistered spots:
- The short script I’ve used:

```
% Scaling parameters
scale = [ 0.177, 0.177, 0.030 ]';
% Reshape the spots 3D positions before reg
load('V:\Spot_Alignement\Align\Gaussian_fit_mRNA_beforealign.mat')
spots3DRaw = vertcat( Xfit, Yfit, Zfit );
spots3DRaw = spots3DRaw./scale; % rescale the spots in pixels
spots3DRaw = vertcat ( spots3DRaw, ones(1, size(spots3DRaw, 2) ) );
clear X* Y* Z* Intensity
% Reshape the spots 3D positions after reg
load('V:\Spot_Alignement\Align\Gaussian_fit_mRNA_afteralign_noCroop.mat')
spots3DTrueReg = vertcat( Xfit, Yfit, Zfit );
spots3DTrueReg = spots3DTrueReg./scale;
spots3DTrueReg = vertcat( spots3DTrueReg, ones(1, size(spots3DTrueReg, 2) ) );
clear X* Y* Z* Intensity
% Reshape the transformation matrix into 4x4 mat
transMat = ...
[0.9521668012751675, 0.01942896215185741, -0.02937386488638527,...
-128.34156434174827, -0.02918781664433573, 0.9670877572733926,...
0.007758961922641361, 22.80922305787985, 0.00666616264027195,...
0.006974539745061396, 0.9102420623462557, -9.704733991824398];
transMat = reshape( transMat, 4, 3 )';
transMat = vertcat( transMat, [ 0, 0, 0, 1 ] );
% Calculate new registered positions
spots3DReg = transMat*spots3DRaw;
% Display both before and after reg
close all
figure
box on
plot3( spots3DRaw(1,:), spots3DRaw(2,:), spots3DRaw(3,:), 'ro' );
hold on
plot3( spots3DReg(1,:), spots3DReg(2,:), spots3DReg(3,:), 'b.' );
plot3( spots3DTrueReg(1,:), spots3DTrueReg(2,:), spots3DTrueReg(3,:), 'go' );
legend({'unregistered', 'spots registered', 'image registered'});
xlabel('X position (px)');
ylabel('Y position (px)');
zlabel('Z position (px)');
grid on;
```

I’m sure I’m missing something here but I’ve tried to play with the parameters order or working with the scaling in physical unit, but even the angle of the registered spots doesn’t match what I expected so I’m wondering what I am doing wrong. If someone has a clue or a solution that would be great!

Thanks!

Sebastien