Proceedings of the Information System for the Tasks of Radiation Biology Workshop (ISRB2020) Dubna, Russia, June 18, 2020 COMPUTER VISION ALGORITHMS FOR STUDYING THE INFLUENCE OF VARIOUS FACTORS ON BIOLOGICAL OBJECTS A.S. Bulatov1,2, A.V. Stadnik1,2 1 Joint Institute for Nuclear Research, 6 Joliot-Curie Street, Dubna, Moscow Region, Russia 2 Dubna State University, Universitetskaya 19, Dubna, Moscow Region, 141980, Russia E-mail: andrey.bulatov20@gmail.com The article discusses the possibilities of automating the analysis of behavioral parameters of laboratory animals during an experiment using computer vision algorithms. Specific algorithms that allow one to calculate the track of a laboratory animal and to automatically read out the parameters of the experiment, such as the marking of the laboratory pool and the coordinates of the test site, are presented. The relevance of the work results from the need for automatically monitored behavioral patterns (vertical stands, minks, grooming, fading, movement in place) in the "Open Field" experimental setup. At the same time, in the "Morris Water Maze" experimental setup, due to the presence of glare on the water surface, tracking an experimental animal is incorrect. Keywords: computer vision, Python, OpenCV, tracking, image segmentation Andrey Bulatov, Aleksey Stadnik Copyright © 2020 for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). 34 Proceedings of the Information System for the Tasks of Radiation Biology Workshop (ISRB2020) Dubna, Russia, June 18, 2020 1. Introduction The article is devoted to the development of a software component of an information system being elaborated as part of the joint project of the Laboratory of Information Technologies and the Laboratory of Radiation Biology of the Joint Institute for Nuclear Research. The major task of the information system is to automate the processing and analysis of photo and video files with experiments underway at the Radiation Physiology Sector of the Laboratory of Radiation Biology. The software component of the information system will make it possible to process video recordings of experiments carried out in experimental setups, such as “Open Field”, “Morris Water Maze” and “T-Maze”, to evaluate the track of an experimental animal, to automate the reading-out of some parameters, namely, the marking and location of the experimental setup, the counting of sectors traversed by the rodent in the “Open Field” experimental setup, the fixation of the fact that the rodent found a platform on the water surface in the “Morris Water Maze” experimental setup, the fixation of the rodent’s final position in the “T-Maze” experimental setup. 2. Development of the software component The software component of the information system is developed in the Python programming language using the OpenCV computer vision algorithm library and allows one to download, process and analyze video files obtained during experiments to study the effects of ionizing radiation on the behavioral responses of laboratory animals in test setups (“Open Field”, “Morris Water Maze”, “T-Maze”). The video recording with the experiment, downloaded in the software component, is processed frame by frame. The experimental animal must be absent from the first frame of the video recording, since the first frame is saved and marked as a background. 3. Image segmentation Segmentation algorithms are used to detect or count details in the image. The result of applying these algorithms represents a set of segments covering the entire image or a set of contours extracted from the image. All pixels in the segment are similar in some characteristic or property (color, brightness or texture). Adjacent segments differ in the given characteristic. After saving the first frame, the Watershed [1] segmentation algorithm is applied to extract the experimental setup and its boundaries in the image (Fig. 1). It is required for processing only the part of the image with the experimental setup. Fig. 1. Extracting the experimental setup using the Watershed algorithm 4. Detecting a platform on the water surface One of the behavioral indicators in the “Morris Water Maze” test is the detection of a platform on the water surface by an experimental animal. 35 Proceedings of the Information System for the Tasks of Radiation Biology Workshop (ISRB2020) Dubna, Russia, June 18, 2020 Since the location of the platform can vary in different experiments, the task of defining the location of the platform in the frame was a separate service task to automate the experiment. The main difficulty in the given task relies on the fact that the platform has a fairly small size comparable to the size of the experimental animal, and in the video it also poorly contrasts with the background, i.e. the pool water, which is a relatively calm, but still dynamic environment with a fairly active noise component. The proposed solution comprises several classical stages of image analysis, which is used for one first or several initial frames of the video recording of the experiment. The selected frames are processed by a specially selected filter, which is a MexicanHat wavelet function with radial symmetry with a peak in the center of a 32х32 square image. The image is converted to the HSV color space, where the Value channel is filtered. Such simple transformations enable the grading of the invisibility of the platform in the water. The filter is selected so that its average is close to zero, therefore it works similarly to some conditional segmentation, aligning homogeneous image segments despite small noise. The adaptive threshold filtering from the OpenCV Adaptive Threshold computer vision algorithm library returns a binary mask where in the pool area there is only a segment almost completely corresponding to the platform pixels. To automate the reading-out of the platform location, the contour detection algorithm is used (Fig. 2). Fig. 2. Detecting a platform on the water surface 5. Searching for a rodent in the frame To search for a rodent in the frame correctly, without false positives, reactions to glare and noise, Gaussian smoothing is applied, after which the Threshold function built into OpenCV is used; with its help the absolute difference between the current frame and the background is calculated (Fig. 3). Fig. 3. Searching for a rodent in the frame At the end, the function to search for the object’s contour is used, the coordinates of the contour are written to a text file, and after processing the video file, a track is built using the coordinates (Fig. 4). 36 Proceedings of the Information System for the Tasks of Radiation Biology Workshop (ISRB2020) Dubna, Russia, June 18, 2020 Fig. 4. Track of the experimental animal 6. Counting traversed sectors To automate the counting of sectors traversed by the rodent in the “Open Field” experimental setup, it is required to detect and write the coordinates of the marking of the experimental setup. To search for circles and lines of the marking, the Hough Transform algorithm is used (Fig. 5). The coordinates of the lines of the marking are written, and sectors traversed by the rodent are counted on their basis. Fig. 5. Marking of the experimental setup Conclusion The first results of the development of the software component to analyze video recordings with experiments are considered, computer vision algorithms for image segmentation to detect the experimental setup in the frame and algorithms to define the marking in the “Open Field” experimental setup and to search for a platform on the water surface in the “Morris Water Maze” experimental setup, as well as algorithms to search for a moving object in the frame and to build the trajectory of its movement, are presented. 37 Proceedings of the Information System for the Tasks of Radiation Biology Workshop (ISRB2020) Dubna, Russia, June 18, 2020 References [1] Watershed algorithm. Electronic resource: https://www.pyimagesearch.com/2015/11/02/watershed-opencv/ [2] Wavelet function MexicanHat. Electronic resource: https://academic.oup.com/mnras/article/369/4/1603/1087163 [3] OpenCV Adaptive Threshold. Electronic resource: https://docs.opencv.org/3.4/d7/d4d/tutorial_py_thresholding.html [4] OpenCV Hough Transform. Electronic resource: https://docs.opencv.org/3.4/d9/db0/tutorial_hough_lines.html [5] “Open Field” experimental setup. Electronic resource: http://www.openscience.ru/index.php?page=ts&item=001 [6] “Morris Water Maze” experimental setup. Electronic resource: http://www.openscience.ru/index.php?page=ts&item=021 [7] “T-Maze” experimental setup. Electronic resource: http://www.openscience.ru/index.php?page=ts&item=006 38