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

Add center_halfway flag

parent d9eafa60
No related branches found
No related tags found
No related merge requests found
......@@ -11,11 +11,12 @@ Adds a readout event with `nsamples` readouts.
## Parameters
- `nsamples`: number of samples in the readout.
- `center_halfway`: by default the `time_to_center` is assumed to be half of the `duration`. Set this to false to disable this assumption.
## Variables
- `dwell_time`: Time between each readout sample in ms.
- `duration`: Total duration of the ADC event in ms.
- `time_to_center`: time till the center of k-space (assumed to be `duration/2` if not set explicitly).
- `time_to_center`: time till the center of k-space.
"""
struct ADC <: BuildingBlock
nsamples :: Integer
......@@ -23,18 +24,18 @@ struct ADC <: BuildingBlock
time_to_center :: Union{Nothing, VariableType}
end
function ADC(nsamples; dwell_time=nothing, time_to_center=nothing, kwargs...)
function ADC(nsamples; dwell_time=nothing, time_to_center=nothing, center_halfway=true, kwargs...)
res = ADC(
nsamples,
get_free_variable(dwell_time),
time_to_center isa VariableType ? time_to_center : nothing
get_free_variable(time_to_center),
)
@constraint global_model() res.dwell_time >= 0
if time_to_center isa VariableType
@constraint global_model() time_to_center >= 0
@constraint global_model() time_to_center <= duration(res)
if center_halfway
@constraint global_model() 2 * res.time_to_center == duration(res)
else
apply_simple_constraint!(effective_time(res), time_to_center)
@constraint global_model() res.time_to_center >= 0
@constraint global_model() res.time_to_center <= duration(res)
end
set_simple_constraints!(res, kwargs)
return res
......@@ -42,9 +43,9 @@ end
dwell_time(adc::ADC) = adc.dwell_time
duration(adc::ADC) = adc.nsamples * dwell_time(adc)
time_to_center(adc::ADC) = isnothing(adc.time_to_center) ? duration(adc) / 2 : adc.time_to_center
time_to_center(adc::ADC) = adc.time_to_center
effective_time(adc::ADC) = time_to_center(adc)
variables(::Type{<:ADC}) = [dwell_time, duration, effective_time]
variables(::Type{<:ADC}) = [dwell_time, duration, time_to_center]
end
\ No newline at end of file
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