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

Set single InstantGradient constructor

parent 49885ce8
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ include("delayed_events.jl") ...@@ -8,7 +8,7 @@ include("delayed_events.jl")
import .AbstractTypes: BaseComponent, GradientWaveform, EventComponent, RFPulseComponent, ReadoutComponent import .AbstractTypes: BaseComponent, GradientWaveform, EventComponent, RFPulseComponent, ReadoutComponent
import .GradientWaveforms: ConstantGradient, ChangingGradient, NoGradient, split_gradient import .GradientWaveforms: ConstantGradient, ChangingGradient, NoGradient, split_gradient
import .InstantGradients: InstantGradient1D, InstantGradient3D import .InstantGradients: InstantGradient
import .Pulses: GenericPulse, InstantPulse, SincPulse, ConstantPulse import .Pulses: GenericPulse, InstantPulse, SincPulse, ConstantPulse
import .Readouts: ADC, SingleReadout import .Readouts: ADC, SingleReadout
import .DelayedEvents: DelayedEvent import .DelayedEvents: DelayedEvent
......
module InstantGradients module InstantGradients
import StaticArrays: SVector, SMatrix import StaticArrays: SVector, SMatrix
import ...Variables: VariableType, duration, qval, bmat_gradient, get_free_variable, set_simple_constraints!, qval, effective_time, make_generic import ...Variables: VariableType, duration, qval, bmat_gradient, get_free_variable, set_simple_constraints!, effective_time, make_generic
import ..AbstractTypes: EventComponent, GradientWaveform import ..AbstractTypes: EventComponent, GradientWaveform
""" """
InstantGradient1D(; orientation=[1, 0, 0], group=nothing, variables...) InstantGradient1D(; orientation=nothing, group=nothing, variables...)
Defines an instantaneous gradient with given fixed `orientation` (default: x-direction). If the `orientation` is set an [`InstantGradient1D`](@ref) is returned, otherwise an [`InstantGradient3D`](@ref).
To have a variable `orientation`, see [`InstantGradient3D`](@ref).
## Parameters ## Parameters
- `orientation` sets the gradient orienation as a length-3 vector. If not set, the gradient can be in any direction. - `orientation` sets the gradient orienation as a length-3 vector. If not set, the gradient can be in any direction.
...@@ -20,20 +18,18 @@ To have a variable `orientation`, see [`InstantGradient3D`](@ref). ...@@ -20,20 +18,18 @@ To have a variable `orientation`, see [`InstantGradient3D`](@ref).
""" """
abstract type InstantGradient <: EventComponent end abstract type InstantGradient <: EventComponent end
""" function (::Type{InstantGradient})(; orientation=nothing, group=nothing, qval=nothing, variables...)
InstantGradient1D(; orientation=[1, 0, 0], group=nothing, variables...) if isnothing(orientaiton)
res = InstantGradient3D(get_free_variable.(qval), group)
Defines an instantaneous gradient with given fixed `orientation` (default: x-direction). else
res = InstantGradient1D(get_free_variable(qval), orientation, group)
To have a variable `orientation`, see [`InstantGradient3D`](@ref). end
set_simple_constraints!(res, variables)
## Parameters return res
- `orientation` sets the gradient orienation as a length-3 vector (default: x-direction). end
- `group`: name of the group to which this gradient belongs (used for scaling and rotating).
## Variables """
- [`qval`](@ref): Spatial frequency on which spins will be dephased due to this pulsed gradient in rad/um. An [`InstantGradient`](@ref) with a fixed orientation.
- [`spoiler_scale`](@ref): Length-scale on which spins will be dephased by exactly 2π in mm.
""" """
struct InstantGradient1D <: InstantGradient struct InstantGradient1D <: InstantGradient
qval :: VariableType qval :: VariableType
...@@ -41,28 +37,10 @@ struct InstantGradient1D <: InstantGradient ...@@ -41,28 +37,10 @@ struct InstantGradient1D <: InstantGradient
group :: Union{Nothing, Symbol} group :: Union{Nothing, Symbol}
end end
function InstantGradient1D(; orientation=[1, 0, 0], group=nothing, qval=nothing, variables...)
res = InstantGradient1D(qval, orientation, group)
set_simple_constraints!(res, variables)
return res
end
qval(ig::InstantGradient1D) = ig.qval qval(ig::InstantGradient1D) = ig.qval
""" """
InstantGradient3D(; group=nothing, variables...) An [`InstantGradient`](@ref) with a variable orientation.
Defines an instantaneous gradient without a fixed orientation.
To have a fixed `orientation`, see [`InstantGradient1D`](@ref).
## Parameters
- `group`: name of the group to which this gradient belongs (used for scaling and rotating).
## Variables
- [`qval`](@ref): Vector of spatial frequency on which spins will be dephased due to this pulsed gradient in rad/um.
- [`spoiler_scale`](@ref): Vector with length-scale on which spins will be dephased by exactly 2π in mm.
""" """
struct InstantGradient3D <: InstantGradient struct InstantGradient3D <: InstantGradient
qvec :: SVector{3, VariableType} qvec :: SVector{3, VariableType}
......
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