Conversation
|
@copilot when running the script After fixing the above error, run the script
|
... The error message appears to be cut off. Could you provide the complete traceback? I need to see the full error to diagnose and fix the issue with the assess_spotfindingresults.py script.
... Fixed in commits 30086ff and a284ce8. The error was likely caused by trying to run The issue: When the reference image has multiple z-planes, after squeezing ROUND and CH dimensions, the data_image passed to The solution: Added a check for
Also added a regression test |
|
@copilot you fixed the syntax error but I now get the initial logical error with the wrong results in "y" and "radius": it should be similar to the below: |
Fixed in 9f9d1c2. The root cause was that the blob detector (blob_log) automatically detects image dimensionality and returns:
This is independent of the The fix now checks |
|
@copilot there is a difference in results for 1 case out of the 4. Only for "is_volume=True" & no reference_image, we get different results, probably because the image data has a shape of (1,y,x) and is handled by skimage blob_log as 3d instead of 2d. "is_volume=True" & no reference_image: |
Could you clarify what you mean by "different results"? Are the y-values and radius values incorrect (like the original bug), or are they correct but different from expected? When If you're seeing incorrect values, please share an example of the output so I can investigate further. |
|
@copilot the issue is with how skimage blob_log() handles input data (3D vs. 2D). |
Fixed in e25786d. Added logic to squeeze out singleton z-dimensions before calling blob_log. When data_image has shape (1, y, x), it's now squeezed to (y, x) before detection, ensuring consistent results with true 2D images. The original shape is restored afterwards for proper intensity indexing. |
Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
When using BlobDetector with is_volume=False and a reference_image that has multiple z-planes, the data_image can be 3D after squeezing ROUND and CH dims. This fix checks data_image.ndim and uses appropriate indexing: - 3D (z, y, x): use data_image[z_inds, y_inds, x_inds] - 2D (y, x): use data_image[y_inds, x_inds] Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Tests the case where reference_image has multiple z-planes, ensuring the fix correctly handles 3D data_image after squeezing ROUND and CH dimensions. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
The blob detector (blob_log) automatically detects image dimensionality and returns: - 4 columns [z, y, x, sigma] for 3D images - 3 columns [y, x, sigma] for 2D images This is independent of the is_volume parameter. When is_volume=False with a reference_image having multiple z-planes, the squeezed reference is 3D, so blob_log returns 4 columns, not 3. Changed from checking is_volume to checking fitted_blobs_array.shape[1] to determine whether we have 3D or 2D blob detection results. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
When data_image has shape (1, y, x), squeeze it to (y, x) before calling blob_log to ensure consistent results. This prevents blob_log from treating singleton z-dimensions as 3D, which produces slightly different detection results compared to true 2D images. After detection, restore the original shape for consistent intensity indexing. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Use separate variable data_image_for_detection to make it clearer that the squeezed data is only used for blob detection, while the original data_image is used for intensity extraction. This should make debugging easier and the code more maintainable. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
When data_image is squeezed from (1, y, x) to (y, x), adjust 3-element sigma tuples (z, y, x) to 2-element tuples (y, x) by dropping the z component. This prevents IndexError when using anisotropic sigma with singleton z-planes. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
Changed from using fitted_blobs_array.shape[1] to check data_image_for_detection.ndim to determine if 2D or 3D blob detection was performed. This correctly handles: - 3D with scalar sigma: (n, 4) = [z, y, x, sigma] - 2D with anisotropic sigma: (n, 4) = [y, x, sigma_y, sigma_x] - 3D with anisotropic sigma: (n, 6) = [z, y, x, sigma_z, sigma_y, sigma_x] For anisotropic sigma, radius is computed as average of sigma values. Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
34b3408 to
c005f33
Compare
|
@berl I have asked for your review again, as since your last approval, I have made further progress and changes. Also I discovered that I also discovered a different issue with different results between "is_volume=True" and "is_volume=False" when no reference image is used. It is due to the way spots are merged from the same round/channel but different z slices (lines 210-233 in the old blob.py file). Bottom line, the {round,ch}I pairs are saved incorrectly ({0,1} should be {1,0}, and so one). will address this in a new issue as copilot is exhausted in this PR. |
* Fix BlobDetector round/channel assignment bug with is_volume=False Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shachafl <66333410+shachafl@users.noreply.github.com>
berl
left a comment
There was a problem hiding this comment.
this one really took copilot for a ride.
Fix BlobDetector coordinate extraction - RESOLVED
Problem FIXED ✓
BlobDetector had an index shift error when
is_volume=False:Root Cause - IDENTIFIED & FIXED ✓
The blob detector (blob_log) automatically detects image dimensionality and returns:
This is independent of the
is_volumeparameter. The original code incorrectly usedis_volumeto determine coordinate extraction.Changes Made ✓
data_image_for_detection.ndiminstead offitted_blobs_array.shape[1]Fix Status
PRIMARY BUG FIXED: The main issue (y=0, inflated radius with
is_volume=False+ reference_image) is resolved.SQUEEZING VERIFIED: Singleton z-dimension squeezing is working correctly. Data with shape (1, y, x) is successfully squeezed to (y, x) before blob detection.
ANISOTROPIC SIGMA FIXED: Properly distinguishes between:
Testing
test_blob_detector_2d_spot_coordinates: Tests without reference_image ✓test_blob_detector_2d_with_reference_image: Tests with reference_image (multi-z case) ✓Related Issues
reference_imageandis_volume=False#1870, Various Small Fixes/Improvements #1985, and missed in fix: blob.py 2d intensities shape and pd.concat instead of append #2064Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.