soft-matter / trackpy-examples

sample images, examples, and speed tests for trackpy
Other
21 stars 42 forks source link

Mass values for walkthrough are off by orders of magnitude #43

Open charlesreid1 opened 6 years ago

charlesreid1 commented 6 years ago

Hi there,

I was going through the walkthrough notebook and noticed that when the images are imported with the line f = tp.locate(frames[0], 11, invert=True), the mass values are O(1)-O(10). However, several cells down there is a f = tp.locate(frames[0], 11, invert=True, minmass=200) call that wipes out all of the features found. Here's an example of what I'm seeing from f['mass'].head():

f['mass'].head()

0    1.211087
1    2.187542
2    1.501123
3    1.333051
4    1.533473
Name: mass, dtype: float64

From the image of the histogram embedded in the notebook, it appears that the (now un-reproducible) output from the masses column was O(1000). It seems this is related to the change in the way mass was calculated in version 0.3.0 (based on this comment in feature.py). I plan to submit a pull request to the walkthrough notebook with updated plots, but I wanted to run it past you first and see if you think the change in version 0.3.0 was, in fact, the cause.

charlesreid1 commented 6 years ago

It appears the pixel values are now normalized from [0-255] to [0-1] and the examples were last updated ~1 year ago so it seems there have been a number of changes to trackpy since then... will submit a PR with fixes to the notebooks soon.

nkeim commented 6 years ago

Thanks!! There have been changes but I didn't think they affected normalization… @caspervdw would be the authority. Are you finding that you can recover the original situation by just multiplying the masses by 255?

charlesreid1 commented 6 years ago

Almost, but there's a little bit of error, ~O(0.001). The top left corner of the first frame has a brightness value of 124 in the original notebook, while using the latest version of trackpy it has a value of 0.4876. But 124/255=0.4862 (and 124/254=0.4882 so that's not it either). Same with the lower right corner, which has a brightness value of 116 in the original notebook and 0.4571, but 116/255=0.4549.

If those differences are okay by you, I've submitted a pull request with these and other updates to the example notebooks. See pull request #44.

charlesreid1 commented 6 years ago

It turns out the behavior of the mass values changes depending on whether scikit-image is installed or not. See soft-matter/trackpy#455 for explanation and soft-matter/pims#280 for fix (which prints a warning to the user about this behavior).