Closed DennisDannecker closed 5 months ago
Hi Dennis,
Glad to see some use of this library. Have you also seen analyzefrc, it might provide some additional function.
Back to the problem: I'll try to investigate this further, but in the meantime you can try by not calculating the intersection (which tries to compute an intersection between a user-defined threshold and the FRC curve) and simply inspecting the plot and see if they intersect at all. In your case that could be done by removing the lines:
frc_res, res_y, thres = frc.frc_res(xs_ang_freq, frc_curve, im_1_array_size)
plt.plot(xs_ang_freq, thres(xs_ang_freq))
I'll also see if I can update the dependencies and make everything compatible with more modern Python versions.
Since I don't have the exact code with which you load the image (e.g. how you define input_directory_test_siemens_iamge
), I can't exactly reproduce your example. But if I run the following:
import numpy as np
import frc
import matplotlib.pyplot as plt
import analyzefrc as afrc
# test siemens image
im_1_array = afrc.get_image('./siemens.tiff')
# Apply tukey window for dft calc
im_1_array = frc.util.apply_tukey(im_1_array)
# Apply 1FRC technique (binomial splitting with method one)
frc_curve = frc.one_frc(im_1_array)
im_1_array_size = im_1_array.shape[0]
xs_pix = np.arange(len(frc_curve)) / im_1_array_size
# scale has units [pixels <length unit>^-1] corresponding to original image
scale = 2
xs_ang_freq = xs_pix * scale
frc_res, res_y, thres = frc.frc_res(xs_ang_freq, frc_curve, im_1_array_size)
plt.plot(xs_ang_freq, thres(xs_ang_freq))
plt.plot(xs_ang_freq, frc_curve)
plt.show()
I get an image with that perfectly intersects for "siemens.tiff" with the above code, so right now I can't reproduce your problem.
Hi,
sorry for the late reply.
I found the error. For my images on which I was using the frc analysis there was actually such high correlation that it would simply never drop to the defined threshold level and thus never intersect. Indeed, if I am using FRC1 doing the binomial splitting, turns out the correlation is heavily overestimated for my images. With FRC2 it works better (provided I have to images of the same signal with different realizations of noise).
I am aware of the analyzefrc package and have actually used it before. Both libraries are actually very cool and helpful, thanks for your contributions. All this in a BSc-Thesis, pretty awesome and impressive.
Is it possible there is significant readout noise? In my thesis I observed that it didn't drop to the threshold if there was significant Gaussian noise in the image. My supervisor (Bernd Rieger) continued the research and will soon publish a paper that provides a more mathematical basis for 1FRC and a way to avoid this problem. If you are interested in it when it comes out, let me know and I can send it to you.
I am aware of the analyzefrc package and have actually used it before. Both libraries are actually very cool and helpful, thanks for your contributions. All this in a BSc-Thesis, pretty awesome and impressive.
Thank you! If there is anything I can help with otherwise, let me know (for instance updating it for more recent versions of Python).
Is it possible there is significant readout noise? In my thesis I observed that it didn't drop to the threshold if there was significant Gaussian noise in the image. My supervisor (Bernd Rieger) continued the research and will soon publish a paper that provides a more mathematical basis for 1FRC and a way to avoid this problem. If you are interested in it when it comes out, let me know and I can send it to you.
That would be great, yes, if you don't mind, I would much appreciate you sending the paper once published.
The images I am dealing with are acquired from a cryo-electron microscope (EM), just in case you are familiar with this type of imaging technique. Indeed, there is a significant amount of noise, however, the dominating noise is "shot-noise" (Poisson-like distributed noise, but can be approximated using Gaussian noise). The signal-to-noise ratio is somewhere around 0.1. 1FRC is interesting in the cases were only single micrographs (micrographs are the images recorded with EM) are available. This way one could estimate SSNR just from the single image available. With the advent of new detectors one can collect several frames (images of the same object (underlying signal) with truly independent realizations of noise), thus no longer requires the 1FRC but can simply use the 2FRC.
Thank you! If there is anything I can help with otherwise, let me know (for instance updating it for more recent versions of Python).
For me it actually worked well, I set up a pip environment with the required packages and everything worked quite smoothly and painless, so I guess we are good here.
Indeed, there is a significant amount of noise, however, the dominating noise is "shot-noise" (Poisson-like distributed noise, but can be approximated using Gaussian noise). The signal-to-noise ratio is somewhere around 0.1. 1FRC is interesting in the cases were only single micrographs (micrographs are the images recorded with EM) are available. This way one could estimate SSNR just from the single image available. With the advent of new detectors one can collect several frames (images of the same object (underlying signal) with truly independent realizations of noise), thus no longer requires the 1FRC but can simply use the 2FRC.
Yes, the Poisson noise is what makes this method work. With readout-noise I meant e.g. electrical noise from the measurement process (or maybe some other process?). In my simulations pure Poisson noise worked great with 1FRC, but the moment that other types of noise were added (for example Gaussian noise), you get the situation you described with your curve. I've added a link to my bachelor thesis in the readme if you're interested in what I looked at!
I was never able to get around to testing EM images (instead mostly at STED images), so it is interesting to see that maybe these have some different noise characteristics that make the technique no longer work.
The upcoming paper by Bernd Rieger/Sjoerd Stallinga should hopefully provide some additional detail. I'll definitely link it in the repository once it gets through the review process.
@DennisDannecker their paper has been published, you can find the link here: https://doi.org/10.1364/OE.524683.
I'm also closing this issue as I think it's not an issue with the library itself.
Hey,
I am currently trying to calculate the FRC for electron microscopy images.
While I can calculate the frc, I am not able to find the intersection. Is there any recommended why of going about this and investigating why the implemented algorithm cannot find an intersection.
To exclude that this is due to the input image, I used the "siemens.tiff" as an input and here I experience the same issue. So I believe something is off.
Here the minimal example:
This part runs:
This part throws an error:
Here the error message:
NoIntersectionException Traceback (most recent call last) Cell In[139], line 9 7 scale = 2 8 xs_ang_freq = xs_pix * scale ----> 9 frc_res, res_y, thres = frc.frc_res(xs_ang_freq, frc_curve, im_1_array_size) 10 plt.plot(xs_ang_freq, thres(xs_ang_freq)) 11 plt.plot(xs_ang_freq, frc_curve)
File ~/frc_calc/lib/python3.9/site-packages/frc/frc_functions.py:208, in frc_res(xs, frc_curve, img_size, threshold) 205 raise ValueError("Unknown threshold!") 207 # Calculate intersection using FRC utility module --> 208 intersect_x, intersect_y = frc_util.intersection(xs, frc_curve, threshold_f) 210 return 1. / intersect_x, intersect_y, threshold_f
File ~/frc_calc/lib/python3.9/site-packages/frc/utility.py:185, in intersection(xs, ys1_f, ys2_f, tol) 183 return closest[0], y_closest[0] 184 else: --> 185 raise NoIntersectionException("Could not find intersection!")
NoIntersectionException: Could not find intersection!
Maybe you can help or point me to a possible cause for this error and a potential solution. Thank you very much for this python package and the elaborate documentation.
Best Dennis