Skip to content

fix: off-grid laser lines, dropped emission sample, and QE without an emission filter - #161

Merged
tlambert03 merged 2 commits into
mainfrom
fix/spectral-sampling
Oct 13, 2026
Merged

tlambert03 merged 2 commits into
mainfrom
fix/spectral-sampling

Conversation

@tlambert03

@tlambert03 tlambert03 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

A few small spectral bugs I found while working on the confocal excitation fix (coming in a follow-up PR):

  • Spectrum * Spectrum zero-filled any wavelength present in only one of the two spectra, so combining spectra on different grids silently lost signal. e.g. FITC with a detector QE sampled every 2 nm gave half the photons it should (53 vs 107 photons/s), and two 1 nm grids offset by 0.5 nm gave exactly 0. Both are now interpolated onto the union of their wavelengths (new Spectrum.at()).
  • similarly, a laser between the 1 nm samples of the absorption spectrum (e.g. 488.5 nm) gave exactly zero excitation. The cross-section is now interpolated at the light's wavelengths, and excitation filters are applied with the new Spectrum.transmitted() (so a laser line stays a laser line).
  • bin_spectrum dropped the lowest-wavelength sample (right-closed bins), so PSF weights were missing a bit of the emission. widefield and confocal images are now ~0.3-1.5% brighter in a fluorophore's main channel (more, relatively, for weak bleedthrough).
  • detector QE wasn't applied to channels without an emission filter.

Also adds OpticalConfig.detected_fraction() and Fluorophore.emission_per_absorbed_photon. filtered_emission_rate now spans the fluorophore's full emission range (zeros outside the filter) and absorption_rate the light's wavelengths; totals are unchanged.

…ission filter

- an excitation wavelength between the 1 nm samples of the fluorophore's
  absorption spectrum (e.g. a 488.5 nm laser) gave zero excitation, because
  spectra were combined with an inner join.  The absorption cross-section is now
  interpolated at the light's wavelengths, Spectrum * Spectrum evaluates both at
  the union of their wavelengths, and excitation filters are applied with the new
  Spectrum.transmitted() (so a laser line stays a laser line).
- bin_spectrum dropped the lowest-wavelength sample (right-closed bins), so the
  PSF weights missed some of the emission (widefield is now 0.2-5% brighter).
- the detector QE was not applied to channels without an emission filter.

Adds OpticalConfig.detected_fraction(), Fluorophore.emission_per_absorbed_photon,
and Spectrum.at().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.26%. Comparing base (8362e0f) to head (8fefa3e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/microsim/schema/optical_config/config.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   88.15%   88.26%   +0.10%     
==========================================
  Files          48       48              
  Lines        3292     3314      +22     
==========================================
+ Hits         2902     2925      +23     
+ Misses        390      389       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tlambert03
tlambert03 merged commit da349b2 into main Oct 13, 2026
14 of 15 checks passed
@tlambert03
tlambert03 deleted the fix/spectral-sampling branch October 13, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant