4.1.1.1.1.3. lib.data_handling.data_preprocessing
#
Module that provides functionality in order to pre-process data, here extract relevant data from input.
@author: Thomas Arne Hensel, 2023
4.1.1.1.1.3.1. Module Contents#
4.1.1.1.1.3.1.1. Classes#
Class to extract data from files to hand the data over to the constructor class. Currently functional for phase scans. |
4.1.1.1.1.3.1.2. API#
- class lib.data_handling.data_preprocessing.Extractor(obj=None, collect_artefacts=True)#
Class to extract data from files to hand the data over to the constructor class. Currently functional for phase scans.
Initialization
Initialize the Extractor.
- Parameters:
obj (str or None) – Object/file to be analyzed (either experiment-object, yaml or tif).
collect_artefacts (bool) – Optional boolean. If True, collect artefacts; otherwise, don’t.
- _set_params(obj)#
Fetch the relevant experimental parameters from the parameter file of the measurement.
- Parameters:
obj (str or None) – Object/file to be analyzed (either experiment-object, yaml or tif).
- get_array_from_tif(path)#
Load a TIF image and convert it into a numpy array.
- Parameters:
path (str) – Absolute path to the file.
- Returns:
ndarray - Shape (2,)
- get_bleach_idx(signal, segment_size=None)#
Detect bleaching steps in a single record and divide it into 2M, 1M, 0M traces.
- Parameters:
signal (MeasurementRecord obj) – MeasurementRecord
segment_size (int or None) – Optional size of the segment.
- Returns:
List of new records of the partial traces corresponding to 0M, 1M or 2M.
- Return type:
list
- _get_moving_avg_segments(imarray, block_size, batchsize, bleach_idx=None, n_cut=2)#
Process an image array. Split array into x- and y-axis. Get a moving average of the arrays with blocksize lines. Segment the averaged traces by bleaching steps.
- Parameters:
imarray (ndarray) – 2D array from image data.
block_size (int) – Block size.
batchsize (int) – Integer, moving avg batch size.
bleach_idx (list or None) – Optional list of indices to segment an array by hand.
n_cut (int) – Number of lines to throw away before and after the bleaching step.
- Returns:
List of averaged segments of shape (bleach_steps, no of axes, averaged lines) and start/end idcs of each segment (idx of line of imarray!)
- Return type:
list