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

Fix some interfaces

parent a54dd318
No related branches found
No related tags found
No related merge requests found
...@@ -183,6 +183,9 @@ function LineReadout(adc::ADC; ramp_overlap=nothing, orientation=nothing, group= ...@@ -183,6 +183,9 @@ function LineReadout(adc::ADC; ramp_overlap=nothing, orientation=nothing, group=
return res return res
end end
Base.keys(::LineReadout) = (Val(:rise), Val(:flat), Val(:adc), Val(:fall))
Base.getindex(lr::LineReadout, ::Val{:adc}) = lr.adc
ramp_overlap(lr::LineReadout) = lr.ramp_overlap ramp_overlap(lr::LineReadout) = lr.ramp_overlap
inverse_fov(lr::LineReadout) = 1e3 * dwell_time(lr.adc) * gradient_strength(lr.trapezoid) inverse_fov(lr::LineReadout) = 1e3 * dwell_time(lr.adc) * gradient_strength(lr.trapezoid)
inverse_voxel_size(lr::LineReadout) = 1e3 * duration(lr.adc) * gradient_strength(lr.trapezoid) inverse_voxel_size(lr::LineReadout) = 1e3 * duration(lr.adc) * gradient_strength(lr.trapezoid)
......
...@@ -2,7 +2,7 @@ module EPIReadouts ...@@ -2,7 +2,7 @@ module EPIReadouts
import ...AllBuildingBlocks: LineReadout, Trapezoid, opposite_kspace_lines import ...AllBuildingBlocks: LineReadout, Trapezoid, opposite_kspace_lines
import ...Components: ADC import ...Components: ADC
import ...Variables: get_free_variable, VariableType, qval, qvec, set_simple_constraints!, resolution, inverse_voxel_size, inverse_fov, resolution, get_readout, apply_simple_constraint! import ...Variables: get_free_variable, VariableType, qval, qvec, set_simple_constraints!, resolution, inverse_voxel_size, inverse_fov, resolution, get_readout, apply_simple_constraint!
import ..BaseSequences: BaseSequence import ..BaseSequences: BaseSequence, get_index_single_TR
""" """
EPIReadout(resolution; ky_lines=-resolution[2]:resolution[2], recenter=false, group=:FOV, variables...) EPIReadout(resolution; ky_lines=-resolution[2]:resolution[2], recenter=false, group=:FOV, variables...)
...@@ -21,7 +21,7 @@ Defines an (accelerated) EPI readout. ...@@ -21,7 +21,7 @@ Defines an (accelerated) EPI readout.
- [`oversample`](@ref): by how much to oversample in the frequency-encode direcion. - [`oversample`](@ref): by how much to oversample in the frequency-encode direcion.
- [`dwell_time`](@ref): dwell time in the frequency-encode direction - [`dwell_time`](@ref): dwell time in the frequency-encode direction
""" """
struct EPIReadout <: BaseSequence{0} struct EPIReadout{N} <: BaseSequence{N}
start_gradient :: Trapezoid start_gradient :: Trapezoid
positive_line :: LineReadout positive_line :: LineReadout
negative_line :: LineReadout negative_line :: LineReadout
...@@ -39,7 +39,7 @@ function EPIReadout(resolution::AbstractVector{<:Integer}; recenter=false, group ...@@ -39,7 +39,7 @@ function EPIReadout(resolution::AbstractVector{<:Integer}; recenter=false, group
ky_lines = -resolution[2]:resolution[2] ky_lines = -resolution[2]:resolution[2]
end end
(pos, neg) = opposite_kspace_lines(; resolution=resolution[1], orientation=[1, 0, 0], group=group) (pos, neg) = opposite_kspace_lines(; resolution=resolution[1], orientation=[1, 0, 0], group=group)
res = EPIReadout( res = EPIReadout{2 * length(ky_lines) + recenter}(
Trapezoid(group=group), Trapezoid(group=group),
pos, pos,
neg, neg,
...@@ -53,6 +53,9 @@ function EPIReadout(resolution::AbstractVector{<:Integer}; recenter=false, group ...@@ -53,6 +53,9 @@ function EPIReadout(resolution::AbstractVector{<:Integer}; recenter=false, group
sign = isodd(length(ky_lines)) ? -1 : 1 sign = isodd(length(ky_lines)) ? -1 : 1
apply_simple_constraint!(qvec(res.recenter_gradient), VariableType[sign * qval(pos)/2, -ky_lines[end] * res.ky_step, 0.]) apply_simple_constraint!(qvec(res.recenter_gradient), VariableType[sign * qval(pos)/2, -ky_lines[end] * res.ky_step, 0.])
end end
for shift in unique(ky_lines[2:end] - ky_lines[1:end-1])
res.blips[shift] = Trapezoid(orientation=[0, shift > 0 ? 1 : -1, 0], group=group, qval=abs(shift) * res.ky_step)
end
set_simple_constraints!(res, variables) set_simple_constraints!(res, variables)
return res return res
end end
...@@ -62,5 +65,23 @@ inverse_voxel_size(epi::EPIReadout) = [inverse_voxel_size(epi.positive_line), 1e ...@@ -62,5 +65,23 @@ inverse_voxel_size(epi::EPIReadout) = [inverse_voxel_size(epi.positive_line), 1e
resolution(epi::EPIReadout) = [resolution(epi.positive_line), maximum(abs.(epi.ky_lines))] resolution(epi::EPIReadout) = [resolution(epi.positive_line), maximum(abs.(epi.ky_lines))]
get_readout(epi::EPIReadout) = epi.positive_line get_readout(epi::EPIReadout) = epi.positive_line
function get_index_single_TR(epi::EPIReadout, index::Integer)
if index == 1
return epi.start_gradient
elseif !isnothing(epi.recenter_gradient) && index == length(epi)
return epi.recenter_gradient
end
current_line = div(index, 2, RoundDown)
if isodd(index)
line_shift = epi.ky_lines[current_line + 1] - epi.ky_lines[current_line]
return epi.blips[line_shift]
else
if isodd(current_line)
return epi.positive_line
else
return epi.negative_line
end
end
end
end end
\ No newline at end of file
...@@ -35,7 +35,7 @@ gradient_strength(cgb::ConstantGradient) = cgb.gradient_strength ...@@ -35,7 +35,7 @@ gradient_strength(cgb::ConstantGradient) = cgb.gradient_strength
slew_rate(::ConstantGradient1D) = 0. slew_rate(::ConstantGradient1D) = 0.
slew_rate(::ConstantGradient3D) = zero(SVector{3, Float64}) slew_rate(::ConstantGradient3D) = zero(SVector{3, Float64})
qval(cgb::ConstantGradient1D) = duration(cgb) * gradient_strength(cgb) * 2π qval(cgb::ConstantGradient1D) = duration(cgb) * gradient_strength(cgb) * 2π
qval(cgb::ConstantGradient3D) = @. duration(cgb) * gradient_strength(cgb) * 2π qval(cgb::ConstantGradient3D) = duration(cgb) .* gradient_strength(cgb) .* 2π
_mult(g1::VariableType, g2::VariableType) = g1 * g2 _mult(g1::VariableType, g2::VariableType) = g1 * g2
_mult(g1::AbstractVector, g2::AbstractVector) = g1 .* permutedims(g2) _mult(g1::AbstractVector, g2::AbstractVector) = g1 .* permutedims(g2)
......
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