Open mathieuboudreau opened 6 days ago
todo: compare these outputs with outputs of Eva's code
susceptibility-to-fieldmap-fft/functions/compute_fieldmap.py Line 84 in 9a60de9 volume_without_buffer = volume_with_buffer[0:dimensions[0], 0:dimensions[1], 0:dimensions[2]]
I second guessed myself and thought maybe this was being handled through an earlier fftshift
, is this what's expected to be happening? Nonetheless, something related to padding seems to be not working as is expected, at least to me there can be improvements to remove the B0 gradients in the actual volume when the body is set up against it (particularly the torso)
Using np.pad(, 50, mode="reflect")
, I got this results:
I just realized that I haded installed this software on editable mode, so when I tried to change the buffer earlier from 1 to 2 in the code, it might not have done it. Let me try again now
Hmm maybe not - I tried with a multiplicative buffer of 1.2 and still got not great stuff:
Instead of the current multiplication buffer method, https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blob/9a60de9e478b724576d390c63070b48951df5e23/functions/compute_fieldmap.py#L63
I'd recommend using numpys .pad
feature with the reflect option, and make a default padding of something non-zero
2) why the air above the brain should be low B0 values whereas the areas outside the neck/chest area in-plane have high B0 values.
After some reflection, this point makes sense to me, see: delta-chi example early.
@sriosq and I were chatting this morning and I had mentioned how the field maps generated using the human-organ labelled chi volume didn't look right to me from a physics point of view, i.e.
there's really no good explanation as to why 1) there should be a gradient at the top and bottom of the volume and 2) why the air above the brain should be low B0 values whereas the areas outside the neck/chest area in-plane have high B0 values.
I tested this software on an empty volume (chi = air), and that looked fine, basically generates a homogeneous B0 value of ~-6:
I then tried air and a "delta" (one voxel) of chi in the middle of the volume that had chi = water, that looked normal. Zoomed in,
zoomed out:
Then, I made a small box of water in the middle of the volume, this looks ok to me:
Next, and here it doesn't look ok, I made a half-volume of water (volume = cup half full of water),
I also tried one where it was only touching on a few boundaries,
There's no reason why there should be a gradient at the top and bottom here - clearly something if off. Maybe no padding?
According to the README, there should be a padding of "2" (but no unit or explanation, 2 voxel, 2x length of each dim?),
https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blame/9a60de9e478b724576d390c63070b48951df5e23/README.md#L131
But when I looked in the code, the buffer was set to "1", contradicting the README,
https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blob/9a60de9e478b724576d390c63070b48951df5e23/functions/compute_fieldmap.py#L42
So, I changed this value to 2, which the README said it should be, and didn't see much difference in the generated fieldmaps for the last case I showed above:
Looking at the code again, it's clear just by when the "original volume" is extracted from the larger "buffered/padded" volume, that the padding wasn't being set correctly, as
https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blob/9a60de9e478b724576d390c63070b48951df5e23/functions/compute_fieldmap.py#L84
means that the "buffered" volume is just in the top left corner of the unbuffered volume, not in the middle.
Lastly, it's not clear to me how the padding is working in the code, as I think the padding + susceptibility assigenemtn to the volume is implicitely set while doing an FFT,
https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blob/9a60de9e478b724576d390c63070b48951df5e23/functions/compute_fieldmap.py#L78-L80
It's clear from my first "box" case all the way earlier, that if the padding is being done by zero-ing, then there will be a gradient in the bottom of the torso; padding here should be done by extending or mirroring the chi values.
@evaalonsoortiz said her code should be working correctly, I havent checked how this was implemented there yet.
@jcohenadad @CharlesPageot