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

Add sequence merging

parent 16bab2fe
No related branches found
No related tags found
No related merge requests found
......@@ -37,8 +37,8 @@ export Pathway, duration_transverse, duration_dephase, bval, bmat, get_pathway
import .Parts: dwi_gradients, readout_event, excitation_pulse, refocus_pulse, Trapezoid, SliceSelect, LineReadout, opposite_kspace_lines, SpoiltSliceSelect, SliceSelectRephase, EPIReadout, interpret_image_size
export dwi_gradients, readout_event, excitation_pulse, refocus_pulse, Trapezoid, SliceSelect, LineReadout, opposite_kspace_lines, SpoiltSliceSelect, SliceSelectRephase, EPIReadout, interpret_image_size
import .PostHoc: adjust
export adjust
import .PostHoc: adjust, merge
export adjust, merge
import .Sequences: GradientEcho, SpinEcho, DiffusionSpinEcho, DW_SE, DWI
export GradientEcho, SpinEcho, DiffusionSpinEcho, DW_SE, DWI
......
......@@ -5,7 +5,7 @@ module PostHoc
import ..Variables: AbstractBlock, adjust_internal, adjustable
import ..Components: GradientWaveform, RFPulseComponent, BaseComponent, NoGradient
import ..Containers: ContainerBlock
import ..Containers: ContainerBlock, Sequence, Wait
"""
adjust(block; kwargs...)
......@@ -68,4 +68,28 @@ adjust_helper(dict_variable::AbstractDict, used_names::Set{Symbol}; kwargs...) =
adjust_helper(tuple_variable::Tuple, used_names::Set{Symbol}; kwargs...) = map(tuple_variable) do v adjust_helper(v, used_names; kwargs...) end
adjust_helper(pair:: Pair, used_names::Set{Symbol}; kwargs...) = adjust_helper(pair[1], used_names; kwargs...) => adjust_helper(pair[2], used_names; kwargs...)
"""
merge(sequences...; wait_time=0.)
Merge multiple sequences together.
Sequences will be run one after each other with `wait_time` in between.
"""
merge(sequences::Sequence{S}...; kwargs...) where {S} = merge_internal(sequences...; name=S, kwargs...)
merge(sequences::Sequence...; kwargs...) = merge_internal(sequences...; kwargs...)
function merge_internal(sequences...; name=:Sequence, wait_time=0.)
wb = Wait(wait_time)
new_blocks = ContainerBlock[]
for seq in sequences
append!(new_blocks, map(b -> b[2], seq.blocks))
push!(new_blocks, wb)
end
new_blocks = new_blocks[1:end-1]
return Sequence(new_blocks; scanner=sequences[1].scanner, name=name)
end
end
\ No newline at end of file
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