reillytilbury / coppafish

Python version of iss software
MIT License
4 stars 2 forks source link

Quality of subvolume shifts #77

Closed reillytilbury closed 1 week ago

reillytilbury commented 8 months ago

Need to ensure that subvolume shifts are actually correct!

kdharris101 commented 8 months ago

When a subvolume shift differs from the linear regression prediction of it, is that because

  1. The subvolume shift was estimated wrong and the linear regression is more accurate
  2. The subvolume shift is accurate, and the linear regression estimate is wrong because of non-affine transformation?

If the latter it might make non-affine registration a lot simpler, maybe even simpler than our current affine registration. We can potentially combine the original subvolume shifts for all round-round registration, with a fixed affine transformation for channel-channel registration. If this works we might not even need to do linear regression to get the affine transformation.

Not a priority though! Let's get the code stable with the new scaling working first.

reillytilbury commented 7 months ago

We have already improved the quality of the shifts a lot by windowing the images before we compute their phase correlation. This is something that @paulshuker and I have looked at a lot.

It looks like phase correlation (left) is much more precise than cross correlation (right) Screenshot from 2024-01-23 00-02-49

When looking at all z-planes of the phase correlation (left) and cross correlation (right) we see that their is quite a wide range of possible z-shifts that work. We may want to quantify this as confidence we have in these shifts. Screenshot from 2024-01-23 00-04-40

I will take a look at subvolumes whose shifts are large outliers from their prediction and compare the predicted and actual shift in their registration.

Changing to non-affine registration will actually be harder than I anticipated, because the only transforms we compute with subvolume shifts are those from R7C0 to RrC0 for each imaging round r. The corrections to other channels ( ie: transforms from R7C27 to R7C5 for example) are then captured by the channel transforms (computed from fluorescent beads) which is an affine transform and further corrected by ICP which again is affine, so we would need a way to make ICP non-affine.

kdharris101 commented 7 months ago

Can we look again at some of the tiles that appeared to show a registration match in most of the tile but not in one corner (I forget which this was, possibly Daphne).

If after tapering this is now fixed, we are done with this issue.

If not, we could see whether the combination of 1, subvolume shifts between roun ds as determined by tapered Fourier; and 2, a single affine transformation between channels determined from the bead images, do better. We might not even need ICP at all. It is possible that ICP was only necessary to compensate for the problems we had in Fourier prior to tapering.

reillytilbury commented 7 months ago

Yes, I think this is likely to be the case. My latest issue (named channel transforms and round transforms) shows that the channel transforms are reasonably constant across tiles and rounds, so we likely will be able to do this!

reillytilbury commented 7 months ago

This has been something I have looked into this week, and I think that non-affine registration could work. In Daphne t6 a non affine registration was found to be better than the affine registration.

Affine registration seems to give less noisy estimates. A solution is to replace bad shifts with averages of their neighbours, this is in theory better than replacing them with their affine prediction, as the neighbour replacement only takes local information while the affine replacement takes global information and tries to interpret it in an affine way.

Neighbour replacement struggles from the fact that bad shifts are highly correlated with their neighbours so after thresholding we often have no neighbour shifts to go off.

I need to look at these bad shifts and try a few things. Instead of replacing, it would be good to know why phase cross correlaton fails.

reillytilbury commented 1 week ago

Closed as we now use optical flow.