jni / affinder

Quickly find the affine matrix mapping one image to another using manual correspondence points annotation
https://jni.github.io/affinder/
BSD 3-Clause "New" or "Revised" License
17 stars 13 forks source link

add tests for most layer types #52

Closed thanushipeiris closed 2 years ago

thanushipeiris commented 2 years ago

Two very simple tests for the shapes layer (Issue #48)

Test 1: reference image layer, moving shapes layer Test 2: reference shapes layer, moving shapes layer

codecov-commenter commented 2 years ago

Codecov Report

Merging #52 (c27805b) into main (fe73724) will increase coverage by 2.60%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   80.00%   82.60%   +2.60%     
==========================================
  Files           4        4              
  Lines         115      138      +23     
==========================================
+ Hits           92      114      +22     
- Misses         23       24       +1     
Impacted Files Coverage Δ
src/affinder/_tests/test_affinder.py 100.00% <100.00%> (ø)
src/affinder/affinder.py 89.87% <0.00%> (-1.27%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update fe73724...c27805b. Read the comment docs.

jni commented 2 years ago

Thanks @thanushipeiris!

I think for this task what we actually need is to produce reference layers of each type corresponding to the cameraman and rotated cameraman (as in the existing image<>image test), then use pytest.mark.parametrize on each layer type pair to make sure things work. That means that only a single test needs to get written, but it tests all possible layer combinations. Does that make sense? Let me know if you need help with this!

For the reference shape, points, and vectors data, you can draw them in napari on top of the cameraman image and then create sample data in text. For labels, you can e.g. manually paint the cameraman, then save the data as a .zarr array somewhere in the test directory. zarr compresses labels very effectively so it's a good way to generate the data.

An alternative is to try to get a reasonable segmentation of the cameraman programmatically using watershed with specific markers, and filters.farid.

thanushipeiris commented 2 years ago

@jni I think I've done that for Image, Shapes, Points and Labels layers but have yet to add Vector and Tracks layers (also should I include tracks layers??).

I was using the camera and rotated camera as the reference and moving layers for all layer types btw.

jni commented 2 years ago

Great! You're right, for tracks you will need to add mixed-dimensionality alignment, so let's leave that layer out for now!

Could you also rechunk the zarr files so that they are one chunk? ie set chunk size to 512x512.

jni commented 2 years ago

Thanks @thanushipeiris! The CI isn't passing. You can see from this line in the failing build that this is because zarr is not installed in the test environment, which can be fixed by adding zarr to this section of setup.cfg.

thanushipeiris commented 2 years ago

I added zarr as a dependency to tox.ini as well and less tests are failing (compared to only adding zarr to the setup.cfg), but some are still failing and I'm not sure how to fix it.

jni commented 2 years ago

Ah, damn, yeah this one is tricky, the only reason I know about it is that it happened on napari a few days ago and Talley fixed it! LOL Here's the references:

Can you look at napari/napari#4046 and imitate that in our test running? Thanks!

thanushipeiris commented 2 years ago

It seems to work now! I didn't need to switch to tlambert03/setup-qt-libs@v1 for the Linux tests, although I don't really understand what's happening here so let me know if I should do that too.

thanushipeiris commented 2 years ago

Alright so I read a little bit more and I believe it's just a set of libraries that are needed for qt packaged together in the one repo. It's tangential to fixing the CI issue but more compact so I put it in anyways.

jni commented 2 years ago

Whoooooo! :tada: Thanks for pushing this all the way over the finish line, @thanushipeiris! :smiley: :tada: :rocket: