nexusLIMS.extractors.plugins.preview_generators.hyperspy_preview#
HyperSpy-based preview generator for microscopy data files.
Module Contents#
Classes#
Preview generator for files that can be loaded with HyperSpy. |
Functions#
Add annotation markers from a DM3/DM4 file to a HyperSpy signal. |
|
Generate a preview thumbnail from an arbitrary HyperSpy signal. |
Data#
Logo background to use for a spectrum image preview |
API#
- nexusLIMS.extractors.plugins.preview_generators.hyperspy_preview.SPECTRUM_IMAGE_LOGO#
Logo background to use for a spectrum image preview
- nexusLIMS.extractors.plugins.preview_generators.hyperspy_preview.add_annotation_markers(s)[source]#
Add annotation markers from a DM3/DM4 file to a HyperSpy signal.
Read annotations from a signal originating from DigitalMicrograph and convert the ones (that we can) into HyperSpy 2.0+ markers for plotting. Uses the modern hs.plot.markers API instead of the deprecated dict2marker.
- Parameters:
s (
hyperspy.signal.BaseSignal(or subclass)) – The HyperSpy signal for which a thumbnail should be generated
- nexusLIMS.extractors.plugins.preview_generators.hyperspy_preview.sig_to_thumbnail(s, out_path: Path, dpi: int = 92)[source]#
Generate a preview thumbnail from an arbitrary HyperSpy signal.
For a 2D signal, the signal from the first navigation position is used (most likely the top- and left-most position. For a 1D signal (i.e. a spectrum or spectrum image), the output depends on the number of navigation dimensions:
0: Image of spectrum
1: Image of linescan (a la DigitalMicrograph)
2: Image of spectra sampled from navigation space
2+: As for 2 dimensions
- Parameters:
s (
hyperspy.signal.BaseSignal(or subclass)) – The HyperSpy signal for which a thumbnail should be generatedout_path – A path to the desired thumbnail filename. All formats supported by
savefig()can be used.dpi (int) – The “dots per inch” resolution for the outputted figure
- Returns:
f – Handle to a matplotlib Figure
- Return type:
Notes:
This method heavily utilizes HyperSpy’s existing plotting functions to figure out how to best display the image
- class nexusLIMS.extractors.plugins.preview_generators.hyperspy_preview.HyperSpyPreviewGenerator[source]#
Preview generator for files that can be loaded with HyperSpy.
This generator handles preview generation for scientific data files that HyperSpy can load, including dm3, dm4, ser, and other formats. It uses the sig_to_thumbnail function to create previews.
- name#
‘hyperspy_preview’
- priority#
100
- supported_extensions#
Type: typing.ClassVar
- supports(context: ExtractionContext) bool[source]#
Check if this generator supports the given file.
- Parameters:
context – The extraction context containing file information
- Returns:
True if file extension is supported by HyperSpy
- Return type:
- generate(context: ExtractionContext, output_path: Path) bool[source]#
Generate a thumbnail preview using HyperSpy.
- Parameters:
context – The extraction context containing file information
output_path – Path where the preview image should be saved
- Returns:
True if preview was successfully generated, False otherwise
- Return type: