-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
Good catch! I’ll take a look at this tomorrow. All my recordings are less
than a second, which is probably why I didn’t run into this bug.
…On Wed, May 22, 2024 at 10:47 PM mgalenb ***@***.***> wrote:
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.png (view on web)
<https://github.com/stillyslalom/CineFiles.jl/assets/6004917/8bcb7e45-53de-4f57-9efe-da9416d1b620>
Frame 299:
Screenshot.2024-05-22.at.9.24.56.PM.png (view on web)
<https://github.com/stillyslalom/CineFiles.jl/assets/6004917/5efb1bcd-b918-4eb8-a9e2-32ef7976aeef>
base code:
Screenshot.2024-05-22.at.9.18.30.PM.png (view on web)
<https://github.com/stillyslalom/CineFiles.jl/assets/6004917/e96e01ef-c734-415b-920c-fe499987d5ec>
new code:
Screenshot.2024-05-22.at.9.06.07.PM.png (view on web)
<https://github.com/stillyslalom/CineFiles.jl/assets/6004917/942eca48-71b1-4855-b3d2-f4a61fbf4be2>
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
------------------------------
You can view, comment on, or merge this pull request online at:
#11
Commit Summary
- da04410
<da04410>
fix dt time calculation
File Changes
(1 file <https://github.com/stillyslalom/CineFiles.jl/pull/11/files>)
- *M* src/CineFiles.jl
<https://github.com/stillyslalom/CineFiles.jl/pull/11/files#diff-cf7d09012d90192dde109fa21544ca0efc4ca270eb772194e50f771d4531ff0c>
(4)
Patch Links:
- https://github.com/stillyslalom/CineFiles.jl/pull/11.patch
- https://github.com/stillyslalom/CineFiles.jl/pull/11.diff
—
Reply to this email directly, view it on GitHub
<#11>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABA73GFFCDI2ZUBWHWXMQRLZDVYFZAVCNFSM6AAAAABIE3RZL6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYTCOJTGE4DKMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Can you produce a sample cine file (minimum resolution, minimum number of frames) that gives incorrect timestamps and add it to |
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? |
actually, the original code is correct also..... maybe there is something about the other cine file I was using....looking into it |
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 |
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.... |
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 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! |
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 softwareFrame 0:
![Screenshot 2024-05-22 at 9 23 30 PM](https://private-user-images.githubusercontent.com/6004917/333034414-8bcb7e45-53de-4f57-9efe-da9416d1b620.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2MzkwODEsIm5iZiI6MTcyNDYzODc4MSwicGF0aCI6Ii82MDA0OTE3LzMzMzAzNDQxNC04YmNiN2U0NS01M2RlLTRmNTctOWVmZS1kYTk0MTZkMWI2MjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjZUMDIxOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NTIzZWIyMTA5NGFiMmU3YTgzNjEzYjE3MjNlNjg3MDVhZGI4YjE1NDFlNDNhZGQ0M2QzZDczMDA1MzA3YzQxNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.A5bluhKajqgSwIdWvoMB4qOiwhf_Q3smoPqOY9ECMIU)
Frame 299:
![Screenshot 2024-05-22 at 9 24 56 PM](https://private-user-images.githubusercontent.com/6004917/333034279-5efb1bcd-b918-4eb8-a9e2-32ef7976aeef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2MzkwODEsIm5iZiI6MTcyNDYzODc4MSwicGF0aCI6Ii82MDA0OTE3LzMzMzAzNDI3OS01ZWZiMWJjZC1iOTE4LTRlYjgtYTllMi0zMmVmNzk3NmFlZWYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZD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aWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.jdMn7mrf4nAbaqB0KFV92J40XlD-6sUWAgaKszesoYk)
new code:
![Screenshot 2024-05-22 at 9 06 07 PM](https://private-user-images.githubusercontent.com/6004917/333034607-942eca48-71b1-4855-b3d2-f4a61fbf4be2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ2MzkwODEsIm5iZiI6MTcyNDYzODc4MSwicGF0aCI6Ii82MDA0OTE3LzMzMzAzNDYwNy05NDJlY2E0OC03MWIxLTQ4NTUtYjNkMi1mNGE2MWZiZjRiZTIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjZUMDIxOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjkxNDk0MzFlYmVkNGRiMDhlOTNkNTU5M2ZjZGIwNWZkNGM4Zjg4MmE5MjAzZjRiMDQyNTI0OGIwZmZmOTczMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.ZZKdxvcv8oPjkkOhEY9CtoIFoKmxjkxVCNcdlL6RBdY)
Here is the new dt calculation