PTB-MR / mrpro

MR image reconstruction and processing.
https://ptb-mr.github.io/mrpro/
Apache License 2.0
18 stars 2 forks source link

GridSamplingOp on dynamics #513

Open guastinimara opened 2 weeks ago

guastinimara commented 2 weeks ago

I had problems using the GridSamplingOp on image dynamics, in particular on images in the shape of (other 1 1 y x) with grids of shape (other y x 2), where in other I had the different timesteps, so other was bigger than 1 both for the images and for the grids (and it was the same value)

the error came from the GridSamplingOp rearrange: x_real = rearrange(torch.view_as_real(x), '... real_imag -> real_imag ...') if x.is_complex() else x which led to a broadcasting error

For what I need it for, I used it just by changing it into x_real = rearrange(torch.view_as_real(x), ' other ... real_imag -> other real_imag ... ') if x.is_complex() else x and result = torch.view_as_complex(rearrange(result, 'other real_imag ... -> other ... real_imag').contiguous())

This worked for me, but it would work only if either other is the same for images and grids, or one of them is equal to one, so maybe there is a better way to generalize this

guastinimara commented 2 weeks ago

Like for example if the other dimension in the images is a multiple of that in the grids, this doesn't work