Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guard against negative z-slice in signal analysis program #426

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project will adhere to [Semantic Versioning](https://semver.org/spec/v2

### Fixed
* Field of view name matching for cross-channel signal analysis. See [Issue 424](https://github.com/gerlichlab/looptrace/issues/424).
* Safety against negative z-slice in cross-channel signal analysis

## [v0.12.0] - 2025-02-18

Expand Down
27 changes: 15 additions & 12 deletions bin/cli/run_signal_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,21 @@ def workflow(
except ValueError as e:
logging.error(f"Can't compute shifted center for original center {pt0}: {e}")
else:
# TODO: need to be robust to bounding box with negative coordinate(s)
# TODO: https://github.com/gerlichlab/gertils/issues/34
for stats in compute_pixel_statistics(
img=img,
pt=dc_pt,
channels=spec.channels,
diameter=spec.roi_diameter,
channel_column=SIGNAL_CHANNEL_COLUMN,
):
ch: int = stats[SIGNAL_CHANNEL_COLUMN]
# Add the original record and signal stats to the growing collection for this channel.
by_raw_channel[ch].append({**r.to_dict(), **stats})
if dc_pt.z < 0:
logging.error(f"Can't extract signal for negative z-coordinate: {dc_pt.z}")
else:
# TODO: need to be robust to bounding box with negative coordinate(s)
# TODO: https://github.com/gerlichlab/gertils/issues/34
for stats in compute_pixel_statistics(
img=img,
pt=dc_pt,
channels=spec.channels,
diameter=spec.roi_diameter,
channel_column=SIGNAL_CHANNEL_COLUMN,
):
ch: int = stats[SIGNAL_CHANNEL_COLUMN]
# Add the original record and signal stats to the growing collection for this channel.
by_raw_channel[ch].append({**r.to_dict(), **stats})

# Write the output file for this ROI type, across all FOVs.
for raw_channel, records in sorted(by_raw_channel.items(), key=itemgetter(0)):
Expand Down
Loading