Note
Go to the end to download the full example code. or to run this example in your browser via Binder
Learn Straight line readout pattern#
A small pytorch example to showcase learning k-space sampling patterns. In this example we learn the 2D sampling pattern for a 3D MRI image, assuming straight line readouts. This example showcases the auto-diff capabilities of the NUFFT operator The image resolution is kept small to reduce computation time.
Warning
This example only showcases the autodiff capabilities, the learned sampling pattern is not scanner compliant as the scanner gradients required to implement it violate the hardware constraints. In practice, a projection \(\Pi_\mathcal{Q}(\mathbf{K})\) into the scanner constraints set \(\mathcal{Q}\) is recommended (see [Proj]). This is implemented in the proprietary SPARKLING package [Sparks]. Users are encouraged to contact the authors if they want to use it.
Imports#
import time
import joblib
import brainweb_dl as bwdl
import matplotlib.pyplot as plt
import numpy as np
import torch
from tqdm import tqdm
from PIL import Image, ImageSequence
from mrinufft import get_operator
Setup a simple class to learn trajectory#
Note
While we are only learning the NUFFT operator, we still need the gradient wrt_data=True to have all the gradients computed correctly. See [Projector] for more details.
class Model(torch.nn.Module):
def __init__(self, num_shots, img_size, factor_cartesian=0.3):
super(Model, self).__init__()
self.num_samples_per_shot = 128
cart_del = 1 / img_size[0]
num_cart_points = np.round(np.sqrt(factor_cartesian * num_shots)).astype(int)
edge_center = cart_del * num_cart_points / 2
self.central_points = torch.nn.Parameter(
data=torch.stack(
torch.meshgrid(
torch.linspace(-edge_center, edge_center, num_cart_points),
torch.linspace(-edge_center, edge_center, num_cart_points),
indexing="ij",
),
axis=-1,
).reshape(-1, 2),
requires_grad=False,
)
self.non_center_points = torch.nn.Parameter(
data=torch.Tensor(
np.random.random((num_shots - self.central_points.shape[0], 2)) - 0.5
),
requires_grad=True,
)
self.operator = get_operator("gpunufft", wrt_data=True, wrt_traj=True)(
np.random.random(
(self.get_2D_points().shape[0] * self.num_samples_per_shot, 3)
)
- 0.5,
shape=img_size,
density=True,
squeeze_dims=False,
)
def get_trajectory(self, get_as_shot=False):
samples = self._get_3D_points(self.get_2D_points())
if not get_as_shot:
return samples
return samples.reshape(-1, self.num_samples_per_shot, 3)
def get_2D_points(self):
return torch.vstack([self.central_points, self.non_center_points])
def _get_3D_points(self, samples2D):
line = torch.linspace(
-0.5,
0.5,
self.num_samples_per_shot,
device=samples2D.device,
dtype=samples2D.dtype,
)
return torch.stack(
[
line.repeat(samples2D.shape[0], 1),
samples2D[:, 0].repeat(self.num_samples_per_shot, 1).T,
samples2D[:, 1].repeat(self.num_samples_per_shot, 1).T,
],
dim=-1,
).reshape(-1, 3)
def forward(self, x):
self.operator.samples = self.get_trajectory()
kspace = self.operator.op(x)
adjoint = self.operator.adj_op(kspace).abs()
return adjoint / torch.mean(adjoint)
Util function to plot the state of the model#
def plot_state(mri_2D, traj, recon, loss=None, save_name=None, i=None):
fig_grid = (2, 2)
if loss is None:
fig_grid = (1, 3)
fig, axs = plt.subplots(*fig_grid, figsize=tuple(i * 5 for i in fig_grid[::-1]))
axs = axs.flatten()
axs[0].imshow(np.abs(mri_2D[0][..., 11]), cmap="gray")
axs[0].axis("off")
axs[0].set_title("MR Image")
if traj.shape[-1] == 3:
if i is not None and i > 50:
axs[1].scatter(*traj.T[1:3, 0], s=10, color="blue")
else:
fig_kwargs = {}
plt_kwargs = {"s": 1, "alpha": 0.2}
if i is not None:
fig_kwargs["azim"], fig_kwargs["elev"] = (
i / 50 * 60 - 60,
30 - i / 50 * 30,
)
plt_kwargs["alpha"] = 0.2 + 0.8 * i / 50
plt_kwargs["s"] = 1 + 9 * i / 50
axs[1].remove()
axs[1] = fig.add_subplot(*fig_grid, 2, projection="3d", **fig_kwargs)
for shot in traj:
axs[1].scatter(*shot.T, color="blue", **plt_kwargs)
else:
axs[1].scatter(*traj.T, s=10)
axs[1].set_title("Trajectory")
axs[2].imshow(np.abs(recon[0][0][..., 11].detach().cpu().numpy()), cmap="gray")
axs[2].axis("off")
axs[2].set_title("Reconstruction")
if loss is not None:
axs[3].plot(loss)
axs[3].grid("on")
axs[3].set_title("Loss")
if save_name is not None:
plt.savefig(save_name, bbox_inches="tight")
plt.close()
else:
plt.show()
Setup model and optimizer#
cart_data = np.flipud(bwdl.get_mri(4, "T1")).T[::8, ::8, ::8].astype(np.complex64)
model = Model(253, cart_data.shape)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-2)
Setup data#
mri_3D = torch.Tensor(cart_data)[None]
mri_3D = mri_3D / torch.mean(mri_3D)
model.eval()
recon = model(mri_3D)
plot_state(mri_3D, model.get_trajectory(True).detach().cpu().numpy(), recon)
/volatile/github-ci-mind-inria/gpu_runner/_work/mri-nufft/mri-nufft/examples/GPU/example_learn_straight_line_readouts.py:174: UserWarning: Casting complex values to real discards the imaginary part (Triggered internally at ../aten/src/ATen/native/Copy.cpp:308.)
mri_3D = torch.Tensor(cart_data)[None]
Start training loop#
losses = []
image_files = []
model.train()
with tqdm(range(100), unit="steps") as tqdms:
for i in tqdms:
out = model(mri_3D)
loss = torch.nn.functional.mse_loss(out, mri_3D[None])
numpy_loss = loss.detach().cpu().numpy()
tqdms.set_postfix({"loss": numpy_loss})
losses.append(numpy_loss)
optimizer.zero_grad()
loss.backward()
optimizer.step()
with torch.no_grad():
# Clamp the value of trajectory between [-0.5, 0.5]
for param in model.parameters():
param.clamp_(-0.5, 0.5)
# Generate images for gif
hashed = joblib.hash((i, "learn_line", time.time()))
filename = "/tmp/" + f"{hashed}.png"
plot_state(
mri_3D,
model.get_trajectory(True).detach().cpu().numpy(),
out,
losses,
save_name=filename,
i=i,
)
image_files.append(filename)
# Make a GIF of all images.
imgs = [Image.open(img) for img in image_files]
imgs[0].save(
"mrinufft_learn_2d_sampling_pattern.gif",
save_all=True,
append_images=imgs[1:],
optimize=False,
duration=2,
loop=0,
)
# sphinx_gallery_thumbnail_path = 'generated/autoexamples/GPU/images/mrinufft_learn_2d_sampling_pattern.gif'
0%| | 0/100 [00:00<?, ?steps/s]
0%| | 0/100 [00:00<?, ?steps/s, loss=0.30268535]
1%| | 1/100 [00:05<08:29, 5.15s/steps, loss=0.30268535]
1%| | 1/100 [00:05<08:29, 5.15s/steps, loss=0.28931198]
2%|▏ | 2/100 [00:09<07:43, 4.73s/steps, loss=0.28931198]
2%|▏ | 2/100 [00:09<07:43, 4.73s/steps, loss=0.2731167]
3%|▎ | 3/100 [00:13<06:56, 4.29s/steps, loss=0.2731167]
3%|▎ | 3/100 [00:13<06:56, 4.29s/steps, loss=0.26329452]
4%|▍ | 4/100 [00:17<06:47, 4.24s/steps, loss=0.26329452]
4%|▍ | 4/100 [00:17<06:47, 4.24s/steps, loss=0.26011577]
5%|▌ | 5/100 [00:21<06:26, 4.06s/steps, loss=0.26011577]
5%|▌ | 5/100 [00:21<06:26, 4.06s/steps, loss=0.25845298]
6%|▌ | 6/100 [00:24<05:59, 3.82s/steps, loss=0.25845298]
6%|▌ | 6/100 [00:24<05:59, 3.82s/steps, loss=0.25623155]
7%|▋ | 7/100 [00:28<05:49, 3.76s/steps, loss=0.25623155]
7%|▋ | 7/100 [00:28<05:49, 3.76s/steps, loss=0.25474057]
8%|▊ | 8/100 [00:31<05:34, 3.64s/steps, loss=0.25474057]
8%|▊ | 8/100 [00:31<05:34, 3.64s/steps, loss=0.2506547]
9%|▉ | 9/100 [00:35<05:30, 3.63s/steps, loss=0.2506547]
9%|▉ | 9/100 [00:35<05:30, 3.63s/steps, loss=0.24784145]
10%|█ | 10/100 [00:38<05:19, 3.55s/steps, loss=0.24784145]
10%|█ | 10/100 [00:38<05:19, 3.55s/steps, loss=0.24519089]
11%|█ | 11/100 [00:41<05:11, 3.50s/steps, loss=0.24519089]
11%|█ | 11/100 [00:42<05:11, 3.50s/steps, loss=0.24287787]
12%|█▏ | 12/100 [00:45<05:12, 3.55s/steps, loss=0.24287787]
12%|█▏ | 12/100 [00:45<05:12, 3.55s/steps, loss=0.24043608]
13%|█▎ | 13/100 [00:49<05:05, 3.51s/steps, loss=0.24043608]
13%|█▎ | 13/100 [00:49<05:05, 3.51s/steps, loss=0.23823528]
14%|█▍ | 14/100 [00:52<04:55, 3.43s/steps, loss=0.23823528]
14%|█▍ | 14/100 [00:52<04:55, 3.43s/steps, loss=0.23669128]
15%|█▌ | 15/100 [00:55<04:54, 3.47s/steps, loss=0.23669128]
15%|█▌ | 15/100 [00:56<04:54, 3.47s/steps, loss=0.23574246]
16%|█▌ | 16/100 [00:59<04:46, 3.41s/steps, loss=0.23574246]
16%|█▌ | 16/100 [00:59<04:46, 3.41s/steps, loss=0.23507021]
17%|█▋ | 17/100 [01:02<04:41, 3.39s/steps, loss=0.23507021]
17%|█▋ | 17/100 [01:02<04:41, 3.39s/steps, loss=0.23364703]
18%|█▊ | 18/100 [01:06<04:42, 3.45s/steps, loss=0.23364703]
18%|█▊ | 18/100 [01:06<04:42, 3.45s/steps, loss=0.23167457]
19%|█▉ | 19/100 [01:09<04:37, 3.43s/steps, loss=0.23167457]
19%|█▉ | 19/100 [01:09<04:37, 3.43s/steps, loss=0.23058435]
20%|██ | 20/100 [01:13<04:37, 3.47s/steps, loss=0.23058435]
20%|██ | 20/100 [01:13<04:37, 3.47s/steps, loss=0.23013712]
21%|██ | 21/100 [01:16<04:29, 3.41s/steps, loss=0.23013712]
21%|██ | 21/100 [01:16<04:29, 3.41s/steps, loss=0.229351]
22%|██▏ | 22/100 [01:19<04:22, 3.37s/steps, loss=0.229351]
22%|██▏ | 22/100 [01:19<04:22, 3.37s/steps, loss=0.22849321]
23%|██▎ | 23/100 [01:23<04:24, 3.44s/steps, loss=0.22849321]
23%|██▎ | 23/100 [01:23<04:24, 3.44s/steps, loss=0.22741716]
24%|██▍ | 24/100 [01:26<04:18, 3.40s/steps, loss=0.22741716]
24%|██▍ | 24/100 [01:26<04:18, 3.40s/steps, loss=0.22634412]
25%|██▌ | 25/100 [01:29<04:13, 3.37s/steps, loss=0.22634412]
25%|██▌ | 25/100 [01:29<04:13, 3.37s/steps, loss=0.22597483]
26%|██▌ | 26/100 [01:33<04:13, 3.43s/steps, loss=0.22597483]
26%|██▌ | 26/100 [01:33<04:13, 3.43s/steps, loss=0.2253507]
27%|██▋ | 27/100 [01:36<04:04, 3.35s/steps, loss=0.2253507]
27%|██▋ | 27/100 [01:36<04:04, 3.35s/steps, loss=0.22480603]
28%|██▊ | 28/100 [01:39<03:55, 3.27s/steps, loss=0.22480603]
28%|██▊ | 28/100 [01:39<03:55, 3.27s/steps, loss=0.22483422]
29%|██▉ | 29/100 [01:42<03:51, 3.26s/steps, loss=0.22483422]
29%|██▉ | 29/100 [01:42<03:51, 3.26s/steps, loss=0.22465006]
30%|███ | 30/100 [01:45<03:43, 3.19s/steps, loss=0.22465006]
30%|███ | 30/100 [01:45<03:43, 3.19s/steps, loss=0.22408889]
31%|███ | 31/100 [01:49<03:45, 3.26s/steps, loss=0.22408889]
31%|███ | 31/100 [01:49<03:45, 3.26s/steps, loss=0.22360456]
32%|███▏ | 32/100 [01:52<03:41, 3.26s/steps, loss=0.22360456]
32%|███▏ | 32/100 [01:52<03:41, 3.26s/steps, loss=0.22234397]
33%|███▎ | 33/100 [01:55<03:37, 3.25s/steps, loss=0.22234397]
33%|███▎ | 33/100 [01:55<03:37, 3.25s/steps, loss=0.22108974]
34%|███▍ | 34/100 [01:59<03:39, 3.33s/steps, loss=0.22108974]
34%|███▍ | 34/100 [01:59<03:39, 3.33s/steps, loss=0.22099553]
35%|███▌ | 35/100 [02:02<03:33, 3.29s/steps, loss=0.22099553]
35%|███▌ | 35/100 [02:02<03:33, 3.29s/steps, loss=0.2210943]
36%|███▌ | 36/100 [02:05<03:27, 3.24s/steps, loss=0.2210943]
36%|███▌ | 36/100 [02:05<03:27, 3.24s/steps, loss=0.22113466]
37%|███▋ | 37/100 [02:08<03:24, 3.25s/steps, loss=0.22113466]
37%|███▋ | 37/100 [02:08<03:24, 3.25s/steps, loss=0.22141442]
38%|███▊ | 38/100 [02:11<03:16, 3.16s/steps, loss=0.22141442]
38%|███▊ | 38/100 [02:11<03:16, 3.16s/steps, loss=0.2214199]
39%|███▉ | 39/100 [02:14<03:09, 3.11s/steps, loss=0.2214199]
39%|███▉ | 39/100 [02:15<03:09, 3.11s/steps, loss=0.22092085]
40%|████ | 40/100 [02:18<03:25, 3.43s/steps, loss=0.22092085]
40%|████ | 40/100 [02:19<03:25, 3.43s/steps, loss=0.22090597]
41%|████ | 41/100 [02:22<03:18, 3.36s/steps, loss=0.22090597]
41%|████ | 41/100 [02:22<03:18, 3.36s/steps, loss=0.21994193]
42%|████▏ | 42/100 [02:25<03:14, 3.35s/steps, loss=0.21994193]
42%|████▏ | 42/100 [02:25<03:14, 3.35s/steps, loss=0.2194898]
43%|████▎ | 43/100 [02:29<03:15, 3.44s/steps, loss=0.2194898]
43%|████▎ | 43/100 [02:29<03:15, 3.44s/steps, loss=0.21915774]
44%|████▍ | 44/100 [02:32<03:10, 3.40s/steps, loss=0.21915774]
44%|████▍ | 44/100 [02:32<03:10, 3.40s/steps, loss=0.2192069]
45%|████▌ | 45/100 [02:36<03:09, 3.45s/steps, loss=0.2192069]
45%|████▌ | 45/100 [02:36<03:09, 3.45s/steps, loss=0.21926722]
46%|████▌ | 46/100 [02:39<03:03, 3.41s/steps, loss=0.21926722]
46%|████▌ | 46/100 [02:39<03:03, 3.41s/steps, loss=0.21893235]
47%|████▋ | 47/100 [02:42<02:56, 3.32s/steps, loss=0.21893235]
47%|████▋ | 47/100 [02:42<02:56, 3.32s/steps, loss=0.21859847]
48%|████▊ | 48/100 [02:45<02:50, 3.28s/steps, loss=0.21859847]
48%|████▊ | 48/100 [02:45<02:50, 3.28s/steps, loss=0.21810988]
49%|████▉ | 49/100 [02:48<02:42, 3.18s/steps, loss=0.21810988]
49%|████▉ | 49/100 [02:48<02:42, 3.18s/steps, loss=0.21784724]
50%|█████ | 50/100 [02:51<02:35, 3.11s/steps, loss=0.21784724]
50%|█████ | 50/100 [02:51<02:35, 3.11s/steps, loss=0.2179914]
51%|█████ | 51/100 [02:54<02:33, 3.13s/steps, loss=0.2179914]
51%|█████ | 51/100 [02:55<02:33, 3.13s/steps, loss=0.21801463]
52%|█████▏ | 52/100 [02:55<01:56, 2.43s/steps, loss=0.21801463]
52%|█████▏ | 52/100 [02:55<01:56, 2.43s/steps, loss=0.21785137]
53%|█████▎ | 53/100 [02:56<01:27, 1.86s/steps, loss=0.21785137]
53%|█████▎ | 53/100 [02:56<01:27, 1.86s/steps, loss=0.21775591]
54%|█████▍ | 54/100 [02:56<01:06, 1.45s/steps, loss=0.21775591]
54%|█████▍ | 54/100 [02:56<01:06, 1.45s/steps, loss=0.2176361]
55%|█████▌ | 55/100 [02:57<00:52, 1.17s/steps, loss=0.2176361]
55%|█████▌ | 55/100 [02:57<00:52, 1.17s/steps, loss=0.21767716]
56%|█████▌ | 56/100 [02:57<00:42, 1.03steps/s, loss=0.21767716]
56%|█████▌ | 56/100 [02:57<00:42, 1.03steps/s, loss=0.21759166]
57%|█████▋ | 57/100 [02:58<00:35, 1.21steps/s, loss=0.21759166]
57%|█████▋ | 57/100 [02:58<00:35, 1.21steps/s, loss=0.21741429]
58%|█████▊ | 58/100 [02:58<00:30, 1.37steps/s, loss=0.21741429]
58%|█████▊ | 58/100 [02:58<00:30, 1.37steps/s, loss=0.2172989]
59%|█████▉ | 59/100 [02:59<00:30, 1.36steps/s, loss=0.2172989]
59%|█████▉ | 59/100 [02:59<00:30, 1.36steps/s, loss=0.21725972]
60%|██████ | 60/100 [02:59<00:26, 1.50steps/s, loss=0.21725972]
60%|██████ | 60/100 [02:59<00:26, 1.50steps/s, loss=0.21724403]
61%|██████ | 61/100 [03:00<00:24, 1.62steps/s, loss=0.21724403]
61%|██████ | 61/100 [03:00<00:24, 1.62steps/s, loss=0.21720923]
62%|██████▏ | 62/100 [03:00<00:22, 1.71steps/s, loss=0.21720923]
62%|██████▏ | 62/100 [03:00<00:22, 1.71steps/s, loss=0.21713124]
63%|██████▎ | 63/100 [03:01<00:20, 1.78steps/s, loss=0.21713124]
63%|██████▎ | 63/100 [03:01<00:20, 1.78steps/s, loss=0.21706678]
64%|██████▍ | 64/100 [03:01<00:19, 1.83steps/s, loss=0.21706678]
64%|██████▍ | 64/100 [03:01<00:19, 1.83steps/s, loss=0.21679564]
65%|██████▌ | 65/100 [03:02<00:18, 1.87steps/s, loss=0.21679564]
65%|██████▌ | 65/100 [03:02<00:18, 1.87steps/s, loss=0.21651252]
66%|██████▌ | 66/100 [03:02<00:17, 1.91steps/s, loss=0.21651252]
66%|██████▌ | 66/100 [03:02<00:17, 1.91steps/s, loss=0.21638726]
67%|██████▋ | 67/100 [03:03<00:17, 1.93steps/s, loss=0.21638726]
67%|██████▋ | 67/100 [03:03<00:17, 1.93steps/s, loss=0.21637212]
68%|██████▊ | 68/100 [03:04<00:18, 1.71steps/s, loss=0.21637212]
68%|██████▊ | 68/100 [03:04<00:18, 1.71steps/s, loss=0.21640885]
69%|██████▉ | 69/100 [03:04<00:17, 1.78steps/s, loss=0.21640885]
69%|██████▉ | 69/100 [03:04<00:17, 1.78steps/s, loss=0.21649477]
70%|███████ | 70/100 [03:05<00:16, 1.82steps/s, loss=0.21649477]
70%|███████ | 70/100 [03:05<00:16, 1.82steps/s, loss=0.21652053]
71%|███████ | 71/100 [03:05<00:15, 1.86steps/s, loss=0.21652053]
71%|███████ | 71/100 [03:05<00:15, 1.86steps/s, loss=0.21662506]
72%|███████▏ | 72/100 [03:06<00:14, 1.88steps/s, loss=0.21662506]
72%|███████▏ | 72/100 [03:06<00:14, 1.88steps/s, loss=0.21631257]
73%|███████▎ | 73/100 [03:06<00:14, 1.91steps/s, loss=0.21631257]
73%|███████▎ | 73/100 [03:06<00:14, 1.91steps/s, loss=0.21613279]
74%|███████▍ | 74/100 [03:07<00:13, 1.94steps/s, loss=0.21613279]
74%|███████▍ | 74/100 [03:07<00:13, 1.94steps/s, loss=0.21634282]
75%|███████▌ | 75/100 [03:07<00:12, 1.97steps/s, loss=0.21634282]
75%|███████▌ | 75/100 [03:07<00:12, 1.97steps/s, loss=0.21614686]
76%|███████▌ | 76/100 [03:08<00:12, 1.99steps/s, loss=0.21614686]
76%|███████▌ | 76/100 [03:08<00:12, 1.99steps/s, loss=0.21598]
77%|███████▋ | 77/100 [03:08<00:13, 1.70steps/s, loss=0.21598]
77%|███████▋ | 77/100 [03:09<00:13, 1.70steps/s, loss=0.21580268]
78%|███████▊ | 78/100 [03:09<00:12, 1.78steps/s, loss=0.21580268]
78%|███████▊ | 78/100 [03:09<00:12, 1.78steps/s, loss=0.21589993]
79%|███████▉ | 79/100 [03:10<00:12, 1.69steps/s, loss=0.21589993]
79%|███████▉ | 79/100 [03:10<00:12, 1.69steps/s, loss=0.21573713]
80%|████████ | 80/100 [03:10<00:12, 1.56steps/s, loss=0.21573713]
80%|████████ | 80/100 [03:10<00:12, 1.56steps/s, loss=0.21582271]
81%|████████ | 81/100 [03:11<00:11, 1.67steps/s, loss=0.21582271]
81%|████████ | 81/100 [03:11<00:11, 1.67steps/s, loss=0.2159705]
82%|████████▏ | 82/100 [03:11<00:10, 1.76steps/s, loss=0.2159705]
82%|████████▏ | 82/100 [03:11<00:10, 1.76steps/s, loss=0.2158449]
83%|████████▎ | 83/100 [03:12<00:09, 1.82steps/s, loss=0.2158449]
83%|████████▎ | 83/100 [03:12<00:09, 1.82steps/s, loss=0.21566625]
84%|████████▍ | 84/100 [03:12<00:08, 1.86steps/s, loss=0.21566625]
84%|████████▍ | 84/100 [03:12<00:08, 1.86steps/s, loss=0.21547748]
85%|████████▌ | 85/100 [03:13<00:07, 1.89steps/s, loss=0.21547748]
85%|████████▌ | 85/100 [03:13<00:07, 1.89steps/s, loss=0.21516772]
86%|████████▌ | 86/100 [03:14<00:08, 1.71steps/s, loss=0.21516772]
86%|████████▌ | 86/100 [03:14<00:08, 1.71steps/s, loss=0.21523438]
87%|████████▋ | 87/100 [03:14<00:07, 1.79steps/s, loss=0.21523438]
87%|████████▋ | 87/100 [03:14<00:07, 1.79steps/s, loss=0.2155516]
88%|████████▊ | 88/100 [03:15<00:06, 1.85steps/s, loss=0.2155516]
88%|████████▊ | 88/100 [03:15<00:06, 1.85steps/s, loss=0.21551025]
89%|████████▉ | 89/100 [03:15<00:05, 1.88steps/s, loss=0.21551025]
89%|████████▉ | 89/100 [03:15<00:05, 1.88steps/s, loss=0.21540111]
90%|█████████ | 90/100 [03:16<00:05, 1.91steps/s, loss=0.21540111]
90%|█████████ | 90/100 [03:16<00:05, 1.91steps/s, loss=0.21508221]
91%|█████████ | 91/100 [03:16<00:04, 1.93steps/s, loss=0.21508221]
91%|█████████ | 91/100 [03:16<00:04, 1.93steps/s, loss=0.21491428]
92%|█████████▏| 92/100 [03:17<00:04, 1.96steps/s, loss=0.21491428]
92%|█████████▏| 92/100 [03:17<00:04, 1.96steps/s, loss=0.21486458]
93%|█████████▎| 93/100 [03:17<00:03, 1.97steps/s, loss=0.21486458]
93%|█████████▎| 93/100 [03:17<00:03, 1.97steps/s, loss=0.21484509]
94%|█████████▍| 94/100 [03:18<00:03, 1.98steps/s, loss=0.21484509]
94%|█████████▍| 94/100 [03:18<00:03, 1.98steps/s, loss=0.21501526]
95%|█████████▌| 95/100 [03:18<00:02, 1.99steps/s, loss=0.21501526]
95%|█████████▌| 95/100 [03:18<00:02, 1.99steps/s, loss=0.21483114]
96%|█████████▌| 96/100 [03:19<00:02, 1.74steps/s, loss=0.21483114]
96%|█████████▌| 96/100 [03:19<00:02, 1.74steps/s, loss=0.2147514]
97%|█████████▋| 97/100 [03:19<00:01, 1.80steps/s, loss=0.2147514]
97%|█████████▋| 97/100 [03:19<00:01, 1.80steps/s, loss=0.21425492]
98%|█████████▊| 98/100 [03:20<00:01, 1.85steps/s, loss=0.21425492]
98%|█████████▊| 98/100 [03:20<00:01, 1.85steps/s, loss=0.21411201]
99%|█████████▉| 99/100 [03:20<00:00, 1.89steps/s, loss=0.21411201]
99%|█████████▉| 99/100 [03:20<00:00, 1.89steps/s, loss=0.21398745]
100%|██████████| 100/100 [03:21<00:00, 1.91steps/s, loss=0.21398745]
100%|██████████| 100/100 [03:21<00:00, 2.01s/steps, loss=0.21398745]
Trained trajectory#
References#
N. Chauffert, P. Weiss, J. Kahn and P. Ciuciu, “A Projection Algorithm for Gradient Waveforms Design in Magnetic Resonance Imaging,” in IEEE Transactions on Medical Imaging, vol. 35, no. 9, pp. 2026-2039, Sept. 2016, doi: 10.1109/TMI.2016.2544251.
G. R. Chaithya, P. Weiss, G. Daval-Frérot, A. Massire, A. Vignaud and P. Ciuciu, “Optimizing Full 3D SPARKLING Trajectories for High-Resolution Magnetic Resonance Imaging,” in IEEE Transactions on Medical Imaging, vol. 41, no. 8, pp. 2105-2117, Aug. 2022, doi: 10.1109/TMI.2022.3157269.
Chaithya GR, and Philippe Ciuciu. 2023. “Jointly Learning Non-Cartesian k-Space Trajectories and Reconstruction Networks for 2D and 3D MR Imaging through Projection” Bioengineering 10, no. 2: 158. https://doi.org/10.3390/bioengineering10020158
Total running time of the script: (3 minutes 30.743 seconds)