-
Notifications
You must be signed in to change notification settings - Fork 26
Fix image array source #383
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
Conversation
janden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah those plots are a little worrisome. Looks like the issue is that the noise PSD is not accurately estimated. We should use something like AnisotropicNoiseEstimator (or ideally IsotropicNoiseEstimator). The drawback there is that there's not that much data to do an accurate estimate, so you may want to replace the image with an image stack (different patches of the face?).
setup.py
Outdated
| author_email="devs.aspire@gmail.com", | ||
| install_requires=[ | ||
| "click", | ||
| "colorednoise", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm dubious about adding more dependencies here, especially for something that we can do ourselves (using the unfortunately named aspire.image.xform.NoiseAdder). It might be better to just strip out that noise-generating function and use that for these examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can try using the noise adder. If it works that probably would be better. I'll try it this morning.
Understood re depends. When I found the package, I looked at the code and it didn't concern me (likely it has worked and will continue forward indefinitely). As you note below, it doesn't do exactly what we want anyway (though I thought it did enough to flex the code a little).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to use noise adder to add white noise. It isn't clear to me how to do anything more than that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You give it a noise filter that defines the desired PSD of the noise. Something like
f = FunctionFilter(lambda x: np.exp(-x ** 2 / (2 * 0.3 ** 2))
should give interesting results. Another option is
f = FunctionFilter(lambda x: 1 / (1 + x ** 2))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks a lot, big help. I was looking at the PowerFilter etc and it didn't make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I think this is a docs issue. Discoverability is a big problem.
| img_src = ArrayImageSource(img) | ||
|
|
||
| # ASPIRE's WhiteNoiseEstimator consumes from a Source | ||
| noise_estimator = WhiteNoiseEstimator(img_src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not going to do anything since that estimator assumes that the noise is already white. You'll want something like AnisotropicNoiseEstimator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll try it.
|
|
||
| # The following will generate additional distributions of noise. | ||
| pink = ( | ||
| colorednoise.powerlaw_psd_gaussian(1, img_data.shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is tricky because it's not an isotropic noise PSD (it has specific directions that have higher magnitude in them), which is less realistic for cryo-EM images. As I mentioned above, using the built-in noise generation code should give something more reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is directional, that is true. I added some noise going orthogonal direction too, but I realize that isn't the same... I figured so long as it crudely gave any different distribution of power vs freq (which it does) that would serve the purpose. I'm curious if the results using the ASPIRE tools are more appealing. Let's see :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the colorednoise package...
5407510 to
e3a72cc
Compare
I'm not sure I'm reading the plot correctly. So all of the dashed (whitened) lines are flat and concentrated around 5? If so, it looks like whitening is working. |

Closes #378 , an initialization bug.
The new example constructs and uses
ImageArraySource.Using a stock scipy image, it creates a small stack, adds three profiles of noise, applies the noise estimation and whitening procedure, and generates related plots. (Attached).
Looking back I realize some of the plotting stuff is distracting from the actual use, but I like the idea that it actually displays the differences. Open to changing it up if there is a better demonstration.
Main point was to fix 378.