Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor] stage 3 prep: consider padding before aligning #118

Open
mperrin opened this issue Dec 12, 2023 · 4 comments
Open

[minor] stage 3 prep: consider padding before aligning #118

mperrin opened this issue Dec 12, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@mperrin
Copy link
Collaborator

mperrin commented Dec 12, 2023

The example/tutorial notebook calls imageTools.align_frames before imageTools.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:

Screenshot 2023-12-12 at 10 19 40 AM

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.

@mperrin mperrin self-assigned this Dec 12, 2023
@mperrin mperrin added the enhancement New feature or request label Dec 12, 2023
@kammerje
Copy link
Collaborator

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.

@mperrin
Copy link
Collaborator Author

mperrin commented Dec 12, 2023

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!)

@kammerje
Copy link
Collaborator

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.

@kammerje
Copy link
Collaborator

kammerje commented Jul 30, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants