detect_data_type() matches extracted metadata against configurable lookup tables to identify what kind of data a file holds (for example Tapping Mode AFM vs Contact Mode AFM), so you can route it to the right processing or visualization.
Detect a type
detect_data_type() returns None when nothing matches, otherwise a dict:
checks reports the metadata field it looked at, a human-readable description, and whether it matched. confidence is simply matched_checks / total_checks.
detect_data_type() raises InvalidMetadataError if you pass something other than a dict, and NoDataTypeDefinitionsError if no data-type definitions are available. Both are importable from dataerai.metaextract.Built-in data types
A freshDataTypeDetector() (and the detect_data_type() convenience function) ships with these built-in definitions:
- AFM/PFM — Tapping Mode AFM, Single Frequency PFM, Vector PFM, DART PFM
- XRD — XRD Rocking Curve, XRD 2Theta-Omega Scan, XRD RSM (reciprocal space map)
- RHEED — kSA RHEED IMM Movie
- Other modalities — Mass Spectrometry Run, NIfTI Neuroimaging Volume, Biological Sequence, Flow Cytometry, FITS Astronomical Data
detector.list_data_types() to print the live list in your environment.
Use the detector directly
Define a custom type
DataTypeCheck’s value can be an exact value, a list or tuple (matches if the metadata value is any item — OR logic), or a callable predicate. min_matches defaults to “all checks must match” when omitted.
check_func can be any predicate, so checks can express ranges or complex validation:
This is the same classifier DataErai runs server-side to tag uploads with a
data_type and confidence score — see Automatic metadata extraction.