Tip
Download this tutorial as a Jupyter notebook
, or as a python script
with code cells.
Tutorial 4: Motion Compensation¶
This tutorial introduces the motion compensation capabilities of optimap
. Motion in optical mapping studies causes severe measurement artifacts, often referred to as ‘motion artifacts’ [Rohde et al.[1], Christoph and Luther[2], Lebert et al.[3], Kappadan et al.[4], Christoph and Ripplinger[5]]. To avoid these artifacts, the vast majority of optical mapping studies are conducted with pharmacological agents, such as Blebbistatin, which suppress the contractile motion of heart tissue by uncoupling the excitation-contraction coupling mechanism [Swift et al.[6]]. optimap
includes numerical methods with which motion artifacts can be substantially reduced. Instead of suppressing motion pharmacologically, we can use optimap
to track, stabilize and inhibit motion and motion artifacts numerically. In many cases, uncoupling agents are no longer needed and optical mapping studies can be performed with freely contracting tissues.
This tutorial explains how to process cardiac optical mapping recordings with motion and discusses best practices to reduce motion artifacts using numerical motion tracking. Tutorial 7 discusses an additional optical technique, ratiometric imaging, which can be applied in combination with numerical motion tracking to further reduce motion artifacts, see also Kappadan et al.[7].
We will discuss several examples which illustrate the effectiveness of numerical motion compensation as well as its limitations.
Motion can be compensated with just 1 line of code in optimap
:
video_compensated = om.motion_compensate(video)
Types of Video Data and Rhythms¶
Numerical motion tracking and artifact compensation can be performed with whole organ, cell culture, and single cell preparations. The effectiveness of numerical motion compensation depends on various factors including properties of the video data and the type of rhythm:
Strong motion and deformation poses the most difficult data, because the tissue can move out of the field of view or deform so strongly that tracking fails. With strong motion (e.g. sinus rhythm) it is also required to use ratiometric imaging in addition to numerical motion compensation, see Tutorial 7 for more details.
Arrhythmias, in particular tachyarrhythmias such as ventricular fibrillation (VF), are easier to process because motion is moderate or small, see Christoph et al.[8], Christoph and Luther[2]. Ratiometric imaging, as described in Tutorial 7, is not necessarily required during arrhythmias depending on the motion and desired analysis, see also Fig. 12 in Kappadan et al.[7].
Measuring action potential durations (APD) (see Tutorial 8) with motion is much more challenging than measuring activation times/maps (see Tutorial 5) or conduction velocities (see Tutorial 6). Action potential duration (APD) measurements with contracting tissues require ratiometric imaging, see Tutorial 7 and Figs. 1-7 in Kappadan et al.[7].
Noisy video data can impede the tracking, see Lebert et al.[3].
A shallow depth of focus and blurring can impede the tracking.
Tracking tissue close to the video boundaries often fails. Keep the tissue centered and leave enough space around it during imaging.
The tissue needs to be illuminated as evenly as possible, see Tutorial 7 for details.
Weak Motion¶
Relatively little contractile motion occurs during tachyarrhythmias, such as ventricular fibrillation (VF) in isolated hearts, or in cell cultures. Such small or finite motion promises the highest success rates when trying to compensate motion artifacts using numerical motion tracking. Tutorial 1 already demonstrated numerical motion compensation with ventricular fibrillation (VF), and numerical motion artifact compensation would be similarly succesful with recordings of other rhythms (e.g. sinus or pacing) in which Blebbistatin was not 100% effective. The VF recording was obtained entirely without Blebbistatin. The dominant frequency of the vortex waves is very high (> 10Hz) and, accordingly, the contractile motion is very small. Numerical motion compensation works very well under these circumstances provided the video quality is sufficiently high. In this VF example, motion artifacts are very strong without numerical motion compensation despite the minimal motion, see below. After numerical motion compensation, it is possible to normalize the data, visualize waves, calculate phase maps, see Tutorial 9, and calculate dominant frequencies. The following lines of code load the VF example file from our website cardiacvision.ucsf.edu, perform the motion compensation and display the result:
import optimap as om
filepath = om.download_example_data("VF_Rabbit_1.npy")
video_VF = om.load_video(filepath, frames=500)
video_VF_compensated = om.motion_compensate(video_VF, contrast_kernel=5, presmooth_spatial=1, presmooth_temporal=1)
calculating flows (CPU): 0%| | 0/500 [00:00<?, ?it/s]
calculating flows (CPU): 71%|███████▏ | 357/500 [00:20<00:08, 17.83it/s]
calculating flows (CPU): 100%|██████████| 500/500 [00:28<00:00, 17.84it/s]
om.show_videos([video_VF, video_VF_compensated], titles=["original video", "compensated"]);
The recording is from Chowdhary et al.[9] and was peformed with voltage-sensitive fluorescent dye (Di-4-ANEPPS) and a Basler acA720-520um camera at 500fps.
The pixel-wise normalized videos show action potential vortex waves in the motion compensated videos and motion artifacts in the uncompensated videos:
video_VF_compensated_norm = om.video.normalize_pixelwise_slidingwindow(video_VF_compensated, window_size=60)
video_VF_norm = om.video.normalize_pixelwise_slidingwindow(video_VF, window_size=60)
om.show_videos([video_VF_compensated_norm, video_VF_norm], titles=["compensated", "uncompensated"]);