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

fixing dt time calculation #11

Merged
merged 6 commits into from
May 27, 2024
Merged

Conversation

mgalenb
Copy link
Contributor

@mgalenb mgalenb commented May 23, 2024

I believe the dt calculation is wrong in the code.

The fractions need be divided by 4 and the two bits for IRIG removed. This is not well documented in the phantom documentation but I checked the time from trigger using the phantom PCC software

Frame 0:
Screenshot 2024-05-22 at 9 23 30 PM

Frame 299:
Screenshot 2024-05-22 at 9 24 56 PM

base code:
Screenshot 2024-05-22 at 9 18 30 PM

new code:
Screenshot 2024-05-22 at 9 06 07 PM

Here is the new dt calculation

for i in eachindex(dt)
     fracstart = read(f, UInt32)/4/2^30
     secstart = read(f, UInt32)
     dt[i] =
          (secstart - cine.TriggerTime.seconds) +
          ((fracstart - cine.TriggerTime.fractions/4/2^30) )
end

@stillyslalom
Copy link
Owner

stillyslalom commented May 23, 2024 via email

@stillyslalom
Copy link
Owner

Can you produce a sample cine file (minimum resolution, minimum number of frames) that gives incorrect timestamps and add it to test/data/? You're welcome to add a corresponding test, otherwise I'll take care of it.

@mgalenb
Copy link
Contributor Author

mgalenb commented May 23, 2024

I added a dt_test.cine to /test/data and checked the new dt calc vs the PCC software and it checks out. I havent written a test before however so not sure how to do that?

@mgalenb
Copy link
Contributor Author

mgalenb commented May 23, 2024

actually, the original code is correct also..... maybe there is something about the other cine file I was using....looking into it

@mgalenb
Copy link
Contributor Author

mgalenb commented May 23, 2024

ok I think it is related to software version. I have a cine save with version 787. this cine file gives two different dt depending on the base or changed code.

then I have just saved a cine and put into test/data with version 804. this cine gives the same dt using either code...looking into this more. the older version save is done using labview SDK the cine I put into test/data was created using PCC v3.8.804.6

@mgalenb
Copy link
Contributor Author

mgalenb commented May 23, 2024

also it now occurs to me that

1/4/(2^30) = 1/(2^32)

lol sorry for the spam

let me try to reproduce the issue using a older cine file version....

@mgalenb
Copy link
Contributor Author

mgalenb commented May 25, 2024

ok I figured it out. it had to do with subtracting fracstart and TriggerTime.fractions which are UInt32. this produced another UInt32 which would not have the correct fraction (see 3 column plot on left). the bottom plot shows cf.header.dt

Screenshot 2024-05-24 at 9 55 19 PM

the solution is to convert them to float64 (by dividing by 2^32) and then subtracting (see plot on the right)

the problem was a bit tricky because checking the first and last value in cf.header.dt sometimes gave the correct answer depending on TriggerTime. I only realized the problem when I plotted cf.header.dt for test/data/dt_test.cine

sorry for the original red herring!

@stillyslalom stillyslalom merged commit a4fc53e into stillyslalom:master May 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants