shimming-toolbox / b0-fieldmap-realistic-simulation

Optimization of shim coil layout placement using simulated B0 and B1 maps constructed from segmented MRI scans of the head and full spine region. This is a collaboration between NeuroPoly Lab (Montreal) and MGH Martinos Center (Boston).
MIT License
0 stars 0 forks source link

Padding strategy: torso, back, arms #12

Open mathieuboudreau opened 1 month ago

mathieuboudreau commented 1 month ago

All our subjects have torso's cut off at the boundary, such that edge padding should be used over zero padding to avoid introducing a non-existent air-torso interface,

Screenshot 2024-10-25 at 9 21 53 AM

Also, several subjects have their backs slightly (or a lot) touching the boundary, and here zero (or air-chi) padding would be best imo. You can clearly see the effect that edge padding has on the field simulation for this case in the example below,

Screenshot 2024-10-25 at 9 22 53 AM

Lasly, all our subjects have their arms and part of their torso cropped latterally,

Screenshot 2024-10-25 at 9 24 03 AM

I'm not sure what would be the best strategy here - I guess it would depend on the padding distance. If we're only going to pad up to 10 cm each boundary, then edge padding would make a bit more sense (but even then, not ideal because it extends the lung cavity), but further away than that we would need to introduce air I think.

tl;dr instead of edge padding all boundaries, we should probably edge pad all the sides besides the back, and air-pad the back. So, a 2-step padding procedure, which numpy can do I believe by selecting which boundaries you want to pad. And then, maybe set a limit for the padding distance where, beyond that, we would start zero padding the sides of the torso (and maybe even, the legs at some point if you really want to pad far away)

mathieuboudreau commented 3 weeks ago

Writing a note here for documentation purposes:

In a discussion yesterday, Eva reminded me that after padding, the pairity of the dimensions must be preserved, i.e. if x dim was odd before it must be odd after padding, same for y and z. If they were even, it also needs to be preserved.

With my suggested padding, this condition is met (since the padding is symmetrical on both sides of each axis, eg a 129 voxel +50 padding on one side then +50 on the other results in 229, for 128 it would result in 128.

Note however that the old implementation done by Charles's initial code (and I think, possibly inherited from the MATLAB version of the code) does not meet this condition. Before, padding was done as a multiplicative factor, with default 2, so 129 with x2 padding would have been 258, changing the parity.

See:

https://github.com/shimming-toolbox/susceptibility-to-fieldmap-fft/blob/9a60de9e478b724576d390c63070b48951df5e23/functions/compute_fieldmap.py#L63

# creating the k-space grid with the buffer
new_dimensions = buffer*np.array(dimensions)