Skip to content

Commit

Permalink
Add auxiliary constructor for FlowPath
Browse files Browse the repository at this point in the history
  • Loading branch information
pvillacorta committed Dec 18, 2024
1 parent 3b6e79e commit 3d4019e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions KomaMRIBase/src/motion/actions/arbitraryactions/FlowPath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ julia> flowpath = FlowPath(
spin_reset::AbstractArray{Bool}
end

FlowPath(dx::AbstractArray{T}, dy::AbstractArray{T}, dz::AbstractArray{T}, spin_reset::BitMatrix) where T<:Real = FlowPath(dx, dy, dz, collect(spin_reset))

function add_jump_times!(t, a::FlowPath, time_span::AbstractTimeSpan)
jump_times = (times(time_span)[end] - times(time_span)[1])/(size(a.spin_reset)[2]-1) * (getindex.(findall(a.spin_reset .== 1), 2) .- 1) .- 1e-6
append!(t, jump_times)
Expand Down
4 changes: 2 additions & 2 deletions KomaMRIBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ end
dx = rand(Ns, Nt)
dy = rand(Ns, Nt)
dz = rand(Ns, Nt)
arbitrarymotion = FlowPath(dx, dy, dz, collect(Bool.(zeros(Ns, Nt))), TimeRange(t_start, t_end))
arbitrarymotion = FlowPath(dx, dy, dz, Bool.(zeros(Ns, Nt)), TimeRange(t_start, t_end))
t = range(t_start, t_end, Nt)
xt, yt, zt = get_spin_coords(arbitrarymotion, ph.x, ph.y, ph.z, t')
@test xt == ph.x .+ dx
Expand All @@ -587,7 +587,7 @@ end
dx = rand(Ns, Nt)
dy = rand(Ns, Nt)
dz = rand(Ns, Nt)
arbitrarymotion = FlowPath(dx, dy, dz, collect(Bool.(zeros(Ns, Nt))), TimeRange(t_start, t_end))
arbitrarymotion = FlowPath(dx, dy, dz, Bool.(zeros(Ns, Nt)), TimeRange(t_start, t_end))
t = range(t_start, t_end, Nt)
xt, yt, zt = get_spin_coords(arbitrarymotion, ph.x, ph.y, ph.z, t')
@test xt == ph.x .+ dx
Expand Down

0 comments on commit 3d4019e

Please sign in to comment.