rs-station / reciprocalspaceship

Tools for exploring reciprocal space
https://rs-station.github.io/reciprocalspaceship/
MIT License
28 stars 11 forks source link

mean_intensity_by_miller_index should use a grid #238

Open kmdalton opened 6 months ago

kmdalton commented 6 months ago

Isotropic French-Wilson scaling uses grid points to efficiently estimate the resolution-dependent average intensity. However, anisotropic scaling currently does not. It just computes the full kernel matrix one row at a time. I see no reason why this couldn't use a grid like the isotropic version which would help combat overfitting and improve performance.

DHekstra commented 6 months ago

Observation: in my use of this procedure in VALDO, I get better final results (difference map peak heights) for the isotropic scaling approach than for the anisotropic approach. It is also ~3-4x faster.

Low-priority remark: Could it also help to first apply an approximate normalization using the inverse of a fitted B matrix, then apply the local averaging, and then unnormalize? It's a bit dubious to calculate a local Sigma when the overall scale of the data varies quite strongly with resolution and direction in the reciprocal lattice. For an example of how to estimate the anisotropic B factor matrix, see https://github.com/Hekstra-Lab/double-wilson/blob/main/1_Dataset_prep_and_local_scaling.ipynb, which calls https://github.com/Hekstra-Lab/double-wilson/blob/main/dw_tools/aniso_scaling_step_1.py (yes, I calculated all the gradients by hand).