Learn Sampling pattern#

A small pytorch example to showcase learning k-space sampling patterns. This example showcases the auto-diff capabilities of the NUFFT operator wrt to k-space trajectory in mri-nufft.

In this example, we solve the following optimization problem:

\[\mathbf{\hat{K}} = \mathrm{arg} \min_{\mathbf{K}} || \mathcal{F}_\mathbf{K}^* D_\mathbf{K} \mathcal{F}_\mathbf{K} \mathbf{x} - \mathbf{x} ||_2^2\]

where \(\mathcal{F}_\mathbf{K}\) is the forward NUFFT operator and \(D_\mathbf{K}\) is the density compensators for trajectory \(\mathbf{K}\), \(\mathbf{x}\) is the MR image which is also the target image to be reconstructed.

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.

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
from mrinufft.trajectories import initialize_2D_radial

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 be setup in get_operator to have all the gradients computed correctly. See [Projector] for more details.

class Model(torch.nn.Module):
    def __init__(self, inital_trajectory):
        super(Model, self).__init__()
        self.trajectory = torch.nn.Parameter(
            data=torch.Tensor(inital_trajectory),
            requires_grad=True,
        )
        self.operator = get_operator("gpunufft", wrt_data=True, wrt_traj=True)(
            self.trajectory.detach().cpu().numpy(),
            shape=(256, 256),
            density=True,
            squeeze_dims=False,
        )

    def forward(self, x):
        # Update the trajectory in the NUFFT operator.
        # Note that the re-computation of density compensation happens internally.
        self.operator.samples = self.trajectory.clone()

        # A simple acquisition model simulated with a forward NUFFT operator
        kspace = self.operator.op(x)

        # A simple density compensated adjoint operator
        adjoint = self.operator.adj_op(kspace)
        return adjoint / torch.linalg.norm(adjoint)

Util function to plot the state of the model#

def plot_state(axs, mri_2D, traj, recon, loss=None, save_name=None):
    axs = axs.flatten()
    axs[0].imshow(np.abs(mri_2D[0]), cmap="gray")
    axs[0].axis("off")
    axs[0].set_title("MR Image")
    axs[1].scatter(*traj.T, s=1)
    axs[1].set_title("Trajectory")
    axs[2].imshow(np.abs(recon[0][0].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].set_title("Loss")
        axs[3].grid("on")
    if save_name is not None:
        plt.savefig(save_name, bbox_inches="tight")
        plt.close()
    else:
        plt.show()

Setup model and optimizer#

init_traj = initialize_2D_radial(16, 512).reshape(-1, 2).astype(np.float32)
model = Model(init_traj)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
schedulder = torch.optim.lr_scheduler.LinearLR(
    optimizer, start_factor=1, end_factor=0.1, total_iters=100
)

Setup data#

mri_2D = torch.Tensor(np.flipud(bwdl.get_mri(4, "T1")[80, ...]).astype(np.complex64))[
    None
]
mri_2D = mri_2D / torch.linalg.norm(mri_2D)
model.eval()
recon = model(mri_2D)
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
plot_state(axs, mri_2D, init_traj, recon)
MR Image, Trajectory, Reconstruction

Start training loop#

losses = []
image_files = []
model.train()
with tqdm(range(100), unit="steps") as tqdms:
    for i in tqdms:
        out = model(mri_2D)
        loss = torch.norm(out - mri_2D[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)
        schedulder.step()
        # Generate images for gif
        hashed = joblib.hash((i, "learn_traj", time.time()))
        filename = "/tmp/" + f"{hashed}.png"
        fig, axs = plt.subplots(2, 2, figsize=(10, 10))
        plot_state(
            axs,
            mri_2D,
            model.trajectory.detach().cpu().numpy(),
            out,
            losses,
            save_name=filename,
        )
        image_files.append(filename)


# Make a GIF of all images.
imgs = [Image.open(img) for img in image_files]
imgs[0].save(
    "mrinufft_learn_traj.gif",
    save_all=True,
    append_images=imgs[1:],
    optimize=False,
    duration=2,
    loop=0,
)

# sphinx_gallery_thumbnail_path = 'generated/autoexamples/GPU/images/mrinufft_learn_traj.gif'
  0%|          | 0/100 [00:00<?, ?steps/s]
  0%|          | 0/100 [00:00<?, ?steps/s, loss=0.29853114]
  1%|          | 1/100 [00:00<01:33,  1.06steps/s, loss=0.29853114]
  1%|          | 1/100 [00:01<01:33,  1.06steps/s, loss=0.3715377]
  2%|▏         | 2/100 [00:01<01:32,  1.06steps/s, loss=0.3715377]
  2%|▏         | 2/100 [00:01<01:32,  1.06steps/s, loss=0.3289515]
  3%|▎         | 3/100 [00:02<01:19,  1.23steps/s, loss=0.3289515]
  3%|▎         | 3/100 [00:02<01:19,  1.23steps/s, loss=0.27463254]
  4%|▍         | 4/100 [00:03<01:23,  1.15steps/s, loss=0.27463254]
  4%|▍         | 4/100 [00:03<01:23,  1.15steps/s, loss=0.28361824]
  5%|▌         | 5/100 [00:04<01:28,  1.07steps/s, loss=0.28361824]
  5%|▌         | 5/100 [00:04<01:28,  1.07steps/s, loss=0.25916383]
  6%|▌         | 6/100 [00:05<01:27,  1.07steps/s, loss=0.25916383]
  6%|▌         | 6/100 [00:05<01:27,  1.07steps/s, loss=0.25019777]
  7%|▋         | 7/100 [00:06<01:27,  1.06steps/s, loss=0.25019777]
  7%|▋         | 7/100 [00:06<01:27,  1.06steps/s, loss=0.24915436]
  8%|▊         | 8/100 [00:07<01:27,  1.05steps/s, loss=0.24915436]
  8%|▊         | 8/100 [00:07<01:27,  1.05steps/s, loss=0.23751041]
  9%|▉         | 9/100 [00:08<01:36,  1.06s/steps, loss=0.23751041]
  9%|▉         | 9/100 [00:08<01:36,  1.06s/steps, loss=0.23241578]
 10%|█         | 10/100 [00:09<01:33,  1.04s/steps, loss=0.23241578]
 10%|█         | 10/100 [00:09<01:33,  1.04s/steps, loss=0.22191127]
 11%|█         | 11/100 [00:10<01:29,  1.01s/steps, loss=0.22191127]
 11%|█         | 11/100 [00:10<01:29,  1.01s/steps, loss=0.21985826]
 12%|█▏        | 12/100 [00:11<01:26,  1.01steps/s, loss=0.21985826]
 12%|█▏        | 12/100 [00:11<01:26,  1.01steps/s, loss=0.2141064]
 13%|█▎        | 13/100 [00:12<01:26,  1.01steps/s, loss=0.2141064]
 13%|█▎        | 13/100 [00:12<01:26,  1.01steps/s, loss=0.21121228]
 14%|█▍        | 14/100 [00:13<01:22,  1.05steps/s, loss=0.21121228]
 14%|█▍        | 14/100 [00:13<01:22,  1.05steps/s, loss=0.20349331]
 15%|█▌        | 15/100 [00:14<01:21,  1.04steps/s, loss=0.20349331]
 15%|█▌        | 15/100 [00:14<01:21,  1.04steps/s, loss=0.19894668]
 16%|█▌        | 16/100 [00:15<01:19,  1.06steps/s, loss=0.19894668]
 16%|█▌        | 16/100 [00:15<01:19,  1.06steps/s, loss=0.19799793]
 17%|█▋        | 17/100 [00:16<01:15,  1.10steps/s, loss=0.19799793]
 17%|█▋        | 17/100 [00:16<01:15,  1.10steps/s, loss=0.19489819]
 18%|█▊        | 18/100 [00:17<01:20,  1.02steps/s, loss=0.19489819]
 18%|█▊        | 18/100 [00:17<01:20,  1.02steps/s, loss=0.18927023]
 19%|█▉        | 19/100 [00:18<01:15,  1.07steps/s, loss=0.18927023]
 19%|█▉        | 19/100 [00:18<01:15,  1.07steps/s, loss=0.18919937]
 20%|██        | 20/100 [00:18<01:07,  1.18steps/s, loss=0.18919937]
 20%|██        | 20/100 [00:18<01:07,  1.18steps/s, loss=0.18728735]
 21%|██        | 21/100 [00:19<01:04,  1.22steps/s, loss=0.18728735]
 21%|██        | 21/100 [00:19<01:04,  1.22steps/s, loss=0.18237497]
 22%|██▏       | 22/100 [00:20<01:00,  1.29steps/s, loss=0.18237497]
 22%|██▏       | 22/100 [00:20<01:00,  1.29steps/s, loss=0.18559013]
 23%|██▎       | 23/100 [00:20<00:58,  1.31steps/s, loss=0.18559013]
 23%|██▎       | 23/100 [00:21<00:58,  1.31steps/s, loss=0.17823769]
 24%|██▍       | 24/100 [00:21<00:59,  1.28steps/s, loss=0.17823769]
 24%|██▍       | 24/100 [00:21<00:59,  1.28steps/s, loss=0.18001139]
 25%|██▌       | 25/100 [00:22<00:55,  1.34steps/s, loss=0.18001139]
 25%|██▌       | 25/100 [00:22<00:55,  1.34steps/s, loss=0.17769814]
 26%|██▌       | 26/100 [00:23<00:55,  1.32steps/s, loss=0.17769814]
 26%|██▌       | 26/100 [00:23<00:55,  1.32steps/s, loss=0.17842996]
 27%|██▋       | 27/100 [00:24<01:01,  1.19steps/s, loss=0.17842996]
 27%|██▋       | 27/100 [00:24<01:01,  1.19steps/s, loss=0.17642964]
 28%|██▊       | 28/100 [00:25<01:02,  1.16steps/s, loss=0.17642964]
 28%|██▊       | 28/100 [00:25<01:02,  1.16steps/s, loss=0.17513345]
 29%|██▉       | 29/100 [00:25<00:58,  1.22steps/s, loss=0.17513345]
 29%|██▉       | 29/100 [00:25<00:58,  1.22steps/s, loss=0.17657809]
 30%|███       | 30/100 [00:26<00:54,  1.27steps/s, loss=0.17657809]
 30%|███       | 30/100 [00:26<00:54,  1.27steps/s, loss=0.16999914]
 31%|███       | 31/100 [00:27<00:52,  1.31steps/s, loss=0.16999914]
 31%|███       | 31/100 [00:27<00:52,  1.31steps/s, loss=0.17742512]
 32%|███▏      | 32/100 [00:28<00:50,  1.34steps/s, loss=0.17742512]
 32%|███▏      | 32/100 [00:28<00:50,  1.34steps/s, loss=0.18291757]
 33%|███▎      | 33/100 [00:28<00:50,  1.33steps/s, loss=0.18291757]
 33%|███▎      | 33/100 [00:28<00:50,  1.33steps/s, loss=0.16693476]
 34%|███▍      | 34/100 [00:29<00:48,  1.37steps/s, loss=0.16693476]
 34%|███▍      | 34/100 [00:29<00:48,  1.37steps/s, loss=0.18133223]
 35%|███▌      | 35/100 [00:30<00:46,  1.41steps/s, loss=0.18133223]
 35%|███▌      | 35/100 [00:30<00:46,  1.41steps/s, loss=0.17097367]
 36%|███▌      | 36/100 [00:31<00:49,  1.29steps/s, loss=0.17097367]
 36%|███▌      | 36/100 [00:31<00:49,  1.29steps/s, loss=0.16787061]
 37%|███▋      | 37/100 [00:31<00:46,  1.34steps/s, loss=0.16787061]
 37%|███▋      | 37/100 [00:31<00:46,  1.34steps/s, loss=0.16886485]
 38%|███▊      | 38/100 [00:32<00:45,  1.37steps/s, loss=0.16886485]
 38%|███▊      | 38/100 [00:32<00:45,  1.37steps/s, loss=0.16610852]
 39%|███▉      | 39/100 [00:33<00:42,  1.43steps/s, loss=0.16610852]
 39%|███▉      | 39/100 [00:33<00:42,  1.43steps/s, loss=0.16008712]
 40%|████      | 40/100 [00:33<00:41,  1.45steps/s, loss=0.16008712]
 40%|████      | 40/100 [00:33<00:41,  1.45steps/s, loss=0.16550618]
 41%|████      | 41/100 [00:34<00:40,  1.46steps/s, loss=0.16550618]
 41%|████      | 41/100 [00:34<00:40,  1.46steps/s, loss=0.15895006]
 42%|████▏     | 42/100 [00:35<00:38,  1.49steps/s, loss=0.15895006]
 42%|████▏     | 42/100 [00:35<00:38,  1.49steps/s, loss=0.16028209]
 43%|████▎     | 43/100 [00:35<00:38,  1.47steps/s, loss=0.16028209]
 43%|████▎     | 43/100 [00:35<00:38,  1.47steps/s, loss=0.16036072]
 44%|████▍     | 44/100 [00:36<00:37,  1.48steps/s, loss=0.16036072]
 44%|████▍     | 44/100 [00:36<00:37,  1.48steps/s, loss=0.15742545]
 45%|████▌     | 45/100 [00:37<00:42,  1.29steps/s, loss=0.15742545]
 45%|████▌     | 45/100 [00:37<00:42,  1.29steps/s, loss=0.16520257]
 46%|████▌     | 46/100 [00:38<00:40,  1.34steps/s, loss=0.16520257]
 46%|████▌     | 46/100 [00:38<00:40,  1.34steps/s, loss=0.16006899]
 47%|████▋     | 47/100 [00:38<00:38,  1.37steps/s, loss=0.16006899]
 47%|████▋     | 47/100 [00:38<00:38,  1.37steps/s, loss=0.17128162]
 48%|████▊     | 48/100 [00:39<00:37,  1.38steps/s, loss=0.17128162]
 48%|████▊     | 48/100 [00:39<00:37,  1.38steps/s, loss=0.15866846]
 49%|████▉     | 49/100 [00:40<00:36,  1.41steps/s, loss=0.15866846]
 49%|████▉     | 49/100 [00:40<00:36,  1.41steps/s, loss=0.15901263]
 50%|█████     | 50/100 [00:40<00:34,  1.44steps/s, loss=0.15901263]
 50%|█████     | 50/100 [00:40<00:34,  1.44steps/s, loss=0.15658824]
 51%|█████     | 51/100 [00:41<00:33,  1.45steps/s, loss=0.15658824]
 51%|█████     | 51/100 [00:41<00:33,  1.45steps/s, loss=0.15355535]
 52%|█████▏    | 52/100 [00:42<00:32,  1.46steps/s, loss=0.15355535]
 52%|█████▏    | 52/100 [00:42<00:32,  1.46steps/s, loss=0.15360205]
 53%|█████▎    | 53/100 [00:42<00:32,  1.45steps/s, loss=0.15360205]
 53%|█████▎    | 53/100 [00:42<00:32,  1.45steps/s, loss=0.15420735]
 54%|█████▍    | 54/100 [00:43<00:31,  1.46steps/s, loss=0.15420735]
 54%|█████▍    | 54/100 [00:43<00:31,  1.46steps/s, loss=0.15479475]
 55%|█████▌    | 55/100 [00:44<00:34,  1.29steps/s, loss=0.15479475]
 55%|█████▌    | 55/100 [00:44<00:34,  1.29steps/s, loss=0.15213309]
 56%|█████▌    | 56/100 [00:45<00:32,  1.34steps/s, loss=0.15213309]
 56%|█████▌    | 56/100 [00:45<00:32,  1.34steps/s, loss=0.14860234]
 57%|█████▋    | 57/100 [00:45<00:31,  1.36steps/s, loss=0.14860234]
 57%|█████▋    | 57/100 [00:46<00:31,  1.36steps/s, loss=0.15003154]
 58%|█████▊    | 58/100 [00:46<00:30,  1.39steps/s, loss=0.15003154]
 58%|█████▊    | 58/100 [00:46<00:30,  1.39steps/s, loss=0.14973503]
 59%|█████▉    | 59/100 [00:47<00:29,  1.41steps/s, loss=0.14973503]
 59%|█████▉    | 59/100 [00:47<00:29,  1.41steps/s, loss=0.14750656]
 60%|██████    | 60/100 [00:47<00:27,  1.43steps/s, loss=0.14750656]
 60%|██████    | 60/100 [00:48<00:27,  1.43steps/s, loss=0.14787951]
 61%|██████    | 61/100 [00:48<00:26,  1.45steps/s, loss=0.14787951]
 61%|██████    | 61/100 [00:48<00:26,  1.45steps/s, loss=0.15791015]
 62%|██████▏   | 62/100 [00:49<00:26,  1.44steps/s, loss=0.15791015]
 62%|██████▏   | 62/100 [00:49<00:26,  1.44steps/s, loss=0.176487]
 63%|██████▎   | 63/100 [00:49<00:24,  1.49steps/s, loss=0.176487]
 63%|██████▎   | 63/100 [00:49<00:24,  1.49steps/s, loss=0.15578654]
 64%|██████▍   | 64/100 [00:50<00:28,  1.28steps/s, loss=0.15578654]
 64%|██████▍   | 64/100 [00:51<00:28,  1.28steps/s, loss=0.16438918]
 65%|██████▌   | 65/100 [00:51<00:25,  1.37steps/s, loss=0.16438918]
 65%|██████▌   | 65/100 [00:51<00:25,  1.37steps/s, loss=0.17212538]
 66%|██████▌   | 66/100 [00:52<00:23,  1.43steps/s, loss=0.17212538]
 66%|██████▌   | 66/100 [00:52<00:23,  1.43steps/s, loss=0.15368888]
 67%|██████▋   | 67/100 [00:52<00:22,  1.47steps/s, loss=0.15368888]
 67%|██████▋   | 67/100 [00:52<00:22,  1.47steps/s, loss=0.15715033]
 68%|██████▊   | 68/100 [00:53<00:21,  1.47steps/s, loss=0.15715033]
 68%|██████▊   | 68/100 [00:53<00:21,  1.47steps/s, loss=0.16245264]
 69%|██████▉   | 69/100 [00:54<00:20,  1.50steps/s, loss=0.16245264]
 69%|██████▉   | 69/100 [00:54<00:20,  1.50steps/s, loss=0.1605418]
 70%|███████   | 70/100 [00:54<00:19,  1.52steps/s, loss=0.1605418]
 70%|███████   | 70/100 [00:54<00:19,  1.52steps/s, loss=0.15610658]
 71%|███████   | 71/100 [00:55<00:18,  1.54steps/s, loss=0.15610658]
 71%|███████   | 71/100 [00:55<00:18,  1.54steps/s, loss=0.15033068]
 72%|███████▏  | 72/100 [00:56<00:18,  1.55steps/s, loss=0.15033068]
 72%|███████▏  | 72/100 [00:56<00:18,  1.55steps/s, loss=0.14960997]
 73%|███████▎  | 73/100 [00:57<00:19,  1.36steps/s, loss=0.14960997]
 73%|███████▎  | 73/100 [00:57<00:19,  1.36steps/s, loss=0.15143587]
 74%|███████▍  | 74/100 [00:57<00:18,  1.44steps/s, loss=0.15143587]
 74%|███████▍  | 74/100 [00:57<00:18,  1.44steps/s, loss=0.15520753]
 75%|███████▌  | 75/100 [00:58<00:16,  1.49steps/s, loss=0.15520753]
 75%|███████▌  | 75/100 [00:58<00:16,  1.49steps/s, loss=0.14738284]
 76%|███████▌  | 76/100 [00:58<00:15,  1.54steps/s, loss=0.14738284]
 76%|███████▌  | 76/100 [00:58<00:15,  1.54steps/s, loss=0.14490451]
 77%|███████▋  | 77/100 [00:59<00:14,  1.57steps/s, loss=0.14490451]
 77%|███████▋  | 77/100 [00:59<00:14,  1.57steps/s, loss=0.14565213]
 78%|███████▊  | 78/100 [01:00<00:14,  1.56steps/s, loss=0.14565213]
 78%|███████▊  | 78/100 [01:00<00:14,  1.56steps/s, loss=0.14625132]
 79%|███████▉  | 79/100 [01:00<00:13,  1.56steps/s, loss=0.14625132]
 79%|███████▉  | 79/100 [01:00<00:13,  1.56steps/s, loss=0.1435625]
 80%|████████  | 80/100 [01:01<00:12,  1.58steps/s, loss=0.1435625]
 80%|████████  | 80/100 [01:01<00:12,  1.58steps/s, loss=0.14449579]
 81%|████████  | 81/100 [01:01<00:12,  1.58steps/s, loss=0.14449579]
 81%|████████  | 81/100 [01:02<00:12,  1.58steps/s, loss=0.14517811]
 82%|████████▏ | 82/100 [01:02<00:11,  1.59steps/s, loss=0.14517811]
 82%|████████▏ | 82/100 [01:02<00:11,  1.59steps/s, loss=0.14757335]
 83%|████████▎ | 83/100 [01:03<00:12,  1.35steps/s, loss=0.14757335]
 83%|████████▎ | 83/100 [01:03<00:12,  1.35steps/s, loss=0.14651722]
 84%|████████▍ | 84/100 [01:04<00:11,  1.41steps/s, loss=0.14651722]
 84%|████████▍ | 84/100 [01:04<00:11,  1.41steps/s, loss=0.14653635]
 85%|████████▌ | 85/100 [01:04<00:10,  1.46steps/s, loss=0.14653635]
 85%|████████▌ | 85/100 [01:04<00:10,  1.46steps/s, loss=0.15002279]
 86%|████████▌ | 86/100 [01:05<00:09,  1.50steps/s, loss=0.15002279]
 86%|████████▌ | 86/100 [01:05<00:09,  1.50steps/s, loss=0.14735469]
 87%|████████▋ | 87/100 [01:06<00:08,  1.52steps/s, loss=0.14735469]
 87%|████████▋ | 87/100 [01:06<00:08,  1.52steps/s, loss=0.14512725]
 88%|████████▊ | 88/100 [01:06<00:07,  1.54steps/s, loss=0.14512725]
 88%|████████▊ | 88/100 [01:06<00:07,  1.54steps/s, loss=0.14405246]
 89%|████████▉ | 89/100 [01:07<00:07,  1.55steps/s, loss=0.14405246]
 89%|████████▉ | 89/100 [01:07<00:07,  1.55steps/s, loss=0.14355968]
 90%|█████████ | 90/100 [01:08<00:06,  1.56steps/s, loss=0.14355968]
 90%|█████████ | 90/100 [01:08<00:06,  1.56steps/s, loss=0.14176393]
 91%|█████████ | 91/100 [01:08<00:05,  1.58steps/s, loss=0.14176393]
 91%|█████████ | 91/100 [01:08<00:05,  1.58steps/s, loss=0.14056619]
 92%|█████████▏| 92/100 [01:09<00:05,  1.37steps/s, loss=0.14056619]
 92%|█████████▏| 92/100 [01:09<00:05,  1.37steps/s, loss=0.13877027]
 93%|█████████▎| 93/100 [01:10<00:04,  1.41steps/s, loss=0.13877027]
 93%|█████████▎| 93/100 [01:10<00:04,  1.41steps/s, loss=0.13921037]
 94%|█████████▍| 94/100 [01:10<00:04,  1.46steps/s, loss=0.13921037]
 94%|█████████▍| 94/100 [01:10<00:04,  1.46steps/s, loss=0.13800207]
 95%|█████████▌| 95/100 [01:11<00:03,  1.49steps/s, loss=0.13800207]
 95%|█████████▌| 95/100 [01:11<00:03,  1.49steps/s, loss=0.13756067]
 96%|█████████▌| 96/100 [01:12<00:02,  1.51steps/s, loss=0.13756067]
 96%|█████████▌| 96/100 [01:12<00:02,  1.51steps/s, loss=0.13689929]
 97%|█████████▋| 97/100 [01:12<00:01,  1.53steps/s, loss=0.13689929]
 97%|█████████▋| 97/100 [01:12<00:01,  1.53steps/s, loss=0.13597475]
 98%|█████████▊| 98/100 [01:13<00:01,  1.54steps/s, loss=0.13597475]
 98%|█████████▊| 98/100 [01:13<00:01,  1.54steps/s, loss=0.13547918]
 99%|█████████▉| 99/100 [01:14<00:00,  1.53steps/s, loss=0.13547918]
 99%|█████████▉| 99/100 [01:14<00:00,  1.53steps/s, loss=0.13551971]
100%|██████████| 100/100 [01:14<00:00,  1.54steps/s, loss=0.13551971]
100%|██████████| 100/100 [01:14<00:00,  1.34steps/s, loss=0.13551971]
example learn_samples

Trained trajectory#

model.eval()
recon = model(mri_2D)
fig, axs = plt.subplots(2, 2, figsize=(10, 10))
plot_state(axs, mri_2D, model.trajectory.detach().cpu().numpy(), recon, losses)
plt.show()
MR Image, Trajectory, Reconstruction, Loss

References#

[Proj]

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.

[Sparks]

Chaithya GR, 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.

[Projector]

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: (1 minutes 20.394 seconds)

Gallery generated by Sphinx-Gallery