Skip to content

Commit

Permalink
fixing dt time calculation (#11)
Browse files Browse the repository at this point in the history
* fix dt time calculation

* adding dt_test.cine

* Add test for frame timestamps

* Filter out dt_test from bulk test list

* Fix loading/filtering order for test files

* convert fracstart and TriggerTime.fractions to Float64 before subtraction

---------

Co-authored-by: Alex Ames <alexander.m.ames@gmail.com>
  • Loading branch information
mgalenb and stillyslalom committed May 27, 2024
1 parent 9d21e31 commit a4fc53e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/CineFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function CineHeader(fname)
secstart = read(f, UInt32)
dt[i] =
(secstart - cine.TriggerTime.seconds) +
((fracstart - cine.TriggerTime.fractions) / 2^32)
((fracstart / 2^32 - cine.TriggerTime.fractions / 2^32 ))
end

# Packing options
Expand Down
Binary file added test/data/dt_test.cine
Binary file not shown.
11 changes: 10 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ function compare_images(cine_file, tiff_image, frame_no=1)
return all(isapprox.(cine_frame_gamma, tiff_image; atol=0.01))
end

cine_file_paths = cine_test_files.(glob("*.cine", "data"))
cine_base_paths = glob("*.cine", "data")
# Don't perform xml/tif cross-verification on dt_test cine file
filter!(f -> !occursin("dt_test", f), cine_base_paths)
cine_file_paths = cine_test_files.(cine_base_paths)
append!(cine_file_paths, cine_test_files.(glob("*.cine", "proprietary_data")))

@testset "CineFiles.jl" begin
Expand Down Expand Up @@ -88,6 +91,12 @@ append!(cine_file_paths, cine_test_files.(glob("*.cine", "proprietary_data")))
parse(Int, xml_data["CameraSetup"]["CameraVersion"])
end
end

@testset "Correct calculation of frame timestamps" begin
cf = CineFile(joinpath("data", "dt_test.cine"))
Δt = diff(cf.header.dt)
@test all(dt -> isapprox(dt, Δt[1], rtol=5e-8), Δt)
end
end

Aqua.test_all(CineFiles)

0 comments on commit a4fc53e

Please sign in to comment.