nexusLIMS.extractors.plugins.fei_emi#

FEI TIA (.ser/.emi) extractor plugin.

Module Contents#

Classes#

SerEmiExtractor

Extractor for FEI TIA series files (.ser with accompanying .emi).

Functions#

parse_basic_info

Parse basic metadata from file.

parse_experimental_conditions

Parse experimental conditions.

parse_acquire_info

Parse acquisition conditions.

parse_experimental_description

Parse experimental description.

get_emi_from_ser

Get the accompanying .emi filename from an ser filename.

fei_unit_to_pint

Convert FEI unit string to Pint unit name.

split_fei_metadata_units

Split metadata into value and units.

map_keys_with_units

Map keys into NexusLIMS metadata structure with unit support.

parse_data_type

Parse the data type from the signal’s metadata.

get_ser_metadata

Get metadata from a .ser file and its accompanying .emi file.

API#

class nexusLIMS.extractors.plugins.fei_emi.SerEmiExtractor[source]#

Extractor for FEI TIA series files (.ser with accompanying .emi).

This extractor handles metadata extraction from files saved by FEI’s (now Thermo Fisher Scientific) TIA (Tecnai Imaging and Analysis) software. The .ser files contain the actual data, while .emi files contain metadata.

name#

‘ser_emi_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 .ser

Return type:

bool

extract(context: ExtractionContext) list[dict[str, Any]][source]#

Extract metadata from a .ser file and its accompanying .emi file.

Returns metadata (as a list of dicts) from an FEI .ser file + its associated .emi files, with some non-relevant information stripped.

Parameters:

context – The extraction context containing file information

Returns:

List containing a single metadata dict with ‘nx_meta’ key. If files cannot be opened, at least basic metadata will be returned ( creation time, etc.)

Return type:

list[dict]

nexusLIMS.extractors.plugins.fei_emi.parse_basic_info(metadata, shape, instrument: Instrument)[source]#

Parse basic metadata from file.

Parse the metadata that is saved at specific places within the .emi tag structure into a consistent place in the metadata dictionary returned by get_ser_metadata(). Specifically, this method handles the creation date, equipment manufacturer, and data shape/type.

Parameters:
  • metadata (dict) – A metadata dictionary as returned by get_ser_metadata()

  • shape – The shape of the dataset

  • instrument (Instrument) – The instrument this file was collected on

Returns:

metadata – The same metadata dictionary with some values added under the root-level nx_meta key

Return type:

dict

nexusLIMS.extractors.plugins.fei_emi.parse_experimental_conditions(metadata)[source]#

Parse experimental conditions.

Parse the metadata that is saved at specific places within the .emi tag structure into a consistent place in the metadata dictionary returned by get_ser_metadata(). Specifically looks at the “ExperimentalConditions” node of the metadata structure.

Parameters:

metadata (dict) – A metadata dictionary as returned by get_ser_metadata()

Returns:

metadata – The same metadata dictionary with some values added under the root-level nx_meta key

Return type:

dict

nexusLIMS.extractors.plugins.fei_emi.parse_acquire_info(metadata)[source]#

Parse acquisition conditions.

Parse the metadata that is saved at specific places within the .emi tag structure into a consistent place in the metadata dictionary returned by get_ser_metadata(). Specifically looks at the “AcquireInfo” node of the metadata structure.

Parameters:

metadata (dict) – A metadata dictionary as returned by get_ser_metadata()

Returns:

metadata – The same metadata dictionary with some values added under the root-level nx_meta key

Return type:

dict

nexusLIMS.extractors.plugins.fei_emi.parse_experimental_description(metadata)[source]#

Parse experimental description.

Parse the metadata that is saved at specific places within the .emi tag structure into a consistent place in the metadata dictionary returned by get_ser_metadata(). Specifically looks at the “ExperimentalDescription” node of the metadata structure.

Parameters:

metadata (dict) – A metadata dictionary as returned by get_ser_metadata()

Returns:

metadata – The same metadata dictionary with some values added under the root-level nx_meta key

Return type:

dict

Notes:

The terms to extract in this section were

nexusLIMS.extractors.plugins.fei_emi.get_emi_from_ser(ser_fname: Path) Path[source]#

Get the accompanying .emi filename from an ser filename.

This method assumes that the .ser file will be the same name as the .emi file, but with an underscore and a digit appended. i.e. file.emi would result in .ser files named file_1.ser, file_2.ser, etc.

Parameters:

ser_fname – The absolute path of an FEI TIA .ser data file

Returns:

  • emi_fname – The absolute path of the accompanying .emi metadata file

  • index (int) – The number of this .ser file (i.e. 1, 2, 3, etc.)

Raises:

FileNotFoundError – If the accompanying .emi file cannot be resolved to be a file

nexusLIMS.extractors.plugins.fei_emi.fei_unit_to_pint(fei_unit)[source]#

Convert FEI unit string to Pint unit name.

Parameters:

fei_unit (str or None) – The unit string from FEI metadata (e.g., “kV”, “uA”, “um”, “deg”)

Returns:

The corresponding Pint unit name, or None if no unit or not recognized

Return type:

str or None

nexusLIMS.extractors.plugins.fei_emi.split_fei_metadata_units(metadata_term)[source]#

Split metadata into value and units.

If present, separate a metadata term into its value and units. In the FEI metadata structure, units are indicated separated by an underscore at the end of the term. i.e. High tension_kV indicates that the High tension metadata value has units of kV.

Parameters:

metadata_term (str) – The metadata term read from the FEI tag structure

Returns:

mdata_and_unit – A length-2 tuple with the metadata value name as the first item and the unit (if present) as the second item

Return type:

tuple of str

nexusLIMS.extractors.plugins.fei_emi.map_keys_with_units(term_mapping, base, metadata)[source]#

Map keys into NexusLIMS metadata structure with unit support.

Maps input metadata terms to NexusLIMS metadata structure, with support for (output_name, unit) tuples in the term_mapping values to create Pint Quantities.

Parameters:
  • term_mapping (dict) – Dictionary where keys are tuples of strings (the input terms), and values are tuples of (output_name, unit) where output_name is either a string or list of strings, and unit is either a string (Pint unit name) or None

  • base (list) – The ‘root’ path within the metadata dictionary

  • metadata (dict) – A metadata dictionary

Returns:

metadata – The same metadata dictionary with values added to nx_meta

Return type:

dict

nexusLIMS.extractors.plugins.fei_emi.parse_data_type(s, metadata)[source]#

Parse the data type from the signal’s metadata.

Determine "Data Type" and "DatasetType" for the given .ser file based off of metadata and signal characteristics. This method is used to determine whether the image is TEM or STEM, Image or Diffraction, Spectrum or Spectrum Image, etc.

Due to lack of appropriate metadata written by the FEI software, a heuristic of axis limits and size is used to determine whether a spectrum’s data type is EELS or EDS. This may not be a perfect determination.

Parameters:
Returns:

  • data_type (str) – The string that should be stored at metadata[‘nx_meta’][‘Data Type’]

  • dataset_type (str) – The string that should be stored at metadata[‘nx_meta’][‘DatasetType’]

nexusLIMS.extractors.plugins.fei_emi.get_ser_metadata(filename)[source]#

Get metadata from a .ser file and its accompanying .emi file.

Deprecated since version This: function is deprecated. Use SerEmiExtractor class instead.

Parameters:

filename (Path) – path to a file saved in the harvested directory of the instrument

Returns:

mdict – A description of the file’s metadata.

Return type:

dict