Open mathieuboudreau opened 1 month 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:
# creating the k-space grid with the buffer
new_dimensions = buffer*np.array(dimensions)
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,
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,
Lasly, all our subjects have their arms and part of their torso cropped latterally,
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)