Git Product home page Git Product logo

sleepr's People

Contributors

qgeissmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sleepr's Issues

sleep dam annotation won't work on keyless data tables

dt <- toy_dam_data()
sleep_dam_annotation(dt) ## OK
dt[, sleep_dam_annotation(.SD), by=id]  ## FAILS
 Error in `[.data.table`(data, , .(t = t, moving = activity > 0), by = key(data)) : 
  by=c(...), key(...) or names(...) must evaluate to 'character' 

This contrast with boot_analysis that does work regardless

Question regarding max_velocity_detector and velocity correction

Dear Gilestro lab

Thank you for developing sleepr and making it publicly available for free. It’s great!

I had a question regarding your max_velocity_detector annotation function, which you use in sleep_annotation to determine the level of activity of a fly in time_window_length seconds.
The logic you implement consists of retrieving the distance computed live on the ethoscopes, and you then divide by the time passed since the previous frame. This time difference is expressed in the dt column, which you compute in the beginning of the function

d[,dt := c(NA,diff(t))]

With the distance and the time difference, you then can compute a velocity
d[,velocity := dist/dt]

In the next lines you simulate beam crosses and mask behavior if an interaction occurs, which is not relevant for my question.
The next relevant line is the following:
d[, velocity_corrected := velocity * dt /a]

Which according to the supplementary material in your PLOS One article https://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.2003026.s005&type=supplementary is designed to correct for the problem

that resulting velocity computation depended on the frame rate of the processed video

i.e. you correct the velocity taking into account the FPS.
However, by having a close look to the code, I would argue that what you effectively do is instead getting the distance again and then normalizing with a. The result of this operation is called velocity_corrected, but it is basically a distance normalized by a. You then select the maximum value in time_window_length and if the maximum is bigger than 1 i.e. the original distance dist is greater than a, the fly is annotated as moving for that block of time, and not moving otherwise.
Wouldn’t it be more correct to omit line 74 and just check if the velocity is greater than a? Or maybe divide again by dt (and not multiply). Under my reasoning, the fact that the velocity is multiplied with dt does not only not correct the velocity but also makes the time between frames irrelevant because it takes the magnitudes to the distance space, and not the velocity space.

This question is related to issue gilestrolab/ethoscope#97 in the ethoscope repository. We are trying to find what is the problem and misannotation could be one of the culprits.

Once again, thank you very much!

Best,
Antonio

bout analysis gives inconsistent results

  a = "a"
  b = "b"
  dt <- data.table(t = c(1:5,10:15),
                   y = c(a,a,a,b,a,b,a,a,a,b,b))

  dt
  bdt <- bout_analysis(y, dt)


  expected <- rbind(
      data.table( y=a,
                  t=c(1,5,8),
                  duration=c(3,5,3)),
      data.table( y=b,
                  t=c(4,7,11),
                  duration=c(1,1,2))
    )[,.SD, keyby=t]

  bdt <- bdt[, .(t,y,duration)][,.SD, keyby=t]

results are shifted. Here, we get a bout of "b" lasting 5. It would make sense to roll forward, not backward so we have a bout of "a" lasting 5, starting at t=5

 dt
     t y
 1:  1 a
 2:  2 a
 3:  3 a
 4:  4 b
 5:  5 a
 6: 10 b
 7: 11 a
 8: 12 a
 9: 13 a
10: 14 b
11: 15 b
> bdt
    t y duration
1:  1 a        2
2:  3 b        1
3:  4 a        1
4:  5 b        5
5: 10 a        3
6: 13 b        2

error whe applying sleep annotation

seq.default(from = d_small[1, t], to = d_small[.N, t], by = time_window_length) : 
  'to' must be of length 1

Seems like d_small[.N, t] could return a vector of length != 1...?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.