Skip to content

Add SIMSSpectrum and FIBSIMSSpectrum signal classes#169

Open
jat255 wants to merge 7 commits intohyperspy:mainfrom
datasophos:sims_signal
Open

Add SIMSSpectrum and FIBSIMSSpectrum signal classes#169
jat255 wants to merge 7 commits intohyperspy:mainfrom
datasophos:sims_signal

Conversation

@jat255
Copy link
Copy Markdown
Member

@jat255 jat255 commented Mar 10, 2026

Closes #167

Summary

  • Adds SIMSSpectrum for general Secondary Ion Mass Spectrometry data with methods for TIC normalisation, reference-peak normalisation, count-rate conversion, and mass-spectrum extraction
  • Adds FIBSIMSSpectrum (subclass) for FIB-ToF-SIMS depth-profiling datasets, with get_depth_profile, integrate_peak, and compute_integration_borders
  • Lazy variants (LazySIMSSpectrum, LazyFIBSIMSSpectrum) registered via hyperspy_extension.yaml
  • Updates eds.py, eels.py, dielectric_function.py to use the public hyperspy.signals API instead of the private hyperspy._signals subpackage
  • Adds tests for signal dispatch, normalisation, count-rate conversion, and integration border computation

- Add SIMSSpectrum for general SIMS data with methods: get_tic,
  normalize_tic, normalize_to_peak, to_count_rate, get_mass_spectrum,
  label_peaks
- Add FIBSIMSSpectrum (subclass) for FIB-ToF-SIMS depth-profiling with
  get_depth_profile, integrate_peak, compute_integration_borders
- Register both signal types (and lazy variants) in hyperspy_extension.yaml
- Update eds.py, eels.py, dielectric_function.py to use public
  hyperspy.signals API instead of private _signals subpackage
- Add tests covering dispatch, normalization, count-rate conversion,
  and integration border computation
@jat255 jat255 marked this pull request as ready for review March 10, 2026 03:38
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 81.08747% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.45%. Comparing base (054cd4b) to head (5a09aec).
⚠️ Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
exspy/signals/fib_sims.py 54.36% 45 Missing and 2 partials ⚠️
exspy/tests/signals/test_sims.py 86.19% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #169      +/-   ##
==========================================
- Coverage   88.90%   88.45%   -0.46%     
==========================================
  Files          79       82       +3     
  Lines        7650     8070     +420     
  Branches      910      935      +25     
==========================================
+ Hits         6801     7138     +337     
- Misses        575      656      +81     
- Partials      274      276       +2     

☔ View full report in Codecov by Sentry.
📢 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.

@jat255
Copy link
Copy Markdown
Member Author

jat255 commented Mar 10, 2026

This should be ready for a first review. Again, not at all a SIMS expert, so some of these implementations may be off, and if we had someone who has worked with SIMS data that could take a look, that would probably be prudent.

- Fix normalize_tic(peaks=...) to use np.argmin instead of value2index
  for robust axis lookup regardless of axis type
- Fix get_mass_spectrum(navigation_indices=...) iteration bug: axes from
  the old signal were passed to the new sliced signal after each sum
- Add tests covering: peaks-based TIC, saturation warning, inplace
  normalization, to_count_rate inplace, get_mass_spectrum both branches,
  get_depth_profile with explicit mass, and normalize_to_peak inplace
- Replace deprecated reader= kwarg with file_format= in TestSignalDispatch
- Suppress expected RuntimeWarning in divide-by-zero test
- Add pragma no branch for unreachable else in SIMSSpectrum.__init__
jat255 added 4 commits March 15, 2026 15:27
- get_tic() promotes spatial (y, x) navigation axes to signal axes,
  returning a Signal2D per depth slice
- plot() defaults to log normalisation for FIB-SIMS data
- reintegrate_peaks() re-derives the 4D peak cube from a raw EventList
  signal, using calibration parameters from original_metadata
- Fix normalize_tic() in SIMSSpectrum to sum over the signal axis
  directly instead of delegating to get_tic(), so subclass overrides
  don't break normalisation
- Update tests: assert Signal2D shape from get_tic(), add
  TestReintegratePeaks with error and success cases
The rsciio.tofwerk event-list API (compute_peak_data_from_eventlist,
_count_active_channels) does not exist in released versions of
rosettasciio yet (pending hyperspy/rosettasciio#491). Add a
module-level availability check and skip_no_reintegrate marker so the
five TestReintegratePeaks success-case tests are skipped in CI until
that PR lands.
@jat255
Copy link
Copy Markdown
Member Author

jat255 commented Mar 18, 2026

Ok @ericpre this one should be ready for review too. The diff coverage is failing because I had to gate the tests of the "reintegrate peaks" function, since it relies on functionality from hyperspy/rosettasciio#491. Once that PR lands, those tests should run and the test coverage should look good.

Copy link
Copy Markdown
Member

@ericpre ericpre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jat255, is it okay if we come back to this after hyperspy/rosettasciio#496 is merged and release?

Comment thread exspy/signals/fib_sims.py
nbr_waveforms_raw = nbr_waveforms_raw[0]
nbr_waveforms = int(nbr_waveforms_raw)
ini = omd.as_dictionary().get("Configuration File Contents", "")
from rsciio.tofwerk._reconstruction import _count_active_channels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is needed here, it should be made public in rsciio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: WIP type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToF-SIMS data format?

2 participants