Bruker#
RosettaSciIO can read .spx
single spectrum and .bcf
“hypermaps” file
formats saved with Bruker’s Esprit v1.x or v2.x in .bcf
hybrid (virtual file system/container with xml and binary data, optionally
compressed) format. Most .bcf
import functionality is implemented. Both
high-resolution 16-bit SEM images and hyperspectral EDX data can be retrieved
simultaneously.
BCF can look as all inclusive format, however it does not save some key EDS parameters: any of dead/live/real times, full width at half maximum (FWHM) at \(Mn_{K\alpha}\) line. However, real time for whole map is calculated from metadata (pixelAverage, lineAverage, pixelTime, lineCounter and map height).
Note that Bruker Esprit uses a similar format for EBSD data, but it is not currently supported by RosettaSciIO.
The format contains an extensive list of details and parameters of EDS analyses
which in HyperSpy are mapped to the metadata
and
original_metadata
dictionaries.
API functions#
- rsciio.bruker.file_reader(filename, lazy=False, select_type=None, index=None, downsample=1, cutoff_at_kV=None, instrument=None)#
Read a Bruker
.bcf
or.spx
file.- Parameters:
- filename
str
,pathlib.Path
Filename of the file to read or corresponding pathlib.Path.
- lazybool, default=False
Whether to open the file lazily or not. The file will stay open until closed in
compute()
or closed manually.get_file_handle()
can be used to access the file handler and close it manually.- select_type
'spectrum_image'
,'image'
orNone
, default=None If specified, only the corresponding type of data, either spectrum image or image, is returned. By default (None), all data are loaded.
- index
int
,None
orstr
, default=None Allow to select the index of the dataset in the
.bcf
file, which can contain several datasets. The default value (None
) results in loading the first dataset. When set to'all'
, all available datasets will be loaded and returned as separate signals.- downsample
int
, default=1 The downsampling ratio of a hyperspectral array (height and width only), can be an integer >=1, where value of 1 results in no downsampling. The underlying method of downsampling is unchangeable: sum. Differently than :py:func:
skimage.measure.block_reduce
, it is memory efficient as it doesn’t create intermediate arrays.- cutoff_at_kV
int
,float
,'zealous'
,'auto'
orNone
, default=None It can be used either to crop or enlarge the energy (or number of channels) range at max values. It can be used to conserve memory or enlarge the range if needed to mach the size of other file. The default value (
None
) does not influence the size. Numerical values should be in kV.'zealous'
truncates to the last non zero channel (this option should not be used for stacks, as low beam current EDS can have a different last non zero channel per slice).'auto'
truncates channels to SEM/TEM acceleration voltage or energy at last channel, depending which is smaller. In case the hv info is not there or hv is off (0 kV) then it falls back to the full channel range.- instrument
str
orNone
, default=None Can be either
'TEM'
or'SEM'
.
- filename
- Returns:
list
ofdict
List of dictionaries containing the following fields:
‘data’ – multidimensional
numpy.ndarray
ordask.array.Array
‘axes’ – list of dictionaries describing the axes containing the fields ‘name’, ‘units’, ‘index_in_array’, and either ‘size’, ‘offset’, and ‘scale’ or a numpy array ‘axis’ containing the full axes vector
‘metadata’ – dictionary containing the parsed metadata
‘original_metadata’ – dictionary containing the full metadata tree from the input file
When the file contains several datasets, each dataset will be loaded as separate dictionary.
Examples
Example of loading reduced (downsampled, and with energy range cropped) “spectrum only” data from
bcf
(original shape: 80 keV EDS range (4096 channels), 100x75 pixels; SEM acceleration voltage: 20kV):>>> file_reader("sample80kv.bcf", select_type='spectrum_image', downsample=2, cutoff_at_kV=10)
Load the same file with limiting array size to SEM acceleration voltage:
>>> file_reader("sample80kv.bcf", cutoff_at_kV='auto')
The loaded array energy dimension can by forced to be larger than the data recorded by setting the ‘cutoff_at_kV’ kwarg to higher value:
>>> file_reader("sample80kv.bcf", cutoff_at_kV=60)
Loading without setting
cutoff_at_kV
value would return data with all 4096 channels. Note that settingdownsample
higher than 1 currently locks out using SEM images for navigation in the plotting.