Skip to content
Snippets Groups Projects

Define variables through new @defvar macro

Merged Michiel Cottaar requested to merge new_variables into main
4 files
+ 95
97
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 19
19
@@ -19,16 +19,16 @@
(0.21, 0., iszero),
(0.23, 0., isnan),
]
@test phase_check(phase(seq, time))
@test amplitude(seq, time) ampl
@test phase_check(variables.phase(seq, time))
@test variables.amplitude(seq, time) ampl
end
# Single ADC event
@test length(readout_times(seq)) == 1024
@test readout_times(seq)[1] 0.22 + 5 + 0.02 + 0.5 * 0.3125
@test readout_times(seq)[end] 0.22 + 5 + 0.02 + 1023.5 * 0.3125
@test variables.readout_times(seq)[1] 0.22 + 5 + 0.02 + 0.5 * 0.3125
@test variables.readout_times(seq)[end] 0.22 + 5 + 0.02 + 1023.5 * 0.3125
@test TR(seq) 0.22 + 5 + 0.02 + 1024 * 0.3125
@test variables.TR(seq) 0.22 + 5 + 0.02 + 1024 * 0.3125
end
@testset "read all v1.4.0 files in 01_from_FID_to_PRESS" begin
path = joinpath(directory, "01_from_FID_to_PRESS_v140")
@@ -45,7 +45,7 @@
seq = read_sequence(fn)
@test length(seq) == 2
(index, pulse) = events(seq[1])[1]
@test flip_angle(pulse) 90
@test variables.flip_angle(pulse) 90
@test start_time(seq, 1, index) 0.1 # determined by RF dead time
@test end_time(seq, 1, index) 0.6 # RF dead time + RF duration
@test phase(seq, 0.3) == 0
@@ -57,8 +57,8 @@
29.730 # Delay until ADC start (to get start at ADC at TE=30)
)
@test length(readout_times(seq)) == 8192
@test readout_times(seq)[1] start_adc + 0.5 * 0.03125
@test readout_times(seq)[end] start_adc + 8191.5 * 0.03125
@test variables.readout_times(seq)[1] start_adc + 0.5 * 0.03125
@test variables.readout_times(seq)[end] start_adc + 8191.5 * 0.03125
end
@testset "check 01_from_FID_to_PRESS/06_PRESS_center.seq" begin
fn = joinpath(directory, "01_from_FID_to_PRESS_v140", "06_PRESS_center.seq")
@@ -69,19 +69,19 @@
#@test flip_angle(excitation) ≈ 90
@test start_time(seq, 1, index) 0.1 # determined by RF dead time
@test end_time(seq, 1, index) 3.1 # RF dead time + RF duration
@test phase(seq, 0.3) 0 + rad2deg(0.5)
@test phase(seq, 1.6) 0
@test length(readout_times(seq)) == 4096
@test variables.phase(seq, 0.3) 0 + rad2deg(0.5)
@test variables.phase(seq, 1.6) 0
@test length(variables.readout_times(seq)) == 4096
refocus_pulses = (
events(seq[3])[1][2],
events(seq[5])[1][2],
)
for p in refocus_pulses
@test duration(p) 3 # should have been 4 for refocus pulses, but there is an error in the matlab generation
@test phase(p, 0.) 90 rtol=1e-5
@test phase(p, 0.38) 90 + rad2deg(0.5) rtol=1e-5
@test phase(p, 1.5) 90 rtol=1e-5
@test variables.duration(p) 3 # should have been 4 for refocus pulses, but there is an error in the matlab generation
@test variables.phase(p, 0.) 90 rtol=1e-5
@test variables.phase(p, 0.38) 90 + rad2deg(0.5) rtol=1e-5
@test variables.phase(p, 1.5) 90 rtol=1e-5
end
end
# JSON encoding has not been implemented yet
@@ -100,12 +100,12 @@
write_sequence(io, seq_orig, format=:serialize)
seek(io, 0)
seq_json = read_sequence(io, format=:serialize)
@test TR(seq_orig) == TR(seq_json)
@test variables.TR(seq_orig) == variables.TR(seq_json)
@test length(seq_orig) == length(seq_json)
@test all(duration.(seq_orig) .== duration.(seq_json))
@test iszero(length(iter_instant_gradients(seq_json)))
@test iszero(length(iter_instant_pulses(seq_json)))
@test all(readout_times(seq_json) .== readout_times(seq_orig))
@test all(variables.readout_times(seq_json) .== variables.readout_times(seq_orig))
end
end
end
@@ -119,12 +119,12 @@
write_sequence(io, seq_orig; format=:serialize)
seek(io, 0)
seq_json = read_sequence(io; format=:serialize)
@test TR(seq_orig) == TR(seq_json)
@test variables.TR(seq_orig) == variables.TR(seq_json)
@test length(seq_orig) == length(seq_json)
@test all(duration.(seq_orig) .== duration.(seq_json))
@test length(iter_instant_gradients(seq_json)) == length(iter_instant_gradients(seq_json))
@test length(iter_instant_pulses(seq_json)) == length(iter_instant_pulses(seq_json))
@test all(readout_times(seq_json) .== readout_times(seq_orig))
@test all(variables.readout_times(seq_json) .== variables.readout_times(seq_orig))
end
end
end
\ No newline at end of file
Loading