Skip to content
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

Test motion-related functions #523

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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/TimeSpan.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
abstract type AbstractTimeSpan{T<:Real} end

Base.:(≈)(t1::AbstractTimeSpan, t2::AbstractTimeSpan) = (typeof(t1) == typeof(t2)) & reduce(&, [getfield(t1, field) ≈ getfield(t2, field) for field in fieldnames(typeof(t1))])

"""
timerange = TimeRange(t_start, t_end)

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, 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
Loading
Loading