Plant-Tracer / webapp

Client and Server for web-based JavaScript app
GNU Affero General Public License v3.0
0 stars 2 forks source link

line graphs for x and y vs time #425

Open sbarber2 opened 3 months ago

sbarber2 commented 3 months ago

The legacy iOS app had line charts for x and y movement in pixels or mm vs frames or time.

This issue requests the replication of that functionality in PlantTracer/webapp.

x,y vs. time graphs for both gravitropism and circumnutation in the legacy iOS app have the initial position of the apex as the origin point (0,0) of the graph, so that's how these graphs should look as well.

Sub-tasks:

JoAnnJuzefyk commented 3 months ago

Replicating the legacy graphs can be done with the data we are currently collecting in CSV file? Actually, without the timestamps those graphs cannot be created.

Maybe we need another issue generated to work on getting timestamps from the movie? Graphing the rate of motion over time is essential to comparing one plant to another.

I can put together a mock up of graphs that I can come up with from data (currently collected or possible to collect). I will use Excel to create these examples. Then we can share them with Eric and Simson to consider what is feasible based on the data available and the current code to collect the data.

simsong commented 3 months ago

@JoAnnJuzefyk — it would be useful if you could do some experiments with LapseIt and find out if it always does the same reduction in speed, or if there are several settings that it tends to make available. Also to investigate the metadata of the lapseIt files to see if it records anything.

Timestamps can always be inferred. And the old graphs can be created with a different X axis, can't they?

sbarber2 commented 3 months ago

The legacy app would simply use the frame # for the x axis if no frame rate is available. That's fine in the interim. Frame # can be considered just a different unit of time.

78 has a picture of the x and y vs time graphs from the legacy app, for

the gravitropism type.

Here https://github.com/Plant-Tracer/webapp/blob/main/docs/media/image29.png is a picture of the circumnutation type in case that was different.

Yes we should get further guidance from @Eric Brenner @.***> on what graphs are useful today, but these legacy ones can be a starting point for work/discussion. I recall validating these with Eric some time ago and then legacy app graphs were still basically what he is looking for.

So it's like this:

On Wed, Jun 12, 2024 at 11:15 AM JoAnn Juzefyk @.***> wrote:

Replicating the legacy graphs can be done with the data we are currently collecting in CSV file? Actually, without the timestamps those graphs cannot be created.

Maybe we need another issue generated to work on getting timestamps from the movie? Graphing the rate of motion over time is essential to comparing one plant to another.

I can put together a mock up of graphs that I can come up with from data (currently collected or possible to collect). I will use Excel to create these examples. Then we can share them with Eric and Simson to consider what is feasible based on the data available and the current code to collect the data.

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2163299177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQOB4RHBQWRUAHV3VUEQ3ZHBQ2JAVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTGI4TSMJXG4 . You are receiving this because you authored the thread.Message ID: @.***>

JoAnnJuzefyk commented 3 months ago

The x axis could be frame number, I guess. The important issue is to be able to compare any 2 plants so the timestamp is important.

sbarber2 commented 3 months ago

Timestamps can always be inferred. And the old graphs can be created with a different X axis, can't they?

Yes, if we have no time rates, we can use frame #s on the x axis of the graphs.

On Wed, Jun 12, 2024 at 11:58 AM Simson L. Garfinkel < @.***> wrote:

@JoAnnJuzefyk https://github.com/JoAnnJuzefyk — it would be useful if you could do some experiments with LapseIt and find out if it always does the same reduction in speed, or if there are several settings that it tends to make available. Also to investigate the metadata of the lapseIt files to see if it records anything.

Timestamps can always be inferred. And the old graphs can be created with a different X axis, can't they?

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2163402631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQOB6F6JA3UWBQP3UIMPLZHBV37AVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTGQYDENRTGE . You are receiving this because you authored the thread.Message ID: @.***>

sbarber2 commented 3 months ago

The important issue is to be able to compare any 2 plants so the timestamp is important.

The most important issue is that the app produces a reasonable graph with the information we have on hand. Not to say it isn't important to use the elapsed timestamp for each frame, but as a matter of application design, we can proceed if we don't have it.

Yes, I'll make an issue to get the time rates/timestamps available in the app.

On Wed, Jun 12, 2024 at 12:06 PM JoAnn Juzefyk @.***> wrote:

The x axis could be frame number, I guess. The important issue is to be able to compare any 2 plants so the timestamp is important.

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2163418861, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQOB57ZPVIWUFAA4OLNALZHBWYXAVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRTGQYTQOBWGE . You are receiving this because you authored the thread.Message ID: @.***>

JoAnnJuzefyk commented 3 months ago

I am trying to code a graph on chart.js using the csv files I have already downloaded from analysis I have done.

from stack overflow: Chartjs doesn't support direct CSV files. So you have to convert it to JSON-like format. What you can do is create a server side script in php/nodejs that will convert csv to json on the go. Then give that data to chartjs

$file="1_23.csv"; $csv= file_get_contents($file); $array = array_map("str_getcsv", explode("\n", $csv)); $json = json_encode($array); print_r($json);

Can I get the data directly from a JSON? Just for a demo, what is the format of the JSON? Is the JSON used to create the csv files? Can you point to where I would find the creation of the JSON in the source code (just so I can learn a bit more about how and when the JSON is created)?

sbarber2 commented 3 months ago

Can I get the data directly from a JSON?

I don't understand where you are going with this question; please elaborate.

Just for a demo, what is the format of the JSON?

In the example code in your comment, the JSON string's format is determined by the line that starts with $array.

Can you point to where I would find the creation of the JSON in the source code (just so I can learn a bit more about how and when the JSON is created)?

In the example above (if that's what you mean by "the source code"), the JSON string itself is created in the line that starts with $json

If you take that example and print out the results of each step (including the explode() call), I think it will become clear to you how it works.

Is the JSON used to create the csv files?

Well, in your example, it's the csv file's contents that is used to make a JSON string.

sbarber2 commented 3 months ago

My guess without running the example code is that it works something like this:

If the contents of 1_23.csv is:

"x","y"
"1","2"
"3","4"

then the resulting JSON string will be something like:

[ {"x": "1", "y": "2"}, {"x": "3", "y": "4"}]

simsong commented 3 months ago

That’s what I would expect. It’s a pretty standard representation. However, it would be best to put together a small demo program.On Jun 13, 2024, at 11:48 AM, Steve Barber @.***> wrote: My guess without running the example code is that it works something like this: If the contents of 1_23.csv is: "x","y" "1","2" "3","4"

then the resulting JSON string will be something like: [ {"x": "1", "y": "2"}, {"x": "3", "y": "4"}]

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

sbarber2 commented 1 week ago

On the dev call today, Eric reminded us/clarified for us that for circumnutation graphs, at least, the starting position of the Apex should be considered the origin point of the graph (0,0) and subsequent motion tracked from that origin, positive or negative. Satisfying that bit of functionality I think can be within the scope of this issue. Editing the description accordingly.

sbarber2 commented 1 week ago

Reconfirming that these graphs for gravitropism also had the graph origin as the initial position of the apex.

sbarber2 commented 1 week ago

Quick status. @JoAnnJuzefyk is doing the work for this issue on the graphing-frame_number-vs-apex-x-and-y branch. As of today on this branch, the two graphs appear on the analyze page always, with no button or other control toggle them on or off as we can't get that to work well, perhaps for the same reason the Download Trackpoints button doesn't work at the moment (#471).

JoAnn's next task is to get the graphs to appear below the Marker table/CRUD affordances, which hopefully is just a matter of figuring out what HTML or CSS hacks we need.

sbarber2 commented 1 week ago

Here's how the graphs look at the moment:

Screenshot 2024-09-20 at 11 44 03 AM

sbarber2 commented 1 week ago

We committed a new version that uses the first frame's Apex as the graphs' origin, and also handled arbitrary "Ruler XXmm" marker labels, including have 0-N such markers. If there are at least two Rule XXmm markers, then these will be used to convert pixels to mm on the vertical axes of the graphs.

We need to make is so the graph axes display the appropriate units. Adding to task list.

sbarber2 commented 1 week ago

I made a fix to the graph logic (real_distance was wrong).

I've also started to code up the frames per minute capture rate calculation but the way we refresh graphs needs a re-think so I've left the code there but it is hidden for now.

sbarber2 commented 1 week ago

Here is what the graphs look like now with the first frame origin and mm calculation.

Screenshot 2024-09-24 at 5 52 16 PM

sbarber2 commented 1 week ago

Also, in the most recent commit the axes will be labelled with the appropriate units.

simsong commented 1 week ago

That’s really great. Now we just need to do the 3-D.!

On Tue, Sep 24, 2024 at 5:59 PM Steve Barber @.***> wrote:

Also, in the most recent commit the axes will be labelled with the appropriate units.

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2372461227, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMFHLCWHWQ5252A5D3RJSDZYHOD5AVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGQ3DCMRSG4 . You are receiving this because you commented.Message ID: @.***>

sbarber2 commented 1 week ago

It occurs to me that scaling calculation for pixels -> mm currently uses the "Ruler XXmm" marker x,y positions from the first frame in the movie rather than the x,y positions of the current frame.

The calculations I think would be "more correct" if we used the Ruler marker positions from each frame. There's no reason to believe that the camera position is absolutely fixed from the beginning to the end of a time-lapse recording. This idea has been discussed before, we just haven't incorporated it into the current implementation.

I'll note that even in the circumnutation sample movie we use for testing, the x positions of the Ruler markers vary by one pixel over the course of the movie.

Adding a task for this.

simsong commented 1 week ago

Correct. The version that I was working on tracks the ruler for this reason. You want to recalc every frame.

On Sep 25, 2024, at 8:22 AM, Steve Barber @.***> wrote:

It occurs to me that scaling calculation for pixels -> mm currently uses the "Ruler XXmm" marker x,y positions from the first frame in the movie rather than the x,y positions of the current frame.

The calculations I think would be "more correct" if we used the Ruler marker positions from each frame. There's no reason to believe that the camera position is absolutely fixed from the beginning to the end of a time-lapse recording. This idea has been discussed before, we just haven't incorporated it into the current implementation.

I'll note that even in the circumnutation sample movie we use for testing, the x positions of the Ruler markers vary by one pixel over the course of the movie.

Adding a task for this.

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2373933722, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMFHLCLFYDJFFTP3D3OZILZYKTGZAVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZTHEZTGNZSGI. You are receiving this because you commented.

JoAnnJuzefyk commented 1 week ago

I did mention that as a comment next to the code to calculate the scale. I can move the lines of code into the forEach() and have the scale conversion calculated on every frame.

JoAnnJuzefyk commented 2 days ago

I failed to get the scale for conversion from pixels to mm on all frames. I have a section (commented out, line 502) in canvas_tracer_controller.js that attempted to recalculate the scale on each frame. The branch graph_2 is up to date with main and works (on my machine).

simsong commented 2 days ago

Well, if it is not available on a frame, can you grab it from the previous frame?

On Sep 29, 2024, at 5:45 PM, JoAnn Juzefyk @.***> wrote:

I failed to get the scale for conversion from pixels to mm on all frames. I have a section (commented out, line 502) in canvas_tracer_controller.js that attempted to recalculate the scale on each frame. The branch graph_2 is up to date with main and works (on my machine).

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2381621317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMFHLEUHEQCWBKQB6YCOQ3ZZBYF5AVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGYZDCMZRG4. You are receiving this because you commented.

sbarber2 commented 2 days ago

Hi JoAnn,

Thanks for the report. It reads like a pure status update of a work in progress, but just checking -- is there something we might assist you with here? Or are you saying you want to be done with this Issue and we should merge as is?

And you know, "failed" is such a harsh word to apply to one's efforts!

-Steve

On Sun, Sep 29, 2024 at 5:45 PM JoAnn Juzefyk @.***> wrote:

I failed to get the scale for conversion from pixels to mm on all frames. I have a section (commented out, line 502) in canvas_tracer_controller.js that attempted to recalculate the scale on each frame. The branch graph_2 is up to date with main and works (on my machine).

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2381621317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQOB7WZXPR3R2FMKAB66DZZBYF3AVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGYZDCMZRG4 . You are receiving this because you were mentioned.Message ID: @.***>

sbarber2 commented 2 days ago

Oh, apologies, I see your message to me about this elsewhere. Got it.

On Mon, Sep 30, 2024 at 9:11 AM Steve Barber @.***> wrote:

Hi JoAnn,

Thanks for the report. It reads like a pure status update of a work in progress, but just checking -- is there something we might assist you with here? Or are you saying you want to be done with this Issue and we should merge as is?

And you know, "failed" is such a harsh word to apply to one's efforts!

-Steve

On Sun, Sep 29, 2024 at 5:45 PM JoAnn Juzefyk @.***> wrote:

I failed to get the scale for conversion from pixels to mm on all frames. I have a section (commented out, line 502) in canvas_tracer_controller.js that attempted to recalculate the scale on each frame. The branch graph_2 is up to date with main and works (on my machine).

— Reply to this email directly, view it on GitHub https://github.com/Plant-Tracer/webapp/issues/425#issuecomment-2381621317, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFQOB7WZXPR3R2FMKAB66DZZBYF3AVCNFSM6AAAAABJGQHV4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRGYZDCMZRG4 . You are receiving this because you were mentioned.Message ID: @.***>

sbarber2 commented 2 days ago

Not sure off hand why the new per frame ruler marker code didn't work for (assuming your test markers were at 0 and 20 mm), but two quick observations:

My QA-brain asks these questions to help ensure that the code is as robust as we can reasonably make it:

sbarber2 commented 2 days ago

OK, we fixed the per frame position axis calculation.

We observed that deleting markers from a traced movie affects only the current frame of the trace points, so handling that case is not something we do well yet.

Closely related, deleting markers mid-movie could conceivably change the units we can graph mid-graph, which we don't want to support. We should default the graph back to pixels if we detect a change from mm->pixels mid-movie.

sbarber2 commented 2 days ago

Deferring frame rate input out of this issue.

JoAnnJuzefyk commented 2 days ago

The scale is now a function and calculates in Frames.forEach(). The last issue is to fix the position of the canvas for the 2 graphs.