Skip to content

Commit

Permalink
safety against negative z-slice in signal analysis program
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Feb 19, 2025
1 parent 911e28d commit ec7a718
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
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

0 comments on commit ec7a718

Please sign in to comment.