mrzerocore 0.2.9__cp37-abi3-win32.whl → 0.2.11__cp37-abi3-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- MRzeroCore/_prepass.pyd +0 -0
- MRzeroCore/phantom/brainweb/brainweb_data.json +1 -1
- MRzeroCore/sequence.py +2 -2
- MRzeroCore/simulation/main_pass.py +24 -10
- {MRzeroCore-0.2.9.dist-info → MRzeroCore-0.2.11.dist-info}/METADATA +2 -2
- {MRzeroCore-0.2.9.dist-info → MRzeroCore-0.2.11.dist-info}/RECORD +8 -8
- {MRzeroCore-0.2.9.dist-info → MRzeroCore-0.2.11.dist-info}/WHEEL +0 -0
- {MRzeroCore-0.2.9.dist-info → MRzeroCore-0.2.11.dist-info}/license_files/LICENSE +0 -0
MRzeroCore/_prepass.pyd
CHANGED
|
Binary file
|
MRzeroCore/sequence.py
CHANGED
|
@@ -289,11 +289,11 @@ class Sequence(list):
|
|
|
289
289
|
|
|
290
290
|
def cuda(self) -> Sequence:
|
|
291
291
|
"""Move this sequence to the specified CUDA device and return it."""
|
|
292
|
-
return Sequence([rep.cuda() for rep in self])
|
|
292
|
+
return Sequence([rep.cuda() for rep in self], self.normalized_grads)
|
|
293
293
|
|
|
294
294
|
def cpu(self) -> Sequence:
|
|
295
295
|
"""Move this sequence to the CPU and return it."""
|
|
296
|
-
return Sequence([rep.cpu() for rep in self])
|
|
296
|
+
return Sequence([rep.cpu() for rep in self], self.normalized_grads)
|
|
297
297
|
|
|
298
298
|
@property
|
|
299
299
|
def device(self) -> torch.device:
|
|
@@ -18,12 +18,9 @@ def execute_graph(graph: Graph,
|
|
|
18
18
|
min_emitted_signal: float = 1e-2,
|
|
19
19
|
min_latent_signal: float = 1e-2,
|
|
20
20
|
print_progress: bool = True,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
This function can optionally return the + or z magnetisation and the
|
|
25
|
-
encoding of all states, if requested. The encoding consists of the signal
|
|
26
|
-
of a distribution and its k-t space trajectory.
|
|
21
|
+
return_mag_z: int | bool | None = None,
|
|
22
|
+
) -> torch.Tensor | list:
|
|
23
|
+
"""Calculate the signal of the sequence by executing the phase graph.
|
|
27
24
|
|
|
28
25
|
Parameters
|
|
29
26
|
----------
|
|
@@ -40,11 +37,18 @@ def execute_graph(graph: Graph,
|
|
|
40
37
|
Should be <= than min_emitted_signal.
|
|
41
38
|
print_progress : bool
|
|
42
39
|
If true, the current repetition is printed while simulating.
|
|
40
|
+
return_mag_z : int or bool, optional
|
|
41
|
+
If set, returns the longitudinal magnetisation of either the given
|
|
42
|
+
repetition (int) or all repetitions (``True``).
|
|
43
|
+
|
|
43
44
|
|
|
44
45
|
Returns
|
|
45
46
|
-------
|
|
46
47
|
signal : torch.Tensor
|
|
47
48
|
The simulated signal of the sequence.
|
|
49
|
+
mag_z : torch.Tensor | list[torch.Tensor]
|
|
50
|
+
The longitudinal magnetisation of the specified or all repetition(s).
|
|
51
|
+
|
|
48
52
|
"""
|
|
49
53
|
if seq.normalized_grads:
|
|
50
54
|
grad_scale = 1 / data.size
|
|
@@ -67,6 +71,7 @@ def execute_graph(graph: Graph,
|
|
|
67
71
|
# Calculate kt_vec ourselves for autograd
|
|
68
72
|
graph[0][0].kt_vec = torch.zeros(4, device=data.device)
|
|
69
73
|
|
|
74
|
+
mag_z = []
|
|
70
75
|
for i, (dists, rep) in enumerate(zip(graph[1:], seq)):
|
|
71
76
|
if print_progress:
|
|
72
77
|
print(f"\rCalculating repetition {i+1} / {len(seq)}", end='')
|
|
@@ -129,6 +134,8 @@ def execute_graph(graph: Graph,
|
|
|
129
134
|
# Use the same adc phase for all coils
|
|
130
135
|
adc_rot = torch.exp(1j * rep.adc_phase).unsqueeze(1)
|
|
131
136
|
|
|
137
|
+
mag_z_rep = []
|
|
138
|
+
mag_z.append(mag_z_rep)
|
|
132
139
|
for dist in dists:
|
|
133
140
|
# Create a list only containing ancestors that were simulated
|
|
134
141
|
ancestors = list(filter(
|
|
@@ -141,6 +148,9 @@ def execute_graph(graph: Graph,
|
|
|
141
148
|
continue # skip dists for which no ancestors were simulated
|
|
142
149
|
|
|
143
150
|
dist.mag = sum([calc_mag(ancestor) for ancestor in ancestors])
|
|
151
|
+
if dist.dist_type in ['z0', 'z'] and return_mag_z in [i, True]:
|
|
152
|
+
mag_z_rep.append(dist.mag)
|
|
153
|
+
|
|
144
154
|
# The pre_pass already calculates kt_vec, but that does not
|
|
145
155
|
# work with autograd -> we need to calculate it with torch
|
|
146
156
|
if dist.dist_type == 'z0':
|
|
@@ -154,9 +164,9 @@ def execute_graph(graph: Graph,
|
|
|
154
164
|
dist_traj = dist.kt_vec + trajectory
|
|
155
165
|
|
|
156
166
|
# Diffusion
|
|
157
|
-
k2 = dist_traj[:, :3]
|
|
167
|
+
k2 = dist_traj[:, :3]
|
|
158
168
|
k1 = torch.empty_like(k2) # Calculate k-space at start of event
|
|
159
|
-
k1[0, :] = dist.kt_vec[:3]
|
|
169
|
+
k1[0, :] = dist.kt_vec[:3]
|
|
160
170
|
k1[1:, :] = k2[:-1, :]
|
|
161
171
|
# Integrate over each event to get b factor (lin. interp. grad)
|
|
162
172
|
b = 1/3 * dt * (k1**2 + k1*k2 + k2**2).sum(1)
|
|
@@ -202,7 +212,7 @@ def execute_graph(graph: Graph,
|
|
|
202
212
|
dist.mag = dist.mag * r2 * diffusion[-1, :]
|
|
203
213
|
dist.kt_vec = dist_traj[-1]
|
|
204
214
|
else: # z or z0
|
|
205
|
-
k = torch.linalg.vector_norm(dist.kt_vec[:3]
|
|
215
|
+
k = torch.linalg.vector_norm(dist.kt_vec[:3])
|
|
206
216
|
diffusion = torch.exp(-1e-9 * data.D * total_time * k**2)
|
|
207
217
|
dist.mag = dist.mag * r1 * diffusion
|
|
208
218
|
if dist.dist_type == 'z0':
|
|
@@ -223,6 +233,10 @@ def execute_graph(graph: Graph,
|
|
|
223
233
|
print(" - done")
|
|
224
234
|
|
|
225
235
|
# Only return measured samples
|
|
226
|
-
|
|
236
|
+
measured = torch.cat([
|
|
227
237
|
sig[rep.adc_usage > 0, :] for sig, rep in zip(signal, seq)
|
|
228
238
|
])
|
|
239
|
+
if return_mag_z is not None:
|
|
240
|
+
return measured, mag_z
|
|
241
|
+
else:
|
|
242
|
+
return measured
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: MRzeroCore
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.11
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -18,8 +18,8 @@ Summary: Core functionality of MRzero
|
|
|
18
18
|
Author-email: Jonathan Endres <jonathan.endres@uk-erlangen.de>
|
|
19
19
|
Requires-Python: >=3.9
|
|
20
20
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
21
|
-
Project-URL: Documentation, https://mrzero-core.readthedocs.io/
|
|
22
21
|
Project-URL: MRzero-Paper, https://arxiv.org/abs/2002.04265
|
|
22
|
+
Project-URL: Documentation, https://mrzero-core.readthedocs.io/
|
|
23
23
|
Project-URL: Repository, https://github.com/MRsources/MRzero-Core
|
|
24
24
|
|
|
25
25
|
[](https://mrzero-core.readthedocs.io/en/latest/?badge=latest)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
MRzeroCore-0.2.
|
|
2
|
-
MRzeroCore-0.2.
|
|
3
|
-
MRzeroCore-0.2.
|
|
4
|
-
MRzeroCore/phantom/brainweb/brainweb_data.json,sha256=
|
|
1
|
+
MRzeroCore-0.2.11.dist-info/METADATA,sha256=U4oPS2MmczYLu2kn73X5CrJ4h42STauc_kIgTlTiQb0,3801
|
|
2
|
+
MRzeroCore-0.2.11.dist-info/WHEEL,sha256=gXYpX75r-fJLXR2RD6r-k3EXD66bMIXTAL43kNqJgxg,92
|
|
3
|
+
MRzeroCore-0.2.11.dist-info/license_files/LICENSE,sha256=rd_IFJ484uAluv8CigP2CpXg4l2GJLLKENqB6-RXPp4,35112
|
|
4
|
+
MRzeroCore/phantom/brainweb/brainweb_data.json,sha256=El9J5dfEIwGi4_SoRif6ic6IVSMKh01jK0hNRbBYNqA,1794
|
|
5
5
|
MRzeroCore/phantom/brainweb/brainweb_data_sources.txt,sha256=Sh6NFLU1bhdaD0pp12D_Hc70cA_UC1s7KdHcuoGTKuA,1853
|
|
6
6
|
MRzeroCore/phantom/brainweb/output/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
MRzeroCore/phantom/brainweb/__init__.py,sha256=R48NlkMNpMgyKKwFm-5iUlhxBKctQ6dXx7yCmyVwm6E,6828
|
|
@@ -26,11 +26,11 @@ MRzeroCore/pulseq/pulseq_loader/pulseq_file/__init__.py,sha256=VzN3j7pirpI8zJdfv
|
|
|
26
26
|
MRzeroCore/pulseq/pulseq_loader/spoiler.py,sha256=R6Hjfno3U-fuICjLUUxmDk_7-Z1HjZYmE55mXTWTIAI,1007
|
|
27
27
|
MRzeroCore/pulseq/pulseq_loader/__init__.py,sha256=6OLwC3k9LSjl8aRin9pV4-Rb-Q3YSbToayyeKbXnUdQ,2812
|
|
28
28
|
MRzeroCore/reconstruction.py,sha256=LGk5EdgQ4AkhWN-7Q81YMkIEEW0T9Q37O2Pat0d-d4o,4277
|
|
29
|
-
MRzeroCore/sequence.py,sha256=
|
|
29
|
+
MRzeroCore/sequence.py,sha256=wqRwpUIKdX9mgmctmIL2Ttr3eZPJ_H1ACLamkzPp7sY,27647
|
|
30
30
|
MRzeroCore/simulation/isochromat_sim.py,sha256=u6KbN7S8REOHiKqzDGMma7937cKX4bnmj3gXoAiNLi0,9185
|
|
31
|
-
MRzeroCore/simulation/main_pass.py,sha256=
|
|
31
|
+
MRzeroCore/simulation/main_pass.py,sha256=DNXEJmN7AEWuqNbMma6AWqJpHH4ihhC3YRJKRhoi4RU,9830
|
|
32
32
|
MRzeroCore/simulation/pre_pass.py,sha256=5wmXKxgFeGwA7yrqTkOjcWoFuGuRYEPzedRGqkx2Evg,5117
|
|
33
33
|
MRzeroCore/util.py,sha256=39TPselHu7f218BRdjHB4_kCSPnFuCC45YmdGotc4uA,11460
|
|
34
34
|
MRzeroCore/__init__.py,sha256=8WViV9GQRwnksnopAAfKWRmtRYk75DC3ke4OQwLx-fU,850
|
|
35
|
-
MRzeroCore/_prepass.pyd,sha256=
|
|
36
|
-
MRzeroCore-0.2.
|
|
35
|
+
MRzeroCore/_prepass.pyd,sha256=IBPl4RZknTboJuiJZDiAuFzc9kMr0a8KwEPicF_B3b4,351232
|
|
36
|
+
MRzeroCore-0.2.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|