java.lang.Object
net.preibisch.mvrecon.process.quality.FRC

public class FRC extends Object
Compute the Fourier Ring Correlation, a measure of the resolution of a microscopy image.

Adapted from the FIRE (Fourier Image REsolution) plugin produced as part of the paper: Niewenhuizen, et al (2013). Measuring image resolution in optical nanoscopy. Nature Methods, 10, 557

  • Field Details

    • perimeterSamplingFactor

      public double perimeterSamplingFactor
      The correlation is computed using intervals around the circle circumference. The number of samples for half the circle is computed as: Pi * radius * sampling factor
    • useHalfCircle

      public boolean useHalfCircle
      The correlation is computed using intervals around the circle circumference of the Fourier transform. The Fourier image is 2-fold radially symmetric and so the calculation can use only half the circle for speed. Note: The results will differ slightly due to the implementation of the Fourier image not being exactly symmetric and the sample points used on the perimeter not matching between the two semi-circles.
  • Constructor Details

    • FRC

      public FRC()
  • Method Details

    • calculateFrcCurve

      public double[][] calculateFrcCurve(ij.process.ImageProcessor ip1, ij.process.ImageProcessor ip2)
      Calculate the Fourier Ring Correlation curve for two images.
      Parameters:
      ip1 - - image 1
      ip2 - - image 2
      Returns:
      An array of triplets representing [][radius,correlation,N] where correlation is the FRC at the given radius from the centre of the Fourier transform (i.e. 1/spatial frequency) and N is the number of samples used to compute the correlation
    • getComplexFFT

      Convert an image into a Fourier image with real and imaginary parts
      Parameters:
      ip - - image
      Returns:
      the real and imaginary parts
    • getSquareTaperedImage

      public ij.process.FloatProcessor getSquareTaperedImage(ij.process.ImageProcessor dataImage)
      Applies a Tukey window function to the image and then pads it to the next square size power of two.
      Parameters:
      dataImage - - image
      Returns:
      The square tapered image
    • getSmoothedCurve

      public double[][] getSmoothedCurve(double[][] frcCurve, double bandwidth, int robustness)
      Perform LOESS smoothing on the FRC curve.

      The input curve is copied and then the correlation values are smoothed using a LOESS interpolation with the given parameters. If smoothing fails the original curve values are returned.

      Parameters:
      frcCurve - - the FRC curve
      bandwidth - - unknown
      robustness - - unknown
      Returns:
      A new FRC curve
    • getSmoothedCurve

      public double[][] getSmoothedCurve(double[][] frcCurve)
      Perform LOESS smoothing on the FRC curve

      The input curve is copied and then the correlation values are smoothed using a LOESS interpolation with a bandwidth of 0.0707 and robustness of 0. If smoothing fails the original curve values are returned.

      Parameters:
      frcCurve - - the FRC curve
      Returns:
      A new FRC curve
    • calculateThresholdCurve

      public double[] calculateThresholdCurve(double[][] frcCurve, FRC.ThresholdMethod method)
      Calculate the curve representing the minimum correlation required to distinguish two images for each resolution in the input FRC curve.
      Parameters:
      frcCurve - - the FRC curve
      method - - one of the methods
      Returns:
      The threshold curve representing the threshold for each input spatial frequency
    • getIntersections

      public double[] getIntersections(double[][] frcCurve, double[] thresholdCurve)
      Computes the crossing points of the FRC curve and the threshold curve. The intersections can be used to determine the image resolution using {getCorrectIntersection(ArrayList, ThresholdMethod)}
      Parameters:
      frcCurve - - the FRC curve
      thresholdCurve - - where to find thresholds
      Returns:
      The crossing points
    • getCorrectIntersection

      public double getCorrectIntersection(double[] intersections, FRC.ThresholdMethod method)
      Get the correction intersection representing the image resolution. The intersection chosen depends on the method used to calculate the threshold curve using {calculateThresholdCurve(double[][], ThresholdMethod)}

      The intersection corresponds the lowest spatial frequency at which there is no significant correlation between the images.

      Parameters:
      intersections - - unknown
      method - - one of the methods
      Returns:
      The intersection (or zero if no crossings)
    • calculateFireNumber

      public double calculateFireNumber(ij.process.ImageProcessor ip1, ij.process.ImageProcessor ip2, FRC.ThresholdMethod method)
      Utility function that calculates the Fourier Image Resolution (FIRE) number using the provided images.
      Parameters:
      ip1 - - image 1
      ip2 - - image 2
      method - - one of the methods
      Returns:
      The FIRE number (in pixels)
    • calculateFireNumber

      public double calculateFireNumber(double[][] frcCurve, FRC.ThresholdMethod method)
      Utility function that calculates the Fourier Image Resolution (FIRE) number using the provided FRC curve data.
      Parameters:
      frcCurve - - the FRC curve
      method - - one of the methods
      Returns:
      The FIRE number (in pixels)
    • batchCalculateFireNumber

      public void batchCalculateFireNumber(File directory1, File directory2, FRC.ThresholdMethod method, ij.measure.ResultsTable rt, boolean is_save_plot)
      Convenience function to batch calculate the FRC by going though file on two separate directories. When one file name is identical in both directories, it opens them and computes the FRC. If is_save_plot is true, then a plot of the FRC and FIRE calculations is saved in the parent of directory1 in a folder named "Graphs" NOTE: This only works for TIFF files at the moment.
      Parameters:
      directory1 - is the first directory containing data
      directory2 - is the first directory containing data
      method - is the {ThresholdMethod} used
      rt - is the {ij.measure.ResultsTable} where you want the batch to write the FIRE number to
      is_save_plot - defines whether the plot will be saved, as described above.
    • doPlot

      public ij.gui.Plot doPlot(double[][] frc_curve, double[][] smooth_frc, FRC.ThresholdMethod tm, double fire, String name)
      Simple method to plot the data using {ij.gui.Plot #Plot}
      Parameters:
      frc_curve - is the raw FRC curve
      smooth_frc - is the smoothed curve computed using {getSmoothedCurve(double[][])} or {getSmoothedCurve(double[][], double, int)}
      tm - is the {ThresholdMethod} used
      fire - is the Fourier Image Resolution given by {calculateFireNumber(double[][], ThresholdMethod)}
      name - is the title of the image that was used for the FRC calculations
      Returns:
      a Plot object to use at your convenience