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

Fix raster timings and effect on min_duration

parent fe502e57
No related branches found
No related tags found
1 merge request!1Add writing to Pulseq files
...@@ -23,11 +23,14 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof ...@@ -23,11 +23,14 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof
stated_duration = pulseq.duration * BlockDurationRaster * 1e3 stated_duration = pulseq.duration * BlockDurationRaster * 1e3
events = [] events = []
min_duration = 0.
if !isnothing(pulseq.rf) if !isnothing(pulseq.rf)
if isnothing(pulseq.rf.time) if isnothing(pulseq.rf.time)
time = ((1:length(pulseq.rf.magnitude.samples)) .- 0.5) .* RadiofrequencyRasterTime .* 1e3 time = ((1:length(pulseq.rf.magnitude.samples)) .- 0.5) .* RadiofrequencyRasterTime .* 1e3
rf_dur = length(pulseq.rf.magnitude.samples) * RadiofrequencyRasterTime * 1e3
else else
time = pulseq.rf.time.samples .* 1e3 time = pulseq.rf.time.samples .* 1e3
rf_dur = maximum(time)
end end
push!(events, ( push!(events, (
pulseq.rf.delay * 1e-3, pulseq.rf.delay * 1e-3,
...@@ -37,11 +40,12 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof ...@@ -37,11 +40,12 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof
rad2deg.(pulseq.rf.phase.samples .+ pulseq.rf.phase_offset .+ pulseq.rf.frequency .* time .* 2π) rad2deg.(pulseq.rf.phase.samples .+ pulseq.rf.phase_offset .+ pulseq.rf.frequency .* time .* 2π)
) )
)) ))
min_duration = max(min_duration, events[end][1] + rf_dur)
end end
if !isnothing(pulseq.adc) if !isnothing(pulseq.adc)
dwell_time = pulseq.adc.dwell * 1e-6 dwell_time = pulseq.adc.dwell * 1e-6
push!(events, ( push!(events, (
pulseq.adc.delay * 1e-3 pulseq.adc.delay * 1e-3,
ADC( ADC(
pulseq.adc.num, pulseq.adc.num,
dwell_time, dwell_time,
...@@ -49,11 +53,12 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof ...@@ -49,11 +53,12 @@ function BuildingBlock(pulseq::PulseqBlock; version, BlockDurationRaster, Radiof
1. 1.
) )
)) ))
min_duration = max(min_duration, events[end][1] + duration(events[end][2]))
end end
grads = [pulseq.gx, pulseq.gy, pulseq.gz] grads = [pulseq.gx, pulseq.gy, pulseq.gz]
min_duration = max( min_duration = max(
maximum(e[1] + duration(e[2]) for e in events; init=0.), min_duration,
maximum(vcat(_control_times.(grads, GradientRasterTime)...); init=0.) maximum(vcat(_control_times.(grads, GradientRasterTime)...); init=0.)
) )
......
@testset "test_IO.jl" begin @testset "test_IO.jl" begin
directory = joinpath(pwd(), "example_pulseseq") directory = joinpath(pwd(), "test", "example_pulseseq")
@testset "read v1.3.1 fiddisp.seq file" begin @testset "read v1.3.1 fiddisp.seq file" begin
seq = read_sequence(joinpath(directory, "fiddisp_v131.seq")) seq = read_sequence(joinpath(directory, "fiddisp_v131.seq"))
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
@test length(events(seq[1])) == 1 @test length(events(seq[1])) == 1
(index, pulse) = events(seq[1])[1] (index, pulse) = events(seq[1])[1]
@test start_time(seq, 1, index) == 0.1 @test start_time(seq, 1, index) 0.1
@test end_time(seq, 1, index) == 0.22 @test end_time(seq, 1, index) 0.2195
for (time, ampl, phase_check) in [ for (time, ampl, phase_check) in [
(0.09, 0., isnan), (0.09, 0., isnan),
......
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