42-AI / Elegant-Elegans

MIT License
3 stars 0 forks source link

Documentation(Activity Index): how to implement celeST's Activity Index measure into WF NTP #29

Closed jhparkkkk closed 2 years ago

jhparkkkk commented 2 years ago

User Story

I want to find out how to implement a measure from celeST(Activity Index) into wf ntp script, so that wf_ntp also calculates and returns the same measure as celeST as an output.

Acceptance Criteria

Definition of Done

cnstll commented 2 years ago

From what I gathered, Activity index is a measure of the area covered (number of pixels?) over a period of time (per min) by a worm.

Some links I used during my research:

jhparkkkk commented 2 years ago

1) Define celeST Activity Index

What is Activity Index ?

Sum of number of pixels that are painted by the body during the time that it takes to an animal to do 2 strokes.

What is it for ?

→ To indicate how vigorously the worm bend while swimming over time. → The bigger the area it takes to swim the more the animal is active (healthy ?)

The Activity Index measure is calculated with the help of another measure : brush strokes which is the area that the body would “paint” (= number of pixels covered) in a single complete stroke.

2) Datas from WF NTP

First, the software identifies individual worms as labeled region giving coordinates of each animal for each frame.

From that, metrics can be defined. Those that could be helpful to use in order to render a measure like Activity Index could be :

If we can get the area of each worm for each frame -> We can sum up the total area for a given time

nb pixel / frame -> nb pixel / time

nb frame / sec

jhparkkkk commented 2 years ago

[weekly 3 - 2022.06.30]

CeleST source code

Activity Index is obtained by this formula (cf. CSTCheckResults.m l. 572):

sweeping_noTimeNorm(ff0) = areaCoveredNorm(ff0) temporalFreq(ff02) fileDB(currentVideo).frames_per_second 60

areaCoveredNorm(ff0) = sum(maskAreaCovered(:) > 0) / (averageWormBodyArea / (1+timeWindowForSweptAreas))

cnstll commented 2 years ago

After some research in the source code I can see that the Activity Index is defined with the variable sweeping_noTimeNorm (link to line).

The calculus of sweeping_noTimeNorm is done there : it is a product of a worm area (areaCoveredNorm) by a time frequency (temporalFreq) by the number of frames per min (fps * 60).

temporalFreq seems to be calculated in the function CSTComputeMeasuresFromBody whose definition begins here. ATM, I have a hard time understanding the calculus here as I am missing a lot of mathematical background.

areaCoveredNorm is defined here and depends on maskAreaCovereddefined here and averageWormBodyArea defined here which also depends on averageWormBodyMask.

In a nutshell, the calculus of these variables is still unclear.

madvid commented 2 years ago

don't forget to rebase