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
b5340fc6
Verified
Commit
b5340fc6
authored
1 year ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Add split_gradient function
parent
5bcb18de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gradients/changing_gradient_blocks.jl
+21
-3
21 additions, 3 deletions
src/gradients/changing_gradient_blocks.jl
src/gradients/constant_gradient_blocks.jl
+6
-0
6 additions, 0 deletions
src/gradients/constant_gradient_blocks.jl
src/gradients/gradients.jl
+1
-1
1 addition, 1 deletion
src/gradients/gradients.jl
with
28 additions
and
4 deletions
src/gradients/changing_gradient_blocks.jl
+
21
−
3
View file @
b5340fc6
module
ChangingGradientBlocks
module
ChangingGradientBlocks
import
StaticArrays
:
SVector
import
StaticArrays
:
SVector
import
...
Variables
:
VariableType
,
variables
import
...
BuildingBlocks
:
GradientBlock
import
JuMP
:
@constraint
,
@variable
,
Model
,
owner_model
import
JuMP
:
@constraint
,
@variable
,
Model
,
owner_model
import
...
Variables
:
VariableType
,
variables
,
get_free_variable
import
...
BuildingBlocks
:
GradientBlock
import
...
Variables
:
qvec
,
bmat_gradient
,
gradient_strength
,
slew_rate
,
duration
,
variables
,
VariableType
import
...
Variables
:
qvec
,
bmat_gradient
,
gradient_strength
,
slew_rate
,
duration
,
variables
,
VariableType
import
...
BuildingBlocks
:
GradientBlock
,
fixed
,
RFPulseBlock
import
...
BuildingBlocks
:
GradientBlock
,
fixed
,
RFPulseBlock
"""
"""
ChangingGradientBlock(grad1, slew_rate, duration, rotate, scale)
ChangingGradientBlock(
model,
grad1, slew_rate, duration, rotate, scale)
Underlying type for any linearly changing part in a gradient waveform.
Underlying type for any linearly changing part in a gradient waveform.
...
@@ -18,6 +18,7 @@ Usually, you do not want to create this object directly, use a gradient waveform
...
@@ -18,6 +18,7 @@ Usually, you do not want to create this object directly, use a gradient waveform
- `scale`: with which user-set parameter will this gradient be scaled (e.g., :bval). Default is no scaling.
- `scale`: with which user-set parameter will this gradient be scaled (e.g., :bval). Default is no scaling.
"""
"""
struct
ChangingGradientBlock
<:
GradientBlock
struct
ChangingGradientBlock
<:
GradientBlock
model
::
Model
gradient_strength_start
::
SVector
{
3
,
<:
VariableType
}
gradient_strength_start
::
SVector
{
3
,
<:
VariableType
}
slew_rate
::
SVector
{
3
,
<:
VariableType
}
slew_rate
::
SVector
{
3
,
<:
VariableType
}
duration
::
VariableType
duration
::
VariableType
...
@@ -66,4 +67,21 @@ end
...
@@ -66,4 +67,21 @@ end
variables
(
::
Type
{
<:
ChangingGradientBlock
})
=
[
duration
,
slew_rate
,
gradient_strength
,
qvec
]
variables
(
::
Type
{
<:
ChangingGradientBlock
})
=
[
duration
,
slew_rate
,
gradient_strength
,
qvec
]
"""
split_gradient(constant/changing_gradient_block, times...)
Split a single gradient at a given times.
All times are relative to the start of the gradient block (in ms).
Times are assumed to be in increasing order and between 0 and the duration of the gradient block.
For N times this returns a vector with the N+1 replacement [`ConstantGradientBlock`](@ref) or [`ChangingGradientBlock`](@ref) objects.
"""
function
split_gradient
(
cgb
::
ChangingGradientBlock
,
times
...::
VariableType
)
all_times
=
[
0.
,
times
...
]
durations
=
[
times
[
1
],
t
[
2
]
-
t
[
1
]
for
t
in
zip
(
times
[
1
:
end
-
1
],
times
[
2
:
end
]),
duration
(
cgb
)
-
times
[
end
]]
return
[
ChangingGradientBlock
(
cgb
.
gradient_strength
.+
cgb
.
slew_rate
.*
t
,
cgb
.
slew_rate
,
d
,
cgb
.
rotate
,
cgb
.
scale
)
for
(
t
,
d
)
in
zip
(
all_times
,
durations
)]
end
end
end
This diff is collapsed.
Click to expand it.
src/gradients/constant_gradient_blocks.jl
+
6
−
0
View file @
b5340fc6
...
@@ -5,6 +5,7 @@ import ...BuildingBlocks: GradientBlock
...
@@ -5,6 +5,7 @@ import ...BuildingBlocks: GradientBlock
import
JuMP
:
@constraint
,
@variable
,
Model
,
owner_model
import
JuMP
:
@constraint
,
@variable
,
Model
,
owner_model
import
...
Variables
:
qvec
,
bmat_gradient
,
gradient_strength
,
slew_rate
,
duration
,
variables
,
VariableType
import
...
Variables
:
qvec
,
bmat_gradient
,
gradient_strength
,
slew_rate
,
duration
,
variables
,
VariableType
import
...
BuildingBlocks
:
GradientBlock
,
fixed
,
RFPulseBlock
import
...
BuildingBlocks
:
GradientBlock
,
fixed
,
RFPulseBlock
import
..
ChangingGradientBlocks
:
split_gradient
"""
"""
ConstantGradientBlock(gradient_strength, duration, rotate, scale)
ConstantGradientBlock(gradient_strength, duration, rotate, scale)
...
@@ -59,4 +60,9 @@ end
...
@@ -59,4 +60,9 @@ end
variables
(
::
Type
{
<:
ConstantGradientBlock
})
=
[
duration
,
gradient_strength
,
qvec
]
variables
(
::
Type
{
<:
ConstantGradientBlock
})
=
[
duration
,
gradient_strength
,
qvec
]
function
split_gradient
(
cgb
::
ConstantGradientBlock
,
times
...::
VariableType
)
durations
=
[
times
[
1
],
t
[
2
]
-
t
[
1
]
for
t
in
zip
(
times
[
1
:
end
-
1
],
times
[
2
:
end
]),
duration
(
cgb
)
-
times
[
end
]]
return
[
ConstantGradientBlock
(
cgb
.
gradient_strength
,
d
,
cgb
.
rotate
,
cgb
.
scale
)
for
d
in
durations
]
end
end
end
This diff is collapsed.
Click to expand it.
src/gradients/gradients.jl
+
1
−
1
View file @
b5340fc6
...
@@ -14,8 +14,8 @@ They are still included here for clarity:
...
@@ -14,8 +14,8 @@ They are still included here for clarity:
"""
"""
module
Gradients
module
Gradients
include
(
"constant_gradient_blocks.jl"
)
include
(
"changing_gradient_blocks.jl"
)
include
(
"changing_gradient_blocks.jl"
)
include
(
"constant_gradient_blocks.jl"
)
include
(
"slice_selects.jl"
)
include
(
"slice_selects.jl"
)
#include("integrate_gradients.jl")
#include("integrate_gradients.jl")
...
...
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