Open mperrin opened 8 months ago
At least if you want to pad with nans, then the re-centering/alignment steps will not work anymore since the SciPy functions cannot handle images with nans.
Good point. Maybe this would have to be combined in one step that does both the alignment shift and the padding, with appropriate careful handling of the NaNs etc.
I'll set this idea aside for now. Like I said, low priority (especially compared to the other PRs!)
We could also move away from scipy.ndimage.fftshift and use pyKLIP's nanrotate function, which can shift/rotate images with nans correctly. However, I'm not sure if it is using Fourier techniques or spline interpolation.
@4ndyJ Marshall and I have been talking about padding and alignment a while ago. I think your current solution is already great, but I think the cleanest way to do it would be to first only compute all required shifts (using the unpadded data), then pad the data with nans, and only then apply all shifts in a final step using pyKLIP
's klip.rotate
function which can handle nans. This would require splitting the current spaceKLIP
alignment function into separate identify_shifts
and apply_shifts
functions.
The example/tutorial notebook calls
imageTools.align_frames
beforeimageTools.pad_frames
. I'd like to suggest flipping the order of those would better handle pixels at the edge of the array. Doing the alignment shift first results in wrapping pixels around the array from one side to the other, unphysically:Padding before wrapping would avoid this, and thus better handle the edge pixels.
I don't see any reason not to just change the order of steps in the tutorial notebook for this? Will test this later.
This issue is relatively low priority, since the outer handful of pixels aren't the interesting area for science in general.