-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_tse_3d_demo.py
70 lines (60 loc) · 2.64 KB
/
write_tse_3d_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from matplotlib import pyplot as plt
from math import pi
from pypulseq.opts import Opts
from packages import tse_3d_demo
from packages.seq_utils import Trajectory
from packages.seq_utils import Dimensions
from packages.seq_utils import Channels
from packages.mr_systems import low_field as default_system
def main(plot:bool, write_seq:bool, seq_filename:str = "tse_3d",
system:Opts = default_system,
fov:tuple = (256e-3, 256e-3, 256e-3),
n_enc:tuple = (64, 64, 64)
):
seq = tse_3d_demo.constructor(
echo_time = 20e-3,
repetition_time = 2000e-3,
etl = 1, # define max sampling period (tmax = 200ms?), etl_max = round(tmax/esp), nr. of pe1 steps should be multiple of etl
dummies = 0,
ro_bandwidth = 20e3,
ro_oversampling = 1,
rf_duration = 100e-6,
input_fov = Dimensions(x = fov[0], y = fov[1], z = fov[2]),
input_enc = Dimensions(x = n_enc[0], y = n_enc[1], z = n_enc[2]),
trajectory=Trajectory.ASCENDING,
refocussing_angle = pi,
excitation_phase = pi/2,
refocussing_phase = 0,
channels = Channels(ro = "x", pe1 = "y", pe2 = "z"),
system = system
) # [0]
if plot:
plot_kspace = True
plot_seq = True
else:
plot_kspace = False
plot_seq = False
## Check whether the timing of the sequence is compatible with the scanner
(ok,error_report,) = seq.check_timing() # Check whether the timing of the sequence is correct
if ok:
print("Timing check passed successfully")
else:
print("Timing check failed. Error listing follows:")
[print(e) for e in error_report]
if plot_kspace:
k_traj_adc, k_traj, t_excitation, t_refocusing, t_adc = seq.calculate_kspace()
plt.figure()
plt.plot(k_traj[0],k_traj[1])
plt.plot(k_traj_adc[0],k_traj_adc[1],'.')
plt.show()
if plot_seq:
seq.plot()
# =========
# WRITE .SEQ
# =========
if write_seq:
seq.set_definition('Name', seq_filename)
seq.write('./sequences/' + seq_filename)
# seq.write(r"C:\Users\hhert\VirtualMachines\SharedFolder\pulseq\external.seq")
if __name__ == "__main__":
main(plot=True, write_seq=True)