Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-23855

Audit and debug current zogy image differencing code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Story Points:
      10
    • Sprint:
      AP S20-5 (April), AP S20-6 (May), AP F20-1 (June), AP F20-2 (July), AP F20-5 (October), AP F20-6 (November), AP S21-3 (February), AP S21-4 (March), AP S21-5 (April), AP F21-1 (June), AP F21-2 (July), AP F21-3 (August), AP F21-4 (September)
    • Team:
      Alert Production
    • Urgent?:
      No

      Description

      The current zogy implementation is assumed to have issues in:

      • Understand how the variance plane should propagate in zogy (convolution then whitening decorrelation).
      • Correct padding and centering of images and PSFs in Fourier space opeartions. (numerical accuracy in DFT vs. origin location and periodicity assumptions)
      • Correct calculation of the difference image variance plane. (variance of image k-space components vs. k-space components of variance plane)
      • zogy.py:384 padSize argument usage

        Attachments

          Issue Links

            Activity

            Hide
            sullivan Ian Sullivan added a comment -

            Could you please add a comment describing the work this ticket covered, and in particular any answers to the issues raised in the description.

            Show
            sullivan Ian Sullivan added a comment - Could you please add a comment describing the work this ticket covered, and in particular any answers to the issues raised in the description.
            Hide
            sullivan Ian Sullivan added a comment -

            Per my previous comment, please add the requested comment describing what was accomplished under this ticket, and what the answers were to the issues raised in the description.

            Show
            sullivan Ian Sullivan added a comment - Per my previous comment, please add the requested comment describing what was accomplished under this ticket, and what the answers were to the issues raised in the description.
            Hide
            gkovacs Gabor Kovacs [X] (Inactive) added a comment -

            The new implementation refers to the major zogy code rewrite in DM-25115 and its updates since then.

            The old implementation had a bug in how to center the PSF properly in an FFT symmetry sense (DM-11990). The centering of the image before and after FFT transformations got unnecessarily much attention while it had no real importance. In the new implementation, we always put the image center to the DFT origin for better symmetry.

             

            The image padding size got into focus at the beginning for the wrong reason. We displayed the zogy matching kernel (and decorrelation afterburner) kernels in image space and had the impression that they contain long tails stretching up to hundreds of pixels. Later it became clear that this was due to noise in high frequency components which fills the image space representations irrespectively of their padding size. Nevertheless, to avoid the introduction of artifacts due to the circular boundary condition of DFT space calculations, we need to estimate the matching kernel dimensions in image space. See the theoretical Gaussian solutions in DMTN-179. Also, in case of splitting the image into sub images, the padding should contain the continued image data outside the cell. The new implementation uses considerations described in DM-28928.

             

            The variance plane calculation was algorithmically incorrect; the variance plane was subject to the very same calculations in the old implementation as the image plane (just with addition instead of subtraction). This is discussed in DMTN-179 Sec. 5.


            In addition to the issues originally raised in this ticket, we also considered the followings:

             

            In the spatially varying PSF case, the old implementation focused on splitting the image into individual small chunks and smoothing the solution by allowing and averaging overlapping borders back in image space. In the new implementation, we split the image into overlapping image chunks for the DFT calculations and keep only smaller “useful inner areas” that do not overlap to account for spatial variability of the PSFs.

             

            The old implementation added noise to low PSF values (in image space) to avoid numerical zero divisions in the calculations. We concluded that this approach did not solve any problem but added artificial noise to scenarios inherently noisy numerically. At close to zero denominators, the expressions should approach mathematical limits to reproduce the theoretically expected smooth solutions. This is discussed in DMTN-179.

             

            The old implementation unnecessarily implemented options to perform convolutions in image space rather than in DFT space. We concluded that this was not a cause of “bad” solutions.

             

            The old implementation did not create a spatially varying result PSF solution. The new implementation does, though the solution can “jump” between grid cells.

             

            The new implementation uses power of two dimensions for the padded (sub-)images for better FFT accuracy.

            Show
            gkovacs Gabor Kovacs [X] (Inactive) added a comment - The new implementation refers to the major zogy code rewrite in DM-25115 and its updates since then. The old implementation had a bug in how to center the PSF properly in an FFT symmetry sense ( DM-11990 ). The centering of the image before and after FFT transformations got unnecessarily much attention while it had no real importance. In the new implementation, we always put the image center to the DFT origin for better symmetry.   The image padding size got into focus at the beginning for the wrong reason. We displayed the zogy matching kernel (and decorrelation afterburner) kernels in image space and had the impression that they contain long tails stretching up to hundreds of pixels. Later it became clear that this was due to noise in high frequency components which fills the image space representations irrespectively of their padding size. Nevertheless, to avoid the introduction of artifacts due to the circular boundary condition of DFT space calculations, we need to estimate the matching kernel dimensions in image space. See the theoretical Gaussian solutions in DMTN-179. Also, in case of splitting the image into sub images, the padding should contain the continued image data outside the cell. The new implementation uses considerations described in DM-28928 .   The variance plane calculation was algorithmically incorrect; the variance plane was subject to the very same calculations in the old implementation as the image plane (just with addition instead of subtraction). This is discussed in DMTN-179 Sec. 5. In addition to the issues originally raised in this ticket, we also considered the followings:   In the spatially varying PSF case, the old implementation focused on splitting the image into individual small chunks and smoothing the solution by allowing and averaging overlapping borders back in image space. In the new implementation, we split the image into overlapping image chunks for the DFT calculations and keep only smaller “useful inner areas” that do not overlap to account for spatial variability of the PSFs.   The old implementation added noise to low PSF values (in image space) to avoid numerical zero divisions in the calculations. We concluded that this approach did not solve any problem but added artificial noise to scenarios inherently noisy numerically. At close to zero denominators, the expressions should approach mathematical limits to reproduce the theoretically expected smooth solutions. This is discussed in DMTN-179.   The old implementation unnecessarily implemented options to perform convolutions in image space rather than in DFT space. We concluded that this was not a cause of “bad” solutions.   The old implementation did not create a spatially varying result PSF solution. The new implementation does, though the solution can “jump” between grid cells.   The new implementation uses power of two dimensions for the padded (sub-)images for better FFT accuracy.
            Hide
            sullivan Ian Sullivan added a comment -

            Thank you for your updates on this ticket. I think you can go ahead and close it now.

            Show
            sullivan Ian Sullivan added a comment - Thank you for your updates on this ticket. I think you can go ahead and close it now.
            Hide
            sullivan Ian Sullivan added a comment -

            Should have been marked Done in July

            Show
            sullivan Ian Sullivan added a comment - Should have been marked Done in July

              People

              Assignee:
              sullivan Ian Sullivan
              Reporter:
              gkovacs Gabor Kovacs [X] (Inactive)
              Reviewers:
              Ian Sullivan
              Watchers:
              Gabor Kovacs [X] (Inactive), Ian Sullivan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.