Skip to content
Snippets Groups Projects
Verified Commit 0bfa5869 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Store instants in dense vector form

parent 2a43fc72
No related branches found
No related tags found
No related merge requests found
Pipeline #23445 passed
...@@ -123,7 +123,7 @@ function split_times(sequences::AbstractVector{<:BaseSequence}, tstart::Number, ...@@ -123,7 +123,7 @@ function split_times(sequences::AbstractVector{<:BaseSequence}, tstart::Number,
timestep = Float64(max_timestep) timestep = Float64(max_timestep)
for sequence in sequences for sequence in sequences
(block_time, block) = sequence[mod(tmean, duration(sequence))] (block_time, block) = sequence(mod(tmean, duration(sequence)))
for key in keys(block) for key in keys(block)
if !(start_time(block, key) < block_time < end_time(block, key)) if !(start_time(block, key) < block_time < end_time(block, key))
continue continue
...@@ -156,8 +156,8 @@ If multiple sequences are provided a vector of `LinearSequence` objects are retu ...@@ -156,8 +156,8 @@ If multiple sequences are provided a vector of `LinearSequence` objects are retu
""" """
struct LinearSequence struct LinearSequence
finite_parts :: Vector{SequencePart} finite_parts :: Vector{SequencePart}
instant_pulses :: Vector{Tuple{Int, InstantPulse}} instant_pulses :: Vector{Union{Nothing, InstantPulse}}
instant_gradient :: Vector{Tuple{Int, InstantGradient3D}} instant_gradient :: Vector{Union{Nothing, InstantGradient3D}}
end end
LinearSequence(sequence::BaseSequence; kwargs...) = LinearSequence(sequence, 0., duration(sequence); kwargs...) LinearSequence(sequence::BaseSequence; kwargs...) = LinearSequence(sequence, 0., duration(sequence); kwargs...)
...@@ -169,8 +169,8 @@ function LinearSequence(container::BaseSequence, times::AbstractVector{<:Number} ...@@ -169,8 +169,8 @@ function LinearSequence(container::BaseSequence, times::AbstractVector{<:Number}
tstart = times[1] tstart = times[1]
tfinal = times[end] tfinal = times[end]
pulses = Tuple{Int, InstantPulse}[] pulses = Union{Nothing, InstantPulse}[nothing for _ in 1:length(times)]
gradients = Tuple{Int, InstantGradient3D}[] gradients = Union{Nothing, InstantGradient3D}[nothing for _ in 1:length(times)]
for nTR in div(tstart, duration(container), RoundDown):div(tfinal, duration(container), RoundUp) for nTR in div(tstart, duration(container), RoundDown):div(tfinal, duration(container), RoundUp)
for (to_store, func) in [ for (to_store, func) in [
(pulses, iter_instant_pulses), (pulses, iter_instant_pulses),
...@@ -181,8 +181,8 @@ function LinearSequence(container::BaseSequence, times::AbstractVector{<:Number} ...@@ -181,8 +181,8 @@ function LinearSequence(container::BaseSequence, times::AbstractVector{<:Number}
if !(tstart <= real_time < tfinal) if !(tstart <= real_time < tfinal)
continue continue
end end
index = findmin(t -> abs(t - real_time), times)[2]-1 index = findmin(t -> abs(t - real_time), times)[2]
push!(to_store, (index, pulse)) to_store[index] = pulse
end end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment