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

Make nsamples a non-integer variable

parent 20ed1a0a
No related branches found
No related tags found
No related merge requests found
module ADCs
import JuMP: @constraint
import ...Variables: variables, dwell_time, duration, effective_time, get_free_variable, VariableType
import ...BuildingBlocks: BuildingBlock, apply_simple_constraint!, set_simple_constraints!
import ...Variables: variables, dwell_time, duration, effective_time, get_free_variable, VariableType, nsamples
import ...BuildingBlocks: BuildingBlock, apply_simple_constraint!, set_simple_constraints!, fixed
import ...BuildSequences: global_model
"""
......@@ -10,23 +10,23 @@ import ...BuildSequences: global_model
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
- `nsamples`: number of samples in the readout. This can be a non-integer value during optimisation
- `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.
"""
struct ADC <: BuildingBlock
nsamples :: Integer
nsamples :: VariableType
dwell_time :: VariableType
time_to_center :: VariableType
end
function ADC(nsamples; dwell_time=nothing, time_to_center=nothing, center_halfway=true, kwargs...)
function ADC(nsamples=nothing, dwell_time=nothing, time_to_center=nothing, center_halfway=true, kwargs...)
res = ADC(
nsamples,
get_free_variable(nsamples),
get_free_variable(dwell_time),
get_free_variable(time_to_center),
)
......@@ -41,11 +41,19 @@ function ADC(nsamples; dwell_time=nothing, time_to_center=nothing, center_halfwa
return res
end
nsamples(adc::ADC) = adc.nsamples
dwell_time(adc::ADC) = adc.dwell_time
duration(adc::ADC) = adc.nsamples * dwell_time(adc)
duration(adc::ADC) = nsamples(adc) * dwell_time(adc)
time_to_center(adc::ADC) = adc.time_to_center
effective_time(adc::ADC) = time_to_center(adc)
variables(::Type{<:ADC}) = [dwell_time, duration, time_to_center]
variables(::Type{<:ADC}) = [nsamples, dwell_time, duration, time_to_center]
function fixed(adc::ADC)
# round nsamples during fixing
nsamples = Int(round(adc.nsamples))
dwell_time = duration(adc) / nsamples
return ADC(nsamples, dwell_time, time_to_center(adc))
end
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