LabeoTech / Umit

universal mesoscale Imaging Toolbox
GNU General Public License v3.0
9 stars 3 forks source link

AlignFrames function Bug #77

Closed C-A25 closed 2 weeks ago

C-A25 commented 2 weeks ago

umiT version : Astrocyte-v1.5

The issue Data were run through run_ImagesClassfication, ManualCoreg2Cams and run_HemoCorrection scripts before using the alignFrames function where the bug occured. Imaging data cannot be aligned due to the bug.

To Reproduce

  1. run_Images Classification (default options)
  2. run_HemoCorrection (no yellow, yes to green and red)
  3. alignFrames (error - see screenshots)

Expected behavior Imaging data should be aligned using the imaging reference frame proposed.

Screenshots image

Thank you!

BrunoOFSouza commented 2 weeks ago

Hi @C-A25, Probably the issue comes from the fact that your images contain NaNs. An improved version of the alignFrames function is available (see commit 06cfcd8b3ac5d76158a22bc1e467843b23c75436) . This should fix the problem. Let us know if it doesn't.

C-A25 commented 2 weeks ago

Hello again,

The new version fixed the previous issue, but I might have found the underlying cause.

When I use the automatic or manual image registration functions, patches of random NaNs are added to displayed imaging reference frame and aligned data. These patches do not appear on the original data extracted with run_ImagesClassification. The previous NaNs issue might be caused by this NaNs addition on my imaging reference frame.

Imaging reference frame and registered data - NaNs appear in both during image registration

It could be related to the alignment process (stretching, etc.), but it covers large portion of images and is not restricted to the borders. Even with the patches, the alignment works well. When I open the imaging reference frame and acquisition images in ROI manager or DataViewer, the NaNs patches aren't there.

Imaging reference frame in ROI manager image Acquisition frame of aligned data in ROI manager (applies to Data Viewer) image

It might be a display issue. I assume I couldn't previously use the alignFrame function due to the NaNs patches in the imaging reference frame. It doesn't look like it transfers to the saved data, but it could hinder the use of other UmIT functions. I'm not too sure where it comes from as I do not have an error message when it happens.

BrunoOFSouza commented 2 weeks ago

Hi @C-A25 ,

Actually, these large patches in the reference and registered masks are the result of a Gaussian filter applied to the images. This filter is not applied to the aligned data. Also, you just remembered me to apply the same NaN management to the manual alignment as well (see commit 70f6f9fd720f5f407cf39e26ca11bc5002b42c74).

Thanks!