This project shows how the behavior analysis was performed in the MAMMAL. It was tested on Windows 10 with anaconda 4.12.0, python 3.7.9.
- Install anaconda.
- Create virtual environment, as
conda create -n MAMMAL1 python=3.7.9
conda activate MAMMAL1
- Install packages.
pip install -r requirements.txt
Download data.zip
from Google Drive and unzip it under the main folder as
`-- MAMMAL_behavior
|-- data/
|-- fonts/
|-- nm_results/
|-- ...
The data
folder contains necessary processed data to run the code.
Download pig_render from https://github.com/anl13/pig_renderer. Put it to current folder like
`-- MAMMAL_behavior
|-- data/
|-- fonts/
|-- nm_results/
|-- pig_render/
|-- Render/
|-- MainRender.py
|-- ...
|-- ...
python nm_drink.py
This file read data from data/drink_data/
folder, and write figures to nm_results/scene_behavior/
folder. To help understand, we also provide motion capture result videos in nm_results/scene_behaivor/
used for eat and drink judgement.
python nm_cluster.py
This file read behavior data from data/clips/
folder (44 clips in total) and cluster them using tsne. It is worth mentioning that, due to the randomness of tsne, we may not get the exactly same results through two runs. However, you can still get some meaningful results from this file.
This file may take about 4 minutes to perform the data processing and clustering. After finishing the process, it will write middle data and density images to nm_results/individual_behavior/
folder, and present a renderer to show cluster peaks. Ususally, with the pre-defined parameters, it will generate 38~44 cluster areas after watershed algorithm, and the pose at the density peak of each area will be shown. You can use LEFT or RIGHT buttom to browse them. The eight distinct postures are manually determined during the browsing. It may not be the best clustering result due to the insufficiency of data used, but the results are still meanningful. Just enjoy browsing them!
python nm_social.py
This file will read data/batch5_nm/
data sequence (1000 frames) and write video and figure result to nm_results/social_behavior/
. Please check the code for more information.
If you use these datasets in your research, please cite the paper
@article{an2023three,
title={Three-dimensional surface motion capture of multiple freely moving pigs using MAMMAL},
author={An, Liang and Ren, Jilong and Yu, Tao and Hai, Tang and Jia, Yichang and Liu, Yebin},
journal={Nature Communications},
volume={14},
number={1},
pages={7727},
year={2023},
publisher={Nature Publishing Group UK London}
}