Skip to content

Add support for EDAX line scan data - #485

Merged
ericpre merged 22 commits into
hyperspy:mainfrom
AndrewHerzing:ENH_Enable_Line_Scan_Compatibility_For_EDAX
Jun 9, 2026
Merged

Add support for EDAX line scan data#485
ericpre merged 22 commits into
hyperspy:mainfrom
AndrewHerzing:ENH_Enable_Line_Scan_Compatibility_For_EDAX

Conversation

@AndrewHerzing

@AndrewHerzing AndrewHerzing commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description of the change

Addresses issue #479

The EDAX reader can read .spd files which are the output from a 2D EDS mapping acquisition. It cannot currently read the .lsd file format which results from a 1D EDS line scan acquisition. Support for this format would be very nice to have. Since the actual file structure of the .lsd files are the same as the .spd files this is fairly easy to implement. The major difference between the two types of data is that the spatial calibration information for mapping data is stored in a .ipr file while it is stored as a column in a .csv file for the line scan data.

Progress of the PR

  • add required functions to edax/_api.py,
  • update specifications.yaml file,
  • update docstring,
  • update user guide,
  • add tests,
  • add a changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting of the changelog entry (and eventual user guide changes) in the docs/readthedocs.org:rosettasciio build of this PR (link in github checks)
  • Check that CI jobs are passing
  • ready for review.

Minimal example of the bug fix or the new feature

from rsciio.edax import file_reader
file_reader("line_scan.lsd")

Since the format of the .lsd files are exactly the same as the .spd files, I simply referred to the PDF for the .spd specification in the EDAX index.rst.

Also, one item to consider for future functionality is the ability to read in the image detector output for the line scan data. This is stored in a single column of the CSV file and is readily accessible. However, the reader only returns the spectral line scan data. Perhaps the image detector signal could be store in the metadata or a helper function could be added?

Comment thread rsciio/edax/_api.py Fixed
Comment thread rsciio/edax/_api.py Fixed
@codecov

codecov Bot commented Feb 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.88%. Comparing base (06c95ac) to head (7473481).

Files with missing lines Patch % Lines
rsciio/edax/_api.py 86.66% 2 Missing and 6 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #485   +/-   ##
=======================================
  Coverage   88.88%   88.88%           
=======================================
  Files         113      113           
  Lines       13045    13082   +37     
  Branches     2414     2420    +6     
=======================================
+ Hits        11595    11628   +33     
- Misses        910      911    +1     
- Partials      540      543    +3     

☔ 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.

@ericpre ericpre left a comment

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.

Thank you @AndrewHerzing for the pull request!

It would be good to refactor the spd_reader and lsd_reader function because they share a lot of the some code!

The test suite failure are unrelated to this PR.

Comment thread CHANGES.rst Outdated
Comment thread upcoming_changes/475.enhancements.rst Outdated
Comment thread doc/file_specification/index.rst Outdated
Comment thread rsciio/edax/_api.py Outdated
Comment thread rsciio/edax/_api.py Outdated
Comment thread rsciio/edax/_api.py Outdated
@ericpre ericpre added this to the v0.13 milestone Mar 11, 2026
@ericpre ericpre modified the milestones: v0.13, v0.14 Apr 8, 2026
@ericpre ericpre modified the milestones: v0.14, v0.15.0 May 26, 2026
Appended "lsd" and "LSD" to list of supported file extensions
specifications.yaml for EDAX reader.
Added files are line_scan.spc, line_scan.lsd, line_scan.csv
Added missing csv_fname argument to file_reader and
fixed some issues with the way the csv header was
being stored in the metadata.
Used TestSpdMap_070_eds as a template and updated
for data shape and expected parameters
… for file_reader

lsd_reader was missing docstring entries for some arguements.  The .lsd
(line scan) was added to the description of the file_reader function. Also
corrected a typo related to the EDAX TEAM software, which should be
"TEAM" instead of "TEAMS".
Note that the file specification is the same as .spd, so I just
linked to the existing .spd file specification pdf.
@AndrewHerzing
AndrewHerzing force-pushed the ENH_Enable_Line_Scan_Compatibility_For_EDAX branch from 51a24cf to 0603276 Compare June 8, 2026 16:16
@AndrewHerzing

Copy link
Copy Markdown
Contributor Author

The suggested changes have now all been implemented. These changes are:

  • The separate lsd_reader and spd_reader functions have been combined into a single si_reader function.
  • Employed standard keywords for filename, endianness, and lazy
  • Reverted changes to CHANGES.RST
  • Moved upcoming_changes/475.enhancements.rst to the correctly numbered upcoming_changes/485.enhancements.rst

@ericpre I think this is ready for another round of review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds EDAX .lsd (1D line scan) support to the EDAX reader by reusing the existing SPD/SPC parsing and adding CSV-based spatial calibration, with corresponding documentation and tests.

Changes:

  • Extend EDAX reader to accept .lsd files and read spatial calibration from a companion .csv.
  • Add test coverage for .lsd line scan loading and update the EDAX test data registry hash.
  • Update EDAX documentation/spec references and add a Towncrier changelog fragment.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
upcoming_changes/485.enhancements.rst Adds changelog entry for EDAX line scan support
upcoming_changes/475.enhancements.rst Adds an additional changelog fragment (scope relevance needs confirmation)
rsciio/tests/test_edax.py Adds tests validating .lsd loading, metadata, axes, and CSV parsing
rsciio/tests/registry.txt Updates the checksum for edax_files.zip test data
rsciio/edax/specifications.yaml Registers .lsd extension and updates EDAX format description
rsciio/edax/_api.py Implements .lsd reading + CSV spatial axis handling via shared reader path
doc/supported_formats/supported_formats.rst Updates supported formats table (currently contains unresolved conflict markers)
doc/supported_formats/edax.rst Updates EDAX user guide docs for .lsd behavior
doc/file_specification/index.rst Adds .lsd entry to file specification downloads list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread doc/supported_formats/supported_formats.rst Outdated
Comment thread doc/supported_formats/edax.rst Outdated
Comment thread upcoming_changes/485.enhancements.rst Outdated
Comment thread rsciio/edax/specifications.yaml
Comment thread rsciio/edax/_api.py
Comment thread rsciio/edax/_api.py Outdated
Comment thread rsciio/edax/_api.py Outdated
Comment thread rsciio/edax/_api.py Outdated
Comment thread upcoming_changes/475.enhancements.rst Outdated
Initialized csv_header as OrderedDict and initialized
spatial_axis_calibration and spatial_axis_offset
variables to 1 and 0, respectively, to prevent
unbounded variable errors.
Previously, `filename`, `lazy`, and `enidanness`
were all desribed.
The main file_reader function defined the keywords
argument as **kwargs.  Elsewhere in the code this was
mistakenly set as **kwds.  All kwds entries were
changed to kwargs
@ericpre
ericpre force-pushed the ENH_Enable_Line_Scan_Compatibility_For_EDAX branch from 456bdda to 293f532 Compare June 9, 2026 16:38
@ericpre
ericpre force-pushed the ENH_Enable_Line_Scan_Compatibility_For_EDAX branch from 293f532 to 7473481 Compare June 9, 2026 16:52

@ericpre ericpre left a comment

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.

This is good - I did a couple of fixes in 7473481.

@ericpre
ericpre merged commit bc5eb91 into hyperspy:main Jun 9, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants