Closed ricshaw closed 3 years ago
Hello @ricshaw,
Basically the size of the trajectory is (num_dimensions, kspace_length)
. As you said the construction in the example is only for radial trajectories.
If you want a Cartesian trajectory you should use FFT/IFFT, but I'll assume that you asked this just to understand the package better. The following would construct a Cartesian trajectory for an (8, 6)
image size:
import numpy as np
import torch
ky = np.linspace(-np.pi, np.pi, 8)
kx = np.linspace(-np.pi, np.pi, 6)
kx2, ky2 = np.meshgrid(kx, ky)
ktraj = torch.tensor(np.stack((ky2.flatten(), kx2.flatten())))
This gives a k-space trajectory of shape (2, 48)
.
Hi @mmuckley, thanks for reply, that makes sense.
The reason I wanted a Cartesian trajectory is that I want to transform the k-space (rotate and phase shift it) to simulate MRI motion artefacts. After rotation, the Cartesian k-space no longer aligns with the grid, which is why I want to use your package.
Hi @mmuckley, just one more question: will this framework extend to 3D images/k-space trajectories?
Hello @ricshaw, it should work for any number of dimensions, but performance will degrade with extra dimensions. If the package gets too slow for you, I mention a few performance tips here: https://mmuckley.github.io/tkbn_newversion/#scaling.
Hi @mmuckley, it's still not clear how the batch dimension is defined in the ktraj. In the examples, the comment reads "unsqueeze batch dimension" (In[5] in BasicExample or SENSE example) but there is no unsqueezing happening (there was in v0.3.4). I would need different trajectories for each batch element. Is this still possible? Thanks!
Hello @ajlok3, thank you for pointing this out. You're right, multiple k-space trajectories are no longer possible, and those notebooks have an error. I've just submitted PR #20 to remove these references.
In v0.3.4 we did support multiple batch dimensions but in the backend this was basically me writing a for
loop over trajectories and batches. This removed some optimization opportunities while not really providing any benefit, so in v1.0 I only allow one trajectory for all batches. However, if you want the old behavior you could simply wrap KbNufft
with your own object that loops over the trajectories, and then you could use it as before.
@ajlok3 follow-up question: does your use case involve a large number of small NUFFTs, such as for dynamic MRI? I could write a pretty efficient backend for that use case, a batched k-space NUFFT, if you don't mind filing a dedicated issue for it.
@mmuckley yes exactly, I'll open an issue
Closing this for now that we have the dedicated issue for k-space batches. Feel free to reopen if necessary.
Hi,
I am a bit confused about how the ktraj is defined. In the examples you provide, you use a radial k-space trajectory, and it's shape is (2, 2 x nspokes x image_size). How can I define a simple Cartesian trajectory?
Thanks!