1 Introduction

Ongoing research of image recognition allows for improvements in animal welfare compliant and increase in data yield in animal experiments. One application for improvements are the so-called rotational tests in animal models of Parkinson research. In these tests, the goal is to determine the amount of the clockwise and counter″​=clockwise rotations of the rats. The state-of-the-art of these rotational tests consists of the following four components, which can be seen in Fig. 5.1: (a) a bowl in which the rat rotates, (b) a breast belt, which is attached to the rat, and (c) a stiff wire, which connects the breast belt to (d) a rotation counter, which determines the amount of rotations.

Abb. 5.1
figure 1

The figure shows a rat in a test setup with a mounted breast belt

This setup has the following drawbacks:

  1. 1.

    Due to simplicity of the electronic device, the output of the rotary counters are only net numbers. At the end of the experiment, the examiner only knows how often the rat rotated clockwise and counter″​=clockwise. The system does not give any time-relevant information.

  2. 2.

    The system is not able to distinguish between rotations and any further movement, like standing up, rolling around or self-cleaning.

  3. 3.

    The breast belt may harm the movement of rat or manipulate its activity.

This paper introduces the Rat Rotation Detection System, or RRDS in short. This system is meant to replace the measurement setup of the rotary detectors. The RRDS works in four basic steps. (1) A camera records the rotation of the rat in the bucket. This video is passed onto a (2) Feature Detection, in this particular application a YoloV4″​=Network which identifies head, tail, and torso of the rat. For each frame, the output of the network are two-dimensional coordinates of the detected features. (3) With these coordinates of the head, the tail and the torso, the system generates two angles. (4) With the changes of these angles over time (frame by frame), the system determines the rotation of the rat. Sect. 5.4 describes the system in more detail.

RRDS was evaluated in a real-world experiment with laboratory animals. In the scope of the experiments, RRDS was compared with the state-of-the-art breast belt system. The laboratory setup is described in Sect. 5.5.

The results, as further described in Sect. 5.6, show that RRDS generates similar results as the breast belt system with a difference of 7.6 % for rats medicated with amphetamine, and 16.7 % for rats medicated with apomorphine. The deviation occurs because of the measuring setup as further described in Sect. 5.7, RRDS is a contribution to more animal welfare and an improvement of the grain of detail in experiments with laboratory animals.

2 Rotational Test in Parkinson Research

In Parkinson research, rats serve as experiment animals and models for this human disease. To generate Parkinson-like symptoms in rats, the animals underlay a surgery which destroys the dopamine″​=producing part of their brain (the substantia nigra pars compacta). In order to identify whether the surgery was successful or not, the rats undergo a so called rotation test. In this test, the rat gets an injection of either amphetamine or apomorphin. In the case of amphetamine and a successful surgery, the rats rotate clockwise. The application of apomorphin causes the rat to turn counterclockwise. The mean rotation speed within a defined period of time indicate the surgery’s success. The state-of-the-art measurement setup for the rotational test is based upon the Brest belt system as described in Sect. 5.1. [1]

Short Comings of the Breast Belt System: Although the term about rotations can be found in works concerning this topic, the solution based on the breast belt and the rotary detectors mainly detect the movement of the upper body of the rat. If a rat moves its upper body, the rotary detector counts the movement of the wire as a rotation, even though the rat did not rotate at all. This may happen through extensive self-cleaning of the rat. Therefore, the conversion of the numbers presented by the rotary detectors into rotations seems to be problematic. In addition, the system does not present any time″​=dependent information about the rotations. In the end, only the numbers of clockwise rotations and of the counterclockwise rotations is known. For research on the medications, a further knowledge about the characteristics of the rotations is valuable, e.g., changes in rotation speed during the test or even brief changes in direction. These parameters can not be detected by the Brest belt system as it is. In addition, the breast-belt may inhibit the movement of the rat.

Previous Work: Mouse-Pi The system Mouse-Pi, stated in [2], tried to enhance the experiments with a video based approach as well. It mainly consists of a Raspberry Pi connected to a camera. In contrast to RRDS, the rats were marked with coloured blobs. The Raspberry Pi tried to detect the coordinates of the blobs. Out of these coordinates, it calculated the rotation of the rat. Although the system showed good results in basic testing with blobs on a sheet of paper, it failed in the field. The reasons for that are stated as: (1) The texture of the rats fur does not allow for a sufficiently homogenous coloring. (2) Solid blobs cannot be applied, because the rat may try to remove them from their body. This may harm their behaviour which would invalidate any experiment. (3) The blobs are not visible for the Raspberry Pi all the time through the experiment because of the movement of the rat.

Fig. 5.2 shows different moving behaviours of the rats, including standing, rolling and self-cleaning. In addition, the rats sometimes tend to duck the head or the tail.

Abb. 5.2
figure 2

The Figure shows different movements of the rat: (a) standing, (b) rolling, (c) a rat with ducked head and tail, (d) a rat which sits on its tail.

3 Similar Approaches

The idea behind an automated position estimation of laboratory animals is already discussed in various literature. Recent studies involve the detection of limbs and pose estimations of mice [3] or pigs [4] using an Opensource″​=Software DeepLabCut [5].

4 The Rat Rotation Detection System (RRDS)

This Section presents RRDS, an improved approach of refining the rotational test. Fig. 5.3 illustrates the general setup of RRDS which consists of the following components:

Abb. 5.3
figure 3

The Figure illustrates some parts of the working principle of RRDS, which involves the following steps: (a) a video camera records the rat from above. (b) A neural network detects certain features: head, tail, and torso of the rat. (c) Out of these features, the system calculates two vectors: \(\vec{r}\) from head to torso and \(\vec{q}\) tail to torso. (d) With the change of the angles between the vectors and a help vector \(\smash{\vec{h}}\), the system concludes of the rotation of the rat.

Video Camera: A video camera is monitoring the rat in its bucket. For the application at hand, a Raspberry Pi video camera with a decent resolution of 1280 × 720 pixels at 25 frames per second (fps) is entirely sufficient.

Feature Extraction by a Neural Network: The first processing stage consists of the well known anchor-box based neural network YoloV4 [6]. Though in comparison with other CNN-based networks, e.g., RetinaNet [7], the YoloV4″​=network achieves a better performance in the COCO-dataset [8]. In the scope of this application, the accuracy of the Yolo-network should be more than sufficient. Furthermore, the YoloV4″​=network achieves faster processing (20 fps faster). The task of the network is to extract bounding boxes of the following features of the rat: (1) the head, (2) the tail and (3) the torso. For this purpose, the network analyzes the video of the rat frame by frame. Though the output of the network are bounding boxes which include the (x , y) coordinates and the width and height of the detected object. For calculating the rotation of the rat, the relevant part are the following coordinates:

$$\begin{aligned}P_{\text{head}} & =(x_{\text{head}},y_{\text{head}})\end{aligned}$$
$$\begin{aligned}P_{\text{tail}} & =(x_{\text{tail}},y_{\text{tail}})\end{aligned}$$
$$\begin{aligned}P_{\text{torso}} & =(x_{\text{torso}},y_{\text{torso}})\end{aligned}$$

Angle Calculation: the second processing stage takes the feature’s coordinates and constructs the two vectors \(\vec{r}=(r_{x},r_{y})^{\mathrm{T}}\) and \(\vec{q}=(q_{x},q_{y})^{\mathrm{T}}\) out of them:

$$\begin{aligned}\vec{r} & =P_{\text{torso}}-P_{\text{head}}\end{aligned}$$
$$\begin{aligned}\vec{q} & =P_{\text{torso}}-P_{\text{tail}}\end{aligned}$$

In order to detect changes in the position of the rat, e.g., through rotation, the system calculates the angles α and β between the vectors \(\vec{r}\), \(\vec{q}\) and a third, constant vector \(\vec{h}\). In general, the angle between two vectors \(\vec{r}\) and \(\vec{h}\) is calculated in the following way:

$$\begin{aligned}\cos(\alpha)=\frac{\vec{r}\cdot\vec{h}}{|\vec{r}|\times|\vec{h}|}\end{aligned}$$
(5.1)

Through setting the vector \(\vec{h}\) to \(\vec{h}=(1,0)^{\mathrm{T}}\), the equations simplifies to:

$$\begin{aligned}\alpha=\operatorname{acos}\left(\frac{r_{x}}{\sqrt{r_{x}^{2}+r_{y}^{2}}}\right)\end{aligned}$$
(5.2)
$$\begin{aligned}\beta=\operatorname{acos}\left(\frac{q_{x}}{\sqrt{q_{x}^{2}+q_{y}^{2}}}\right)\end{aligned}$$
(5.3)

Calculating the Rotation: The calculated angles αt and βt of the analyzed frame at the time t are subtracted from the angles of the previous frame: \(\Updelta\alpha=\alpha_{t}-\alpha_{t-1}\) and \(\Updelta\beta=\beta_{t}-\beta_{t-1}\). Both angles are summed up from frame to frame to αs =  ∑ Δαf and βs =  ∑ Δβf. If both of these sums are greater than a specified angle-accuracy, e.g., θ = 6 deg, the clockwise″​=rotational counter Cc is increased and the sums are reduced by the angle-accuracy: αs = as − θ, βs = βs − θ. If both of the sums are smaller than the negative angle-accuracy, the counter″​=clockwise″​=rotational counter Ccc is increased and the sums are increased by the angle-accuracy: αs = αs + θ, βs = βs + θ. This approach imitates the working principle of the rotational counters. In addition, the changes of the values of the counters Cc and Ccc are used to calculated the rotating speed of the animal in [deg s−1].

5 Prototypical Experiment with RRDS

This section describes the experimental setup in terms of the procedure of the rotational test as well as the measuring setup of the prototypical RRDS. The laboratory environment allows a measurement of four rats simultaneous. Therefore, four instances of RRDS camera systems took videos of the rats. In total, the examination included 18 rats which were treated with both medications on different days as mentioned in Sect. 5.2. Some of the videos were not recorded properly, which results in a total of 15 videos of rats treated amphetamine and 16 videos of rats treated with apomorphine.

Procedure of Rotational Test As seen in Fig. 5.4a, the experimental setup consists of four cylindrical buckets of approximately 30 cm in diameter. Inside of each bucket, a rat is rotating with a breast belt, as seen in Fig. 5.1. which is connected to an electromechanical rotary detector. Each rat has to be medicated by the examiner before the experiment can start. After the medication, each rat is getting mounted with the breast belt which is connected to the rotary detector. After a short wake-up time, the examiner resets the rotary detector and starts the experiment, which lasts typically 40 min for apomorphine and 60 min for amphetamine. During the experiments, the experimental laboratory is illuminated with dimmed light.

Abb. 5.4
figure 4

(a) Experimental Setup of the medical research. (b) The Figure shows a camera of RRDS mounted next to the rotational counter

Prototypical RRDS in a Laboratory EnvironmentFig. 5.4b shows one instance of RRDS camera″​=system. The camera of this instance is mounted next to a rotational counter of the old measurement system. The mounting system is a special 3D printed holder. The camera″​=system contains a Raspberry Pi Camera V2.1 that is connected to a Raspberry Pi 3B+ (RPi). The RPi controls the camera in regard to starting, stopping and converting the video into h264″​=stream with 1280 × 720 px with 25 fps. In addition, the RPI transfers the video stream onto a mass storage device, which is connected over the USB 3.0 Port of the RPi. The RPis are controlled via Ethernet from a Laptop.

Feature Extraction After the RPi has stopped the recording of the videos, the data were transferred to an AI-capable computer with a NVIDIA RTX 2080TI GPU. The videos were analysed frame by frame with anchor-box based neural network YoloV4 utilized by the DarkNet″​=Framework [9]. The network was trained with roughly 30.000 labeled images in order to learn to detect the features (1) head, (2) tail and (3) torso. Though the torso is the easiest feature to detect, the task to detect the tail is quite complicated. In order to fit into the RAM of the GPU (11 GB), the input resolution of the network was set to 1024 × 672. The Batch-Size is set to 64 The initial learning rate was set to 0.01 × 10−3 in order to prevent a gradient explosion.

Resolution of Rotation″​=Detection: In order to compare both systems, the resolution for the rotation″​=detection of RRDS is set to 6 deg, which is equal to the resolution of the hardware of the rotary detector. However, smaller resolutions may generate more false detections of generations due to noise in the feature detection.

Limitations of the Experiment The comparison of both systems requires a simultaneous measurement with both systems of each rat. Therefore, the camera based system RRDS has to detect the features of the rat even though the visual field is impaired by the wire and the breast belt. The consequence of this is, that the training images taken to train the neural network are probably only suitable for this particular case. When using RRDS without the rotary detector, the neural network of the feature detection may need to train with new images.

6 Results of Experiments

This Section presents the results of the experiments described in Sect. 5.5. Though the reasons for different characteristics in the behaviour of the rats are quite interesting, the main focus lies on the evaluation of RRDS in comparison with the rotation encoder.

6.1 Rotation-Detection

The following tables (Table 5.1) present the difference D = Cc − Ccc between the clockwise and counter″​=clockwise counters (Cc and Ccc) of the Brest belt system and the new RRDS.

Tab. 5.1 The table presents the difference between the net numbers given by the rotation encoder DBB for rats rotating medicated with amphetamine (a) and apomorphine (b) as well as the difference between the counters measured by RRDS DRRDS. The average deviation results in 7.5% for amphetamine and 16.7 % for apomorphine.

Detection of Head, Torso and Tail In sum, the network was not able to detect the features in the following amount of frames:

  • Ehead 69 434

  • Etail 114 330

  • Etorso 13 138

6.2 Rotation over Time

Fig. 5.5 shows the rotation over time of two different rats medicated with Amphetamine (Fig. 5.5b, d) and apomorphine (Fig. 5.5a, c). Both rats show different rotating characteristic, rotating clockwise and counter″​=clockwise. As Fig. 5.5d shows a more or less linear increase of both directions of rotation, the Fig. 5.5b shows a greater increase in the clockwise rotation.

Abb. 5.5
figure 5

The Figure shows the summarized changes over time of two rats medicated with apomorphine ((a) and (c)) and amphetamine ((b) and (d)). It shows, that different rats do not show the same response to the medication.

7 Discussion and Conclusion

Rotation Numbers: The experiment has shown that RRDS is able to detect similar numbers of rotation as the rotary detector with the breast belt. The results presented in Table 5.1 shows an average deviation of 7.6 % for the rats treated with amphetamine and 16.7 % for the rats treated with apomorphine. The average deviation of all rats is 12.1 %. Though the deviation seems to be large, it is neglectable. The reason for this is that the ratio between the difference of rotation and the sum of the rotations is quite small.

The main reason for the deviation lies in the detection of the head, tail, and torso. The neural network of RRDS is easily trainable to detect the features on a calm rat, as seen in Fig. 5.1. However, the difficulties in detection occur when the rat rotates with the head ducked and the tail under its body (as seen in Fig. 5.2c) or close to the side of its body. In addition, fast movements of the rat can result in blurred images (Fig. 5.6a), which are harder to detect for the neural network. In addition, the positioning of the camera was not optimal. Some of the rats tend to stand up and move their heads out of the scope of the camera as Fig. 5.6b shows. In addition, the wire of the breast belt and the rotary detector blocked a part of the vision of the camera onto the rat (Fig. 5.6c). This leads to more not-detectable frames in the video and furthermore to not-detectable rotations.

Abb. 5.6
figure 6

The Figure shows different different situations in the videos, which lead to the deviation between the RRDS and the Brest belt system. (a) shows a blurred image, which can occur when the rat is moving fast. (b) shows a standing rat with its head out of the vision of the camera. (c) shows a frame of the video with a blocked view on the head of a rat.

Rotation Over Time:Fig. 5.5 shows, that two rats show a different rotating characteristic even though both were medicated in the same way. These rotating characteristic will be addressed in future Parkinson research.

Drawbacks of RRDS: A drawback of RRDS lies in the overall energy consumption and hardware prerequisite. Due to the usage of the neural″​=network on a state-of-the-art GPU, the energy consumption can easily reach up to 250 W, which is significantly higher than the consumption of the rotary detectors. In contrast, it delivers far more information about the rats than the rotary detectors.

Future Work: Based on the problems described above, future work will have the following goals:

  1. 1.

    In order to decrease the energy consumption, the feature detection of RRDS could be replaced by a smaller neural network or a more energy″​=efficient algorithm.

  2. 2.

    RRDS is able to generate more data from the experiments. Future Parkinson research will address these information which may lead to a better understanding of the disease.

  3. 3.

    Testing the accuracy of other networks, e.g., DeepLabCut, with the generated training data.

  4. 4.

    Adapting the network in order to generate a behaviour profile of the rat, including standing, rolling and self-cleaning.

  5. 5.

    Though the state of RRDS is more or less prototypical, the examiner needs fundamental knowledge about the workflow inside the system. Future work will target the automatization of the working processes, with the aim of a user friendly system.

In conclusion, RRDS is a step to more animal welfare and more accurate results in animal experimentations.