diff --git a/Stats/.Rhistory b/Stats/.Rhistory
index 0557ac4b0d57c105e9c1818e857089aec69ee2fd..eaeec58bc8f3e60a62ebaf75c4b87c485c66063f 100644
--- a/Stats/.Rhistory
+++ b/Stats/.Rhistory
@@ -1,29 +1,3 @@
-library(multcompView) # "multcompLetters" function
-library(ggplot2)
-library(pgirmess)
-library(postHoc)
-#library(tidyquant)    # geom_ma() if rolling average needed
-################# DATASET IMPORTS #####################################
-folder <- './../'
-whistles.dta <-read.table(file=paste0(folder,
-'Whistles/Evaluation/whistles_durations.csv'),
-sep = ',', header=TRUE)
-whistles.dta <- whistles.dta[order(whistles.dta$audio_names),]
-bbp.dta <-read.table(file=paste0(folder,
-'BBPs/Results/16-06-22_14h00_number_of_BBP.csv'),
-sep = ',', header=TRUE)
-bbp.dta <- bbp.dta[order(bbp.dta$audio_names),]
-clicks.dta <-read.table(file=paste0(folder,
-'Clicks/Results/projection_updated_number_of_clicks_02052022.csv'), #number_of_clicks_02052022.csv
-sep = ',', header=TRUE)
-clicks.dta <- clicks.dta[order(clicks.dta$audio_names),]
-# Merge files into 1 dataset
-acoustic.dta <- clicks.dta
-acoustic.dta$number_of_bbp <- bbp.dta$number_of_BBP
-acoustic.dta$total_whistles_duration <- whistles.dta$total_whistles_duration
-rm(whistles.dta, bbp.dta, clicks.dta)
-# add group IDs
-id2020 <- read.table(file=paste0(folder, 'CSV_data/Audio_Data_2020.csv'),
 sep = ',', header=TRUE)[1:396,]
 id2021 <- read.table(file=paste0(folder, 'CSV_data/Audio_Data_2021.csv'),
 sep = ',', header=TRUE)[1:96,]
@@ -93,7 +67,7 @@ shapiro.test(acoustic.dta$total_whistles_duration)
 shapiro.test(acoustic.dta$number_of_bbp)
 shapiro.test(acoustic.dta$number_of_clicks)
 # p-values are significant => they do not follow normal distributions
-# will need a transformation or the use of a glm model
+# will need a transformation or the use of a glim model
 # X Number of individuals per level
 summary(factor(acoustic.dta$acoustic))
 summary(factor(acoustic.dta$fishing_net))
@@ -110,11 +84,11 @@ ftable(factor(acoustic.dta$fishing_net), factor(acoustic.dta$behavior), factor(a
 # => They will be treated apart from the rest as they are likely to be biased
 ##################### STATISTICAL MODELLING ###########################
 ### Model tested
-# LM: Linear model (residual hypothesis: normality, homoscedasticity, independant)
-# GLM: Generalized linear model (residual hypothesis: homoscedasticity, independant)
-# NB : Negative Binomial model (usually, when overdispersion with GLM)
-# ZINB: Zero inflated negative binomial model (residual hypothesis: homoscedasticity, independant
-# using number as an offset (more dolphins => more signals)
+# GLM: General linear model (residual hypothesis: normality, homoscedasticity, independant)
+# GLIM: Generalized linear model (residual hypothesis: uncorrelated residuals)
+# NB : Negative Binomial model (residual hypothesis: independantM)
+# ZINB: Zero inflated negative binomial model (residual hypothesis: independant)
+# We are using number as an offset (more dolphins => more signals)
 # beacon and net explanatory variables could not be tested in models
 # as they contain information already present in "fishing_net" which is more
 # interesting to keep for our study. They will be treated after
@@ -123,8 +97,8 @@ ftable(factor(acoustic.dta$fishing_net), factor(acoustic.dta$behavior), factor(a
 # If a variable is it in a model, it is because it had no significant effect.
 par(mfrow=c(1,1))
 ### Model for whistles
-# Residual hypotheses not verified for LM
-# Overdipsersion when using GLM (negative binomial)
+# Residual hypotheses not verified for GLM
+# Overdipsersion when using GLIM (negative binomial)
 # Using ZINB:
 zero.whi <- zeroinfl(total_whistles_duration ~
 acoustic + fishing_net + behavior + offset(log(number)),
@@ -138,11 +112,12 @@ mod.whi <- zero.whi # => zeroinflated model is indeed better suited
 car::Anova(mod.whi, type=3)
 dwtest(mod.whi) # H0 -> independent if p>0.05 (autocorrelation if p<0.05)
 bptest(mod.whi) # H0 -> homoscedasticity if p<0.05
-# No normality but we do not need it
+mod.whi$df.null/mod.whi$df.residual
+# no dispersion, perfect
 ### Model for BBP
-# No normality of residuals for LM
-# overdispersion with GLM quasipoisson
-#try with glm NB:
+# No normality of residuals for GLM
+# overdispersion with GLIM quasipoisson
+#try with glim NB:
 mod.bbp <- glm.nb(number_of_bbp ~ acoustic + fishing_net + behavior
 + offset(log(number)),
 data=acoustic.dta)
@@ -156,7 +131,6 @@ mod.bbp$deviance/mod.bbp$df.residual
 mod.cli <- glm.nb(number_of_clicks ~ acoustic + fishing_net + acoustic:fishing_net + offset(log(number)),
 data=acoustic.dta)
 car::Anova(mod.cli, type=3)
-shapiro.test(residuals(mod.cli)) # H0 : normality -> cannot be rejected if p > 0.05
 dwtest(mod.cli) # H0 -> independent if p>0.05 (autocorrelation if p<0.05)
 bptest(mod.cli) # H0 -> homoscedasticity if p<0.05
 mod.cli$deviance/mod.cli$df.residual
@@ -216,11 +190,11 @@ acoustic.dta$clicks_per_dolphin <- acoustic.dta$number_of_clicks/acoustic.dta$nu
 table <- cld(emmeans(mod.whi, pairwise~fishing_net, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(fishing_net=table$fishing_net,
 letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/375), # 375 bins = 1 sec
+barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/n_bins),
 myletters_df, fishing_net,
 old_names = c("SSF","F"), new_names = c("Absent", "Present"),
 xname="Presence/Asence of fishing net", height=.5,
-ytitle="Mean whistling time per dolphin per min")
+ytitle="Mean whistling time per dolphin per min (in sec)")
 # BBP
 table <- cld(emmeans(mod.bbp, pairwise~fishing_net, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(fishing_net=table$fishing_net,
@@ -243,8 +217,8 @@ ytitle="Mean number of clicks per dolphin per min")
 # Whistles
 table <- cld(emmeans(mod.whi, pairwise~acoustic, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(acoustic=table$acoustic,letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/375),
-myletters_df, acoustic, height=0.65, ytitle="Mean whistling time per dolphin per min",
+barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/n_bins),
+myletters_df, acoustic, height=0.65, ytitle="Mean whistling time per dolphin per min (in sec)",
 old_names = c("AV","AV+D","D","D+AP","AP"),
 new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
 xname="Activation sequence")
@@ -272,9 +246,9 @@ letters_df$acoustic <- computeLetters(emmeans(mod.whi, pairwise~fishing_net:acou
 "acoustic")$acoustic
 letters_df <- letters_df[, c("acoustic","fishing_net","letter")]
 letters_df$letter <- gsub(" ", "", letters_df$letter)
-barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/375, two=acoustic),
+barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/n_bins, two=acoustic),
 NULL, acoustic, fill=fishing_net,
-old_names = c("AV","AV+D","D","D+AP","AP"), ytitle="Mean whistling time per dolphin per min",
+old_names = c("AV","AV+D","D","D+AP","AP"), ytitle="Mean whistling time per dolphin per min (in sec)",
 new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
 xname="Activation sequence", height=c(.95,.95,.95,1,.95,1,.95,1,1,1),
 colours=c("#E69F00","#999999"), size=5,
@@ -311,8 +285,8 @@ legend_title="Fishing net", legend_labs=c("Present", "Absent"))
 # Whistles
 table <- cld(emmeans(mod.whi, pairwise~behavior, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(behavior=table$behavior,letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, behavior, whistling_time_per_dolphin/375),
-myletters_df, behavior, height=0.75, ytitle="Mean whistling time per dolphin per min",
+barPlot(computeStats(acoustic.dta, behavior, whistling_time_per_dolphin/n_bins),
+myletters_df, behavior, height=0.75, ytitle="Mean whistling time per dolphin per min (in sec)",
 old_names = c("CHAS", "DEPL", "SOCI"),
 new_names = c("Foraging", "Travelling", "Socialising"),
 xname="Behaviours of dolphins")
@@ -344,12 +318,12 @@ kruskalmc(acoustic.dta$whistling_time_per_dolphin, acoustic.dta$net)
 # DIY : letters
 myletters_df <- data.frame(net=c("SSF", "chalut_blanc", "chalut_vert", "tremail", "grand_filet"),
 letter = c("a","ad","bd","cd","a"))
-barPlot(computeStats(acoustic.dta, net, whistling_time_per_dolphin/375),
+barPlot(computeStats(acoustic.dta, net, whistling_time_per_dolphin/n_bins),
 NULL,
 net, old_names = c("SSF", "chalut_blanc", "chalut_vert", "tremail", "grand_filet"),
 new_names = c("Absent", "Nylon trawl net", "PE trawl net", "Nylon gill net", "Long nylon gill net"),
 xname="Fishing nets", height=.6,
-ytitle="Mean whistling time per dolphin per min")+
+ytitle="Mean whistling time per dolphin per min (in sec)")+
 theme(axis.text.x=element_text(size=8.5))
 # BBPs
 #KW test
@@ -385,19 +359,19 @@ theme(axis.text.x=element_text(size=8.5))
 # Whistles
 #KW test
 kruskal.test(acoustic.dta$whistling_time_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
-barPlot(computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375),
+names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/n_bins)["beacon"]
+barPlot(computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/n_bins),
 NULL,
 beacon, old_names = unlist(names), new_names = unlist(names),
 xname="Signals from bio-inspired beacon", height=0.9, size=3,
-ytitle="Mean whistling time per dolphin per min")+
+ytitle="Mean whistling time per dolphin per min (in sec)")+
 theme(axis.text.x=element_text(size=8))+
 scale_x_discrete(guide=guide_axis(n.dodge = 2))
 # NC stands for "Unknown". Corresponding to categories where the beacon was not turned on yet ('BEF')
 # BBPs
 #KW test
 kruskal.test(acoustic.dta$BBPs_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
+names = computeStats(acoustic.dta, beacon, BBPs_per_dolphin)["beacon"]
 barPlot(computeStats(acoustic.dta, beacon, BBPs_per_dolphin),
 NULL,
 beacon, old_names = unlist(names), new_names = unlist(names),
@@ -409,7 +383,7 @@ scale_x_discrete(guide=guide_axis(n.dodge = 2))
 # Clicks
 #KW test
 kruskal.test(acoustic.dta$clicks_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
+names = computeStats(acoustic.dta, beacon, clicks_per_dolphin)["beacon"]
 barPlot(computeStats(acoustic.dta, beacon, clicks_per_dolphin),
 NULL,
 beacon, old_names = unlist(names), unlist(names),
@@ -420,7 +394,7 @@ scale_x_discrete(guide=guide_axis(n.dodge = 2))
 # NC stands for "Unknown". Corresponding to categories where the beacon was not turned on yet ('BEF')
 #### Plots by number of dolphins ####
 # Whistles
-numb_stats_w <- computeStats(acoustic.dta, number, total_whistles_duration/375)
+numb_stats_w <- computeStats(acoustic.dta, number, total_whistles_duration/n_bins)
 numb_stats_w[is.na(numb_stats_w)] <- 0
 numb_stats_w$number <- as.factor(numb_stats_w$number)
 numb_stats_w %>%
@@ -429,7 +403,7 @@ geom_errorbar(aes(x=number, ymin=mean-ic, ymax=mean+ic),
 color="red", width=.1, show.legend = FALSE)+
 geom_point() + geom_line() +
 theme_classic() + theme(text=element_text(size=12)) +
-ylab("Mean whistling time per min")+
+ylab("Mean whistling time per dolphin per min (in sec)")+
 xlab("Number of dolphins in group")
 # BBPs
 numb_stats_b <- computeStats(acoustic.dta, number, number_of_bbp)
@@ -441,7 +415,7 @@ geom_errorbar(aes(x=number, ymin=mean-ic, ymax=mean+ic),
 color="red", width=.1, show.legend = FALSE)+
 geom_point() + geom_line() +
 theme_classic() + theme(text=element_text(size=12)) +
-ylab("Number of BBPs per min")+
+ylab("Number of BBPs per dolphin per min")+
 xlab("Number of dolphins in group")
 # Clicks
 numb_stats_c <- computeStats(acoustic.dta, number, number_of_clicks)
@@ -453,11 +427,11 @@ geom_errorbar(aes(x=number, ymin=mean-ic, ymax=mean+ic),
 color="red", width=.1)+
 geom_point() + geom_line() +
 theme_classic() + theme(text=element_text(size=12)) +
-ylab("Mean number of clicks per min")+
+ylab("Mean number of clicks per dolphin per min")+
 xlab("Number of echolocation clicks in group")
 #### Plots by Group ID ####
 # Whistles
-numb_stats_w <- computeStats(acoustic.dta, ID, whistling_time_per_dolphin/375)
+numb_stats_w <- computeStats(acoustic.dta, ID, whistling_time_per_dolphin/n_bins)
 numb_stats_w[is.na(numb_stats_w)] <- 0
 numb_stats_w$ID <- as.factor(numb_stats_w$ID)
 numb_stats_w %>%
@@ -466,7 +440,7 @@ geom_errorbar(aes(x=ID, ymin=mean-sd, ymax=mean+sd),
 color="red", width=.1, show.legend = FALSE)+
 geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
 theme_light() + theme(text=element_text(size=12)) +
-ylab("Mean whistling time per min")+
+ylab("Mean whistling time per dolphin per min (in sec)")+
 xlab("ID of dolphins group")
 # BBPs
 numb_stats_b <- computeStats(acoustic.dta, ID, BBPs_per_dolphin)
@@ -478,7 +452,7 @@ geom_errorbar(aes(x=ID, ymin=mean-sd, ymax=mean+sd),
 color="red", width=.1, show.legend = FALSE)+
 geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
 theme_light() + theme(text=element_text(size=12)) +
-ylab("Number of BBPs per min")+
+ylab("Number of BBPs per dolphin per min")+
 xlab("ID of dolphins group")
 # Clicks
 numb_stats_c <- computeStats(acoustic.dta, ID, clicks_per_dolphin)
@@ -490,7 +464,7 @@ geom_errorbar(aes(x=ID, ymin=mean-sd, ymax=mean+sd),
 color="red", width=.1)+
 geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
 theme_light() + theme(text=element_text(size=12)) +
-ylab("Mean number of clicks per min")+
+ylab("Mean number of clicks per dolphin per min")+
 xlab("ID of dolphin group")
 # KW test on IDs
 # whistles (excluding groups "2" because 1 sample and groups because no whistles recorded )
@@ -498,15 +472,41 @@ data_test <- acoustic.dta[acoustic.dta$ID!="2",]
 print( posthocKW(data_test$whistling_time_per_dolphin, data_test$ID))
 print( posthocKW(data_test$BBPs_per_dolphin, data_test$ID))
 print( posthocKW(data_test$clicks_per_dolphin, data_test$ID))
-mod.cli$deviance/mod.cli$df.residual
-mod.bbp$deviance/mod.bbp$df.residual
-mod.whi$deviance/mod.whi$df.residual
-mod.whi$deviance/mod.whi$df.residual
-mod.whi$deviance
-mod.whi
-mod.whi$fitted.values
-mod.whi$df.null
-mod.whi$df.residual
-mod.whi$df.null/mod.whi$df.residual
-mod.bbp$deviance/mod.bbp$df.residual
-mod.cli$deviance/mod.cli$df.residual
+#### Fishing net  ####
+# whistles
+table <- cld(emmeans(mod.whi, pairwise~fishing_net, adjust="tukey"), Letters = letters)
+myletters_df <- data.frame(fishing_net=table$fishing_net,
+letter = trimws(table$.group))
+barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/n_bins),
+myletters_df, fishing_net,
+old_names = c("SSF","F"), new_names = c("Absent", "Present"),
+xname="Presence/Asence of fishing net", height=1,
+ytitle="Mean whistling time per dolphin per min (in sec)")
+#### Acoustic plots  ####
+# Whistles
+table <- cld(emmeans(mod.whi, pairwise~acoustic, adjust="tukey"), Letters = letters)
+myletters_df <- data.frame(acoustic=table$acoustic,letter = trimws(table$.group))
+barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/n_bins),
+myletters_df, acoustic, height=1.2, ytitle="Mean whistling time per dolphin per min (in sec)",
+old_names = c("AV","AV+D","D","D+AP","AP"),
+new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
+xname="Activation sequence")
+barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/n_bins),
+myletters_df, acoustic, height=1.3, ytitle="Mean whistling time per dolphin per min (in sec)",
+old_names = c("AV","AV+D","D","D+AP","AP"),
+new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
+xname="Activation sequence")
+#### Behaviour plots ####
+# Whistles
+table <- cld(emmeans(mod.whi, pairwise~behavior, adjust="tukey"), Letters = letters)
+myletters_df <- data.frame(behavior=table$behavior,letter = trimws(table$.group))
+barPlot(computeStats(acoustic.dta, behavior, whistling_time_per_dolphin/n_bins),
+myletters_df, behavior, height=1.5, ytitle="Mean whistling time per dolphin per min (in sec)",
+old_names = c("CHAS", "DEPL", "SOCI"),
+new_names = c("Foraging", "Travelling", "Socialising"),
+xname="Behaviours of dolphins")
+25.8/19.1
+5.65/(25.8/19.1)
+25.15/20.9
+5.65/(25.15/20.9)
+5.65/(25.8/23.4)
diff --git a/Stats/BBP-click-whistles_3models.R b/Stats/BBP-click-whistles_3models.R
index d00efb1da45548877a58c5bf3b93034eaabc0ecd..17d7dcd9b8382dfae551ee8a5b222ec383f25a7e 100644
--- a/Stats/BBP-click-whistles_3models.R
+++ b/Stats/BBP-click-whistles_3models.R
@@ -19,6 +19,7 @@ library(pgirmess)
 library(postHoc)
 #library(tidyquant)    # geom_ma() if rolling average needed
 
+n_bins = 187.5 # number of bins per sec for spectrograms (whistles)
 
 ################# DATASET IMPORTS #####################################
 folder <- './../'
@@ -268,11 +269,11 @@ acoustic.dta$clicks_per_dolphin <- acoustic.dta$number_of_clicks/acoustic.dta$nu
 table <- cld(emmeans(mod.whi, pairwise~fishing_net, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(fishing_net=table$fishing_net,
                            letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/375), # 375 bins = 1 sec
+barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/n_bins),
         myletters_df, fishing_net, 
         old_names = c("SSF","F"), new_names = c("Absent", "Present"),
-        xname="Presence/Asence of fishing net", height=.5, 
-        ytitle="Mean whistling time per dolphin per min")
+        xname="Presence/Asence of fishing net", height=1, 
+        ytitle="Mean whistling time per dolphin per min (in sec)")
 
 # BBP
 table <- cld(emmeans(mod.bbp, pairwise~fishing_net, adjust="tukey"), Letters = letters)
@@ -299,8 +300,8 @@ barPlot(computeStats(acoustic.dta, fishing_net, clicks_per_dolphin),
 # Whistles
 table <- cld(emmeans(mod.whi, pairwise~acoustic, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(acoustic=table$acoustic,letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/375),
-        myletters_df, acoustic, height=0.65, ytitle="Mean whistling time per dolphin per min",
+barPlot(computeStats(acoustic.dta, acoustic, whistling_time_per_dolphin/n_bins),
+        myletters_df, acoustic, height=1.3, ytitle="Mean whistling time per dolphin per min (in sec)",
         old_names = c("AV","AV+D","D","D+AP","AP"),
         new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
         xname="Activation sequence")
@@ -332,9 +333,9 @@ letters_df$acoustic <- computeLetters(emmeans(mod.whi, pairwise~fishing_net:acou
                                       "acoustic")$acoustic
 letters_df <- letters_df[, c("acoustic","fishing_net","letter")]
 letters_df$letter <- gsub(" ", "", letters_df$letter)
-barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/375, two=acoustic),
+barPlot(computeStats(acoustic.dta, fishing_net, whistling_time_per_dolphin/n_bins, two=acoustic),
         NULL, acoustic, fill=fishing_net,
-        old_names = c("AV","AV+D","D","D+AP","AP"), ytitle="Mean whistling time per dolphin per min",
+        old_names = c("AV","AV+D","D","D+AP","AP"), ytitle="Mean whistling time per dolphin per min (in sec)",
         new_names = c("BEF","BEF+DUR","DUR", "DUR+AFT", "AFT"),
         xname="Activation sequence", height=c(.95,.95,.95,1,.95,1,.95,1,1,1), 
         colours=c("#E69F00","#999999"), size=5,
@@ -374,8 +375,8 @@ barPlot(computeStats(acoustic.dta, fishing_net, clicks_per_dolphin, two=acoustic
 # Whistles
 table <- cld(emmeans(mod.whi, pairwise~behavior, adjust="tukey"), Letters = letters)
 myletters_df <- data.frame(behavior=table$behavior,letter = trimws(table$.group))
-barPlot(computeStats(acoustic.dta, behavior, whistling_time_per_dolphin/375),
-        myletters_df, behavior, height=0.75, ytitle="Mean whistling time per dolphin per min",
+barPlot(computeStats(acoustic.dta, behavior, whistling_time_per_dolphin/n_bins),
+        myletters_df, behavior, height=1.5, ytitle="Mean whistling time per dolphin per min (in sec)",
         old_names = c("CHAS", "DEPL", "SOCI"),
         new_names = c("Foraging", "Travelling", "Socialising"),
         xname="Behaviours of dolphins")
@@ -410,12 +411,12 @@ kruskalmc(acoustic.dta$whistling_time_per_dolphin, acoustic.dta$net)
 # DIY : letters
 myletters_df <- data.frame(net=c("SSF", "chalut_blanc", "chalut_vert", "tremail", "grand_filet"),
                            letter = c("a","ad","bd","cd","a"))
-barPlot(computeStats(acoustic.dta, net, whistling_time_per_dolphin/375),
+barPlot(computeStats(acoustic.dta, net, whistling_time_per_dolphin/n_bins),
         NULL,
         net, old_names = c("SSF", "chalut_blanc", "chalut_vert", "tremail", "grand_filet"),
         new_names = c("Absent", "Nylon trawl net", "PE trawl net", "Nylon gill net", "Long nylon gill net"),
         xname="Fishing nets", height=.6,
-        ytitle="Mean whistling time per dolphin per min")+
+        ytitle="Mean whistling time per dolphin per min (in sec)")+
     theme(axis.text.x=element_text(size=8.5))
 
 # BBPs
@@ -455,12 +456,12 @@ barPlot(computeStats(acoustic.dta, net, clicks_per_dolphin),
 # Whistles
 #KW test
 kruskal.test(acoustic.dta$whistling_time_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
-barPlot(computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375),
+names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/n_bins)["beacon"]
+barPlot(computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/n_bins),
         NULL,
         beacon, old_names = unlist(names), new_names = unlist(names),
         xname="Signals from bio-inspired beacon", height=0.9, size=3,
-        ytitle="Mean whistling time per dolphin per min")+
+        ytitle="Mean whistling time per dolphin per min (in sec)")+
   theme(axis.text.x=element_text(size=8))+
   scale_x_discrete(guide=guide_axis(n.dodge = 2))
 # NC stands for "Unknown". Corresponding to categories where the beacon was not turned on yet ('BEF')
@@ -468,7 +469,7 @@ barPlot(computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375),
 # BBPs
 #KW test
 kruskal.test(acoustic.dta$BBPs_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
+names = computeStats(acoustic.dta, beacon, BBPs_per_dolphin)["beacon"]
 barPlot(computeStats(acoustic.dta, beacon, BBPs_per_dolphin),
         NULL,
         beacon, old_names = unlist(names), new_names = unlist(names),
@@ -481,7 +482,7 @@ barPlot(computeStats(acoustic.dta, beacon, BBPs_per_dolphin),
 # Clicks
 #KW test
 kruskal.test(acoustic.dta$clicks_per_dolphin ~ acoustic.dta$beacon)
-names = computeStats(acoustic.dta, beacon, whistling_time_per_dolphin/375)["beacon"]
+names = computeStats(acoustic.dta, beacon, clicks_per_dolphin)["beacon"]
 barPlot(computeStats(acoustic.dta, beacon, clicks_per_dolphin),
         NULL,
         beacon, old_names = unlist(names), unlist(names),
@@ -494,7 +495,7 @@ barPlot(computeStats(acoustic.dta, beacon, clicks_per_dolphin),
 
 #### Plots by number of dolphins ####
 # Whistles
-numb_stats_w <- computeStats(acoustic.dta, number, total_whistles_duration/375)
+numb_stats_w <- computeStats(acoustic.dta, number, total_whistles_duration/n_bins)
 numb_stats_w[is.na(numb_stats_w)] <- 0
 numb_stats_w$number <- as.factor(numb_stats_w$number)
 
@@ -504,7 +505,7 @@ numb_stats_w %>%
                 color="red", width=.1, show.legend = FALSE)+
   geom_point() + geom_line() +
   theme_classic() + theme(text=element_text(size=12)) +
-  ylab("Mean whistling time per min")+
+  ylab("Mean whistling time per dolphin per min (in sec)")+
   xlab("Number of dolphins in group")
 
 # BBPs
@@ -518,7 +519,7 @@ numb_stats_b %>%
                 color="red", width=.1, show.legend = FALSE)+
   geom_point() + geom_line() +
   theme_classic() + theme(text=element_text(size=12)) +
-  ylab("Number of BBPs per min")+
+  ylab("Number of BBPs per dolphin per min")+
   xlab("Number of dolphins in group")
 
 # Clicks
@@ -532,13 +533,13 @@ numb_stats_c %>%
                 color="red", width=.1)+
   geom_point() + geom_line() +
   theme_classic() + theme(text=element_text(size=12)) +
-  ylab("Mean number of clicks per min")+
+  ylab("Mean number of clicks per dolphin per min")+
   xlab("Number of echolocation clicks in group")
 
 
 #### Plots by Group ID ####
 # Whistles
-numb_stats_w <- computeStats(acoustic.dta, ID, whistling_time_per_dolphin/375)
+numb_stats_w <- computeStats(acoustic.dta, ID, whistling_time_per_dolphin/n_bins)
 numb_stats_w[is.na(numb_stats_w)] <- 0
 numb_stats_w$ID <- as.factor(numb_stats_w$ID)
 numb_stats_w %>%
@@ -547,7 +548,7 @@ numb_stats_w %>%
                 color="red", width=.1, show.legend = FALSE)+
   geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
   theme_light() + theme(text=element_text(size=12)) +
-  ylab("Mean whistling time per min")+
+  ylab("Mean whistling time per dolphin per min (in sec)")+
   xlab("ID of dolphins group")
 
 # BBPs
@@ -561,7 +562,7 @@ numb_stats_b %>%
                 color="red", width=.1, show.legend = FALSE)+
   geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
   theme_light() + theme(text=element_text(size=12)) +
-  ylab("Number of BBPs per min")+
+  ylab("Number of BBPs per dolphin per min")+
   xlab("ID of dolphins group")
 
 # Clicks
@@ -575,7 +576,7 @@ numb_stats_c %>%
                 color="red", width=.1)+
   geom_point() + scale_x_discrete(guide = guide_axis(n.dodge = 2))+
   theme_light() + theme(text=element_text(size=12)) +
-  ylab("Mean number of clicks per min")+
+  ylab("Mean number of clicks per dolphin per min")+
   xlab("ID of dolphin group")
 
 # KW test on IDs 
diff --git a/Stats/Rplot.pdf b/Stats/Rplot.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..c0a784b09ff71619a9a38531c657c12fea02ae3c
Binary files /dev/null and b/Stats/Rplot.pdf differ
diff --git a/Whistles/1-Identification_of_whistles.py b/Whistles/1-Identification_of_whistles.py
index 82cb471a450a3a6dcfd1552f589921834634cfcd..ec49c2dd6764976171e178859ea248bbe664ff9e 100644
--- a/Whistles/1-Identification_of_whistles.py
+++ b/Whistles/1-Identification_of_whistles.py
@@ -55,7 +55,7 @@ print("Parameters ready to use!")
 
 #%% Importation of data and functions
 print("\rImportation of csv data...", end="\r")
-from WhistleUtils import get_csv, plot_spectrums, get_local_maxima, get_trajectories, \
+from WhistleUtils import get_csv, get_local_maxima, get_trajectories, \
 	select_trajectories, sparsity_ridoff, harmonize_trajectories
 data_20_21, audio_paths = get_csv(csv_f, slash="/")
 print("Importation of csv data complete!\n")
diff --git a/Whistles/__pycache__/WhistleUtils.cpython-39.pyc b/Whistles/__pycache__/WhistleUtils.cpython-39.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..74433f17a2ffe316c18bfcba11f488fd62e37294
Binary files /dev/null and b/Whistles/__pycache__/WhistleUtils.cpython-39.pyc differ