Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/console/utilities/sequences/calibration/fid_tx_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import numpy as np
import pypulseq as pp

from console.utilities.sequences.system_settings import raster, system
from console.utilities.sequences.system_settings import raster
from console.utilities.sequences.system_settings import system as default_system


def constructor(
Expand All @@ -16,7 +17,8 @@ def constructor(
use_sinc: bool = False,
num_adc_samples: int = 256,
acq_bandwidth: float | int = 20e3,
ring_down_time: float = 2e-3
ring_down_time: float = 2e-3,
system: pp.Opts = default_system,
) -> tuple[pp.Sequence, np.ndarray]:
"""Construct transmit adjust sequence.

Expand All @@ -38,6 +40,8 @@ def constructor(
Acquisition bandwidth in Hz
ring_down_time
RF ring down time in s
system
Sequence system to be used for sequence construction

Returns
-------
Expand Down
8 changes: 6 additions & 2 deletions src/console/utilities/sequences/calibration/se_tx_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy as np
import pypulseq as pp

from console.utilities.sequences.system_settings import raster, system
from console.utilities.sequences.system_settings import raster
from console.utilities.sequences.system_settings import system as default_system


def constructor(
Expand All @@ -14,7 +15,8 @@ def constructor(
echo_time: float = 20e-3,
rf_duration: float = 400e-6,
acq_bandwidth: float | int = 50e3,
use_sinc: bool = False
use_sinc: bool = False,
system: pp.Opts = default_system,
) -> tuple[pp.Sequence, np.ndarray]:
"""Construct transmit adjust sequence.

Expand All @@ -34,6 +36,8 @@ def constructor(
Acquisition bandwidth in Hz
use_sinc
Use sinc pulse if True, block pulse otherwise
system
Sequence system to be used for sequence construction

Returns
-------
Expand Down
28 changes: 14 additions & 14 deletions src/console/utilities/sequences/spectrometry/fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ def constructor(

Parameters
----------
rf_duration, optional
Comment thread
h3lg3 marked this conversation as resolved.
RF duration in s, by default 200e-6
num_samples, optional
Number of ADC sample points, by default 256
acq_bandwidth, optional
Acquisition bandwidth in Hz, by default 20e3
use_sinc, optional
If set, sinc RF pulse is used, otherwise block pulse, by default False
time_bw_product, optional
Time bandwidth product, by default 4
flip_angle, optional
Flip angle of RF pulse, by default pi/2
system, optional
Sequence system to be used for sequence construction, by default default_system
rf_duration
RF duration in s
num_samples
Number of ADC sample points
acq_bandwidth
Acquisition bandwidth in Hz
use_sinc
If set, sinc RF pulse is used, otherwise block pulse
time_bw_product
Time bandwidth product
flip_angle
Flip angle of RF pulse
system
Sequence system to be used for sequence construction

Returns
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import pypulseq as pp

from console.utilities.sequences.system_settings import raster, system
from console.utilities.sequences.system_settings import raster
from console.utilities.sequences.system_settings import system as default_system


def constructor(
Expand All @@ -17,6 +18,7 @@ def constructor(
rf_duration: float = 400e-6,
channel: str = "x",
use_sinc: bool = False,
system: pp.Opts = default_system,
) -> pp.Sequence:
"""Construct spin echo spectrum sequence with projection gradient (1D).

Expand All @@ -38,6 +40,8 @@ def constructor(
Gradient channel to use for projection
use_sinc
RF pulse type, if true: sinc pulse is used, rect otherwise
system
Sequence system to be used for sequence construction

Returns
-------
Expand Down
32 changes: 17 additions & 15 deletions src/console/utilities/sequences/spectrometry/se_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def constructor(
use_sinc: bool = False,
time_bw_product: float = 4,
use_fid: bool = True,
system: pp.Opts | None = None,
system: pp.Opts = default_system,
) -> pp.Sequence:
"""Construct spin echo spectrum sequence.

Expand All @@ -35,6 +35,8 @@ def constructor(
Time-bandwidth product for the sinc pulse
use_fid
If true, only acquire FID part of the spin-echo
system
Sequence system to be used for sequence construction

Returns
-------
Expand All @@ -45,7 +47,7 @@ def constructor(
ValueError
Sequence timing check failed
"""
seq = pp.Sequence(system=system) if system is not None else pp.Sequence(system=default_system)
seq = pp.Sequence(system=system)

if use_fid:
seq.set_definition("Name", "se_decay_spectrum")
Expand All @@ -55,60 +57,60 @@ def constructor(
# Define RF pulses for excitation and refocusing
if use_sinc:
rf_90 = pp.make_sinc_pulse(
system=seq.system,
system=system,
flip_angle=pi / 2,
phase_offset=0,
duration=rf_duration,
time_bw_product=time_bw_product,
delay=seq.system.rf_dead_time,
delay=system.rf_dead_time,
)
rf_180 = pp.make_sinc_pulse(
system=seq.system,
system=system,
flip_angle=pi,
phase_offset=pi / 2,
duration=rf_duration,
time_bw_product=time_bw_product,
delay=seq.system.rf_dead_time,
delay=system.rf_dead_time,
)
else:
rf_90 = pp.make_block_pulse(
system=seq.system,
system=system,
flip_angle=pi / 2,
phase_offset=0,
duration=rf_duration,
delay=seq.system.rf_dead_time,
delay=system.rf_dead_time,
)
rf_180 = pp.make_block_pulse(
system=seq.system,
system=system,
flip_angle=pi,
phase_offset=pi / 2,
duration=rf_duration,
delay=seq.system.rf_dead_time,
delay=system.rf_dead_time,
)
# Define ADC duration
adc_duration = raster(val=num_samples / acq_bandwidth, precision=seq.system.adc_raster_time)
adc_duration = raster(val=num_samples / acq_bandwidth, precision=system.adc_raster_time)

# Define ADC event
adc = pp.make_adc(
num_samples=num_samples,
duration=adc_duration,
system=seq.system,
system=system,
)

# Calculate delays to achieve desired echo time
te_delay_1 = raster(
echo_time / 2 - rf_duration - rf_90.ringdown_time - rf_180.delay,
seq.system.grad_raster_time,
system.grad_raster_time,
)
if use_fid:
te_delay_2 = raster(
echo_time / 2 - rf_duration / 2 - rf_180.ringdown_time - adc.dead_time,
seq.system.grad_raster_time,
system.grad_raster_time,
)
else:
te_delay_2 = raster(
echo_time / 2 - rf_duration / 2 - adc_duration / 2 - rf_180.ringdown_time - adc.dead_time,
seq.system.grad_raster_time,
system.grad_raster_time,
)

seq.add_block(rf_90)
Expand Down
8 changes: 6 additions & 2 deletions src/console/utilities/sequences/spectrometry/t2_relaxation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy as np
import pypulseq as pp

from console.utilities.sequences.system_settings import raster, system
from console.utilities.sequences.system_settings import raster
from console.utilities.sequences.system_settings import system as default_system


def constructor(
Expand All @@ -13,7 +14,8 @@ def constructor(
repetition_time: float = 600e-3,
rf_duration: float = 400e-6,
num_samples: int = 64,
acq_bandwidth: float | int = 20e3
acq_bandwidth: float | int = 20e3,
system: pp.Opts = default_system,
) -> tuple[pp.Sequence, np.ndarray]:
"""Construct spin echo T2 relaxation sequence.

Expand All @@ -31,6 +33,8 @@ def constructor(
Number of data points to acquire
acq_bandwidth
Bandwidth of the acquisition in Hz
system
Sequence system to be used for sequence construction

Returns
-------
Expand Down
8 changes: 4 additions & 4 deletions src/console/utilities/sequences/system_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
block_duration_raster=1e-6,
adc_raster_time=1e-6,

# Time delay at the beginning of an RF event, SETS RF DELAY!
rf_dead_time=100e-6,
# time delay at the end of RF event
rf_ringdown_time=20e-6,
# Time delay at the beginning of an RF event, covered by rf_delay.
rf_dead_time=20e-6,
# Time delay at the end of RF event
rf_ringdown_time=30e-6,
# Time delay at the beginning of ADC event
adc_dead_time=0.,

Expand Down
69 changes: 40 additions & 29 deletions src/console/utilities/sequences/tse/tse_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,55 @@ def constructor(

Parameters
----------
echo_time, optional
Time constant between center of 90 degree pulse and center of ADC, by default 15e-3
repetition_time, optional
Time constant between two subsequent 90 degree pulses (echo trains), by default 600e-3
etl, optional
Echo train length, by default 7
dummies, optional
Number of dummy shots to acquire, default is 0
rf_duration, optional
Duration of the RF pulses (90 and 180 degree), by default 400e-6
gradient_correction, optional
Time constant to center ADC event, by default 510e-6
adc_correction, optional
echo_time
Time constant between center of 90 degree pulse and center of ADC
repetition_time
Time constant between two subsequent 90 degree pulses (echo trains)
etl
Echo train length
dummies
Number of dummy shots to acquire
rf_duration
Duration of the RF pulses (90 and 180 degree)
ramp_duration
Duration of the gradient ramps
gradient_correction
Time constant to center ADC event
adc_correction
Time constant which is added at the end of the ADC and readout gradient.
This value is not taken into account for the prephaser calculation.
ro_bandwidth, optional
Readout bandwidth in Hz, by default 20e3
fov, optional
Field of view per dimension, by default default_fov
n_enc, optional
Number of encoding steps per dimension, by default default_encoding = Dimensions(x=70, y=70, z=49).
ro_bandwidth
Readout bandwidth in Hz
fov
Field of view per dimension
n_enc
Number of encoding steps per dimension
If an encoding dimension is set to 1, the TSE sequence becomes a 2D sequence.
trajectory, optional
The k-space trajectory, by default set to in-out, other currently implemented options are out in and linear
excitation_angle, excitation_phase, optional
set the flip angle and phase of the excitation pulse in radians, defaults to 90 degree flip angle, 0 phase
refocussing_angle, refocussing_phase, optional
Set the flip angle and phase of the refocussing pulse in radians,
defaults to 180 degree flip angle, 90 degree phase
trajectory
The k-space trajectory, options are in-out, out-in and linear
excitation_angle, excitation_phase
set the flip angle and phase of the excitation pulse in radians
refocussing_angle, refocussing_phase
Set the flip angle and phase of the refocussing pulse in radians
TODO: allow this to be a list/array to vary flip angle along echo train.
channel_ro, channel_pe1, channel_pe2, optional
set the readout, phase1 and phase2 encoding directions, default to y, z and x.
inversion_pulse
If true, an inversion pulse is added at the beginning of each TR, with inversion time defined by inversion_time
inversion_time
Time between inversion pulse and excitation pulse in s, only used if inversion_pulse is true
inversion_angle
Flip angle of the inversion pulse in radians, only used if inversion_pulse is true
channel_ro, channel_pe1, channel_pe2
set the readout, phase1 and phase2 encoding directions
noise_scan
If true, a noise scan is acquired after each echo train, with the same duration as the echo train
system
Sequence system to be used for sequence construction

Returns
-------
Pulseq sequence and a list which describes the trajectory
"""
seq = pp.Sequence(system)
seq = pp.Sequence(system=system)
# Get the dimension and type of the sequence and set the name accordingly
n_dim = int(n_enc.x > 1) + int(n_enc.y > 1) + int(n_enc.z > 1)
seq_type = "tse" if etl > 1 else "se"
Expand Down
Loading