fix: index shift correction for blob detection in 2d tiles#2076
fix: index shift correction for blob detection in 2d tiles#2076
Conversation
|
so the reference_image handles things a bit differently, first running somewhat orthogonally, the |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an index shift issue in blob detection for 2D tiles by correcting how array dimensions are interpreted and indexed. The change addresses a discrepancy where blob detection results have different dimensionality (3D vs 4D) depending on whether a reference image is used.
- Replaces
is_volumeflag check with dynamic shape inspection offitted_blobs_array - Corrects 2D indexing to use
(y_inds, x_inds)instead of incorrectly including z_inds for 2D data
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if fitted_blobs_array.shape[1] == 4: | ||
| z_inds = fitted_blobs_array[:, 0].astype(int) | ||
| y_inds = fitted_blobs_array[:, 1].astype(int) | ||
| x_inds = fitted_blobs_array[:, 2].astype(int) | ||
| radius = np.round(fitted_blobs_array[:, 3] * np.sqrt(3)) | ||
| intensities = data_image[tuple([z_inds, y_inds, x_inds])] | ||
| else: | ||
| elif fitted_blobs_array.shape[1] == 3: |
There was a problem hiding this comment.
The condition checks only for shapes with 3 or 4 columns, but doesn't handle other potential array shapes. If fitted_blobs_array.shape[1] is neither 3 nor 4, the code will silently skip both branches, leaving intensities, z_inds, y_inds, x_inds, and radius undefined, which will cause errors in subsequent code. Add an else clause to raise an informative error for unexpected array shapes.
|
closing this here, as a more comprehensive fix is done in #2154. |
This closes #2075 & #1870
There might be another solution to this as I couldn't figure why when running blob detection with
is_volume=Falseand with a reference image gives a 4d result (z, y, x, sigma) vs. without a reference image which gives a 3d output (y, x, sigma).