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

Get a new flow to normalize density compensators #231

Open
chaithyagr opened this issue Jan 16, 2025 · 3 comments
Open

Get a new flow to normalize density compensators #231

chaithyagr opened this issue Jan 16, 2025 · 3 comments

Comments

@chaithyagr
Copy link
Member

In #214 we see that its probably a bad idea to have same normalization across for different backends and methods.
This issue can be used to discuss on how we could have it in a single function which could be a wrapper over density function possibly, something like:

def normalize(func, normalize=<method>, *args, **kwargs):
    dens = func(*args, **kwargs)
    dens = _normalize(dens, method=<method>)

The question is that some normalizations need a fourier_op, which need not be required for estimation schemes like voronoi.
It raises the question on which backend to use then?
I propose the following defaults:

  1. If it is voronoi, we use finufft by default to keep compute on CPU
  2. If it is pipe use the backend same as which backend carried out the estimation.

WDYT @paquiteau ?

@paquiteau
Copy link
Member

paquiteau commented Jan 16, 2025

you are right, the normalizatoin wrt to the psf/energy requires a fourier op. A solution could be to have a normalize_density=False / True (by default to True ?) argument to FourierOperatorBase. And when True, the density is normalized at the end of compute_density

This way the density is normalize with the same backend that is used for the computations.
Note that it works also when given an arbitrary array :)

Another solution is to put this normalization in the density.setter

@chaithyagr
Copy link
Member Author

I like the idea of the setter function, but it could potentially make the code harder to read. Esp, right now the call to the setter is anyway only needed when the trajectory is updated and in that case the compute_density function is anyway called.

I think we are on same page for the stuff which need's fourier_op to normalize. What we need to discuss is mainly for functions like voronoi which doesnt use a fourier_op inherently to calculate the density, which backend do we choose for normalization and how would we proceed with it?

For example, if we do get_density('voronoi')(...) how do we carry out normalization?
I dont think touching compute_density is a good idea. We should rather be updating get_density, as it calls compute_density in any case. This way if user just calls get_density also, he still can get normalized density.

@paquiteau
Copy link
Member

My point is that if the normalization only makes sense with respect to a specific operator, it should be embedded in it. Getting sure that the density is normalized with the same backend used for the computation should not be on the user's shoulders.

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

No branches or pull requests

2 participants