Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_n_obs() does not seem to work for WI dp (because sequenceID==NA?) #167

Closed
Rafnuss opened this issue Sep 13, 2022 · 8 comments
Closed
Assignees
Labels
help wanted Extra attention is needed
Milestone

Comments

@Rafnuss
Copy link
Collaborator

Rafnuss commented Sep 13, 2022

Using get_n_obs(), I get really low observation counts (<20) while I have usually several hundreads of pictures per deployement.

Could it be possible that this is due to NA value assigned to sequenceID in the import (https://github.com/inbo/camtraptor/blob/HEAD/R/read_wi.R#L326)? According to the documentation (https://inbo.github.io/camtraptor/reference/get_n_obs.html), this is how the number of observations is counted. I am however surprise that I don't get a count of 1 all the time because all sequenceID are NA. Any idea?

@damianooldoni
Copy link
Member

Hi @Rafnuss! Thanks for reporting your issues with the package.
Yes, I think sequenceID = NA is the reason of the low number of observations.
The bulk of the calculation is in these lines:
https://github.com/inbo/camtraptor/blob/main/R/get_n_obs.R#L130-L135

However, as you said, seqeunceID equal to NA should result to n = 1.
See example here below using mica dataset:

library(dplyr)
library(camtraptor)

n_obs1 <- get_n_obs(mica1)
n_obs <- get_n_obs(mica)

n_obs1 %>%
  filter(n > 0)
#> # A tibble: 9 × 3
#>   deploymentID                         scientificName         n
#>   <chr>                                <chr>              <int>
#> 1 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Anas strepera          1
#> 2 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Anas platyrhynchos     1
#> 3 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Castor fiber           1
#> 4 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Mustela putorius       1
#> 5 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Vulpes vulpes          1
#> 6 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Martes foina           1
#> 7 62c200a9-0e03-4495-bcd8-032944f6f5a1 Ardea cinerea          1
#> 8 62c200a9-0e03-4495-bcd8-032944f6f5a1 Ardea                  1
#> 9 7ca633fa-64f8-4cfc-a628-6b0c419056d7 Homo sapiens           1

n_obs %>%
  filter(n > 0)
#> # A tibble: 9 × 3
#>   deploymentID                         scientificName         n
#>   <chr>                                <chr>              <int>
#> 1 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Anas strepera          3
#> 2 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Anas platyrhynchos     4
#> 3 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Castor fiber           1
#> 4 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Mustela putorius       3
#> 5 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Vulpes vulpes          1
#> 6 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Martes foina           1
#> 7 62c200a9-0e03-4495-bcd8-032944f6f5a1 Ardea cinerea          1
#> 8 62c200a9-0e03-4495-bcd8-032944f6f5a1 Ardea                  2
#> 9 7ca633fa-64f8-4cfc-a628-6b0c419056d7 Homo sapiens           1


n_obs1 %>%
  filter(n == 0)
#> # A tibble: 27 × 3
#>    deploymentID                         scientificName         n
#>    <chr>                                <chr>              <int>
#>  1 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Castor fiber           0
#>  2 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Mustela putorius       0
#>  3 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Vulpes vulpes          0
#>  4 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Martes foina           0
#>  5 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Ardea cinerea          0
#>  6 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Ardea                  0
#>  7 29b7d356-4bb4-4ec4-b792-2af5cc32efa8 Homo sapiens           0
#>  8 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Anas strepera          0
#>  9 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Anas platyrhynchos     0
#> 10 577b543a-2cf1-4b23-b6d2-cda7e2eac372 Ardea cinerea          0
#> # … with 17 more rows


# all observations per deployment
n_obs_all <- get_n_obs(mica, species = NULL)
n_obs_all
#> # A tibble: 4 × 2
#>   deploymentID                             n
#>   <chr>                                <int>
#> 1 29b7d356-4bb4-4ec4-b792-2af5cc32efa8    10
#> 2 577b543a-2cf1-4b23-b6d2-cda7e2eac372     9
#> 3 62c200a9-0e03-4495-bcd8-032944f6f5a1     5
#> 4 7ca633fa-64f8-4cfc-a628-6b0c419056d7     3

n_obs_all1 <- get_n_obs(mica1, species = NULL)
n_obs_all1
#> # A tibble: 4 × 2
#>   deploymentID                             n
#>   <chr>                                <int>
#> 1 29b7d356-4bb4-4ec4-b792-2af5cc32efa8     3
#> 2 577b543a-2cf1-4b23-b6d2-cda7e2eac372     5
#> 3 62c200a9-0e03-4495-bcd8-032944f6f5a1     3
#> 4 7ca633fa-64f8-4cfc-a628-6b0c419056d7     2

Created on 2022-09-13 with reprex v2.0.2

So, indeed, you should have some ones, not zeros... Can you provide me a reproducible example?

@damianooldoni damianooldoni added the help wanted Extra attention is needed label Sep 13, 2022
@Rafnuss
Copy link
Collaborator Author

Rafnuss commented Sep 13, 2022

Yes, that's right, I got n>1 because I was simply adding the number of species (get_n_obs(dp, species = NULL)).

So, I guess we should change https://github.com/inbo/camtraptor/blob/main/R/read_wi.R#L308? But see https://github.com/inbo/camtraptor/blob/main/R/read_wi.R#L145. Here is the doc on sequence vs image type: https://www.wildlifeinsights.org/get-started/basics/projects#type.

I'm not really familiar with this differences and their implication for analysis. But intuitively, I would want to be able to define sequenceInterval outside my data (during analysis) and I would expect that a sequence would be computed "on the fly" taking the max count for each species seperatly during that duration.

What would be your recommendation?

@peterdesmet
Copy link
Member

I recommend updating read_wi() and assign sequenceID = imageID for image-level datasets.

@damianooldoni
Copy link
Member

@Rafnuss: is this solved now?

@Rafnuss
Copy link
Collaborator Author

Rafnuss commented Sep 15, 2022

Sorry, I didn't finished my work last time, here is the fully functional solution (ie. tested) #174

@damianooldoni
Copy link
Member

@Rafnuss: is this issue solved?

@PietrH
Copy link
Member

PietrH commented Sep 6, 2023

Is this solved? Or do we need more tests for #174?

@PietrH
Copy link
Member

PietrH commented Jul 4, 2024

@damianooldoni Is it ok to close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants