Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MRIBuilder.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michiel Cottaar
MRIBuilder.jl
Commits
44a2dffe
Unverified
Commit
44a2dffe
authored
9 months ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Update pathways to use @defvar
parent
25a97cb0
No related branches found
No related tags found
1 merge request
!2
Define variables through new @defvar macro
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/MRIBuilder.jl
+3
-3
3 additions, 3 deletions
src/MRIBuilder.jl
src/pathways.jl
+23
-37
23 additions, 37 deletions
src/pathways.jl
with
26 additions
and
40 deletions
src/MRIBuilder.jl
+
3
−
3
View file @
44a2dffe
...
...
@@ -8,7 +8,7 @@ include("build_sequences.jl")
include
(
"variables.jl"
)
include
(
"components/components.jl"
)
include
(
"containers/containers.jl"
)
#
include("pathways.jl")
include
(
"pathways.jl"
)
#include("parts/parts.jl")
#include("post_hoc.jl")
#include("sequences/sequences.jl")
...
...
@@ -31,8 +31,8 @@ export InstantPulse, ConstantPulse, SincPulse, GenericPulse, InstantGradient, Si
import
.
Containers
:
ContainerBlock
,
start_time
,
end_time
,
waveform
,
waveform_sequence
,
events
,
BaseBuildingBlock
,
BuildingBlock
,
Wait
,
BaseSequence
,
nrepeat
,
Sequence
,
AlternativeBlocks
,
match_blocks!
,
get_index_single_TR
,
readout_times
,
iter_blocks
,
iter_instant_gradients
,
iter_instant_pulses
export
ContainerBlock
,
start_time
,
end_time
,
waveform
,
waveform_sequence
,
events
,
BaseBuildingBlock
,
BuildingBlock
,
Wait
,
BaseSequence
,
nrepeat
,
Sequence
,
AlternativeBlocks
,
match_blocks!
,
get_index_single_TR
,
readout_times
,
iter_blocks
,
iter_instant_gradients
,
iter_instant_pulses
#
import .Pathways: Pathway, duration_transverse, duration_dephase, bval, bmat, get_pathway
#
export Pathway, duration_transverse, duration_dephase, bval, bmat, get_pathway
import
.
Pathways
:
Pathway
,
duration_transverse
,
duration_dephase
,
bval
,
bmat
,
get_pathway
export
Pathway
,
duration_transverse
,
duration_dephase
,
bval
,
bmat
,
get_pathway
#import .Parts: dwi_gradients, readout_event, excitation_pulse, refocus_pulse, Trapezoid, SliceSelect, LineReadout, opposite_kspace_lines, SpoiltSliceSelect, SliceSelectRephase, EPIReadout, interpret_image_size
#export dwi_gradients, readout_event, excitation_pulse, refocus_pulse, Trapezoid, SliceSelect, LineReadout, opposite_kspace_lines, SpoiltSliceSelect, SliceSelectRephase, EPIReadout, interpret_image_size
...
...
This diff is collapsed.
Click to expand it.
src/pathways.jl
+
23
−
37
View file @
44a2dffe
...
...
@@ -3,7 +3,7 @@ import LinearAlgebra: norm, tr
import
StaticArrays
:
SVector
,
SMatrix
import
..
Components
:
NoGradient
,
RFPulseComponent
,
ReadoutComponent
,
InstantGradient
,
GradientWaveform
import
..
Containers
:
BaseSequence
,
Sequence
,
BaseBuildingBlock
,
waveform
,
events
,
waveform_sequence
,
start_time
,
AlternativeBlocks
import
..
Variables
:
qvec
,
qval
,
qval3
,
bmat_gradient
,
VariableType
,
effective_time
,
duration
,
TR
,
bmat
,
bval
,
area_under_curve
,
duration_dephase
,
duration_transverse
,
VariableNotAvailable
import
..
Variables
:
VariableType
,
get_pathway
,
variables
,
@defvar
"""
...
...
@@ -71,6 +71,9 @@ function Pathway(sequence::Sequence, pulse_effects::AbstractVector, readout_inde
)
end
@defvar
function
duration_state
(
pathway
::
Pathway
,
transverse
,
positive
)
return
pathway
.
duration_states
[
duration_state_index
(
transverse
,
positive
)]
end
"""
duration_state(pathway::Pathway, transverse::Bool, positive::Bool)
...
...
@@ -83,10 +86,11 @@ The requested state can be set using `transverse` and `positive` as follows:
- `transverse=false`, `positive=false`: -longitudinal
- `transverse=true`, `positive=false`: -transverse
"""
function
duration_state
(
pathway
::
Pathway
,
transverse
,
positive
)
return
pathway
.
duration_states
[
duration_state_index
(
transverse
,
positive
)]
end
duration_state
@defvar
function
duration_transverse
(
pathway
::
Pathway
)
return
duration_state
(
pathway
,
true
,
true
)
+
duration_state
(
pathway
,
true
,
false
)
end
"""
duration_transverse(pathway::Pathway)
...
...
@@ -95,10 +99,11 @@ This determines the amount of T2-weighting as ``e^{t/T_2}``, where ``t`` is the
Also see [`duration_dephase`](@ref) for T2'-weighting.
"""
function
duration_transverse
(
pathway
::
Pathway
)
return
duration_state
(
pathway
,
true
,
true
)
+
duration_state
(
pathway
,
true
,
false
)
end
duration_transverse
@defvar
function
duration_dephase
(
pathway
::
Pathway
)
return
duration_state
(
pathway
,
true
,
true
)
-
duration_state
(
pathway
,
true
,
false
)
end
"""
duration_dephase(pathway::Pathway)
...
...
@@ -107,23 +112,23 @@ This determines the amount of T2'-weighting as ``e^{t/T_2'}``, where ``t`` is th
Also see [`duration_transverse`](@ref) for T2-weighting.
"""
function
duration_dephase
(
pathway
::
Pathway
)
return
duration_state
(
pathway
,
true
,
true
)
-
duration_state
(
pathway
,
true
,
false
)
end
duration_dephase
@defvar
net_dephasing
(
pathway
::
Pathway
)
=
pathway
.
qvec
"""
qvec
(pathway::Pathway)
net_dephasing
(pathway::Pathway)
Return net displacement vector in k-space/q-space experienced by the spins following a specific [`Pathway`](@ref).
Return net displacement vector in k-space/q-space experienced by the spins following a specific [`Pathway`](@ref)
in kHz/um
.
Only gradients active while the spins are in the transverse plane are considered.
Returns a NamedTuple with the `qvec` for all gradient groups.
"""
qvec
(
pathway
::
Pathway
)
=
pathway
.
qvec
net_dephasing
@defvar
area_under_curve
(
pathway
::
Pathway
)
=
norm
(
qvec
(
pathway
))
"""
area_under_curve(pathway::Pathway)
...
...
@@ -133,9 +138,10 @@ Only gradients active while the spins are in the transverse plane are considered
Returns a NamedTuple with the `area_under_curve` for all gradient groups.
"""
area_under_curve
(
pathway
::
Pathway
)
=
norm
(
qvec
(
pathway
))
area_under_curve
@defvar
bmat
(
pathway
::
Pathway
)
=
pathway
.
bmat
"""
bmat(pathway::Pathway)
...
...
@@ -145,8 +151,9 @@ Only gradients active while the spins are in the transverse plane are considered
Returns a NamedTuple with the `bmat` for all gradient groups.
"""
bmat
(
pathway
::
Pathway
)
=
pathway
.
bmat
bmat
@defvar
bval
(
pathway
::
Pathway
)
=
tr
(
bmat
(
pathway
))
"""
bval(pathway::Pathway)
...
...
@@ -156,7 +163,7 @@ Only gradients active while the spins are in the transverse plane will contribut
Returns a NamedTuple with the `bval` for all gradient groups.
"""
bval
(
pathway
::
Pathway
)
=
tr
(
bmat
(
pathway
))
bval
"""
...
...
@@ -168,27 +175,6 @@ Multiple pathways might be returned as an array or (named)tuple.
"""
function
get_pathway
end
for
fn
in
(
:
qvec
,
:
area_under_curve
,
:
bmat
,
:
bval
,
:
duration_dephase
,
:
duration_transverse
)
@eval
function
$fn
(
seq
::
Sequence
)
pathway
=
try
get_pathway
(
seq
)
catch
e
if
e
isa
MethodError
throw
(
VariableNotAvailable
(
typeof
(
seq
),
$
fn
))
end
rethrow
()
end
if
pathway
isa
Pathway
return
$
fn
(
pathway
)
elseif
pathway
isa
AbstractVector
||
pathway
isa
Tuple
return
$
fn
.
(
pathway
)
elseif
pathway
isa
NumedTuple
return
NamedTuple
(
k
=>
$
fn
(
v
)
for
(
k
,
v
)
in
pairs
(
pathway
))
end
error
(
"get_pathway returned unexpected type for
$
seq"
)
end
end
"""
interpret_pulse_effects(number_or_symbol)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment