TomographicImaging / CILViewer

A simple Viewer for 3D data built with VTK
Apache License 2.0
9 stars 6 forks source link

`numpy2vtkImage` does not account of 2D images #436

Closed DanicaSTFC closed 2 months ago

DanicaSTFC commented 2 months ago

When https://github.com/TomographicImaging/CIL/pull/1885 is merged in CIL, this will fix the error on the reconstruction of a single slice https://github.com/TomographicImaging/CIL-GUI/issues/153.

However, an extra error on the viewer occurs when the result of the reconstruction of a single slice (a 2D image) wants to be visualised in the viewer

 File "\epac_ct\executables\downsample_dataset.py", line 146, in run_downsample_dataset
    reader = downsample_from_memory(dataset, target_size)
  File "epac_ct\executables\downsample_dataset.py", line 39, in downsample_from_memory
    vtk_data = Converter.numpy2vtkImage(numpy_data)
  File "\ccpi\viewer\utils\conversion.py", line 120, in numpy2vtkImage
    img_data.SetExtent(0, shape[i] - 1, 0, shape[1] - 1, 0, shape[k] - 1)
IndexError: tuple index out of range
paskino commented 2 months ago

The easiest is to add an extra dimension when the image is 2D for the viewer.

DanicaSTFC commented 2 months ago

The easiest is to add an extra dimension when the image is 2D for the viewer.

Hi Edo, I opened a PR on this, could you add your suggestions there please? I am not sure if you are suggesting edits otherwise.