ITKElastix icon indicating copy to clipboard operation
ITKElastix copied to clipboard

Problem when opening a big TIF file

Open Jeremie-BIC opened this issue 2 years ago • 8 comments

Hello,

I am doing mouse brains alignement to the Allen Brain Atlas. Samples are optically cleared and images are obtained on a light sheet microscope.

It works nicely on small files (25x25x25 um voxel : 100 Mo in size).

However, when I am trying to apply the transformation to a high resolution data set of 70 Go, I have a problem: I cannot open the file at all:

  • when using the view module from ITKWIDGETS, the big image looks empty.
  • when trying to change the voxel spacing, it works on small size file but not on the big one.

If I crop the big one, it is opened correctly... That makes me think that the data type is good, but that it is some sort of memory problem.

I am working on Windows 10, with 512 Go Ram.

Thank you very much for your help!!

Best,

Jérémie

Jeremie-BIC avatar Mar 10 '22 06:03 Jeremie-BIC

Hi @Jeremie-BIC

Thank you for reporting this issue. Marius Staring (@mstaring) and I just looked at it, and it seems to us that it isn't a specific elastix/ITKElastix issue, but rather an ITK issue, or an itkwidgets issue. In that case, maybe you'd better report this to ITK (https://discourse.itk.org or https://github.com/InsightSoftwareConsortium/ITK/issues) or itkwidgets: https://github.com/InsightSoftwareConsortium/itkwidgets

Kind regards, Niels

N-Dekker avatar Mar 10 '22 13:03 N-Dekker

Dear Niels,

Thank you for taking the time. I will report this to ITK.

Best regards,

Jérémie

Jeremie-BIC avatar Mar 10 '22 14:03 Jeremie-BIC

This is most likely a limitation of the graphics subsystem (GPU does not have enough memory to fit the entire image in it) or VTK, the visualization library https://github.com/InsightSoftwareConsortium/itkwidgets uses. @floryst or @thewtex might have a better idea of where the problem comes from.

dzenanz avatar Mar 10 '22 18:03 dzenanz

For itkwidgets, browser tabs usually have a ceiling on the memory allocation, though that usually results in a browser tab crash and not a blank image. If it's a TIF image, my guess would be that the underlying itk-wasm WebWorker is failing or crashing silently (possibly due to out-of-memory), leading to the display of a blank image...

floryst avatar Mar 10 '22 18:03 floryst

Hi,

Thank you for help!

I understand that such a big file might be impossible to display in the Jupyter Notebook through the Itk Widget viewer.

However when I try to do a simpler operation, such as change the pixel spacing, I get an error. I think that the problem is happening when I open my image (using itk.imread).

I guess that, like Niels suggested, it is an ITK problem...

In case, I am putting the error I get. Any suggestion would be super appreciated. Error is:

TypeError Traceback (most recent call last) in 1 fixed_image.SetSpacing((25,25,25)) 2 moving_image.SetSpacing((25,25,25)) ----> 3 upscale_image.SetSpacing((2,2,4)) 4 5 #fixed_image_resolution=fixed_image.GetSpacing() #prints spacing

TypeError: Expecting an itkVectorD2, an int, a float, a sequence of int or a sequence of float. Additional information: Wrong number or type of arguments for overloaded function 'itkImageBase2_SetSpacing'. Possible C/C++ prototypes are: itkImageBase2::SetSpacing(itkVectorD2 const &) itkImageBase2::SetSpacing(double const *) itkImageBase2::SetSpacing(float const *)

Thank you very much.

Best,

Jérémie

Jeremie-BIC avatar Mar 11 '22 10:03 Jeremie-BIC

You might need something like:

spacing = itk.spacing((2,2,4))  # like this?
spacing = itk.spacing([2,2,4])  # or maybe like this?
upscale_image.SetSpacing(spacing)

dzenanz avatar Mar 11 '22 14:03 dzenanz

Large scale registration support coming via https://github.com/InsightSoftwareConsortium/itk-dreg.

thewtex avatar Feb 15 '23 11:02 thewtex

itk-widgets has support for large-scale images via NGFF. See: https://github.com/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/zarr/OME-NGFF-Brainstem-MRI.ipynb

thewtex avatar Feb 15 '23 11:02 thewtex