nexusLIMS.extractors.plugins.digital_micrograph#
Digital Micrograph (.dm3/.dm4) extractor plugin.
Module Contents#
Classes#
Extractor for Gatan DigitalMicrograph files (.dm3 and .dm4). |
Functions#
Get metadata from a dm3 or dm4 file. |
|
Get the appropriate pre-path in the metadata tag structure for a given signal. |
|
Parse the “microscope info” metadata. |
|
Parse EELS information from the metadata. |
|
Parse EDS information from the dm3 metadata. |
|
Parse “spectrum image” information from the metadata. |
|
Process the Microscope_Info metadata string into a dictionary of key-value pairs. |
API#
- class nexusLIMS.extractors.plugins.digital_micrograph.DM3Extractor[source]#
Extractor for Gatan DigitalMicrograph files (.dm3 and .dm4).
This extractor handles metadata extraction from files saved by Gatan’s DigitalMicrograph software, commonly used on FEI/Thermo and JEOL TEMs.
- name#
‘dm3_extractor’
- priority#
100
- supported_extensions#
Type: typing.ClassVar
- supports(context: ExtractionContext) bool[source]#
Check if this extractor supports the given file.
- Parameters:
context – The extraction context containing file information
- Returns:
True if file extension is .dm3 or .dm4
- Return type:
- extract(context: ExtractionContext) dict[str, Any] | list[dict[str, Any]][source]#
Extract metadata from a DM3/DM4 file.
- Parameters:
context – The extraction context containing file information
- Returns:
For DM3/DM4 files: Always returns a list of metadata dicts. Each dict contains ‘nx_meta’ with NexusLIMS-specific metadata. Single-signal files return a 1-element list for consistency. If the file cannot be opened, returns basic metadata as a single dict (following the standard extractor contract for error cases).
- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.get_dm3_metadata(filename: Path, instrument=None)[source]#
Get metadata from a dm3 or dm4 file.
Returns the metadata from a .dm3 file saved by Digital Micrograph, with some non-relevant information stripped out. Instrument-specific metadata parsing is handled by instrument profiles (see nexusLIMS.extractors.plugins.profiles).
- Parameters:
filename (str) – path to a .dm3 file saved by Gatan’s Digital Micrograph
instrument (Instrument, optional) – The instrument object (used for timezone info). Instrument-specific parsing is now handled via profiles, not this parameter.
- Returns:
metadata – List of extracted metadata dicts, one per signal. If None, the file could not be opened.
- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.get_pre_path(mdict: Dict) List[str][source]#
Get the appropriate pre-path in the metadata tag structure for a given signal.
Get the path into a dictionary where the important DigitalMicrograph metadata is expected to be found. If the .dm3/.dm4 file contains a stack of images, the important metadata for NexusLIMS is not at its usual place and is instead under a
plan infotag, so this method will determine if the stack metadata is present and return the correct path.- Parameters:
mdict (dict) – A metadata dictionary as returned by
get_dm3_metadata()- Returns:
A list containing the subsequent keys that need to be traversed to
get to the point in the
mdictwhere the important metadata is stored
- nexusLIMS.extractors.plugins.digital_micrograph.parse_dm3_microscope_info(mdict)[source]#
Parse the “microscope info” metadata.
Parse the “important” metadata that is saved at specific places within the DM3 tag structure into a consistent place in the metadata dictionary returned by
get_dm3_metadata(). Specifically looks at the “Microscope Info”, “Session Info”, and “Meta Data” nodes (these are not present on every microscope).- Parameters:
mdict (dict) – A metadata dictionary as returned by
get_dm3_metadata()- Returns:
mdict – The same metadata dictionary with some values added under the root-level
nx_metakey- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.parse_dm3_eels_info(mdict)[source]#
Parse EELS information from the metadata.
Parses metadata from the DigitalMicrograph tag structure that concerns any EELS acquisition or spectrometer settings, placing it in an
EELSdictionary underneath the root-levelnx_metanode.- Parameters:
mdict (dict) – A metadata dictionary as returned by
get_dm3_metadata()- Returns:
mdict – The metadata dict with all the “EELS-specific” metadata added under
nx_meta- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.parse_dm3_eds_info(mdict)[source]#
Parse EDS information from the dm3 metadata.
Parses metadata from the DigitalMicrograph tag structure that concerns any EDS acquisition or spectrometer settings, placing it in an
EDSdictionary underneath the root-levelnx_metanode. Metadata values that are commonly incorrect or may be placeholders are specified in a list under thenx_meta.warningsnode.- Parameters:
mdict (dict) – A metadata dictionary as returned by
get_dm3_metadata()- Returns:
mdict – The metadata dictionary with all the “EDS-specific” metadata added as sub-node under the
nx_metaroot level dictionary- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.parse_dm3_spectrum_image_info(mdict)[source]#
Parse “spectrum image” information from the metadata.
Parses metadata that concerns any spectrum imaging information (the “SI” tag) and places it in a “Spectrum Imaging” dictionary underneath the root-level
nx_metanode. Metadata values that are commonly incorrect or may be placeholders are specified in a list under thenx_meta.warningsnode.- Parameters:
mdict (dict) – A metadata dictionary as returned by
get_dm3_metadata()- Returns:
mdict – The metadata dictionary with all the “EDS-specific” metadata added as sub-node under the
nx_metaroot level dictionary- Return type:
- nexusLIMS.extractors.plugins.digital_micrograph.process_tecnai_microscope_info(microscope_info, delimiter='\u2028')[source]#
Process the Microscope_Info metadata string into a dictionary of key-value pairs.
This method is only relevant for FEI Titan TEMs that write additional metadata into a unicode-delimited string at a certain place in the DM3 tag structure
- Parameters:
- Returns:
info_dict – The information contained in the string, in a more easily-digestible form.
- Return type: