SyneRBI / SIRF-Exercises

SIRF Training and demonstration material
http://www.ccpsynerbi.ac.uk
Apache License 2.0
18 stars 21 forks source link

update Gradient descent notebook #218

Closed KrisThielemans closed 6 months ago

KrisThielemans commented 6 months ago
KrisThielemans commented 6 months ago

@DANAJK I'm currently still using the "simulated" data. This has the disadvantage that a gradient descent step immediatelly gets the correct solution (but then things with the current default step-size get into difficulties).

With your new data, I also have to set the tau smaller (.1 as opposed to .3), and then get Figure 41 Figure 42

I'm tempted to leave this as-is for now as updating the data will be hard (including retagging SIRF)

DANAJK commented 6 months ago

My new data was a Shepp-Logan phantom so not sure how you get a real looking image!

KrisThielemans commented 6 months ago

😄 ok. I must have run this with the "simulated" data (from brainweb), as in the notebook.

I just now tried to reproduce that on a GitHub Codespace, but I get garbage backprojection (and reconstruction...) Maybe you could give it a go?

image = bwd_mr.as_array()
centre_slice = image.shape[0]//2
plt.figure();plot_2d_image([1,1,1],numpy.abs(image[centre_slice,:,:]),'bla', cmap="viridis")

Figure 3

I'm a bit lost in different versions that I have of everything at the moment.

KrisThielemans commented 6 months ago

correction: the gradient_descent_mr_pet_ct doesn't reconstruct the data in the .h5 file, but just uses it as a template.

KrisThielemans commented 6 months ago

So... the image above was created in a GitHub Codespace, running the synerbi/jupyter docker image, which is apparently somehow 3.5 (see email).

On my VM with SIRF 3.6, I get the following backprojection in the notebook when using simulated_MR_2D_cartesian.h5 Figure 6 and this with your Rep1 data Figure 9 These make sense I believe.

My takeaway therefore is that the MR version that is on the current docker (latest I guess) is broken.

ckolbPTB commented 6 months ago

correction: the gradient_descent_mr_pet_ct doesn't reconstruct the data in the .h5 file, but just uses it as a template.

Yes, we get the parameters for the acquisition model from the .h5 file. We also use the .h5 file to calculate realistic coil maps. Unfortunately, they need to somehow match the brainweb data. This I guess is the reason for the strange image which you had before which looked like it had bits cut out. These were the black ellipses in the centre of the Shepp-Logan-phantom which don't have any signal. This lead to 0 in the csm due to some threshholding which we had at some point. Probably by solving this issue #1221 we indirectly fixed this notebook in 3.6

KrisThielemans commented 6 months ago

interesting. Thanks for that clarification, @ckolbPTB.

So, this PR is good to merge? I might take the opportunity to move it to Introduction, as I suggested in https://github.com/SyneRBI/SIRF-Exercises/issues/193#issuecomment-1404520795