From 126157885d88cb6d7a102cb5af5beacd5b10badc Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk> Date: Wed, 6 Mar 2024 17:00:28 +0000 Subject: [PATCH] Add start time to events --- src/containers/base_sequences.jl | 2 +- src/containers/building_blocks.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containers/base_sequences.jl b/src/containers/base_sequences.jl index b0a1c6d..cb98596 100644 --- a/src/containers/base_sequences.jl +++ b/src/containers/base_sequences.jl @@ -160,7 +160,7 @@ Converst object into something that can be included in the sequence: to_block(cb::ContainerBlock) = cb to_block(s::Symbol) = to_block(Val(s)) to_block(s::Union{VariableType, Nothing, Val{:min}, Val{:max}}) = Wait(s) -to_block(ec::EventComponent) = BuildingBlock([(0., 0.), (duration(ec), 0.)], [(1, ec)]) +to_block(ec::EventComponent) = BuildingBlock([(0., 0.), (duration(ec), 0.)], [(1, (0., ec))]) function make_generic(seq::BaseSequence) diff --git a/src/containers/building_blocks.jl b/src/containers/building_blocks.jl index 2293399..4b59f4b 100644 --- a/src/containers/building_blocks.jl +++ b/src/containers/building_blocks.jl @@ -265,7 +265,7 @@ Scanner constraints are automatically applied. - `group`: group of the gradient waveform """ struct BuildingBlock <: BaseBuildingBlock - parts :: Vector{<:BaseComponent} + parts :: Vector{Union{GradientWaveform, Tuple{Number, EventComponent}}} end function BuildingBlock(waveform::AbstractVector, events::AbstractVector; orientation=nothing, group=nothing) @@ -278,7 +278,7 @@ function BuildingBlock(waveform::AbstractVector, events::AbstractVector; orienta events = [(i+1, e) for (i, e) in events] end - components = BaseComponent[] + components = Union{GradientWaveform, Tuple{Number, EventComponent}}[] for (index_grad, ((prev_time, prev_grad), (time, grad))) in enumerate(zip(waveform[1:end-1], waveform[2:end])) duration = time - prev_time if norm(prev_grad) <= 1e-12 && norm(grad) <= 1e-12 -- GitLab