AUTHOR=Li Mingkang , Liu Changhao , Cui Xin , Jung Hayoung , You Heecheon , Feng Linqing , Zhang Shaomin TITLE=An Open-Source Real-Time Motion Correction Plug-In for Single-Photon Calcium Imaging of Head-Mounted Microscopy JOURNAL=Frontiers in Neural Circuits VOLUME=Volume 16 - 2022 YEAR=2022 URL=https://www.frontiersin.org/journals/neural-circuits/articles/10.3389/fncir.2022.891825 DOI=10.3389/fncir.2022.891825 ISSN=1662-5110 ABSTRACT=Single-photon-based head-mounted microscopy is widely used to record the brain activities of freely-moving animals. However, during data acquisition, the free movement of animals will cause shaking in the field of view, which influences subsequent neural signal analyses. Existing motion correction methods applied to calcium imaging data either focus on offline analyses or cannot provide sufficient accuracy in real-time acquisition for single-photon data. In this study, we proposed an open-source real-time motion correction (RTMC) plug-in for single-photon calcium imaging data acquisition. The RTMC plug-in is a real-time subpixel registration algorithm that runs on a GPU in UCLA Miniscope data acquisition software. When used with the UCLA Miniscope, the RTMC algorithm satisfies real-time processing requirements in terms of speed, memory, and accuracy. We tested the RTMC algorithm by extending a manual neuron labeling function to extract calcium signals in a real experimental setting and found it effective to restore neural calcium dynamics and calcium events. Our method could become an essential component in brain science research, where real-time brain activity is needed for closed-loop experiments.