-
Notifications
You must be signed in to change notification settings - Fork 0
/
Component.py
75 lines (53 loc) · 2.29 KB
/
Component.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
71
72
73
74
75
# Purpose: Component class for the simulation of MRI sequences
class Component:
def __init__(self, time, duration):
self.time = time
self.duration = duration
def __repr__(self):
return f"{Component.__name__} t={self.time}ms duration={self.duration}ms"
def get_time(self):
return self.time
# Radio frequency pulse component
class RFComponent(Component):
def __init__(self, time, duration, angle):
super().__init__(time, duration)
self.angle = angle
def __repr__(self):
return f"RF t={self.time}ms duration={self.duration}ms angle={self.angle}°"
# Relaxation component
class RelaxationComponent(Component):
def __init__(self, time, duration):
super().__init__(time, duration)
def __repr__(self):
return f"Relaxation t={self.time}ms duration={self.duration}ms"
# Multi gradient component
class MultiGradientComponent(Component):
def __init__(self, time, duration, sign, balanced=False):
super().__init__(time, duration)
self.sign = sign
self.balanced = balanced
def __repr__(self):
return f"Multi Gradient t={self.time}ms duration={self.duration}ms"
# Gradient component
class GradientComponent(Component):
def __init__(self, time:float, duration:float, encoding:str, sign, balanced=False):
super().__init__(time, duration)
if encoding != "phase" and encoding != "frequency":
raise ValueError("Encoding must be either phase or frequency")
self.sign = sign
self.encoding = encoding
self.balanced = balanced
def __repr__(self):
return f"{self.encoding} Gradient t={self.time}ms duration={self.duration}ms balanced={self.balanced}"
# Readout component
class ReadoutComponent(Component):
def __init__(self, time, duration):
super().__init__(time, duration)
def __repr__(self):
return f"Readout t={self.time}ms duration={self.duration}ms"
# Spoiler component
class SpoilerComponent(Component):
def __init__(self, time, duration):
super().__init__(time, duration)
def __repr__(self):
return f"Spoiler t={self.time}ms duration={self.duration}ms"