- `orientation` sets the gradient orienation (ignored if `qvec` is set). Can be set to a vector for a fixed orientation. Otherwise the orientation will be aligned with the `rotate` (if set) or fully free (if `rotate` is nothing).
- `orientation` sets the gradient orienation (ignored if `qvec` is set). Can be set to a vector for a fixed orientation. Otherwise the orientation will be aligned with the `rotate` (if set) or fully free (if `rotate` is nothing). Set to :flip to point in the inverse of the user-provided `rotate`.
- `rotate`: with which user-set parameter will this gradient be rotated (e.g., :bvec). Default is no rotation.
- `scale`: with which user-set parameter will this gradient be scaled (e.g., :bval). Default is no scaling.
...
...
@@ -28,31 +28,40 @@ end
@global_model_constructorInstantGradientBlock
function InstantGradientBlock(model::Model;orientation=nothing,qval=nothing,qvec=nothing,rotate=nothing,scale=nothing)
used_qval=false
ifisnothing(qvec)
ifisnothing(orientation)
ifisnothing(rotate)
qvec=SVector{3}(
get_free_variable(nothing),
get_free_variable(nothing),
get_free_variable(nothing),
)
else
qvec=SVector{3}(
get_free_variable(qval),
0.,
0.,
)
used_qval=true
end
function interpret_orientation(orientation,qval,qvec,will_rotate)
if!isnothing(qvec)
return(false,qvec)
end
iforientation==:flip
@assertwill_rotate"setting `orientation=:flip` only makes sense if the `rotate` is set as well."
- `orientation` sets the gradient orienation. Can be set to a vector for a fixed orientation. Alternatively, can be set to :bvec (default) to rotate with the user-provided `bvecs` or to :neg_bvec to always be the reverse of the `bvecs`.
- `orientation` sets the gradient orienation (ignored if `qvec` is set). Can be set to a vector for a fixed orientation. Otherwise the orientation will be aligned with the `rotate` (if set) or fully free (if `rotate` is nothing). Set to :flip to point in the inverse of the user-provided `rotate`.
- `rotate`: with which user-set parameter will this gradient be rotated (e.g., :bvec). Default is no rotation.
- `scale`: with which user-set parameter will this gradient be scaled (e.g., :bval). Default is no scaling.
## Variables
Variables can be set during construction or afterwards as an attribute.
...
...
@@ -33,74 +37,90 @@ If not set, they will be determined during the sequence optimisation.
The [`bvalue`](@ref) can be constrained for multiple gradient pulses.
"""
mutable struct PulsedGradient<:GradientBlock
mutable struct PulsedGradient<:ContainerBlock
model::Model
orientation::Any
slew_rate::VariableType
rise_time::VariableType
flat_time::VariableType
rise::ChangingGradientBlock
flat::ConstantGradientBlock
fall::ChangingGradientBlock
slew_rate_vec::SVector{3,VariableType}
scaling::Union{Nothing,VariableType}
end
@global_model_constructorPulsedGradient
function PulsedGradient(model::Model;orientation=:bvec,slew_rate=nothing,rise_time=nothing,flat_time=nothing,kwargs...)
function PulsedGradient(model::Model;orientation=nothing,rise_time=nothing,flat_time=nothing,rotate=nothing,scale=nothing,kwargs...)
ifisnothing(orientation)&&isnothing(rotate)
rate_1d=nothing
slew_rate=(
get_free_variable(model,nothing),
get_free_variable(model,nothing),
get_free_variable(model,nothing),
)
else
rate_1d=get_free_variable(model,nothing)
@constraintmodelrate_1d>=0
ifisnothing(orientation)
rate_1d=get_free_variable(model,nothing)
slew_rate=(
rate_1d,
0.,
0.,
)
elseiforientation==:flip
@assert!isnothing(rotate)"setting `orientation=:flip` only makes sense if the `rotate` is set as well."