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

Adds fully defined RF pulse

parent 989563fd
No related branches found
No related tags found
No related merge requests found
module FixedPulses
import ...BuildingBlock: PulseBlock
import ...Variables: variables, duration
"""
FixedPulse(time, amplitude, phase)
FixedPulse(time, amplitude; phase=0., frequency=0.)
Create a Pulse profile that has been fully defined by N control point.
All arguments should be arrays of the same length N defining these control points.
- `time`: time since the start of this [`BuildingBlock`](@ref) in ms.
- `amplitude`: amplitude of the RF pulse at every timepoint in kHz.
- `phase`: phase of the RF pulse at every timpoint in degrees. If not set explicitly it will be determined by the provided starting `phase` (degrees) and the `frequency` (kHz).
"""
struct FixedPulse <: PulseBlock
time :: Vector{Float64}
amplitude :: Vector{Float64}
phase :: Vector{Float64}
function FixedPulse(time::AbstractVector{<:Number}, amplitude::AbstractVector{<:Number}, phase::AbstractVector{<:Number})
@assert length(time) == length(amplitude)
@assert length(time) == length(phase)
new(Float64.(time), Float64.(amplitude), Float64.(phase))
end
end
function FixedPulse(time::AbstractVector{<:Number}, amplitude::AbstractVector{<:Number}; phase=0., frequency=0.)
return FixedPulse(time, amplitude, (time .- time[1]) .* (frequency * 360) .+ phase)
end
FixedPulse(single_arg::Tuple) = FixedPulse(single_arg...)
variables(::Type{<:FixedPulse}) = []
duration(fg::FixedPulse) = maximum(fg.time)
Base.show(io::IO, fb::FixedPulse) = print(io, "FixedPulse for $(duration(fb)) ms")
end
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