A method, device and system for detecting the behavior of laboratory animals
By using classic computer vision technology to eliminate passive motion interference and combining it with reinforcement learning models, it solves the problem of distinguishing active and passive motion and the lack of fine-grained data analysis, achieving high-accuracy recognition of animal motion states and in-depth behavioral patterns. analyze.
Patent Information
- Application Number
- CN202410208188.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-26
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-02-26
AI Technical Summary
When existing technology automatically identifies the movement status of experimental animals, it is difficult to distinguish active movements from passive movements, and data analysis lacks fine granularity, making it impossible to deeply explore the cognitive mechanisms behind animal behavior patterns.
A method based on classic computer vision is used to eliminate passive motion interference through contour recognition and passive motion offset, and report the motion sequence in a time window manner, combined with a reinforcement learning model to analyze the dynamic changes in the animal's motion state.
It improves the recognition accuracy of animals' active motion states, provides fine-grained motion data analysis, deeply explores animal behavior patterns, and explores their cognitive mechanisms.
Smart Images

Figure CN117994850B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition technology, and more specifically, to a method, device, system, and computer-readable storage medium for detecting behavior of experimental animals. Background Art
[0002] Forced swimming and tail suspension tests are the most commonly used depressive behavior models for mice and rats, and play an important role in neuroscience and drug-related research. However, traditional research based on these two paradigms usually requires manual annotation of the animal's movement state, which takes a lot of time and effort. Although there are a few products that automatically identify animal behavior (such as Xinruan VisuTrack rodent behavior video analysis software, American any-maze, etc.), these software are expensive and the data results are single indicators, which is very inconvenient to use. There is an urgent need for an easy-to-use and relatively accurate automated movement state identification method.
[0003] There are two technical problems in automatically identifying the movement status of animals: 1. There is a difference between active movement and passive movement of animals (such as inertial floating in forced swimming, simple pendulum movement in tail suspension task, etc.). Researchers usually need to identify the active movement of animals, but passive movement will interfere with automated recognition methods such as frame difference, reducing recognition accuracy; 2. In terms of data analysis and presentation, the total immobility time / proportion of immobility time is mostly used as an indicator, without a fine-grained description of the animal's movement status in the time dimension, such as reporting the movement sequence that changes over time in a time window, which makes it impossible for researchers to deeply explore the cognitive mechanisms behind the different behavioral patterns of animals.
[0004] In terms of animal motion state detection methods, the methods for automatically detecting the motion state of animals in forced swimming and tail suspension experiments can be roughly divided into two types: those based on deep learning and those based on traditional computer vision: (1) Shanghai Xinruan VisuTrack rodent behavior video analysis software and American any-maze animal behavior video analysis software. The technical methods are unknown. The software and hardware costs are high, the detection technology solution cannot be customized, there is no data analysis and presentation method with fine time granularity, and it does not support manual annotation of customized time window length. (2) Methods based on deep learning models such as deeplabcut detect animal joints through deep learning models, and judge the animal motion state based on the joint motion trajectory in the training model. A large amount of data needs to be manually annotated to fine-tune the key point recognition model. In addition, the recognition of specific actions requires the training of action classification models, which also requires a large amount of data annotation. The deployment and application of this type of solution is very inconvenient. Both current solutions have some problems: (1) The method based on traditional computer vision will be affected by the difference in camera distance and angle, resulting in low recognition accuracy. In addition, it is difficult to distinguish between the active movement of animals and passive movements such as inertial floating and swinging. (2) Deep learning-based methods usually require manual annotation of a large amount of data to fine-tune the key point recognition pre-training model. In addition, training an action classification model to recognize specific actions is required, making the deployment and application of such solutions very inconvenient.
[0005] In terms of animal movement data analysis, existing methods simply analyze the total time and proportion of different movement states during the entire experiment. They are unable to reflect the dynamic development process of animal movement states over time, and are even less able to explore the cognitive computing mechanisms behind movement behavior. Summary of the invention
[0006] In view of the above problems, the present invention proposes a method based on classical computer vision, which is insensitive to the distance and angle of the camera and can eliminate the interference of the passive movement of animals. In addition, the movement sequence of animals can be reported in a time window manner, which provides data for in-depth exploration of the movement behavior patterns of animals and analysis of the cognitive computing mechanism of the dynamic development and change of the animal's movement state based on the reinforcement learning model. This solution is plug-and-play, and users can highly customize parameters such as calibration methods, special extraction methods, denoising methods, recognition thresholds, etc., and can fit the development process of the animal's movement behavior based on multiple models such as RW models, counterfactual models, and physical strength models, and analyze the cognitive computing mechanism behind the movement behavior.
[0007] A behavioral detection method based on experimental animals, comprising:
[0008] Obtain videos of experimental animals;
[0009] Performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0010] Based on the relative invariance of the contour of the experimental animal in the passive motion state, each frame of the contour image sequence is predicted to obtain a predicted passive motion contour image sequence; the difference between the contour image sequence and the predicted passive motion contour image sequence is calculated to obtain a contour image sequence after the passive motion is offset;
[0011] Behavior detection is performed based on the contour image sequence after the passive motion is offset to obtain a behavior sequence.
[0012] Further, the relative invariance is the relative invariance of contour corner points and / or contour moments;
[0013] Preferably, the step of obtaining a predicted passive motion contour map sequence based on the relative invariance prediction of contour corner points comprises: performing corner point detection on each frame contour map of the contour map sequence to obtain a corner point P0, calculating a passive motion corner point P1 corresponding to the corner point P0 in the next frame contour map, using an affine transformation to predict a predicted passive motion corner point P′1 corresponding to P0 in the next frame contour map, minimizing the distance between the passive motion corner point P1 and the predicted passive motion corner point P′1 to obtain an affine transformation, and sequentially applying the affine transformation to each frame contour map of the contour map sequence to obtain the predicted passive motion contour map sequence;
[0014] Preferably, an optical flow method is used to calculate the passive motion corner point P1 corresponding to the corner point P0 in the next frame contour image;
[0015] Preferably, the optical flow method includes one or more of the following: Lucas-Kanade method, Horn-Schunck method, Farneback method, pyramid Lucas-Kanade optical flow algorithm, optical flow algorithm based on deep learning;
[0016] Preferably, the pyramid Lucas-Kanade optical flow algorithm is used to identify the corner point P1, and the contour map is converted into s The scale is scaled to different levels, and the optical flow V is first calculated at the smallest scale level s , and the optical flow V s Calculate the optical flow V as the initial value of the previous scale s-1 , iterate in sequence until the maximum scale optical flow V is calculated 0 ;
[0017] Preferably, the calculation method of the optical flow V is as follows:
[0018]
[0019] Among them I x with I y are the grayscale gradients of the image in the x and y directions, I tis the gradient of the image grayscale changing with time, and n×n represents the size of the local image area for solving the gradient.
[0020] Further, the method used for the corner detection includes one or more of the following: Harris corner detection, Shi-Tomasi corner detection, FAST corner detection, ORB corner detection, GFTT corner detection, Moravec corner detection;
[0021] Preferably, the corner point detection is performed using Harris corner point detection, a window is used to slide in the x and y directions of the image, the grayscale change of the image in the window is calculated, for each window at a position, a corner point response function is calculated, a response function threshold is set, and for pixels whose corner point response function is greater than the response function threshold, non-maximum suppression is used to screen the local optimal corner points, and the screened corner points are included in the corner point P0;
[0022] Preferably, the corner point response function is calculated as follows:
[0023] R = det(M) - k(trace(M)) 2
[0024] Where R represents the corner response function, det(M) is the determinant of the covariance matrix M, trace(M) is the trace of the covariance matrix M, k is a constant, and the calculation of the covariance matrix M is based on the gradient information of the local area of the image. The gradients in the x and y directions are I x and I y , then the covariance matrix M is defined as follows:
[0025]
[0026] Among them, w(x,y) is the weight of the pixel in the window, I x with I y are the grayscale gradients of the window image in the x and y directions respectively.
[0027] Further, an intersection contour map sequence is obtained based on the neighborhood calculation of the contour map sequence after the passive motion is offset, and behavior detection is performed based on the intersection contour map sequence;
[0028] Preferably, the intersection contour map is obtained using a three-frame method, the steps of the three-frame method comprising: calculating the contour map I(t) of the current frame in the contour map sequence and the predicted passive motion contour map of the corresponding frame in the predicted passive motion contour map sequence The first differential image is obtained by performing the difference between the first differential image and the second differential image, and the contour image I(t+1) of the next frame in the contour image sequence and the predicted passive motion contour image of the corresponding frame in the predicted passive motion contour image sequence are calculated. The first differential image and the second differential image are subjected to an AND operation to obtain an intersection contour image of the three-frame method, and the intersection contour image of each frame is calculated in sequence to form the intersection contour image sequence;
[0029] Preferably, the first differential image is binarized to obtain a first binary image, the second differential image is binarized to obtain a second binary image, the first binary image and the second binary image are ANDed to obtain an intersection contour map of the three-frame method, and the intersection contour map of each frame is calculated in sequence to form the intersection contour map sequence.
[0030] Furthermore, the behavior detection uses an image frame difference method to determine the behavior of the animal, and the image frame difference method determines the behavior of the animal based on an area threshold of a difference image between adjacent frame images;
[0031] Preferably, the image frame difference method binarizes the difference image of adjacent frame images according to a threshold value to obtain a binarized image, and judges the behavior of the animal according to the area threshold of the binarized image;
[0032] Preferably, the binary image is subjected to morphological processing before the behavior detection, and the morphological processing includes one or more of the following: dilation, erosion, opening operation, and closing operation.
[0033] Further, the behavior sequence is divided into time windows according to a preset time granularity, and whether the state of the time window is active motion is determined based on the ratio of the number of frames of the motion state sequence in the time window that is greater than a threshold to the total number of frames in the time window, and the determination is performed on all time windows to obtain a behavior sequence of the set time granularity;
[0034] Preferably, the motion state sequence is subjected to data processing to obtain a processed sequence, the processed sequence is divided into time windows according to a preset time granularity, and the judgment is performed on all time windows to obtain a behavior sequence of the set time granularity, wherein the data processing includes one or more of the following: floating point conversion, Gaussian smoothing.
[0035] Furthermore, the contour recognition is performed after preprocessing the video of the experimental animal, and the preprocessing includes one or more of the following: camera calibration, recognition area selection, and recognition area standardization.
[0036] A method for analyzing the cognitive mechanism of experimental animal behavior, the method comprising:
[0037] Acquiring a behavior sequence of an experimental animal, and obtaining the behavior sequence of the experimental animal according to the above-mentioned behavior detection method of the experimental animal;
[0038] splicing the behavior sequences of the experimental animals in different experimental animal groups respectively to obtain group behavior sequences of different experimental animal groups;
[0039] Using Bayesian modeling method to fit the group behavior sequence to obtain a model and parameters;
[0040] The cognitive mechanism of the experimental animal group is analyzed based on the model and parameters.
[0041] Further, the Bayesian modeling method includes one or more of the following: Rescorla-Wagner model, counterfactual model, and physical strength model;
[0042] Preferably, the group behavior sequence is fitted using a Rescorla-Wagner model, which is as follows:
[0043]
[0044] V t+1 =V t +αδ
[0045] δ=R t -V t
[0046] in, is the probability of active movement of the experimental animal, τ is the inverse of temperature, V is the value corresponding to active movement, α is the learning rate, δ is the prediction error, and R is the reward or punishment experienced by the animal;
[0047] Preferably, a counterfactual model is used to fit the group behavior sequence, and the counterfactual model is as follows:
[0048]
[0049]
[0050]
[0051]
[0052]
[0053] in and are the values corresponding to active movement and passive movement, V c and V nc are the values corresponding to the behaviors that are consistent with and inconsistent with the current behavior, δ and δ respectively. nc are the prediction errors corresponding to the behaviors that are consistent with and inconsistent with the current behavior, respectively;
[0054] Preferably, a physical strength model is used to fit the group behavior sequence, and the physical strength model is as follows:
[0055]
[0056] V t+1 =V t +αδ
[0057] δ=R t -V t
[0058] S t =tanh(β(a tot -i tot ))
[0059] Where S t is the animal's physical state, γ is the physical influence coefficient, β is the physical renewal coefficient, a tot and i tot They are the total number of active movements and the total number of passive movements of the animal so far;
[0060] Preferably, a winning model is selected by model comparison, and the cognitive mechanism of the experimental animal group is analyzed based on the winning model and the parameters of the winning model;
[0061] Preferably, the winning model is used to generate a predicted animal behavior sequence, and if the animal behavior sequence obtained from the actual experiment is within the posterior credible interval of the predicted animal behavior sequence, the model is determined to be valid;
[0062] Preferably, the model comparison is performed by information criteria, wherein the information criteria include one or more of the following: AIC, BIC, DIC, MDL, WAIC;
[0063] Preferably, WAIC is used for model comparison, and the model with the smallest WAIC is selected as the winning model. WAIC is calculated as follows:
[0064] WAIC=-2lppd+2p waic
[0065]
[0066]
[0067] Where y is the sample observation, θ is the parameter, i represents each sample, and s represents the predicted animal behavior sequence.
[0068] A behavior detection system for experimental animals, comprising:
[0069] Acquisition module: used to acquire videos of experimental animals;
[0070] Contour recognition module: used for performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0071] Passive motion prediction module: used for predicting each frame of the contour image sequence based on the relative invariance of the contour of the experimental animal in the passive motion state to obtain a predicted passive motion contour image sequence;
[0072] Passive motion cancellation module: used for calculating the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation;
[0073] Behavior detection module: used for performing behavior detection based on the contour image sequence after the passive motion is offset to obtain a behavior sequence.
[0074] A cognitive mechanism analysis system for experimental animal behavior, comprising:
[0075] Acquisition module: used to acquire videos of experimental animals;
[0076] Contour recognition module: used for performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0077] Passive motion prediction module: used for predicting each frame of the contour image sequence based on the relative invariance of the contour of the experimental animal in the passive motion state to obtain a predicted passive motion contour image sequence;
[0078] Passive motion cancellation module: used for calculating the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation;
[0079] Behavior detection module: used for performing behavior detection based on the contour image sequence after the passive motion is offset to obtain a behavior sequence;
[0080] Group behavior splicing module: used for splicing the behavior sequences of the experimental animals in different experimental animal groups to obtain group behavior sequences of different experimental animal groups;
[0081] Bayesian modeling module: used to fit the group behavior sequence using the Bayesian modeling method to obtain a model and parameters;
[0082] Cognitive mechanism analysis module: used to analyze the cognitive mechanism of the experimental animal group based on the model and parameters.
[0083] A device for detecting the behavior of an experimental animal, comprising: a memory and a processor;
[0084] The memory is used to store program instructions; the processor is used to call program instructions, and when the program instructions are executed, any one of the steps of the experimental animal behavior detection method is implemented.
[0085] A device for analyzing the cognitive mechanism of experimental animal behavior, comprising: a memory and a processor;
[0086] The memory is used to store program instructions; the processor is used to call program instructions, and when the program instructions are executed, any one of the steps of the method for analyzing the cognitive mechanism of experimental animal behavior is implemented.
[0087] A computer-readable storage medium for detecting the behavior of an experimental animal stores a computer program, and when the computer program is executed by a processor, any one of the steps of the method for detecting the behavior of an experimental animal is implemented.
[0088] A computer-readable storage medium for analyzing the cognitive mechanism of experimental animal behavior stores a computer program, which, when executed by a processor, implements any one of the steps of the method for analyzing the cognitive mechanism of experimental animal behavior.
[0089] Advantages of this application:
[0090] 1. This application eliminates the interference of passive movement of animals in the process of detecting animal behavior, and improves the accuracy of identifying the active movement state of animals;
[0091] 2. This application is different from the traditional method of reporting simple indicators such as total immobility time / percentage of immobility time. Instead, it reports the movement sequence in a time window manner, providing data for in-depth exploration of animal behavior patterns;
[0092] 3. This application combines the information of neighboring image frames on the basis of the traditional image frame difference method, thereby reducing the error of behavior detection.
[0093] 4. This application proposes a method for analyzing motion state sequence data, analyzes behavior sequences through Bayesian modeling, and explores the cognitive mechanism behind the behavior. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0095] Figure 1 is a schematic flow chart of a behavior detection method for experimental animals provided by an embodiment of the present invention;
[0096] Figure 2 is a schematic flow chart of a behavior detection system for experimental animals provided by an embodiment of the present invention;
[0097] Figure 3 is a schematic flow chart of a method for analyzing the cognitive mechanism of experimental animal behavior provided by an embodiment of the present invention;
[0098] Figure 4 is a schematic flow chart of a cognitive mechanism analysis system for experimental animal behavior provided by an embodiment of the present invention;
[0099] Figure 5 It is a schematic block diagram of an experimental animal behavior detection device or an experimental animal behavior cognitive mechanism analysis device provided by an embodiment of the present invention;
[0100] Figure 6 An interface for selecting an identification area of an experimental animal video provided by an embodiment of the present invention;
[0101] Figure 7 This is an animal outline recognition result provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0102] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0103] In some of the processes described in the specification and claims of the present invention and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The sequence numbers of the operations, such as S101, S102, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0104] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0105] Figure 11 is a schematic flow chart of a behavior detection method for an experimental animal provided by an embodiment of the present invention. Specifically, the method comprises the following steps:
[0106] S101: Obtain videos of experimental animals;
[0107] In one embodiment, the video of the experimental animal is a recorded video.
[0108] In one embodiment, the video of the experimental animal is a video of the experimental animal recorded in real time by a camera.
[0109] In one embodiment, the video of the experimental animal is preprocessed before subsequent contour recognition, and the preprocessing includes one or more of the following: camera calibration, recognition area selection, and recognition area standardization.
[0110] In one embodiment, the input video is a behavioral despair experiment video. The behavioral despair experiment refers to providing an animal with an unavoidable oppressive environment, which makes it extremely uncomfortable and struggles, but it cannot escape, resulting in intermittent immobility. This typical "immobility state" exhibited by the animal reflects a state called "behavioral despair", which is similar to depression. Therefore, this model is often used to evaluate the efficacy of drugs such as antidepressants, stimulants, and sedatives.
[0111] The tail suspension test and forced swimming test are the most commonly used behavioral despair tests for mice. In the tail suspension test, the mouse's tail is fixed so that its head is facing downward. After the mouse struggles desperately for a period of time, when it finds that it cannot escape this state, it will give up struggling and enter a state of "behavioral despair", and will continue to struggle. In the forced swimming test, the mouse is placed in water. The mouse will struggle to prevent drowning. When it finds that it cannot escape this state, it will give up struggling and enter a state of "behavioral despair", and will continue to struggle. The struggling behavior is an active movement state. The behavioral despair state may include inertial movement after struggling. At this time, the mouse's behavior is classified as a "passive movement state". By detecting and comparing the behavior of mice, such as the relative duration of active movement, the clinical effect of a certain drug can be obtained.
[0112] 1. Camera Calibration
[0113] In one embodiment, since the camera position is often incorrect during experiments, resulting in image distortion due to changes in viewing angle and size scaling, the video needs to be calibrated.
[0114] In one embodiment, when calibrating the camera, first extract the first frame of the video, mark the four vertices of the cantilever box in the front direction as feature anchor points on the frame, and solve the perspective transformation matrix so that the upper left, upper right, lower right, and lower left vertices of the cantilever box in the new viewing plane are located at (0,0), (1280,0), (1280,720), and (0,720), respectively, where the upper left corner is the origin of the coordinates, and the right and downward directions are the positive directions of the x and y axes, respectively. The perspective matrix P is calculated according to the following position mapping relationship:
[0115]
[0116]
[0117] The obtained perspective transformation matrix is used to perform perspective transformation on all frames of the video, so that the size of the experimental area in the video is fixed and the viewing angle is located directly in front. The video camera is calibrated to normalize the videos under different shooting conditions to a uniform size and eliminate distortion, ensuring the consistency of the motion state recognition results under different experimental conditions.
[0118] 2. Identification area selection
[0119] In one embodiment, each recorded video of the forced swimming and tail suspension tasks includes multiple animals. For the forced swimming task, the smallest rectangular frame containing the swimming beaker of each animal is selected; for the tail suspension task, the smallest rectangular frame containing the swing range of each animal is selected. The target area selection box in the scheme is always visible, and the horizontal / vertical size can be adjusted in real time through the set adjustment keys (for example, the "-" key is used to reduce horizontally, the "=" key is used to enlarge, the "[" key is used to reduce vertically, and the "]" key is used to enlarge). It is clear and convenient to use. The recognition area selection interface is as follows: Figure 6 shown.
[0120] In one embodiment, each selected recognition area is scaled to a size of 480*640 for subsequent contour recognition.
[0121] S102: performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0122] 3. Animal outline recognition
[0123] In one embodiment, the identified area is converted into a grayscale image G, and the animal outline is detected in the grayscale image.
[0124] In one embodiment, the grayscale image is first convolved using the Scharr operator in the x and y directions as the convolution kernel to calculate the gradient G of the grayscale image in the x and y directions. x With G y :
[0125]
[0126]
[0127] Fusion G x With G y Get the contour plot:
[0128]
[0129] The obtained contour map is as follows Figure 7 As shown, the contour map is used for subsequent passive motion cancellation and active motion recognition. The Scharr operator is an operator for edge detection, which is usually used for gradient calculation of images. It is similar to the Sobel operator and the Prewitt operator, but uses different convolution kernels when calculating the gradient. The Scharr operator has better performance than the Sobel and Prewitt operators, especially for the detection of detail edges in images.
[0130] In one embodiment, OpenCV in Python is used to perform contour detection. OpenCV is a popular computer vision library that provides functions for contour detection and can specify edge detection operators used in contour detection.
[0131] S103: predicting each frame of the contour image sequence based on the relative invariance of the contour of the experimental animal in the passive motion state to obtain a predicted passive motion contour image sequence;
[0132] 4. Passive motion offset
[0133] In one embodiment, the input video is a video of a mouse performing a tail suspension task. Through a large number of observations of mouse experimental videos, it is found that the time that the mouse is in a completely static state during the experiment is very short, and can even be ignored (because after the mouse starts to move, even if there is no struggle in the subsequent sequence, the inertial swing still exists), so the "complete static" can be merged into the "inertial swing" state, collectively referred to as the "passive motion state". Mouse behavior detection is to distinguish the process of "passive motion state" and "active motion state" of mice, which can be simplified to a state switching process, or a behavior switching process. Therefore, as long as the behavior switching moment in the experimental process can be found, the behavior switching process can be extracted, thereby completing the identification of mouse behavior detection.
[0134] In one embodiment, the relative invariance is the relative invariance of contour corner points and / or contour moments; preferably, the step of predicting a predicted passive motion contour map sequence based on the relative invariance of contour corner points includes: performing corner point detection on each frame contour map of the contour map sequence to obtain corner point P0, calculating the passive motion corner point P1 corresponding to the corner point P0 in the next frame contour map, using affine transformation to predict the predicted passive motion corner point P1′ corresponding to P0 in the next frame contour map, minimizing the distance between the passive motion corner point P1 and the predicted passive motion corner point P1′ to obtain an affine transformation, and applying the affine transformation to each frame contour map of the contour map sequence in turn to obtain the predicted passive motion contour map sequence.
[0135] In the field of image processing and computer vision, corners refer to locations in an image with significant grayscale changes. These locations are usually corners or edges in the image, with stronger grayscale gradients than other areas. Corners usually represent some important features in the image. Therefore, corner detection can be used to identify key features in an image, which is an important step in tasks such as image stitching, target tracking, and object recognition.
[0136] Harris corner detection is a method for calculating corners in an image and is widely used in computer vision and image processing. The algorithm was proposed by Chris Harris and Mike Stephens in 1988. The core idea of Harris corner detection is to determine whether a region is a corner by observing the change in grayscale intensity in a local area of the image. The key is to detect the relationship between the grayscale change in a local area of the image and the displacement in different directions. The basic steps of the algorithm are as follows: (1) Calculate the gradient of the image: Smooth the image and then calculate the gradient of the image in the horizontal and vertical directions. This can be achieved using some common filters (such as Sobel filters). (2) Calculate the Harris matrix: For each pixel, the Harris matrix is calculated by using the gradient information. The Harris matrix is a 2×2 matrix that represents the information about the grayscale change near the pixel. (3) Calculate the corner response function: Using the eigenvalues of the Harris matrix, calculate a value called the corner response function. Usually, the corner response function is defined as: R = λ1×λ2-k(λ1+λ2) 2, where λ1 and λ2 are the eigenvalues of the Harris matrix, and k is a constant that is usually a small value. (4) Select corner points: Perform threshold judgment on the corner point response function, and pixels greater than a certain threshold are considered to be corner points. The Harris corner detection method is a corner detection algorithm based on local image features. It is sensitive to areas with significant grayscale changes in the image, so it is suitable for detecting corner points. This method has been widely used in fields such as image stitching, object recognition and tracking.
[0137] In one embodiment, the optical flow method is used to calculate the passive motion corner point P1 corresponding to the corner point P0 in the next frame contour image.
[0138] In one embodiment, the optical flow method includes one or more of the following: Lucas-Kanade method, Horn-Schunck method, Farneback method, pyramid Lucas-Kanade optical flow algorithm, and optical flow algorithm based on deep learning.
[0139] In one embodiment, the contour map G obtained from each frame is used to extract the corner points P0 required for optical flow estimation. Compared with directly using the original image, the contour line eliminates the noise in the background image to a certain extent, making the extracted corner points more likely to be located on the animal, thereby enhancing the accuracy of passive motion state estimation. The Harris corner point detection method is used to extract the corner points, and a small window is used to slide in the x and y directions to calculate the grayscale change E(u,v) of the image in the window. For each window position, the corner point response function R is calculated:
[0140] R = det(M) - k(trace(M)) 2
[0141] Where R represents the corner response function, det(M) is the determinant of the covariance matrix M. trace(M) is the trace of the covariance matrix M, k is a constant, and the calculation of the covariance matrix M is based on the gradient information of the local area of the image. The gradients in the x and y directions are I x and I y , then the covariance matrix M is defined as follows:
[0142]
[0143] Where w(x,y) is the weight of the pixel in the window, I x and Iy are the grayscale gradients of the window image in the x and y directions respectively. Set the threshold thr, and for pixels with R>thr, use non-maximum suppression to filter the local optimal corner points, and include the filtered corner points into P0.
[0144] After obtaining the animal corner point P0 in the current frame, the optical flow method is used to identify the corner point P1 corresponding to P0 in the next frame.
[0145] Optical flow is a technique for calculating the movement of pixels in an image over time. Optical flow represents the direction and speed of movement of each pixel in an image within a time interval. This technique is very important for applications such as understanding motion in images, target tracking, and video compression. The following are some key concepts and methods of optical flow: (1) Optical flow vector: The core of the optical flow method is to calculate the optical flow vector of each pixel, which contains the direction and speed of movement of the pixel in the image. The optical flow vector is usually expressed as (u, v), where (u) is the horizontal component of movement and (v) is the vertical component of movement. (2) Optical flow field: The optical flow vectors of all pixels on the entire image are calculated, and the results form an optical flow field, which displays the motion information of each position in the image.
[0146] The Lucas-Kanade method is a classic method for optical flow estimation, which assumes that the motion in the image is local and uses partial derivatives in the local area to estimate the optical flow. This method is suitable for relatively small motions.
[0147] Unlike the Lucas-Kanade method, the Horn-Schunck method processes the entire image and solves the optical flow of the entire image by minimizing the smoothness of the global optical flow field. This method is suitable for relatively large motions.
[0148] With the development of deep learning, modern optical flow estimation methods use deep learning models such as convolutional neural networks (CNNs) to learn the motion information of images through end-to-end training. These methods perform better when dealing with complex scenes and large motions.
[0149] The dense optical flow method calculates the optical flow of all pixels in the image, while the sparse optical flow method only calculates the optical flow of a portion of the pixels in the image. Dense optical flow provides more detailed information globally, but the computational cost is higher, while sparse optical flow can be calculated more efficiently in some applications.
[0150] When the animal only has passive motion (inertial floating, simple pendulum motion, etc.) and its posture remains unchanged, the relative positions of the corner points in two adjacent frames remain unchanged, and only an overall drift exists.
[0151] In one embodiment, the passive motion of the animal meets the spatial consistency assumption of the Lucas-Kanade optical flow algorithm, so the pyramid Lucas-Kanade optical flow algorithm is used to identify the corresponding corner point P1 in the next frame. s The scale of M is scaled to different levels L (L=0,1,…,s), first at the smallest level M sCalculate the optical flow and use the result as the previous scale M s-1 The initial guess of M, until the maximum scale (original image) 0 The calculation method of optical flow V is as follows:
[0152]
[0153] Among them I x with I y are the grayscale gradients of the image in the x and y directions, I t is the gradient of the image grayscale changing over time. Using the corresponding corner points P0 and P1 in the two adjacent frames, use the affine transformation A to predict the overall drift of the animal, and obtain the prediction of the corner point position in the next frame P′1=AP0, so that the geometric distance between P′1 and P1 is minimized. At this time, the affine matrix A simulates the passive motion state of the animal as a whole, and the passive motion offset prediction of the next frame can be obtained by performing an affine transformation on the current frame contour map I(t)
[0154] The basic idea of the Lucas-Kanade optical flow algorithm is to assume that the motion of a small area in the image is basically consistent, and use this assumption to establish a local motion model. The algorithm calculates partial derivatives of the grayscale values of pixels in a small window over time, establishes a set of equations, and then estimates the motion by solving this set of equations.
[0155] The Lucas–Kanade optical flow method is a gradient-based local parameterized optical flow estimation method. The algorithm assumes that the optical flow vector is constant in a neighborhood of spatial size Ω, and then estimates the optical flow using weighted least squares. In a small spatial neighborhood Ω, the optical flow estimation error is defined as:
[0156]
[0157] Where W 2 (x) represents the window weight function, which makes the central area of the neighborhood have a greater impact on the constraint than the peripheral area, and a Gaussian function is often used.
[0158] The pyramid Lucas-Kanade optical flow algorithm is an improved method based on the Lucas-Kanade optical flow algorithm by introducing an image pyramid. Image pyramid is a method of expressing images at multiple scales. By downsampling the image to different degrees, a series of images of different scales are generated. In the optical flow algorithm, the introduction of pyramid helps to handle motion at different scales, thereby improving the robustness of the algorithm.
[0159] The steps of the pyramid Lucas-Kanade optical flow algorithm include: (1) constructing an image pyramid to generate images of different scales; (2) applying the Lucas-Kanade optical flow algorithm to each scale of the image to obtain the motion vector of each pixel; (3) interpolating or superimposing the motion vectors of different scales to obtain the final motion field. By introducing the image pyramid, the algorithm can better adapt to the motion changes at different scales and improve the optical flow estimation effect in complex scenes. This is very useful for dealing with situations with large motion or images containing multi-scale structures.
[0160] S104: Calculate the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation;
[0161] 5. Active motion recognition
[0162] In one embodiment, the difference between the contour sequence and the predicted passive motion contour sequence is calculated, that is, the contour sequence I(t) at time t and the passive motion offset prediction at time t are calculated. The difference is used to obtain the contour map after passive motion offset, and the contour map after passive motion offset is used for subsequent behavioral detection to eliminate the erroneous distinction caused by inertial motion.
[0163] S105: Performing behavior detection based on the contour image sequence after the passive motion is offset to obtain a behavior sequence.
[0164] In one embodiment, the behavior sequence is divided into time windows according to a preset time granularity, and whether the state of the time window is active motion is judged based on the ratio of the number of frames in the motion state sequence within the time window that is greater than a threshold to the total number of frames in the time window. The judgment is performed on all time windows to obtain the behavior sequence of the set time granularity.
[0165] In one embodiment, the motion state sequence is subjected to data processing to obtain a processed sequence, the processed sequence is divided into time windows according to a preset time granularity, and the judgment is performed on all time windows to obtain a behavior sequence of the set time granularity, wherein the data processing includes one or more of the following: floating point conversion, Gaussian smoothing.
[0166] In one embodiment, the behavior detection uses an image frame difference method to determine the behavior of the animal, and the image frame difference method determines the behavior of the animal based on an area threshold of a differential image between adjacent frame images; preferably, the image frame difference method binarizes the differential image between two adjacent frame images based on a threshold to obtain a binarized image, and determines the behavior of the animal based on the area threshold of the binarized image.
[0167] In one embodiment, when the animal is actively moving, even after the passive motion offset process, there is still a large difference between two adjacent frames. This is because after the mouse struggles violently, the body stops moving, but due to the inertial swing caused by the violent struggle, the amplitude is still large. Although the mouse is in a passive motion state at this time, its differential image area may still exceed the area threshold, resulting in misidentification and affecting the final experimental results. Based on this fact, the intersection contour map sequence is calculated based on the neighborhood of the contour map sequence after passive motion offset, and behavior detection is performed based on the intersection contour map sequence.
[0168] In one embodiment, a three-frame method is used to perform inter-frame difference, and the current frame contour I(t) is predicted by the passive motion offset of the previous frame. Difference; the next frame contour I(t+1) and the current frame passive motion offset prediction Difference. The binary image D is obtained by judging whether the absolute value of the difference is greater than the threshold td. t and D t+1 , and the intersection is obtained by AND operation The resulting binary image The morphological operations of dilation and erosion are used to remove noise and obtain more accurate animal motion contours. Set the active motion recognition threshold ta, when When the number of pixels of is not less than ta, it is determined that the animal is in active motion at that frame. Calculate whether each recognition area (each animal) in the video is in active motion in each frame. Save the motion state of each frame and The number of pixels.
[0169] In one embodiment, the motion state of each frame is saved and The number of pixels is smoothed and counted in time windows, and the sensitivity of recognition can be adjusted by changing the active motion recognition threshold ta.
[0170] 6. Windowed smoothing statistics
[0171] In one embodiment, the binary sequence of the motion state of each animal is converted into a floating point sequence and then Gaussian smoothing is used to obtain a sequence a s , and use the threshold tg to determine the binary state of each frame If all frames in the time window The ratio is greater than the threshold t r , then the state of the time window is determined to be active movement, otherwise it is determined to be no active movement. After judging the movement state of all animals and all time windows, a behavior sequence with fine time granularity is obtained. The granularity depends on the width and step size of the preset time window.
[0172] Figure 2is a schematic flow chart of a behavior detection system for experimental animals provided by an embodiment of the present invention;
[0173] A behavior detection construction system for experimental animals, comprising:
[0174] Acquisition module 201: Acquisition of video of experimental animals;
[0175] Contour recognition module 202: used for performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0176] Passive motion prediction module 203: used for predicting each frame of the contour image sequence based on the relative invariance of the contour of the experimental animal in the passive motion state to obtain a predicted passive motion contour image sequence;
[0177] Passive motion cancellation module 204: used for calculating the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation;
[0178] The behavior detection module 205 is used to perform behavior detection based on the contour image sequence after the passive motion is offset to obtain a behavior sequence.
[0179] Figure 3 is a schematic flow chart of a method for analyzing the cognitive mechanism of experimental animal behavior provided by an embodiment of the present invention;
[0180] A method for analyzing the cognitive mechanism of experimental animal behavior, characterized in that the method comprises:
[0181] Acquiring a behavior sequence of an experimental animal, and obtaining the behavior sequence of the experimental animal according to the behavior detection method of the experimental animal;
[0182] splicing the behavior sequences of the experimental animals in different experimental animal groups respectively to obtain group behavior sequences of different experimental animal groups;
[0183] Using Bayesian modeling method to fit the group behavior sequence to obtain a model and parameters;
[0184] The cognitive mechanism of the experimental animal group is analyzed based on the model and parameters.
[0185] In one embodiment, the behavior sequence of experimental animals or the behavior sequence of a set time granularity is obtained, the sequences of animals in different groups are spliced and integrated according to the experimental design, and the animal behavior state sequence is fitted using reinforcement learning models such as the RW model, the counterfactual model, and the physical strength model. The fitting results of different models are compared, and the model with the smallest WAIC is selected as the winning model. The reliability of the model is verified through a posterior prediction test, and finally the model is analyzed to obtain the cognitive characteristics output of the animal.
[0186] 7. Sequence splicing
[0187] In one embodiment, the behavior sequences of all animals in each group are concatenated according to the experimental animals being grouped. Assuming that there are N animals in a group and the length of the behavior sequence of each animal is T, the size of the concatenated behavior matrix used for model fitting is N×T.
[0188] 8. Reinforcement Learning Model Fitting
[0189] Based on the hierarchical Bayesian modeling method, three reinforcement learning models, including the Rescorla-Wagner (RW) model, the counterfactual model, and the physical model, were used to fit the behavioral data.
[0190] The RW model is as follows:
[0191]
[0192] Vt+1=V t +αδ
[0193] δ=R t -V t
[0194] in is the probability that the animal swims in the forced swimming task or struggles in the tail suspension task, τ is the inverse of the temperature, V is the value corresponding to swimming and struggling, α is the learning rate, δ is the prediction error, and R is the reward or punishment experienced by the animal. This model assumes that the value of the animal being immobile in the forced swimming task or the tail suspension task is always 0.
[0195] The counterfactual model is as follows:
[0196]
[0197]
[0198]
[0199]
[0200]
[0201] in and are the values corresponding to swimming / struggling and standing still, V c and V nc are the values corresponding to the behaviors that are consistent with and inconsistent with the current behavior (e.g., if the animal's motion state is swimming / struggling at the current moment, then V c V a , then V nc Vi ; On the contrary, if the current motion state is static, then V c V i , then V nc V a ), δ and δ nc are the prediction errors corresponding to the behaviors that are consistent and inconsistent with the current behavior, respectively.
[0202] Consider the following physical model:
[0203]
[0204] V t+1 =V t +αδ
[0205] δ=R t -V t
[0206] S t =tanh(β(a tot -i tot ))
[0207] The model assumes that the animal's movement state is affected by both value and physical factors. t is the animal's physical state, γ is the physical influence coefficient, β is the physical renewal coefficient, a tot and i tot They are the total number of times the animal has swam, struggled, and remained stationary so far.
[0208] 9. Model comparison
[0209] WAIC is calculated based on the fitting results of the model and is defined as follows:
[0210] WAIC=-2lppd+2p waic
[0211]
[0212]
[0213] Where y is the sample observation, θ is the parameter, i represents each sample, and s represents the posterior simulation. The model with the smallest WAIC is selected as the winning model.
[0214] 10. Posterior Predictive Test
[0215] The winning model was used to generate predictions of animal behavior, and the model was considered valid if the actual experimental observations were within the 95% posterior credible interval of the model predictions.
[0216] 11. Export animal cognitive characteristics
[0217] The winning model and its parameters are output to obtain an analysis of the cognitive computing mechanism behind the development process of animal movement state.
[0218] Figure 4 is a schematic flow chart of a cognitive mechanism analysis system for experimental animal behavior provided by an embodiment of the present invention;
[0219] A cognitive mechanism analysis system for experimental animal behavior, comprising:
[0220] Acquisition module: obtain videos of experimental animals;
[0221] Contour recognition module: used for performing contour recognition on the video of the experimental animal to obtain a contour image sequence;
[0222] Passive motion prediction module: used for predicting each frame of the contour image sequence based on the relative invariance of the contour of the experimental animal in the passive motion state to obtain a predicted passive motion contour image sequence;
[0223] Passive motion cancellation module: used for calculating the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation;
[0224] Behavior detection module: used for performing behavior detection based on the contour image sequence after the passive motion is offset to obtain a behavior sequence;
[0225] Group behavior splicing module: used for splicing the behavior sequences of the experimental animals in different experimental animal groups to obtain group behavior sequences of different experimental animal groups;
[0226] Bayesian modeling module: used to fit the group behavior sequence using the Bayesian modeling method to obtain a model and parameters;
[0227] Cognitive mechanism analysis module: used to analyze the cognitive mechanism of the experimental animal group based on the model and parameters.
[0228] Figure 5 The present invention is a schematic block diagram of a behavior detection device for experimental animals provided in an embodiment of the present invention.
[0229] A behavior detection device for experimental animals, comprising: a memory and a processor;
[0230] The memory is used to store program instructions;
[0231] The processor is used to call program instructions, and when the program instructions are executed, the steps of the experimental animal behavior detection method or any one of the steps of the experimental animal behavior cognitive mechanism analysis method are implemented.
[0232] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the experimental animal behavior detection method or any one of the steps of the experimental animal behavior cognitive mechanism analysis method.
[0233] The validation results of this validation example show that assigning intrinsic weights to indications can moderately improve the performance of the method relative to the default setting.
[0234] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0235] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0236] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0237] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0238] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0239] A person skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc.
[0240] The above is a detailed introduction to a computer device provided by the present invention. For a person skilled in the art, according to the concept of the embodiments of the present invention, there may be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for detecting the behavior of experimental animals, characterized in that: The method comprises: Obtain videos of experimental animals; Performing contour recognition on the video of the experimental animal to obtain a contour image sequence; Based on the relative invariance of the contour of the experimental animal in the passive motion state, each frame of the contour image sequence is predicted to obtain a predicted passive motion contour image sequence; Calculating the difference between the contour map sequence and the predicted passive motion contour map sequence to obtain the contour map sequence after passive motion cancellation; An intersection contour map sequence is obtained by neighborhood calculation based on the contour map sequence after passive motion offset, and a behavior sequence is obtained by behavior detection based on the intersection contour map sequence; the behavior detection uses an image frame difference method to judge the behavior of the animal, and the image frame difference method judges the behavior of the animal according to the area threshold of the difference image of adjacent frame images.
2. The method for detecting the behavior of experimental animals according to claim 1, characterized in that: The relative invariance is the relative invariance of contour corner points and / or the relative invariance of contour moments.
3. The method for detecting the behavior of experimental animals according to claim 2, characterized in that: The step of obtaining a predicted passive motion contour map sequence based on the relative invariance prediction of the contour corner points includes: performing corner point detection on each frame contour map of the contour map sequence to obtain corner point P0, calculating the passive motion corner point P1 corresponding to the corner point P0 in the next frame contour map, using affine transformation to predict the predicted passive motion corner point P′1 corresponding to P0 in the next frame contour map, minimizing the distance between the passive motion corner point P1 and the predicted passive motion corner point P′1 to obtain the affine transformation, and applying the affine transformation to each frame contour map of the contour map sequence in turn to obtain the predicted passive motion contour map sequence.
4. The method for detecting the behavior of experimental animals according to claim 3, characterized in that: The optical flow method is used to calculate the passive motion corner point P1 corresponding to the corner point P0 in the next frame contour image.
5. The method for detecting the behavior of experimental animals according to claim 4, characterized in that: The optical flow method includes one or more of the following: Lucas-Kanade method, Horn-Schunck method, Farneback method, pyramid Lucas-Kanade optical flow algorithm, and optical flow algorithm based on deep learning.
6. The method for detecting the behavior of experimental animals according to claim 5, characterized in that: The pyramid Lucas-Kanade optical flow algorithm is used to identify the corner point P1 and convert the contour map into 2 s The scale is scaled to different levels, and the optical flow V is first calculated at the smallest scale level s , and the optical flow V s Calculate the optical flow V as the initial value of the previous scale s-1 , iterate in sequence until the maximum scale optical flow V is calculated 0 .
7. The method for detecting the behavior of experimental animals according to claim 6, characterized in that: The calculation method of optical flow is as follows: Among them, V represents optical flow, I x with I y are the grayscale gradients of the image in the x and y directions, I t is the gradient of the image grayscale changing with time, and n×n represents the size of the local image area for solving the gradient.
8. The method for detecting the behavior of experimental animals according to claim 3, characterized in that: The method used for the corner detection includes one or more of the following: Harris corner detection, Shi-Tomasi corner detection, FAST corner detection, ORB corner detection, GFTT corner detection, and Moravec corner detection.
9. The method for detecting the behavior of experimental animals according to claim 8, characterized in that: Harris corner detection is used to perform the corner detection. The window is slid in the x and y directions of the image to calculate the grayscale change of the image in the window. For the window at each position, the corner response function is calculated and the response function threshold is set. For the pixel points whose corner response function is greater than the response function threshold, non-maximum suppression is used to filter the local optimal corner points, and the filtered corner points are included in the corner point P0.
10. The method for detecting the behavior of experimental animals according to claim 9, characterized in that: The calculation formula of the corner point response function is as follows: R=det(M)-k(trace(M)) 2 Where R represents the corner response function, det(M) is the determinant of the covariance matrix M, trace(M) is the trace of the covariance matrix M, k is a constant, and the calculation of the covariance matrix M is based on the gradient information of the local area of the image. The gradients in the x and y directions are I x and I y , then the covariance matrix M is defined as follows: Among them, w(x,y) is the weight of the pixel in the window, I x with I y are the grayscale gradients of the window image in the x and y directions respectively.
11. The method for detecting the behavior of experimental animals according to claim 10, characterized in that: The intersection contour map is obtained by using a three-frame method, wherein the steps of the three-frame method include: calculating the contour map I(t) of the current frame in the contour map sequence and the predicted passive motion contour map of the corresponding frame in the predicted passive motion contour map sequence; The first differential image is obtained by performing the difference between the first differential image and the second differential image, and the contour image I(t+1) of the next frame in the contour image sequence and the predicted passive motion contour image of the corresponding frame in the predicted passive motion contour image sequence are calculated. The second differential image is obtained by performing an AND operation on the first differential image and the second differential image to obtain an intersection contour map of the three-frame method, and the intersection contour map of each frame is calculated in turn to form the intersection contour map sequence.
12. The method for detecting the behavior of experimental animals according to claim 11, characterized in that: The first differential image is binarized to obtain a first binary image, the second differential image is binarized to obtain a second binary image, and the first binary image and the second binary image are ANDed to obtain an intersection contour map of the three-frame method, and the intersection contour map of each frame is calculated in turn to form the intersection contour map sequence.
13. The method for detecting the behavior of experimental animals according to claim 1, characterized in that: The image frame difference method binarizes the difference image of adjacent frame images according to a threshold value to obtain a binarized image, and judges the behavior of the animal according to the area threshold value of the binarized image.
14. The method for detecting the behavior of experimental animals according to claim 13, characterized in that: The binary image is subjected to morphological processing before behavior detection, wherein the morphological processing includes one or more of the following: dilation, erosion, opening operation, and closing operation.
15. The method for detecting the behavior of experimental animals according to claim 1, characterized in that: The contour recognition is performed after the video of the experimental animal is preprocessed, and the preprocessing includes one or more of the following: camera calibration, recognition area selection, and recognition area standardization.
16. The method for detecting the behavior of experimental animals according to claim 15, characterized in that: The behavior sequence is divided into time windows according to a preset time granularity, and whether the state of the time window is active motion is judged based on the ratio of the number of frames of the motion state sequence in the time window that is greater than a threshold to the total number of frames in the time window. The judgment is performed on all time windows to obtain the behavior sequence of the set time granularity.
17. The method for detecting the behavior of experimental animals according to claim 16, characterized in that: The motion state sequence is subjected to data processing to obtain a processed sequence, the processed sequence is divided into time windows according to a preset time granularity, and the judgment is performed on all time windows to obtain a behavior sequence of the set time granularity, wherein the data processing includes one or more of the following: floating point conversion, Gaussian smoothing.
18. A method for analyzing the cognitive mechanism of experimental animal behavior, characterized in that: The method comprises: Acquiring a behavior sequence of an experimental animal, according to claims 1-17; splicing the behavior sequences of the experimental animals in different experimental animal groups respectively to obtain group behavior sequences of different experimental animal groups; Using Bayesian modeling method to fit the group behavior sequence to obtain a model and parameters; The cognitive mechanism of the experimental animal group is analyzed based on the model and parameters.
19. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 18, characterized in that: The Bayesian modeling method includes one or more of the following: Rescorla-Wagner model, counterfactual model, and physical strength model.
20. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 19, characterized in that: The Rescorla-Wagner model is used to fit the group behavior sequence. The Rescorla-Wagner model is as follows: In t+1 =V t +aδ δ=R t -V t in, is the probability of active movement of the experimental animal, τ is the inverse of temperature, V is the value corresponding to active movement, a is the learning rate, δ is the prediction error, and R is the reward or punishment experienced by the animal.
21. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 19, characterized in that: The group behavior sequence is fitted using a counterfactual model, which is as follows: in and are the values corresponding to active movement and passive movement, V c and V nc are the values corresponding to the behaviors that are consistent with and inconsistent with the current behavior, δ and δ respectively. nc are the prediction errors corresponding to the behaviors that are consistent and inconsistent with the current behavior, respectively.
22. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 19, characterized in that: The group behavior sequence is fitted using a physical force model, which is as follows: In t+1 =V t +aδ δ=R t -V t S t =tanh(β(a tot -i tot )) Where S t is the animal's physical state, γ is the physical influence coefficient, β is the physical renewal coefficient, a tot and i tot They are the total number of active movements and the total number of passive movements of the animal so far.
23. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 19, characterized in that: A winning model is selected by model comparison, and the cognitive mechanism of the experimental animal group is analyzed based on the winning model and the parameters of the winning model.
24. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 23, characterized in that: The winning model is used to generate a predicted animal behavior sequence. If the animal behavior sequence obtained from the actual experiment is within the posterior credible interval of the predicted animal behavior sequence, the model is determined to be valid.
25. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 23, characterized in that: Model comparison is performed using information criteria, including one or more of the following: AIC, BIC, DIC, MDL, WAIC.
26. The method for analyzing the cognitive mechanism of experimental animal behavior according to claim 25, characterized in that: Use WAIC to compare models and select the model with the smallest WAIC as the winning model. WAIC is calculated as follows: WAIC=-2lppd+2p waic Where y is the sample observation value, θ is the parameter, and i represents each sample.
27. A system, characterized in that: The system includes a computer program, which, when executed by a processor, implements the steps of the method for detecting the behavior of experimental animals described in any one of claims 1 to 17 or the steps of the method for analyzing the cognitive mechanism of the behavior of experimental animals described in any one of claims 18 to 26.
28. An apparatus comprising: Memory and processor; The memory is used to store program instructions; The processor is used to call program instructions, and when the program instructions are executed, the steps of the experimental animal behavior detection method described in any one of claims 1-17 or the steps of the experimental animal behavior cognitive mechanism analysis method described in any one of claims 18-26 are implemented.
29. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for detecting the behavior of experimental animals described in any one of claims 1 to 17 or the steps of the method for analyzing the cognitive mechanism of the behavior of experimental animals described in any one of claims 18 to 26 are implemented.
Citation Information
Cited By
Active motion identification method, device and system for experimental animal
CN119206863A
A method, apparatus and system for identifying voluntary movement of an experimental animal
CN119206863B
