Closed mb1069 closed 3 years ago
I don't think that code actually runs: can you supply a minimal working example with plotting?
model_kwargs = dict(
wl=525, na=1.27, ni=1.33, res=70, size=32, zrange=32, vec_corr="none", condition="none",
)
model = HanserPSF(**model_kwargs)
model = apply_named_aberration('oblique astigmatism', 1)
model = apply_named_aberration('piston', 0)
gives
TypeError Traceback (most recent call last)
<ipython-input-2-d4529ddce059> in <module>
3 )
4 model = HanserPSF(**model_kwargs)
----> 5 model = apply_named_aberration('oblique astigmatism', 1)
6 model = apply_named_aberration('piston', 0)
TypeError: apply_named_aberration() missing 1 required positional argument: 'magnitude'
You can't apply apply_named_aberration
more than once, it will overwrite any previously applied aberrations.
If you want to use more than one aberration see apply_aberration
:
If you think updating apply_named_aberration
to accept multiple aberrations please open another issue.
Oop sorry about, here is a better example with layers plotted
import numpy as np
from skimage import img_as_ubyte
import matplotlib.pyplot as plt
from data.pyOTF.pyotf.otf import apply_named_aberration, HanserPSF
model_kwargs = dict(
wl=525, na=1.27, ni=1.33, res=70, size=32, zsize=32, vec_corr="none", condition="none",
)
model = HanserPSF(**model_kwargs)
psf1 = apply_named_aberration(model, 'oblique astigmatism', 1)
psf2 = apply_named_aberration(psf1, 'piston', 0)
sub_psf = np.concatenate((psf1.PSFi, psf2.PSFi), axis=2)
axial_psf = np.concatenate(sub_psf[slice(5, sub_psf.shape[0]-5, 3)], axis=0)
axial_psf = axial_psf / axial_psf.max()
plt.imshow(axial_psf)
plt.show()
I think I've solved the issue though;
I'd be happy to open a pull request if you think this may be useful to share?
Sure, go for it.
On Feb 21, 2021, at 00:44, Miguel Boland notifications@github.com wrote:
Oop sorry about, here is a better example with layers plotted
import numpy as np from skimage import img_as_ubyte import matplotlib.pyplot as plt
from data.pyOTF.pyotf.otf import apply_named_aberration, HanserPSF
model_kwargs = dict( wl=525, na=1.27, ni=1.33, res=70, size=32, zsize=32, vec_corr="none", condition="none", ) model = HanserPSF(**model_kwargs) psf1 = apply_named_aberration(model, 'oblique astigmatism', 1) psf2 = apply_named_aberration(psf1, 'piston', 0)
sub_psf = np.concatenate((psf1.PSFi, psf2.PSFi), axis=2)
axial_psf = np.concatenate(sub_psf[slice(5, sub_psf.shape[0]-5, 3)], axis=0) axial_psf = axial_psf / axial_psf.max() plt.imshow(axial_psf) plt.show() I think I've solved the issue though;
Convert each named aberration to an array of pcoefs Sum arrays of Pcoefs to obtain coefficients containing multiple abberations Apply as un-named abberation to PSF I'd be happy to open a pull request if you think this may be useful to share?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
@mb1069 one extra thing to note, piston
is just a constant offset so has no effect on the PSF when applied to the phase.
Hi, thank you for writing this great package! I'm trying to apply multiple named aberrations to a PSF, but it seems like only the last aberration is applied.
For example, the PSF generated from this code block is equivalent to an un-abberated PSF.
Is this expected behaviour? If not, is it possible to merge the mcoefs for various named abberations to produce a PSF aberrated using multiple Zernike polynomials?