This repository contains a Fiji/ImageJ Jython script that measures and corrects translational drift in 2D or 3D time-lapse data. It uses phase correlation to estimate frame-to-frame shifts and can optionally apply sub-pixel correction.
GPU phase correlation (CLIJ2/VkFFT) is implemented via CLIJ2 and VkFFT:
- Convert frames to
ClearCLBufferobjects with CLIJ2. - Call a JNI wrapper (
VkFFTPhaseCorrelation) that loads the native libraryclijx_vkfft. - The JNI code receives the OpenCL context/queue/buffer pointers from ClearCL and runs VkFFT-based phase correlation on the GPU.
- A plugin wrapper (
PhaseCorrelationFFT) exposes this to scripting and returns the shift vector.
This requires a compiled clijx_vkfft native library and a CLIJX_VKFFT_PATH (or PATH) entry so Fiji can load it.
- Computes translation-only drift across time frames in 2D or 3D stacks
- Supports multi-time-scale drift estimation for slow drifts
- Optional sub-pixel correction using imglib2 interpolation
- Can limit analysis to a ROI that moves with the tracked structure
- Optional edge enhancement and background thresholding
- Can save output as a virtual stack to reduce RAM usage
- Install the modified
clijx_-0.32.2.0.jarintoFiji.app/plugins/. - Place
clijx_vkfft.dllinFiji.app\lib\win64\(auto-detected), or anywhere and setCLIJX_VKFFT_PATHto its full path. - Install
Correct_3D_drift_clij2.pyinto your Plugins menu. - Restart Fiji and run the CLIJ2 script. The Log should report the GPU name and "GPU phase correlation active".
- "GPU phase correlation unavailable, falling back to CPU": check
CLIJX_VKFFT_PATHpoints toclijx_vkfft.dlland restart Fiji. - "no clijx_vkfft in java.library.path": the native DLL is not found; set
CLIJX_VKFFT_PATHor put the DLL onPATH. - "Unable to access native OpenCL pointer": verify you are using the modified
clijx_-0.32.2.0.jar, not the stock CLIJx JAR.
Correct_3D_drift_clij2.py: CLIJ2/VkFFT-enabled variantclijx_-0.32.2.0.jar: modified CLIJx plugin with VkFFT phase correlationclijx_vkfft.dll: native VkFFT library for GPU phase correlationinstallation.md: how to install and register the script in Fijiuser_manual.md: usage guide and option descriptionschange.md: differences between the original and CLIJ2/VkFFT variantsLICENSES.md: third-party license references for bundled code
- Original Correct_3D_Drift: https://github.com/fiji/Correct_3D_Drift
- CLIJx: https://github.com/clij/clijx
- VkFFT: https://github.com/DTolm/VkFFT
This script is licensed under GPL-3.0 (see header in Correct_3D_drift_clij2.py).