JaneliaSciComp/bigstream

Providing spot coordinates to `ransac_affine`

Closed this issue · 3 comments

I'm just looking for a little guidance/clarification on the fix_spots and mov_spots arguments of this function in the case where, e.g., objects are already at known locations due to segmentation.

Am I correct that these just need to be arrays of shape n_spots x 4 with the columns being x, y, z, and something to sort with? When I attempt this, I get an error in the _stats call in pairwise_correlation, and I'm not sure if it is due to the coordinates I am providing or something else.

You are correct. When ransac_affine finds the spots itself the array columns are [x, y, z, I] with (x, y, z) being voxel indices and (I,) being the intensity of the image at (x, y, z). If providing fix_spots and mov_spots yourself you could use any score you like for (I,).

Note here that the blob_detection function takes an exclude_border=X parameter. This excludes any detected point within X voxels of the edge of the image. Such spots do not have sufficient context around them to compute correlations in subsequent steps.

My guess is that your custom spots (e.g. from segmentation centroids) may have some spots that are within cc_radius voxels of the image edge. Though I can't rule out other problems without seeing the error messages.

It would definitely be an improvement to have ransac_affine double check the spot lists to remove any spots within cc_radius of an edge and I would really welcome a pull request with such a change since my available time for bigstream right now is unfortunately really thin.

Thanks, I think this was exactly the problem! I did have a function that I was culling the points near boundaries with, but it had an embarrassing typo in it and wasn't actually doing its job. I can take a look at adding it to the repo at an appropriate location in ransac_affine.

Thanks again, this makes it a lot easier to explore the match_threshold parameter without waiting for blob_log!

I think that's a good working pattern for first run through on new data: get your spots from an existing segmentation (or run with fix_spots/mov_spots = None the first time and save the results as an npy or similar) then you can test downstream parameters without waiting like you suggested. Glad I could help you find the embarrassing typo!