Skip to content

refactor: rewrite simulation stages, improve optical config spectral considerations#74

Merged
tlambert03 merged 49 commits intomainfrom
new-flux
Sep 10, 2024
Merged

refactor: rewrite simulation stages, improve optical config spectral considerations#74
tlambert03 merged 49 commits intomainfrom
new-flux

Conversation

@tlambert03
Copy link
Owner

@tlambert03 tlambert03 commented Aug 24, 2024

this generally rewords the simulation pipeline. I think the biggest conceptual shift is probably this:

  • there is no longer an illumination_flux method (with a full zyx extent); instead there is a new filtered_emission_rates() method that returns a non-spatial (C, F, W) array, representing the full spectral emission profile of each channel/fluorophore pair (without binning), in units of photons/sec.
  • emission_flux still exists as a convenience method, but isn't used internally by the simulation anymore
  • instead, the modality.render() method now takes in the ground_truth ((F, Z, Y, X)) and the filtered_emission_rates ((C, F, W)). it is then responsible for binning of the emission (if desired), which is only necessary for "hyperaccurate" simulations that want to represent a single channel as a superposition of many slightly different PSFs. The default is simply to bin all the emission photons (per channel/fluor) into an average wavelength and use a single PSF, but that setting is controlled by settings.spectral_bins_per_emission_channel. One advantage here is that all channels don't need to "agree" on the binning edges or strategy: the binning is an interim step that happens only within a single channel/fluorophore.
  • there is a new method optical_image_per_fluor that represents the fullest expansion of dimensions in the pipeline (C, F, Z, Y, X), all it does is return modality.render; and optical_image is simply the output of that method summed over fluorophores: (C, Z, Y, X)

the rest is pretty much the same.

New tutorial added here, which will be in the docs:

https://github.com/tlambert03/microsim/blob/bdc748878df587691809d951bbe8a654fa323463/docs/tutorial.ipynb

@tlambert03 tlambert03 changed the title big refactor, better illumination path refactor: rewrite simulation stages, improve optical config spectral considerations Aug 25, 2024
@codecov
Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 86.22642% with 73 lines in your changes missing coverage. Please review.

Project coverage is 84.84%. Comparing base (2c05362) to head (a9a376b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/microsim/schema/optical_config/config.py 84.37% 20 Missing ⚠️
src/microsim/schema/optical_config/lib.py 31.57% 13 Missing ⚠️
src/microsim/schema/simulation.py 90.90% 12 Missing ⚠️
src/microsim/schema/modality/_simple.py 86.95% 9 Missing ⚠️
src/microsim/schema/spectrum.py 81.57% 7 Missing ⚠️
src/microsim/fpbase.py 62.50% 3 Missing ⚠️
src/microsim/psf.py 83.33% 3 Missing ⚠️
src/microsim/schema/sample/fluorophore.py 87.50% 3 Missing ⚠️
src/microsim/schema/sample/sample.py 90.90% 2 Missing ⚠️
src/microsim/util.py 97.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   84.19%   84.84%   +0.64%     
==========================================
  Files          49       47       -2     
  Lines        2892     3094     +202     
==========================================
+ Hits         2435     2625     +190     
- Misses        457      469      +12     

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

@tlambert03
Copy link
Owner Author

@federico-carrara, if you have time/interest, you may wish to take a peek at this. I don't expect you to review the entire thing, but if you have any questions/concerns about your particular use case, let me know

@federico-carrara
Copy link
Contributor

Hi @tlambert03!
Thank you for pointing me to this PR.
I am definitely up for having a look at it over the week as I also plan to get back to work on data simulation in a few days :)
Have a nice day!!

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.

2 participants