PIV#
Particle image velocimetry (PIV) analysis on an image sequence. This script utilize the extended_search_area_piv()
function of the openpiv-python package. Every pair of frames will give a velocity field, which will be saved as a table of [x, y, u, v]. For example, a 3-frame sequence will lead to 2 velocity fields, namely 1-2 and 2-3. More generally, an n-frame image will result in an (n-1)-frame velocity field.
Syntax
python PIV.py img [winsize piv_folder]
img: can be i) tif sequence folder, ii) nd2 file dir, iii) tiffstack dir.
winsize (optional): interrogation window size. Default is 32. Specify a different value with
--winsize 16
.piv_folder (optional): folder to save PIV results. Default is “.”, i.e. the same directory as the script. Specify a different folder with
--piv_folder /folder/you/like
.
Note
In this implementation, we set overlap as half of winsize.
Test
python PIV.py test_images/piv_drop/ --piv_folder test_images/piv_drop/
Edit
Nov 03, 2022 – Initial commit.
Dec 06, 2022 – i) Enable this script to process *.nd2 files. ii) Check if reults already exist. iii) Pick up job from middle. (Only work for nd2 PIV for the moment) iv) query num frames using metadata, rather than
images.shape
Dec 07, 2022 – Fix undefined “start” issue.
Jan 05, 2023 – (i) Check if img exists. (ii) Adapt myimagelib import style.
Feb 08, 2023 – Rewrite in function wrapper form, to make autodoc work properly. (autodoc import the script and execute it, so anything outside
if __name__=="__main__"
will be executed, causing problems)Mar 23, 2023 – Also process tiff stacks.
Apr 28, 2023 – (i) improve docstring, (ii) remove argument
dt
, (iii) rewrite argument parser with argparse, (iv) make pair sampling consistent (every frame instead of every 2 frames).