Skip to content

Conversation

@garrettwrong
Copy link
Collaborator

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

ArrayImageSource_1
ArrayImageSource_2

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.

@garrettwrong garrettwrong added bug Something isn't working enhancement New feature or request labels Feb 10, 2021
@garrettwrong garrettwrong self-assigned this Feb 10, 2021
@garrettwrong garrettwrong requested a review from janden as a code owner February 10, 2021 15:36
@garrettwrong garrettwrong linked an issue Feb 10, 2021 that may be closed by this pull request
Copy link
Collaborator

@janden janden left a 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",
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

@garrettwrong garrettwrong marked this pull request as draft February 11, 2021 14:22
@garrettwrong
Copy link
Collaborator Author

I updated to use one of the suggested noise functions in a FunctionFilter along with the anisotropic estimator.
ArrayImageSource_customNoise

If I'm on the right track now we can talk about where we want to go from here.

@janden
Copy link
Collaborator

janden commented Feb 16, 2021

If I'm on the right track now we can talk about where we want to go from here.

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.

@garrettwrong garrettwrong marked this pull request as ready for review February 18, 2021 15:56
@garrettwrong garrettwrong requested a review from janden February 18, 2021 15:57
@garrettwrong garrettwrong requested a review from janden February 19, 2021 13:25
@garrettwrong garrettwrong merged commit 8cda150 into develop Feb 19, 2021
@garrettwrong garrettwrong deleted the fix_ImageArraySource branch February 19, 2021 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImageArraySource doesn't work with filter/pipelines

3 participants