imagestructurefunction#
This module contains the image structure function data class.
The ImageStructureFunction
object is used to store and retrieve information
about the image structure function computed in DDM.
The ImageStructureFunction.data
contains the image structure function
values in \((\Delta t, k_y, k_x)\) order. For instance, the image
structure function at the 10th delay computed can be accessed via
dqt.data[9]
Note
Remember that Python uses zero-based indexing.
The ImageStructureFunction
can then be saved into a binary file by using
ImageStructureFunction.save()
(it will have a .sf.ddm extension)
and later retrieved from the memory using
SFReader.load()
, which you can call directly from fastddm
as
# load image structure function
dqt = fastddm.load('path/to/my_dqt_file.sf.ddm')
In order to avoid reading and loading the entire file, we also provide
a fast reader through the SFReader
, which can be used to
access directly from the disk the relevant data, for example:
from fastddm.imagestructurefunction import SFReader
# open file
r = SFReader('path/to/my_dqt_file.sf.ddm')
# access quantities in full plane representation
# access kx array
kx = r.get_kx()
# access 10th computed delay
frame = r.get_frame(index=9)
# access the same quantities in half plane representation
kx_half = r.get_kx(full=False)
frame_half = r.get_frame(index=9, full=False)
- class fastddm.imagestructurefunction.ImageStructureFunction(_data: ndarray, _kx: ndarray, _ky: ndarray, _width: int, _height: int, _tau: ndarray, _pixel_size: float = 1.0, _delta_t: float = 1.0)#
Image structure function container class.
- Parameters:
_data (numpy.ndarray) – The packed data (2D image structure function, power spectrum, and variance).
_kx (numpy.ndarray) – The array of wavevector values over x.
_ky (numpy.ndarray) – The array of wavevector values over y.
_width (int) – The width of the full (symmetric) 2D image structure function.
_height (int) – The height of the full (symmetric) 2D image structure function.
_tau (numpy.ndarray) – The array of time delays.
_pixel_size (float, optional) – The effective pixel size. Default is 1.
_delta_t (float, optional) – The time delay between two consecutive frames. Default is 1.
- __len__()#
The length of the image structure function data. It coincides with the number of lags.
- Returns:
The length of data.
- Return type:
- full_kx() ndarray #
Get the full array of wavevector values over x.
- Returns:
The full
kx
array.- Return type:
- full_ky() ndarray #
Get the full array of wavevector values over y.
- Returns:
The full
ky
array.- Return type:
- full_power_spec() ndarray #
Get the full (symmetric) average 2D power spectrum of the input images.
- Returns:
The full 2D power spectrum.
- Return type:
- full_slice(idx: int) ndarray #
Get the full (symmetric) 2D image structure function at index
idx
.- Parameters:
idx (int) – The slice index.
- Returns:
The full 2D image structure function slice.
- Return type:
- Raises:
IndexError – If
idx
is out of bounds.
- full_var() ndarray #
Get the full (symmetric) 2D variance (over time) of the Fourier transformed images.
- Returns:
The full 2D variance.
- Return type:
- save(fname: str = 'analysis_blob') None #
Save
ImageStructureFunction
to binary file.- Parameters:
fname (str, optional) – The full file name, by default “analysis_blob”.
- save_as_tiff(seq: Sequence[int], fnames: Sequence[str]) None #
Save
ImageStructureFunction
frames as images.- Parameters:
- Raises:
RuntimeError – If number of elements in
fnames
andseq
are different.
- set_frame_rate(frame_rate: float) None #
Set the acquisition frame rate.
This will propagate also on the values of
tau
.- Parameters:
frame_rate (float) – The acquisition frame rate.
- property data: ndarray#
The 2D image structure function (in \((\Delta t, k_y, k_x)\) order).
- Returns:
The 2D image structure function.
- Return type:
- property delta_t: float#
The time delay between to consecutive frames.
- Returns:
Time delay.
- Return type:
- property height: int#
The height of the full (symmetric) 2D image structure function.
- Returns:
The full height.
- Return type:
- property kx: ndarray#
The array of wave vector values over x.
- Returns:
The array of
kx
.- Return type:
- property ky: ndarray#
The array of wave vector values over y.
- Returns:
The array of
ky
.- Return type:
- property power_spec: ndarray#
The average 2D power spectrum of the input images.
- Returns:
The average 2D power spectrum of the input images.
- Return type:
- class fastddm.imagestructurefunction.SFParser(fh: BinaryIO)#
Image structure function file parser class. Inherits from
Parser
.
- class fastddm.imagestructurefunction.SFReader(file: str)#
FastDDM image structure function reader class. Inherits from
Reader
.- get_frame(index: int, full: bool | None = True) ndarray #
Read
data
slice array from file.- Parameters:
- Returns:
The
data
slice array.- Return type:
- Raises:
IndexError – If
index
is out of range.
- get_kx(full: bool | None = True) ndarray #
Read
kx
array from file.- Parameters:
full (Optional[bool]) – If True, return the full (symmetric)
kx
array. Default is True.- Returns:
The
kx
array.- Return type:
- get_ky(full: bool | None = True) ndarray #
Read
ky
array from file.- Parameters:
full (Optional[bool]) – If True, return the full (symmetric)
ky
array. Default is True. This flag has in fact no effect on the output sinceky
is already full.- Returns:
The
ky
array.- Return type:
- get_power_spec(full: bool | None = True) ndarray #
Read power spectrum array from file.
- Parameters:
full (Optional[bool]) – If True, return the full (symmetric) power spectrum. Default is True.
- Returns:
The power spectrum array.
- Return type:
- get_var(full: bool | None = True) ndarray #
Read variance array from file.
- Parameters:
full (Optional[bool]) – If True, return the full (symmetric) variance. Default is True.
- Returns:
The variance array.
- Return type:
- load() ImageStructureFunction #
Load image structure function from file.
- Returns:
ImageStructureFunction
object.- Return type:
- Raises:
IOError – If file version not supported.
- class fastddm.imagestructurefunction.SFWriter(file: str)#
FastDDM image structure function writer class. Inherits from
Writer
.- write_obj(obj: ImageStructureFunction) None #
Write
ImageStructureFunction
object to binary file.- Parameters:
obj (ImageStructureFunction) –
ImageStructureFunction
object.