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
490bc5b2
Unverified
Commit
490bc5b2
authored
9 months ago
by
Michiel Cottaar
Browse files
Options
Downloads
Patches
Plain Diff
Add InstantPulse extension
parent
0d29983d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Add InstantPulse and InstantGradient pulseq extension support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sequence_io/pulseq.jl
+41
-11
41 additions, 11 deletions
src/sequence_io/pulseq.jl
with
41 additions
and
11 deletions
src/sequence_io/pulseq.jl
+
41
−
11
View file @
490bc5b2
...
...
@@ -3,9 +3,10 @@ Module converting MRIBuilder sequences to and from sequences recognised by [`Pul
"""
module
Pulseq
import
Interpolations
:
linear_interpolation
import
..
PulseqIO
.
Types
:
PulseqSequence
,
PulseqBlock
,
PulseqTrapezoid
,
PulseqGradient
,
PulseqRFPulse
,
PulseqShape
,
PulseqADC
,
PulseqExtension
import
...
Containers
:
Sequence
,
BuildingBlock
,
BaseBuildingBlock
,
events
,
waveform
,
iter_blocks
import
...
Components
:
GenericPulse
,
ADC
,
RFPulseComponent
import
..
PulseqIO
.
Types
:
PulseqSequence
,
PulseqBlock
,
PulseqTrapezoid
,
PulseqGradient
,
PulseqRFPulse
,
PulseqShape
,
PulseqADC
import
..
PulseqIO
.
Extensions
:
parse_extension
,
get_extension_name
,
add_extension_definition!
,
PulseqExtension
,
PulseqExtensionDefinition
import
...
Containers
:
Sequence
,
BuildingBlock
,
BaseBuildingBlock
,
events
,
waveform
,
iter_blocks
,
start_time
import
...
Components
:
GenericPulse
,
ADC
,
RFPulseComponent
,
InstantPulse
,
InstantGradient
import
...
Scanners
:
Scanner
import
...
Variables
:
variables
,
make_generic
...
...
@@ -111,7 +112,7 @@ function PulseqSequence(seq::Sequence{S}) where {S}
BlockDurationRaster
=
1e-9
,
RadiofrequencyRasterTime
=
1e-9
,
GradientRasterTime
=
1e-9
,
TotalDuration
=
duration
(
seq
)
*
1e-3
,
TotalDuration
=
variables
.
duration
(
seq
)
*
1e-3
,
B0
=
seq
.
scanner
.
B0
,
)
blocks
=
[
PulseqBlock
(
block
;
definitions
...
)
for
(
_
,
block
)
in
iter_blocks
(
seq
)]
...
...
@@ -125,12 +126,15 @@ end
function
PulseqBlock
(
block
::
BaseBuildingBlock
;
BlockDurationRaster
,
AdcRasterTime
,
kwargs
...
)
rf
=
nothing
adc
=
nothing
ext
=
[]
for
(
key
,
event
)
in
events
(
block
)
if
event
isa
RFPulseComponent
gen
=
make_generic
(
event
)
if
event
isa
InstantPulse
push!
(
ext
,
(
Int
(
div
(
start_time
(
block
,
key
),
1e-3
,
RoundNearest
)),
event
))
elseif
event
isa
RFPulseComponent
if
!
isnothing
(
rf
)
error
(
"Pulseq does not support a single building block containing multiple RF pulses."
)
end
gen
=
make_generic
(
event
)
rf
=
PulseqRFPulse
(
maximum
(
gen
.
amplitude
)
*
1e3
,
PulseqShape
(
gen
.
amplitude
./
maximum
(
gen
.
amplitude
)),
...
...
@@ -140,14 +144,14 @@ function PulseqBlock(block::BaseBuildingBlock; BlockDurationRaster, AdcRasterTim
0.
,
0.
)
elseif
ev
en
t
isa
ADC
elseif
g
en
isa
ADC
if
!
isnothing
(
rf
)
error
(
"Pulseq does not support a single building block containing multiple ADC events."
)
end
adc
=
PulseqADC
(
variables
.
nsamples
(
ev
en
t
),
div
(
variables
.
dwell_time
(
ev
en
t
),
AdcRasterTime
,
RoundNearest
),
Int
(
div
(
delay
,
1e-3
,
RoundNearest
)),
variables
.
nsamples
(
g
en
),
div
(
variables
.
dwell_time
(
g
en
),
AdcRasterTime
,
RoundNearest
),
Int
(
div
(
start_time
(
block
,
key
)
,
1e-3
,
RoundNearest
)),
0.
,
0.
)
else
...
...
@@ -176,8 +180,34 @@ function PulseqBlock(block::BaseBuildingBlock; BlockDurationRaster, AdcRasterTim
rf
,
grads
...
,
adc
,
Tuple
{
PulseqExtension
,
Int
}[]
ext
)
end
# I/O of InstantPulse
function
parse_extension
(
ext
::
PulseqExtensionDefinition
{
:
InstantPulse
})
mapping
=
Dict
{
Int
,
InstantPulse
}()
for
line
in
ext
.
content
(
id
,
delay
,
flip_angle
,
phase
)
=
parse
.
((
Int
,
Float64
,
Float64
,
Float64
),
split
(
line
))
mapping
[
id
]
=
(
delay
,
InstantPulse
(
flip_angle
,
phase
,
nothing
))
end
return
mapping
end
get_extension_name
(
::
Tuple
{
<:
Number
,
InstantPulse
})
=
:
InstantPulse
function
add_extension_definition!
(
content
::
Vector
{
String
},
obj
::
Tuple
{
Int
,
InstantPulse
})
to_store
=
(
obj
[
1
],
obj
[
2
]
.
flip_angle
,
obj
[
2
]
.
phase
)
for
line
in
content
(
id
,
this_line
...
)
=
parse
.
((
Int
,
Int
,
Float64
,
Float64
),
split
(
line
))
if
all
(
to_store
.
≈
this_line
)
return
id
end
end
push!
(
content
,
"
$
(length(content) + 1) "
*
join
(
string
.
(
to_store
),
" "
))
return
length
(
content
)
end
end
\ No newline at end of file
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