Estimating genetics of body dimensions and activity levels in pigs using automated pose estimation | Scientific Reports – Nature.com

Posted: September 14, 2022 at 1:04 am

Ethics statement

All experimental procedures were approved by the Animal Ethics Committee of KU Leuven (P004/2020), in accordance with European Community Council Directive 86/609/EEC, the ARRIVE guidelines and the ILAR Guide to the Care and Use of Experimental Animals. Researchers obtained informed consent for publication from all identifiable persons to display and reuse videos.

The study was carried out on 794 female and 746 castrated male Pitrain x PIC Camborough pigs (Vlaamse Pitrain Fokkerij, Belgium; offspring from 73 different sires and 204 dams), which had a mean age of 83.4 (2.2) days and a mean weight of 30.6 (5.1) kg at the start of the experiment. Observations were made during the fattening period which could span up to 120days and ended when pigs reached a body weight of approximately 115kg. Per sire, a median of 26 crossbred piglets (full-sibs and half-sibs from the same Pitrain sire) were allocated in equal numbers to two identical pens in mixed-sex groups. The pig building (experimental farm, located in Belgium) consisted of seventeen identical compartments with eight semi-slatted pens (2.5m4.0m) per compartment and on average thirteen pigs per pen (0.77m2 per pig). Food and water were provided ad-libitum in each pen throughout, from one trough and one nipple drinker.

Pigs were weighed individually over their fattening period every two weeks from January to July 2021. Pen-by-pen, all individuals were driven to the stables central hallway, after which pigs were weighed sequentially. Weighing was carried out between 08:00 a.m. and 16:00 p.m. and was video-recorded. All piglets were weighed for the first at thirteen days after arrival at the fattening farm. For practical limitations, only one out of two pens per sire was hereafter selected for subsequent follow-up. All 1556 pigs were weighed up to eight times, resulting in a total of 7428 records.

Additionally, each pig was scored manually during weighing on the following physical abnormalities: ear swellings or hematomas (0=none, 1=one ear, 2=both ears); the presence and size of umbilical hernia (0=not present, 1=present); ear biting wounds (0=none, 1=one ear, 2=both ears) and tail biting wounds (0=none, 1=small scratches, 3=bloody and/or infected tail; Additional File 1). All recordings were collected by the same trained professional. Lean meat percentage was recorded individually at the slaughterhouse of the Belgian Pork Group in Meer (Belgium) using AutoFom III (Frontmatec, Smoerum A/S, Denmark)31. Feed intake was measured at the pen level.

The walk-through pig weighing setup consisted of a ground scale weighing platform, a radio frequency identification (RFID) reader, a video camera and a computer (Fig.1). The ground scale platform (3.4m1.8m) had an accuracy of0.5kg (T.E.L.L. EAG80, Vreden, Germany) and was situated in the central hallway of the pig building. A wooden aisle helped pigs to walk individually and forward over the balance (2.5m0.6m; Fig.1a; Additional File 2Video S1). Body weights were registered electronically and coupled to the pigs ID using an RFID-reader and custom-made software. The camera (Dahua IPC-HDW4831EMP-ASE, Dahua Technology Co., Ltd, Hangzhou, China) was mounted 2.5m above floor at the center of the weighing scale. Pigs were recorded from an overhead camera perspective with a frame rate of 15 frames per second and a resolution of 38402160. An example of our data collection and a video recording is provided in Fig.1b.

Experimental setup (created with BioRender.com). (a) Schematic top view diagram of the experimental setup used in this study in the center hallway of the pig building. The blue area indicates the ground scale platform with a wooden aisle (in red). The red dashed lines indicate gates to regulate individual pig passage. (b) Schematic side view diagram of the experimental setup.

DeepLabCut 2.2b.827 was installed in an Anaconda environment with Python 3.7.7.30 on a custom-built computer running a Windows 10 64-bit operating system with Intel Core i5-vPro CPU processor (2.60GHz) and 8GB RAM memory. Training, evaluation and analysis of the neural network was performed using DeepLabCut in the Google Colaboratory (COLAB) (https://colab.research.google.com/).

To detect body parts on a pig that is walking through the experimental setup, a neural network was trained using DeepLabCut 2.2b27 as described in Nath et al.32. A minimalistic eight body part configuration (Fig.2a; Table 1) was necessary to estimate hip width, shoulder width and body length. Operational definitions can be found in Table 1. Head body parts (Nose, Ear left, and Ear right) were also labeled, but not included in our final structural model as these body parts were frequently occluded in consecutive frames.

(a) Schematic overview of the eight body positions annotated for pose configuration in DeepLabCut27 (created with BioRender.com). 1=Spine1; 2=Shoulder left; 3=shoulder right; 4=Center; 5=Spine2; 6=Hip left; 7=Hip right; 8=Tail base. (b) Example of a labeled pig during weighing using the DeepLabCut software.

Seven videos of approximately one hour recorded on two different days were selected to include variable pig sizes (20120kg) and each video contained multiple pig weighings. From these seven videos, several frames were extracted for annotation using k-means clustering in DeepLabCut. We first annotated 457 frames (~1 frame per pig) which were split into a training dataset (95%; 434 frames) and a test dataset (5%; 23 frames). The network was trained in Google Colaboratory using the ResNet-50 architecture with a batch size of 2. We trained our algorithm until the loss function reached an optimum, which indicated a minimal loss with a minimum number of iterations in this study. Next, we compared mean pixel errors of several models within this optimal region. Models with lowest mean pixel errors were visually checked for body part tracking performance on entire videos. Hereafter, the model that performed optimal was tested for flexibility using unseen single pig videos with pigs of variable size (20 vs 120kg) weighed on different days. As model performance was suboptimal at first, poorly tracked outlier frames were extracted using the DeepLabCut jump algorithm32. This algorithm identifies frames in which one or more body parts jumped more than a criterion value (in pixels) from the last frame32. These outlier frames were refined manually and hereafter added to the training dataset for re-training. In total, 150 outlier frames were extracted from six novel videos containing one single pig to improve tracking performance (25 frames per pig). The final training dataset consisted of 577 (95%) frames and a test dataset of 30 frames (5%). The network was then trained again using the same features as the first training. Additional File 3Video S2 shows an example of a pig with body part tracking.

After posture extractions of body parts using DeepLabCut, body dimension parameters were estimated. The raw dataset contained body part positions and tracking probabilities of 5,102,260 frames. Individual pig IDs were first coupled with video recordings based on time of measurement from the weight dataset. The following steps and analyses were performed in R33. Frames with a mean tracking probability<0.1 over all eight body parts were removed (2,792,252 frames left). This large reduction in number of frames (50% removed) was mainly caused by video frames without any pigs, for example in between weighing of different pens or in between weighings of pigs.

Next, for every weighing event, start and end points were determined to estimate body dimensions and activity traits. For a specific weighing event, a subset was first created containing all frames between the previous and next weighing event. The time of entrance and departure of the pig on the weighing scale was estimated using the x-position (in pixels) of the tail base, as the movement of pigs was predominantly along the x-axis (from right to left; Fig.2b). The frame of entrance was defined as the first frame of a subset where the rolling median (per 10 frames) of the tail base x-position exceeded 1100 pixels (Fig.3). Likewise, the first frame after a pigs weighing event with a rolling median tail base x-position<250 pixels was used to determine time of departure. If these criteria were not met, the first frame and/or the frame at which the weight record took place were used for the time of entrance/departure.

Determination of time window for a weight recording. (a) First, a subset is created as all tail base x-positions between time of recording of the next (orange) and previous (red) weight recording. The start time of the time window is determined as the first value before the own weight recording (green) above the threshold of 1100 pixels (dashed purple line; pig entering weighing scale). The end time of the time window is determined as the first value after the own weight recording (green) below the threshold of 250 pixels (dashed purple line; pig leaving weighing scale). (b) The extracted time window on which body part dimensions will be estimated and trajectory analysis will be performed.

Hip width, shoulder width and body length of a pig were estimated by using the median value of the distance between certain body parts over all frames for a specific weight recording (Table 1, Fig.2). These body dimensions in pixels, were transformed to metrics as 1cm was calculated to be equivalent to 29.1 pixels. The conversion ratio from pixels to centimeters was based on the distance between tiles of the weighing scale, which was known to be exactly 50cm. Total surface area was estimated using the mean value of the area calculated with the st_area function in R from the R-package sf34 using all outer body part locations. Standard deviations of the body part positions were also calculated for all frames between entrance and departure after quality control (as described above), to assess the stability of estimates.

Trajectory analysis was performed using the R-package trajr35 for left and right shoulder, left and right hip and the tail base. For each body part, pixel coordinates were extracted, trajectories were rescaled from pixels to cm and a smoothed trajectory was created using the TrajSmoothSG function. From these smoothed trajectories, the following activity-related features were derived: mean and standard deviation of speed and acceleration (TrajDerivatives), a straightness index (TrajStraightness) and sinuosity (TrajSinuosity2).

The straightness index and sinuosity are related to the concept of tortuosity and associated with an animals orientation and searching behavior35,36. The straightness index is calculated as the Euclidean distance between the start and the endpoint divided by the total length of the movement36. The straightness index is an indication of how close the animals path was to a straight line connecting the start and final point and varies from 0 to 1. Thus it quantifies path efficiency whereas the closer to 1, the higher the efficiency. In our experiment, this path efficiency will be highest when a pigs walks in a straight line during weighing (straightness index=1). Any deviations from this straight linedue to an increased activity of the pig during weighingwill lower the straightness index towards zero. Sinuosity tries to estimate the tortuosity of a random research path by combining step length and the mean cosine of an animals turning angles35,36,37. The sinuosity of a trajectory varies between 0 (random movement) and 1 (directed movement).

In this study we hypothesize that mean speed, straightness index and sinuosity are related to pigs activity during weighing. In an extreme case, a pig will walk in a straight line towards the RFID reader, stand motionless until weight is recorded and continues its walk in a straight line after the gate is opened. This would result in a low mean speed (m/s), a sinuosity >0 and a straightness index of 1. We hypothesize that more active pigs will present more lateral movements, increasing the mean speed and lowering the straightness index and sinuosity. So generally, more calm pigs during weighing will display a lower mean speed, although they might have run with a high speed towards the RFID reader.

The estimations of body dimensions using video recordings analyzed with DeepLabCut were validated by an independent set of 60 pigs after the initial experiment. These pigs came from five pens of different ages (92166days) and were measured manually for tail-neck length and hip width using a simple measuring tape. Pig surface area was estimated for the manual recordings as the multiplication of tail-neck length and hip width. The manual estimates for tail-neck length, hip width and pig surface area were then compared to the estimates from the video analysis by calculating Pearson correlations and root mean squared error (RMSE).

Automated activity traits were validated by comparing these values with manual activity scores given by five trained observers. Video footage of 1748 pig weighings were manually scored for pig activity by at least two observers per pig on a scale from 1 (calm) to 5 (very active). This ordinal activity scale was constructed based on DEath et al. and Holl et al.17,24. The average activity score per pig was then compared with automated activity scores by calculating Pearson correlations.

After estimation of body dimension and activity traits, additional quality control was performed. First, estimates of hip and shoulder width, tail-neck length and pig surface area were set to missing for records with frame by frame standard deviation estimates higher than the mean+3 standard deviations for all records. The thresholds were 10.2cm for hip distance (132 records), 11.8cm for shoulder distance (135 records), 20.6cm for tail-neck length (121 records) and 0.058 m2 for pig surface area (96 records). If the standard deviation of the estimated hip widths over frames within one weighing event of a pig was>8.9cm, the record was set to missing.

Second, for every individual with at least four records (941 pigs, 6807 records), outliers were determined using a second order polynomial regression on the variable of interest in function of age in days. Based on the distribution of the difference between observed and predicted phenotypes for all animals, a threshold for exclusion (record set to missing) was set as three times the standard deviation of the differences. The thresholds were 2.1cm for hip distance (61 records), 2.2cm for shoulder distance (58 records), 6.4cm for tail-neck length (75 records), 0.021 m2 for pig surface area (85 records) and 3.7kg for weight (86 records).

The final dataset after data cleaning included 7428 records from 1556 finishing pigs descending from 73 Pitrain sires and 204 crossbred dams. Pedigree comprised 4089 animals, where the median pedigree depth of Pitrain sires was 15 generations (min 10; max 17) and 3 (min 0; max 6) for crossbred dams.

We estimated genetic parameters (heritability and genetic correlations) using the blupf90 suite of programs38. Genetic variances and heritabilities were estimated with average information REML, implemented in airemlf90 and invoked with the R-package breedR39 with the options EM-REML 20, "use_yams" and se_covar_function. Genetic parameters were first estimated on the full dataset and thereafter on subsets per pigs weight recording (1 to 8). The first weight recording, for example, corresponds with a dataset of 1176 pigs between 78 and 89days of age (Table 2). We estimated h2 as the proportion of additive genetic variance divided by total variance, whereas the common environmental effect (c2) was estimated as the proportion of variance explained by random environmental effects (c), divided by total variance.

Genetic correlations (rg) between traits were estimated using bivariate animal models (airemlf90). Genetic correlations were first calculated between all possible trait combinations using the full dataset. Hereafter, the genetic correlations within traits for all pairwise weighing events were estimated (so two recordings of the same trait were treated as two different traits). By doing this, we can evaluate if a trait genetically changes over time.

The estimated animal models were of the form:

where y is the vector with phenotypes for the studied trait(s); b is the vector containing the fixed effects (sex, 2 levels; parity of dam, 4 levels) and covariates (age); a is the vector of additive genetic effects (4089 levels); c is the vector of random environmental effects (65 levels); e is the vector of residual effects; X, Z and W are incidence matrices for respectively fixed effects, random animal effects and random permanent environmental effects. The random environmental effect c is a combination of date of entrance at the fattening farm and weighing date. Every two weeks, a new batch of pigs arrived at fattening farm. Parity of dams consisted of four classes (1, 23, 45, 6+).

More here:
Estimating genetics of body dimensions and activity levels in pigs using automated pose estimation | Scientific Reports - Nature.com

Related Posts