This repository provides an end-to-end Particle Image Velocimetry (PIV) analysis pipeline tailored for xCELLigence timelapse image data, with potential applicability to other multi-frame TIFF video sources. The workflow automates preprocessing, PIV computation, visualization, metric extraction, result compilation, condition mapping, and comparative plotting.
The notebook is designed to run in Google Colab with integrated Google Drive support for input and output handling.
To run the notebook click here:
- Time-lapse multi-frame TIFF files (RGB or grayscale).
- File naming: Well/identifier at the start of the filename (e.g.,
A3_frames0-60orA3_W2_frames0-60or just the identifier). - RGB images are automatically converted to grayscale.
-
Flow Field Visualizations
- Frame-by-frame color-coded flow vectors.
- Summary flow fields for user-defined frame intervals.
- Overall summary flow field for the full video.
-
PIV Metrics (per frame pair)
- Average velocity (µm/min)
- Maximum flow magnitude (µm/min)
- Average flow direction (degrees)
- Divergence (1/min)
-
Plots
- Individual plots for each video and metric.
- Condition-mapped individual and averaged plots.
- Error-bar plots for grouped conditions.
-
CSV Data
- One per video containing all calculated metrics.
- A combined CSV for all processed videos with condition mapping.
- Automatic installation of required libraries:
numpy,opencv-python,matplotlib,openpiv,tifffile,natsort,scipy,pandas,ipywidgets - Force-reinstall of NumPy for compatibility with
openpiv.
- Google Drive integration for accessing and saving files.
- Configurable input/output folder paths.
- Automatic file counting for verification.
- Supports multi-frame RGB and grayscale TIFFs.
- Automatic grayscale conversion for RGB frames.
- Modularized functions for loading and processing frames.
- Parameters configurable via UI in Colab:
pixel_size_um– physical calibrationtime_interval_min– time per framewindow_size,overlap,search_area_size– PIV grid parameterssummary_interval– cumulative frame count before summary plots are generated
- OpenPIV-based computation using
extended_search_area_piv. - Outlier removal with local mean replacement.
For each frame pair:
- Calibrated u and v velocity components.
- Magnitude and direction of flow.
- Divergence from spatial velocity gradients.
- Metrics stored with timestamps in structured dictionaries before CSV export.
- Per-frame flow vectors saved as
.tiff. - Interval summary flows saved periodically.
- Full-video cumulative flow field saved at the end.
- HSV colormap based on flow direction.
- Each video gets an individual
_flow_summary.csv. - Concatenation function merges all individual CSVs into a single
combined_results.csv. - Adds
"CSV File Name"column for traceability.
- Extracts identifiers from filenames (e.g.,
A4,A4_1W). - Interactive ipywidgets interface for mapping identifiers to conditions.
- Saves updated
combined_results.csvwith"Condition"column.
For each video CSV:
- Average Velocity (µm/min)
- Average Direction (degrees)
- Maximum Flow Magnitude (µm/min)
- Divergence (1/min)
- Styled with markers, legends, and axis labels.
- User-selected conditions and metrics.
- Optional smoothing (
uniform_filter1d). - Output in PNG and PDF formats.
- Groups data by condition and averages across replicates.
- Error bars represent standard deviation.
- Supports smoothing and custom graph naming.
-
Open the Notebook in Google Colab
- Click the provided link or upload to Colab manually.
-
Mount Google Drive
- Connect your Google Drive for input/output file access.
-
Set Input/Output Paths
- Specify folders containing
.tif/.tiffvideos and desired output location.
- Specify folders containing
-
Calibrate and Configure Parameters
- Set physical calibration, PIV grid size, overlap, and summary interval.
-
Run Analysis
- The notebook processes each video sequentially, outputs visualizations, and saves metrics.
-
Concatenate CSV Files
- Combine all individual CSVs into one for easier downstream processing.
-
Map Experimental Conditions
- Use the interactive widget to link file identifiers to condition names.
-
Generate Plots
- Create individual, comparative, or averaged plots with or without error bars.
- Python 3.x
- NumPy
- OpenCV
- Matplotlib
- OpenPIV
- tifffile
- natsort
- pandas
- scipy
- ipywidgets