Skip to content

feat: add Tofwerk pFIB-ToF-SIMS HDF5 extractor and preview generator#90

Merged
jat255 merged 5 commits intomainfrom
89-tofwerk-extractor
Mar 20, 2026
Merged

feat: add Tofwerk pFIB-ToF-SIMS HDF5 extractor and preview generator#90
jat255 merged 5 commits intomainfrom
89-tofwerk-extractor

Conversation

@jat255
Copy link
Copy Markdown
Contributor

@jat255 jat255 commented Mar 18, 2026

Closes #89

Summary

  • Add TofwerkPfibExtractor plugin (priority 150) with content sniffing for Tofwerk fibTOF FIB-SIMS .h5 files. Extracts: creation time (from AcquisitionLog with timezone, with fallbacks), FIB hardware, accelerating voltage (kV), beam current (A), field of view (mm), pixel size (µm), data dimensions, mass range min/max (Da), ion mode, chamber pressure (Pa), GUI/DAQ versions, and file variant (raw vs. opened).
  • Add TofwerkPfibPreviewGenerator plugin (priority 150) producing a 500×500 px composite PNG. Raw layout: FIB SE image, TIC map, depth profile, and annotated sum spectrum. Opened layout: FIB SE image, TIC map, RGB composite (top-3 peaks), sum spectrum, and per-peak depth profiles.
  • Add synthetic HDF5 fixture generator (generate_tofwerk_test_files.py) and 30 unit tests covering both extractor and preview generator.
  • Add PII-stripped real pFIB-ToF-SIMS files to test_record_files.tar.gz (Computer ID, FileSignature, and DataPath username anonymized) and extend record builder tests to include a Tofwerk-pFIB-TOFSIMS instrument session.

Implementation notes

  • FIBParams.ViewField is stored in millimeters; pixel size = ViewField_mm × 1e3 / NbrX µm/pixel.
  • Configuration File Contents INI Ch*FullScale values are ADC voltage ranges, not spatial dimensions -- not used for pixel size.
  • TIC computation for raw files reads EventList one write at a time to avoid loading the full ragged 4D array into memory.
  • All vendor-specific fields are stored in nx_meta["extensions"] via add_to_extensions(), not at the top level.

Test plan

  • 30 unit tests in tests/unit/test_extractors/test_tofwerk_pfib.py pass (extractor supports/extract, preview supports/generate)
  • TestRecordBuilder (27 tests) passes with updated 4-session assertions
  • Ruff lint and format checks pass

…89)

- Add TofwerkPfibExtractor (priority 150) with content sniffing for
  fibTOF FIB-SIMS HDF5 files; extracts creation time, FIB parameters
  (voltage, current, FOV, pixel size), mass range, ion mode, chamber
  pressure, and file variant (raw vs. opened)
- Add TofwerkPfibPreviewGenerator with composite layout: FIB SE image,
  TIC map, depth profile/RGB composite, and annotated sum spectrum
- Add synthetic HDF5 test fixture generator and 30 unit tests
- Add PII-stripped real pFIB-ToF-SIMS files to test_record_files.tar.gz
  (Computer ID, FileSignature, and DataPath anonymized); update record
  builder tests to cover the new Tofwerk-pFIB-TOFSIMS instrument session
@jat255 jat255 self-assigned this Mar 18, 2026
@jat255 jat255 added enhancement New feature or request engagement From an external client/engagement extractors Metadata extraction plugins labels Mar 18, 2026
@jat255 jat255 added this to the 2.6.0 milestone Mar 18, 2026
Add quick reference table entry, full format section (file format
detection, two file variants, extracted metadata fields, preview
generator layouts), and API reference link for the new
TofwerkPfibExtractor and TofwerkPfibPreviewGenerator plugins.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 18, 2026

📚 Documentation Preview

The documentation for this PR has been deployed to:

This preview will be updated on each push to this PR.

jat255 added 2 commits March 18, 2026 17:52
- Add 11 new tests covering exception paths, edge cases in
  _norm_channel, _read_attr_scalar, _depth_plot_style,
  _tic_display_limits, _parse_creation_time, and _extract_fib_params
- Fix IndexError in RGB channel padding when no peaks exceed min_mass:
  pre-compute _zero_channel so the padding loop has a valid fallback
  when rgb_channels is still empty
- Fix ValueError in depth-profile y-limit calculation when an opened
  file has peaks but none above min_mass (top_idx empty): fall back to
  depth_prof.sum(axis=1) instead of concatenating an empty list
…integration test, fix warnings

- Rename extension keys to Title Case: FIB Hardware, Pixel Size,
  Number of Peaks, Ion Mode, FibLys GUI Version, TofDAQ Version,
  Chamber Pressure, File Variant, Mass Range Minimum/Maximum;
  keep standard EM Glossary snake_case keys unchanged
- Rename file variant value "opened" to "pre-processed"
- Increase preview output resolution to 1500x1500
- Guard ax.legend() calls to only fire when labeled artists exist,
  eliminating UserWarnings in zero-peaks-above-min-mass test case
- Add tofwerk_integration_record fixture and test_tofwerk_pfib_record
  integration test for end-to-end record build and CDCS upload validation
- Update all unit test assertions to match new key/value names
… preview resolution

- Replace "opened/processed" and "Opened" with "pre-processed" throughout
- Update File Variant key names from snake_case to "File Variant" (Title Case)
- Change preview size from 500×500 to 1500×1500 px
@jat255 jat255 marked this pull request as ready for review March 20, 2026 03:11
@jat255 jat255 merged commit ab2b407 into main Mar 20, 2026
9 checks passed
@jat255 jat255 deleted the 89-tofwerk-extractor branch March 20, 2026 03:12
github-actions Bot added a commit that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engagement From an external client/engagement enhancement New feature or request extractors Metadata extraction plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tofwerk TOF-SIMS h5 extractor

1 participant