-
Notifications
You must be signed in to change notification settings - Fork 30
Add key time points in DiscreteSequence when evaluating periodic and flow-related motions
#638
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
base: master
Are you sure you want to change the base?
Conversation
|
This should be ready. |
|
I am re-trying the failed jobs |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #638 +/- ##
==========================================
+ Coverage 90.14% 91.22% +1.07%
==========================================
Files 57 57
Lines 3228 3248 +20
==========================================
+ Hits 2910 2963 +53
+ Misses 318 285 -33
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Ok, I have to review code coverage |
|
The way I tested the included functions is by manually determining key points from a specified "TimeCurve": t = [0.0, 0.1, 0.3]
t_unit = [0.0, 0.4, 1.0]
periods = [1.0, 0.5, 2.0]
periodic = true
dx = dy = [0.0 0.0 0.0 0.0]
dz = [3.0 4.0 -4. -3.]
reset = [false false true false]
Δ = 1e-6
fpth = flowpath(dx, dy, dz, reset, TimeCurve(t, t_unit, periodic, periods), AllSpins())period_times = reduce(vcat, [t .+ [-Δ, Δ] for t in [0.0, 0.3, 0.45, 1.05, 1.35, 1.5]])
reset_times = [0.2, 0.4, 0.85, 1.25, 1.45] .- Δ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KomaMRI Benchmarks
| Benchmark suite | Current: e8d5ca2 | Previous: ee3bc2f | Ratio |
|---|---|---|---|
MRI Lab/Bloch/CPU/2 thread(s) |
339465202.5 ns |
341921413 ns |
0.99 |
MRI Lab/Bloch/CPU/4 thread(s) |
272873331 ns |
275323882 ns |
0.99 |
MRI Lab/Bloch/CPU/8 thread(s) |
205654119 ns |
285513733 ns |
0.72 |
MRI Lab/Bloch/CPU/1 thread(s) |
556512232.5 ns |
552505595.5 ns |
1.01 |
MRI Lab/Bloch/GPU/CUDA |
21615042.5 ns |
21193443 ns |
1.02 |
MRI Lab/Bloch/GPU/oneAPI |
76004686 ns |
76632822 ns |
0.99 |
MRI Lab/Bloch/GPU/Metal |
96513083 ns |
96112375 ns |
1.00 |
MRI Lab/Bloch/GPU/AMDGPU |
24666705 ns |
28621139 ns |
0.86 |
Slice Selection 3D/Bloch/CPU/2 thread(s) |
1598294292 ns |
1622705599 ns |
0.98 |
Slice Selection 3D/Bloch/CPU/4 thread(s) |
885748828 ns |
891208860 ns |
0.99 |
Slice Selection 3D/Bloch/CPU/8 thread(s) |
556034306 ns |
571183580.5 ns |
0.97 |
Slice Selection 3D/Bloch/CPU/1 thread(s) |
3040144004 ns |
3037417759.5 ns |
1.00 |
Slice Selection 3D/Bloch/GPU/CUDA |
32496243 ns |
32085949 ns |
1.01 |
Slice Selection 3D/Bloch/GPU/oneAPI |
121113069.5 ns |
121193856.5 ns |
1.00 |
Slice Selection 3D/Bloch/GPU/Metal |
110020292 ns |
112065187.5 ns |
0.98 |
Slice Selection 3D/Bloch/GPU/AMDGPU |
32605152 ns |
36595885 ns |
0.89 |
This comment was automatically generated by workflow using github-action-benchmark.
cncastillo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pleases remove all of this "sampling_params["Δt_rise"]" and use MIN_RISE_TIME if you need a constant for a small time.
- Avoid type pyracy (new `CenterOfMass` struct and related `≈` methods) - Remove `sampling_params["Δt_rise"]` parameter - Use `MIN_RISE_TIME` KomaMRIBase constant - Clarify tests - Improve coverage
- Improve `==` and `≈` definitions: remove redundant methods and dispatch basing on the abstract type - Solve bug when reading writing the rotation center into a phantom file
|
I tried to address all the requested changes. @cncastillo feel free to resolve the comments if you agree. |
- Fix type pyracy - Fix and test `RotateX` functions - Fix type stability in `displacement!` (new `get_center` function) - Change variable name `per` -> `periods` - Improve test clarity - Add tests: `times` and non-periodic `add_key_time_points!`
|
Re-running again the failed job, let me know if it passes to bump and register after merge. |
|
@cncastillo documentation is still failing, but only in CI/CD servers. When run locally, docs are correctly built. It seems as a timeout error or something similar. Is this happening in other PRs? |
|
That is weird, I run it again with debug logs on, to see what is going on. |
|
I still don't get why docs are failing :-/ |
|
It says that we need to re-run it. https://github.com/JuliaHealth/KomaMRI.jl/actions/runs/19511907808/job/55858775999 |
|
I can't figure out it maybe add a timeout, like this one: https://github.com/JuliaHealth/KomaMRI.jl/blob/master/.github%2Fworkflows%2FCI.yml#L15 |
|
It turns out this line in for n in 1:floor(t_max/period) append!(aux, aux .+ n*period) endwas absurdly inefficient. When the input I fixed this in 8695493, using method dispatch, the sizehint!(aux, initial_size * (n_periods + 1))
for n in 1:n_periods
append!(aux, aux[1:initial_size] .+ n*period)
end |
|
This should be ready to merge! It might be good to check that this improvement actually meets its goal of providing accurate simulations when periodic flow motions are present. @mcgrathcm do you have any experiment or scenario where this is easy to verify? It would be helpful to at least see the differences between the results before and after this PR (even if we don’t include it in the tests). |
cncastillo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, can you point to the issue this PR is solving so @mcgrathcm can remember what the problem was and potentially test it?
|
It is #620 |
|
@mcgrathcm is finishing testing, in the meantime, can you bump versions and tell me wish packages to register? |
|
I ran these change with one of the encodes of my 4DFlow sequence, and see no noticeable difference, which is a good thing in this case. Overall, I cannot say whether this change fixes what it was set out to fix (as I don't have an example demonstrating the problem), but I can say it did not break anything that already worked! |
|
Very nice example and simulations :) And thank you for testing this!
(PD: I have just noticed that these test images are gifs :O) |
cncastillo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that some changes in base are breaking for core and files (like the use of CenterOfMass and removal of add_jump_times!), so i bumped the compat versions. As this is not breaking for the user API it is fine as a minor bump. Do you agree?
Co-authored-by: Carlos Castillo Passi <[email protected]>
Co-authored-by: Carlos Castillo Passi <[email protected]>
cncastillo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check that the versions of the files are above master and the compats make sense as I think I registered a minor version for komafiles.
KomaFiles version is set to 0.9.7 in master. This PR sets it to 0.9.8 |
Co-authored-by: Carlos Castillo Passi <[email protected]>



Try with:
From #620 (comment):
This is the PR intended to solve the above. I have created and renamed some functions to obtain the following structure:
add_key_time_points!: this function is called fromget_variable_timesand adds all the necessary time points to the sequence when motion is present. These key points can be divided into two categories: period-related and flow-related, which are obtained through two different and consecutive function calls fromadd_key_time_points!:add_period_times!: adds to the time vector all the key points related to pseudo-periodic motions (i.e., motions where theperiodsfield is a vector). This is necessary for all motion types, not onlyFlowPathactions.add_reset_times!: this function is equivalent to the oldadd_jump_times!, but it has been improved to support pseudo-periodicity.Finally, when
periodic == true, all key time points obtained from bothadd_period_times!andadd_reset_times!are periodically extended.This PR does not fully resolve issue #620 but provides a partial fix. Based on the figure in this comment, it addresses the point marked with the blue bullet.
This change might slightly impact performance in dynamic simulations, since we now check periodicity and add key time points for all motion types, not just for FlowPath motions. I realized that any motion (not only FlowPath) can lead to discontinuities when extended periodically, which is why these checks are now always performed (except, of course, in the
NoMotioncase).