Repository navigation
Conversation
|
Hello @seanbudd! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-07-01 20:51:19 UTC |
|
@jni @GenevieveBuckley , any additional thoughts? |
|
@seanbudd yes, we just don't have a solution! @GenevieveBuckley and I were playing with the example and we noticed that the end alignment is pretty terrible. Which is a bad sign as this is not a particularly challenging image. Here are the things we've considered but not experimented with:
|
|
I feel strongly that this third point is the one to attack first:
It doesn't really solve the issue, since users are likely to pass in similar data at some stage, but if it works we can at least put this in the docs as a suggested workaround/fix. |
|
@seanbudd I believe adding a blank line at the end of your file
|
|
@GenevieveBuckley what do you mean? He has |
|
@jni oooh oops, the .rst is autogenerated. Hm, then I'm not sure I understand this error either. Let's try your suggestion, that sounds reasonable. |
This comment has been minimized.
This comment has been minimized.
|
I've done a fix for the RST issue, hopefully that should be fine now. I'm not really sure what the best approach for fixing the registration is. What makes the example sub-optimal? I don't think that basinhopping is such a good idea as far as I can tell, the registration isn't being caught in a different local minima (right?). Is it possible pre-processing would be enough to aid registration (eg filtering on a colour and registering using the filtered images)? |
|
I can't tell from the discussion above what the problem is you are trying to solve. Could you please elaborate? |
|
@stefanv as written, the registration in the gallery example doesn't converge on the correct transformation. Here's the output from the script: This points to a problem in the example at least, but probably a deeper problem about whether the optimisation is good enough to be useful as it is. (This is not a particularly hard problem as far as I can tell.) |
|
@jni I'm going to see if doing a couple iterations improves anything. |
I ran into strange problems doing this. Here's the body of the modified register_affine function I was testing with. I messed around with different callbacks but this one showed my issue the best Basically, the second iteration had invalid pixel values in the registered images? |
|
@seanbudd can you tell us the error you're seeing? ie print the full traceback/warning? Anyway, I'm not sure the approach you're taking will help to kick us out of a local minimum without changing the optimization method or the image comparison computation... |
As the curve on the top of the pyramid is smoother, a better initial guess for registration makes it more likely to avoid local minima as pyramid is traversed. I've attached an image to help explain my theory. Imagine if there is a small local minima at the base of each of these arrows, so we move on to the next layer, and then traverse down the curve to the next arrow base. When we reach the base of the pyramid, we are not at a global minima, we are still stuck at a local minima, so we move down to the point of the pyramid and try again, except this time we are closer to the global minima. |
|
@seanbudd can you also explain what the criteria is for stopping/avoiding an endless loop with your changed code? |
Sure, @GenevieveBuckley . The idea was to quit the while loop when the registered image converges, the final registration is the same/similar to the previous iteration |
|
also I can't see why the builds are failing now, it appears to be due to different causes. Is there anything still needed to be addressed from the CI tests? |
|
There should never be an open while loop in code. (It's one of NASA's rules for reliable code.) So, if we take this approach, which I don't think is the right one generally (more below), we would need a Your error is caused by our float range checking, which I think we should abolish but it'll take time (see #3009 for discussion), because you didn't set As to the approach: I see what you're saying, but I think you'll get few cases where the bumps in the lower levels are less bumpy / more in the right direction than the bumps in the highest level of the pyramid. (As shown in that very curve diagram.) So you're better off using a better optimiser at that level than rotating through all the levels, I think, in general. Obviously there are bound to be counter-examples and also my whole intuition could be wrong, but let's see how it all plays out. =) |
|
thanks @jni for the explanation, was just curious to see if any improvements could be made. I'm not sure if there is much we can do to improve the optimiser. All the papers I have read suggest Powell to be the best optimisation method for image registration in general (or Powell-Brent http://elastix.isi.uu.nl/marius/downloads/2011_c_SPIEMI.pdf) |
|
@seanbudd Very cool paper, thanks! Well, basin-hopping is kind of a "meta-optimisation". It basically does what you're suggesting, but on a single optimisation problem: run an optimisation (say, Powell). Then, jitter the parameters by something proportional to how much you moved from your initial guess to the "optimum", and try again. If it's the same optimum, increase the jitter, otherwise, jitter another time. This way you can really explore the space. It's quite clever! Have a look at the original paper, it's quite accessible. But, getting back to your point, each of those optimisation steps can be a Powell step. So basin hopping is going to do strictly better than whatever method you're using as a "backend". |
No approach. =P Currently everything is zero-padded, as is the default in ndimage transforms. See my third suggestion above:
|
stacklevel is already specified in our own utils, so adding it is redundant when using our own warn function.
Co-authored-by: Sean Budd <[email protected]>
|
@stefanv so we pulled out a lot of the stuff into smaller PRs (nD transforms, simple metrics), so this needs to merge in main and and then check over all the APIs... Otherwise I think it probably still works? 😅 |
|
@jni - would you like me to perform the merge and testing? |
|
I notice there's been some activity, sorry I missed the previous ping |
|
OHAI @seanbudd! How are you doing??? @jboulanger has picked up our commits and added a few more features and modifications based on your work and other work in the meantime, so I think we can close this and the work can continue in #7421. If you want to get involved again let me know, if you were just politely responding, we're all good, just slow! 😅 |
|
Was just responding - glad to see there's been some movement! |


Description
In this pull request, we implement n-dimensional image registration for affine transformations.
See ch7 elegant scipy for design philosophy
Checklist
[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]
./doc/examples(new features only)[For detailed information on these and other aspects see scikit-image contribution guidelines]
References
addresses issue: #3502
implements: https://github.com/elegant-scipy/elegant-scipy/blob/master/markdown/ch7.markdown
For reviewers
(Don't remove the checklist below.)
later.
__init__.py.doc/release/release_dev.rst.@meeseeksdev backport to v0.14.x