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

Fix duration calculation

parent 2023f056
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ struct NoGradient{N} <: GradientWaveform{N} ...@@ -23,7 +23,7 @@ struct NoGradient{N} <: GradientWaveform{N}
end end
end end
duration(ngb::NoGradient) = duration(ngb) duration(ngb::NoGradient) = ngb.duration
for func in (:qval, :gradient_strength, :slew_rate) for func in (:qval, :gradient_strength, :slew_rate)
@eval $func(::NoGradient{1}) = 0. @eval $func(::NoGradient{1}) = 0.
@eval $func(::NoGradient{3}) = zero(SVector{3, Float64}) @eval $func(::NoGradient{3}) = zero(SVector{3, Float64})
......
...@@ -24,7 +24,6 @@ Main interface: ...@@ -24,7 +24,6 @@ Main interface:
Sub-types need to implement: Sub-types need to implement:
- `Base.keys`: returns sequence of keys to all the components. - `Base.keys`: returns sequence of keys to all the components.
- `Base.getindex`: returns the actual component for each key. - `Base.getindex`: returns the actual component for each key.
- [`duration`](@ref): total duration of the building block.
""" """
abstract type BaseBuildingBlock <: ContainerBlock end abstract type BaseBuildingBlock <: ContainerBlock end
...@@ -126,6 +125,8 @@ function start_time(building_block::BaseBuildingBlock, index) ...@@ -126,6 +125,8 @@ function start_time(building_block::BaseBuildingBlock, index)
error("Building block with index '$index' not found") error("Building block with index '$index' not found")
end end
duration(bb::BaseBuildingBlock) = sum([duration(wv) for (_, wv) in waveform_sequence(bb)])
# Pathway support # Pathway support
""" """
waveform_sequence(building_block, first, last) waveform_sequence(building_block, first, last)
...@@ -259,8 +260,6 @@ make_generic(other_block::BaseBuildingBlock) = BuildingBlock(duration(other_bloc ...@@ -259,8 +260,6 @@ make_generic(other_block::BaseBuildingBlock) = BuildingBlock(duration(other_bloc
Base.keys(bb::BuildingBlock) = 1:length(bb.parts) Base.keys(bb::BuildingBlock) = 1:length(bb.parts)
Base.getindex(bb::BuildingBlock, i::Integer) = bb.parts[i] Base.getindex(bb::BuildingBlock, i::Integer) = bb.parts[i]
duration(bb::BuildingBlock) = sum(duration, waveform_sequence(bb); init=0.)
function get_pulse(bb::BuildingBlock) function get_pulse(bb::BuildingBlock)
pulses = [p for p in events(bb) if p isa RFPulseComponent] pulses = [p for p in events(bb) if p isa RFPulseComponent]
if length(pulses) == 0 if length(pulses) == 0
......
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