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

Use iter for readout_times rather than custom implementation

parent fdd85ba6
No related branches found
No related tags found
No related merge requests found
module Abstract module Abstract
import ...Variables: AbstractBlock, duration, effective_time, gradient_strength, amplitude, phase, VariableType import ...Variables: AbstractBlock, duration, effective_time, gradient_strength, amplitude, phase, VariableType
import ...Components.Readouts: readout_times import ...Components.Readouts: readout_times
import ...Components: BaseComponent, InstantPulse, InstantGradient import ...Components: BaseComponent, InstantPulse, InstantGradient, ReadoutComponent
""" """
Parent type for `BuildingBlock` or `BaseSequence`, i.e., any building block that contains other MRI components/blocks. Parent type for `BuildingBlock` or `BaseSequence`, i.e., any building block that contains other MRI components/blocks.
...@@ -47,13 +47,6 @@ effective_time(container::ContainerBlock, index, indices...) = start_time(contai ...@@ -47,13 +47,6 @@ effective_time(container::ContainerBlock, index, indices...) = start_time(contai
effective_time(block::Tuple{<:VariableType, <:AbstractBlock}) = block[1] + effective_time(block[2]) effective_time(block::Tuple{<:VariableType, <:AbstractBlock}) = block[1] + effective_time(block[2])
"""
readout_times(sequence/ADC)
Return the times of all of the readout events in ms.
"""
function readout_times end
""" """
edge_times(container) edge_times(container)
...@@ -125,4 +118,12 @@ Returns all the [`InstantGradient`](@ref) within the sequence with their timings ...@@ -125,4 +118,12 @@ Returns all the [`InstantGradient`](@ref) within the sequence with their timings
iter_instant_gradients(container::ContainerBlock) = iter(container, Val(:instantgradient)) iter_instant_gradients(container::ContainerBlock) = iter(container, Val(:instantgradient))
iter(component::Tuple{<:Number, <:InstantGradient}, ::Val{:instantgradient}) = [component] iter(component::Tuple{<:Number, <:InstantGradient}, ::Val{:instantgradient}) = [component]
"""
readout_times(sequence)
Returns all the times that the sequence will readout.
"""
readout_times(container::ContainerBlock) = [time for (time, _) in iter(container, Val(:readout))]
iter(component::Tuple{<:Number, <:ReadoutComponent}, ::Val{:readout}) = [(time, nothing) for time in readout_times(component[2])]
end end
\ No newline at end of file
...@@ -100,14 +100,6 @@ repetition_time(bs::BaseSequence) = duration(bs) ...@@ -100,14 +100,6 @@ repetition_time(bs::BaseSequence) = duration(bs)
duration(bs::BaseSequence{0}) = 0. duration(bs::BaseSequence{0}) = 0.
duration(bs::BaseSequence) = sum(duration.(bs); init=0.) duration(bs::BaseSequence) = sum(duration.(bs); init=0.)
function readout_times(seq::BaseSequence)
res = Float64[]
for (index, block) in enumerate(seq)
append!(res, readout_times(block) .+ start_time(seq, index))
end
return res
end
function edge_times(seq::BaseSequence) function edge_times(seq::BaseSequence)
res = Float64[] res = Float64[]
for (index, block) in enumerate(seq) for (index, block) in enumerate(seq)
......
...@@ -208,16 +208,6 @@ function bmat_gradient(bb::BaseBuildingBlock, qstart, index1, index2) ...@@ -208,16 +208,6 @@ function bmat_gradient(bb::BaseBuildingBlock, qstart, index1, index2)
end end
bmat_gradient(bb::BaseBuildingBlock, qstart) = bmat_gradient(bb, qstart, nothing, nothing) bmat_gradient(bb::BaseBuildingBlock, qstart) = bmat_gradient(bb, qstart, nothing, nothing)
function readout_times(bb::BaseBuildingBlock)
res = Float64[]
for (key, event) in events(bb)
if event isa ReadoutComponent
append!(res, readout_times(event) .+ start_time(bb, key))
end
end
return res
end
function edge_times(bb::BaseBuildingBlock) function edge_times(bb::BaseBuildingBlock)
res = Float64[] res = Float64[]
for key in keys(bb) for key in keys(bb)
......
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