Skip to content

Commit

Permalink
Merge pull request #523 from JuliaHealth/test-motion
Browse files Browse the repository at this point in the history
Test motion-related functions
  • Loading branch information
cncastillo authored Jan 16, 2025
2 parents 8d7338c + 85c01f8 commit 64efca0
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 159 deletions.
1 change: 1 addition & 0 deletions KomaMRIBase/src/motion/Action.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
abstract type AbstractAction{T<:Real} end

Base.:()(a1::AbstractAction, a2::AbstractAction) = (typeof(a1) == typeof(a2)) & reduce(&, [getfield(a1, field) getfield(a2, field) for field in fieldnames(typeof(a1))])
is_composable(m::AbstractAction) = false

# Simple actions
Expand Down
3 changes: 2 additions & 1 deletion KomaMRIBase/src/motion/SpinSpan.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
abstract type AbstractSpinSpan end

Base.:()(s1::AbstractSpinSpan, s2::AbstractSpinSpan) = (typeof(s1) == typeof(s2)) & reduce(&, [getfield(s1, field) getfield(s2, field) for field in fieldnames(typeof(s1))]; init=true)

"""
allspins = AllSpins()
Expand Down Expand Up @@ -64,7 +66,6 @@ function Base.getindex(spins::SpinRange, p)
return intersect, spin_range
end
Base.view(spins::SpinRange, p) = spins[p]
Base.:(==)(sr1::SpinRange, sr2::SpinRange) = sr1.range == sr2.range
Base.length(sr::SpinRange) = length(sr.range)
get_indexing_range(spins::SpinRange) = spins.range
expand(sr::SpinRange, Ns::Int) = sr
Expand Down
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, tc::TimeCurve)
jump_times = (tc.t_end - tc.t_start)/(size(a.spin_reset)[2]-1) * (getindex.(findall(a.spin_reset .== 1), 2) .- 1) .- 1e-6
append!(t, jump_times)
Expand Down
Loading

0 comments on commit 64efca0

Please sign in to comment.