Skip to content
Snippets Groups Projects
Commit 2f8dd863 authored by Adriaens, Ines's avatar Adriaens, Ines :v_tone2:
Browse files

manuscript and analysis metadata

parent f95e4420
No related branches found
No related tags found
No related merge requests found
%% NewCHP analysis
% ------------------------------------------------------------------------
% Created September 29, 2021 by Ines Adriaens @adria036
% ------------------------------------------------------------------------
% Working in new git branch elegant_penalty
% ------------------------------------------------------------------------
% Context:
% previously, a changepoint analysis was implemented to detect changes of
% distributions within the z- and CP distance time series. A changepoint
% analysis detects sudden changes based on the minimalisation of a cost
% function togehter with a penalty for the number of changes to be
% detected. The number of changes can be either a fixed number, or can be
% based on a minimal improvement of the goodness-of-fit. The fixed
% number approach is not very elegant, but penalty are, in literature,
% typically based on 'expert knowledge'. In this part of the analysis,
% following steps are implemented.
% ------------------------------------------------------------------------
% Steps:
% 1) set constants and filepaths
% 2) load data
% 3) summarize lying bouts
% 4) calculate minimum "residue" for no changepoint found + plot
% 5) create function to evaluate performance cp detection
% 6) determine and test penalties based on residue of no cp
% 7) visualise
% ------------------------------------------------------------------------
clear variables
close all
clc
%% STEP 1: constants and filepaths
% this folder contains the results of the smoothing and data imputation
% scripts
% results directory
init_.resdir = ['C:\Users\adria036\OneDrive - Wageningen '...
'University & Research\iAdriaens_doc\Projects\' ...
'eEllen\B4F_indTracking_cattle\B4F_results\'];
%% STEP 2: load data
% data resulting from data imputation script / reference data
% the 'ground truth' = comparison base = data_meta.selection = from first
% to last bout
% load data
load([init_.resdir 'D3_sdata_IQ_UWB.mat']) % from first to last icebout
load([init_.resdir 'D2_data_meta.mat'])
% delete cow 280 (no data)
sdata = rmfield(sdata,'cow_280');
%% STEP 2a: calculate summary of lying bouts for manuscript and penalty
% based on data_meta.selection = selection
% step 1: select data_meta.selection based on sdata available
for i = 1:height(data_meta.selection)
% check whether all the data is available in sdata
fields_ = ['cow_' num2str(data_meta.selection.cow(i))]; % field of sdat
ind = find(sdata.(fields_).date == data_meta.selection.bDat(i) & ...
sdata.(fields_).date == data_meta.selection.eDat(i))
end
% summary
data_meta.sums = table(unique(data_meta.selection.cow),'VariableNames',...
{'cow'});
for i = 1:height(data_meta.sums)
% no of days
data_meta.sums.NoDays(i) = length(unique(floor(data_meta.selection.numtime)));
% no of lying bouts
data_meta.sums.NoBouts(i) = sum(data_meta.selection.cow == ...
data_meta.sums.cow(i));
% max no of bouts per day
days = unique(
for j = 1:un
% min no of bouts per day
% avg number of bouts per day
% no of days sdata
field_ = ['cow_' num2str(data_meta.sums.cow(i))];
data_meta.sums.NoDaysSd(i) = length(unique(floor(datenum(sdata.(field_).date))));
end
...@@ -16,4 +16,90 @@ ...@@ -16,4 +16,90 @@
% following steps are implemented. % following steps are implemented.
% ------------------------------------------------------------------------ % ------------------------------------------------------------------------
% Steps: % Steps:
% 1) load data ( % 1) set constants and filepaths
\ No newline at end of file % 2) load data
% 3) summarize lying bouts
% 4) calculate minimum "residue" for no changepoint found + plot
% 5) create function to evaluate performance cp detection
% 6) determine and test penalties based on residue of no cp
% 7) visualise
% ------------------------------------------------------------------------
clear variables
close all
clc
%% STEP 1: constants and filepaths
% this folder contains the results of the smoothing and data imputation
% scripts
% results directory
init_.resdir = ['C:\Users\adria036\OneDrive - Wageningen '...
'University & Research\iAdriaens_doc\Projects\' ...
'eEllen\B4F_indTracking_cattle\B4F_results\'];
%% STEP 2: load data
% data resulting from data imputation script / reference data
% the 'ground truth' = comparison base = data_meta.selection = from first
% to last bout
% load data
load([init_.resdir 'D3_sdata_IQ_UWB.mat']) % from first to last icebout
load([init_.resdir 'D2_data_meta.mat'])
% delete cow 280 (no data)
sdata = rmfield(sdata,'cow_280');
%% STEP 2a: calculate summary of lying bouts for manuscript and penalty
% based on data_meta.selection = selection
% step 1: select data_meta.selection based on sdata available
for i = 1:height(data_meta.selection)
% check whether all the data is available in sdata
fields_ = ['cow_' num2str(data_meta.selection.cow(i))]; % field of sdat
start = find(datenum(sdata.(fields_).date) == ...
datenum(data_meta.selection.bDat(i)) + data_meta.selection.bTim(i));
endb = find(datenum(sdata.(fields_).date) == ...
datenum(data_meta.selection.eDat(i)) + data_meta.selection.eTim(i));
if ~isempty(start) & ~isempty(endb)
data_meta.selection.include(i) = 1;
else
data_meta.selection.include(i) = 0;
end
end
% summary
data_meta.sums = table(unique(data_meta.selection.cow),'VariableNames',...
{'cow'});
for i = 1:height(data_meta.sums)
% no of days
data_meta.sums.NoDays(i) = length(unique(floor(...
data_meta.selection.numtime(...
data_meta.selection.cow ==data_meta.sums.cow(i)))));
% no of lying bouts
data_meta.sums.NoBouts(i) = sum(data_meta.selection.cow == ...
data_meta.sums.cow(i));
% max no of bouts per day
% days = unique(
% for j = 1:un
% min no of bouts per day
% avg number of bouts per day
% no of days sdata
field_ = ['cow_' num2str(data_meta.sums.cow(i))];
data_meta.sums.NoDaysSd(i) = length(...
unique(floor(datenum(sdata.(field_).date))));
end
...@@ -516,7 +516,7 @@ saveas(h, [init_.resdir 'FIG_lyingBouts_Z_CD.tif']) ...@@ -516,7 +516,7 @@ saveas(h, [init_.resdir 'FIG_lyingBouts_Z_CD.tif'])
%% changepoint analysis - modelling %% changepoint analysis - modelling
% 1) comparison = "selection" = data_meta_selection - first down-up event % 1) comparison = "selection" = data_meta.selection - first down-up event
% 2) check data "z" and "cd" availability + make additional selection % 2) check data "z" and "cd" availability + make additional selection
% 3) perform the changepoint analysis (set "hyperparameters") = mean vs std % 3) perform the changepoint analysis (set "hyperparameters") = mean vs std
% + number of changepoints + per day/week / ? % + number of changepoints + per day/week / ?
......
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2) (preloaded format=pdflatex 2021.5.7) 20 SEP 2021 19:29 This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2) (preloaded format=pdflatex 2021.5.7) 28 SEP 2021 10:59
entering extended mode entering extended mode
**./20210908_Adriaens_UWB_.tex **./20210908_Adriaens_UWB_.tex
(20210908_Adriaens_UWB_.tex (20210908_Adriaens_UWB_.tex
...@@ -277,7 +277,7 @@ ers/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr7. ...@@ -277,7 +277,7 @@ ers/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr7.
pfb><C:/Users/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfont pfb><C:/Users/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfont
s/cm/cmsy10.pfb><C:/Users/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/pu s/cm/cmsy10.pfb><C:/Users/adria036/AppData/Local/Programs/MiKTeX/fonts/type1/pu
blic/amsfonts/cm/cmsy7.pfb> blic/amsfonts/cm/cmsy7.pfb>
Output written on 20210908_Adriaens_UWB_.pdf (8 pages, 155542 bytes). Output written on 20210908_Adriaens_UWB_.pdf (8 pages, 155682 bytes).
PDF statistics: PDF statistics:
311 PDF objects out of 1000 (max. 8388607) 311 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000) 0 named destinations out of 1000 (max. 500000)
......
No preview for this file type
No preview for this file type
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
Precision livestock farming solutions typically aim at supporting monitoring and decision taking by farmers using on-farm sensors measuring a specific aspect of the animals' behavior, performance or, in the case of e.g. dairy cows, product. The resulting raw sensor data are often noisy time series, prone to errors caused not only by sensor failure or the harsh and changing farm environments in which they operate, but also by the animals' specific physiology itself. Consequently, these data have little value without proper (pre-)processing algorithms that translate the raw measures in features interpret-able by the targeted end-users. Precision livestock farming solutions typically aim at supporting monitoring and decision taking by farmers using on-farm sensors measuring a specific aspect of the animals' behavior, performance or, in the case of e.g. dairy cows, product. The resulting raw sensor data are often noisy time series, prone to errors caused not only by sensor failure or the harsh and changing farm environments in which they operate, but also by the animals' specific physiology itself. Consequently, these data have little value without proper (pre-)processing algorithms that translate the raw measures in features interpret-able by the targeted end-users.
In dairy production, precision technologies are vastly deployed and implemented. Individual animals are not only vulnerable because of the physiological stress they endure during lactation, timely and specific interventions can obviate animal suffering and financial losses. As each cow is highly valued and modern dairy farms grew larger over the past decade, investments in sensor technology became increasingly justifiable. Out of the many technologies available, a system monitoring cow position and its derived behavioral features not only promises to disclose cow health, but might also reveal welfare and social interactions - aspects that become increasingly important in the livestock production landscape. Hence, monitoring cow behavior offers new paths both for research and commercial decision support systems that can help the farmer manage their herd, optimize production and quickly act upon health and welfare problems. A continuous and essential step to better unlock the potential of cow behavioral analyses is the development of new sensor technologies, and more importantly, the corresponding data-processing algorithms that allow precise and timely interpretation of their data. In dairy production, precision technologies are vastly deployed and implemented. The reason for the dairy sector being pacesetter in this area, is that animals are highly valuable but rather vulnerable, rendering individual monitoring crucial to optimize production, welfare and sustainability. Because of the physiological stress they endure during lactation, timely and specific interventions obviate animal suffering and financial losses. As modern dairy farms grew larger over the past decade, investments in sensor technology to guide these interventions became increasingly justifiable. Out of the many technologies available, a system monitoring cow position and its derived behavioral features not only promises to disclose cow health, but might also reveal welfare and social interactions - aspects that become increasingly important in the livestock production landscape. Hence, monitoring cow behavior offers new paths both for research and commercial decision support systems that can help the farmer manage their herd, optimize production and quickly act upon health and welfare problems. A continuous and essential step to better unlock the potential of cow behavioral analyses is the development of new sensor technologies, and more importantly, the corresponding data-processing algorithms that allow precise and timely interpretation of their data.
[Lying behaviour and why we chose this.] [Lying behaviour and why we chose this.]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment