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
ade4e941
Verified
Commit
ade4e941
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Add walker for generic container
parent
db3804dd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pathways.jl
+17
-12
17 additions, 12 deletions
src/pathways.jl
with
17 additions
and
12 deletions
src/pathways.jl
+
17
−
12
View file @
ade4e941
module
Pathways
module
Pathways
import
LinearAlgebra
:
norm
import
LinearAlgebra
:
norm
import
StaticArrays
:
SVector
,
SMatrix
,
MVector
,
MMatrix
import
StaticArrays
:
SVector
,
SMatrix
,
MVector
,
MMatrix
import
..
BuildingBlocks
:
BuildingBlock
,
GradientBlock
,
RFPulseBlock
import
..
BuildingBlocks
:
BuildingBlock
,
GradientBlock
,
RFPulseBlock
,
ContainerBlock
,
get_children_blocks
import
..
Containers
:
Sequence
import
..
Containers
:
Sequence
import
..
Variables
:
qvec
,
qval
,
bmat_gradient
,
VariableType
import
..
Variables
:
qvec
,
qval
,
bmat_gradient
,
VariableType
,
start_time
,
effective_time
"""
"""
...
@@ -58,9 +58,9 @@ struct Pathway
...
@@ -58,9 +58,9 @@ struct Pathway
bmat
::
Dict
{
Any
,
SMatrix
{
3
,
3
,
VariableType
,
9
}}
bmat
::
Dict
{
Any
,
SMatrix
{
3
,
3
,
VariableType
,
9
}}
end
end
function
Pathway
(
sequence
::
Sequence
,
pulse_effects
::
AbstractVector
,
readout_index
::
Integer
)
function
Pathway
(
sequence
::
Sequence
,
pulse_effects
::
AbstractVector
,
readout_index
::
Integer
=
1
)
walker
=
PathwayWalker
()
walker
=
PathwayWalker
()
walk_pathway!
(
sequence
,
interpret_pulse_effects
.
(
pulse_effects
),
walker
,
Ref
(
readout_index
))
walk_pathway!
(
sequence
,
walker
,
interpret_pulse_effects
.
(
pulse_effects
),
Ref
(
readout_index
))
return
Pathway
(
return
Pathway
(
sequence
,
sequence
,
pulse_effects
,
pulse_effects
,
...
@@ -256,10 +256,6 @@ PathwayWalker() = PathwayWalker(
...
@@ -256,10 +256,6 @@ PathwayWalker() = PathwayWalker(
Computes the effect of a specific [`BuildingBlock`](@ref) (starting at `start_time`) on the [`PathwayWalker`](@ref).
Computes the effect of a specific [`BuildingBlock`](@ref) (starting at `start_time`) on the [`PathwayWalker`](@ref).
This needs to be defined for any [`ContainerBlock`](@ref) that the walker may encounter.
This might be as simpla as calling [`walk_pathway!`] on all the children (i.e., for a `Sequence`).
For individual pulses and gradients, the following behaviour is implemented:
For individual pulses and gradients, the following behaviour is implemented:
- If a pulse is encountered, call [`update_walker_pulse!`](@ref)`(walker, pulse_effects, pulse_effective_time)`
- If a pulse is encountered, call [`update_walker_pulse!`](@ref)`(walker, pulse_effects, pulse_effective_time)`
- If a gradient is encountered, call [`update_walker_gradient!`](@ref)(gradient, walker, gradient_start_time)
- If a gradient is encountered, call [`update_walker_gradient!`](@ref)(gradient, walker, gradient_start_time)
...
@@ -270,16 +266,25 @@ This effective time can be passed on to [`update_walker_gradient!`](@ref) to all
...
@@ -270,16 +266,25 @@ This effective time can be passed on to [`update_walker_gradient!`](@ref) to all
The function should return `true` if the `Pathway` has reached its end (i.e., the final readout) and `false` otherwise.
The function should return `true` if the `Pathway` has reached its end (i.e., the final readout) and `false` otherwise.
"""
"""
function
walk_pathway!
(
grad
::
GradientBlock
,
walker
::
PathwayWalker
,
pulse_effects
::
Vector
{
Symbol
},
nreadout
::
Ref
{
Int
},
start_time
=
0.
::
VariableType
)
function
walk_pathway!
(
grad
::
GradientBlock
,
walker
::
PathwayWalker
,
pulse_effects
::
Vector
{
Symbol
},
nreadout
::
Ref
{
Int
},
block_
start_time
=
0.
::
VariableType
)
update_walker_gradient!
(
grad
,
walker
,
start_time
)
update_walker_gradient!
(
grad
,
walker
,
block_
start_time
)
return
false
return
false
end
end
function
walk_pathway!
(
pulse
::
RFPulseBlock
,
walker
::
PathwayWalker
,
pulse_effects
::
Vector
{
Symbol
},
nreadout
::
Ref
{
Int
},
start_time
=
0.
::
VariableType
)
function
walk_pathway!
(
pulse
::
RFPulseBlock
,
walker
::
PathwayWalker
,
pulse_effects
::
Vector
{
Symbol
},
nreadout
::
Ref
{
Int
},
block_
start_time
=
0.
::
VariableType
)
update_walker_pulse
(
walker
,
pulse_effects
,
nreadout
,
start_time
+
effective_time
(
pulse
))
update_walker_pulse
(
walker
,
pulse_effects
,
nreadout
,
block_
start_time
+
effective_time
(
pulse
))
return
iszero
(
length
(
pulse_effects
))
&&
iszero
(
nreadout
[])
return
iszero
(
length
(
pulse_effects
))
&&
iszero
(
nreadout
[])
end
end
function
walk_pathway!
(
container
::
ContainerBlock
,
walker
::
PathwayWalker
,
pulse_effects
::
Vector
{
Symbol
},
nreadout
::
Ref
{
Int
},
block_start_time
=
0.
::
VariableType
)
for
(
index
,
child
)
in
get_children_blocks
(
container
)
if
walk_pathway!
(
child
,
walker
,
pulse_effects
,
nreadout
,
block_start_time
+
start_time
(
container
,
index
))
return
true
end
end
return
false
end
"""
"""
update_walker_pulse!(walker::PathwayWalker, pulse_effects::Vector, pulse_time)
update_walker_pulse!(walker::PathwayWalker, pulse_effects::Vector, pulse_time)
...
...
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