Discrepancy in half-tomo size calculations, get_extended_sinogram_width() vs convert_halftomo()
It seems there's an internal discrepancy (tested with 2024.1.1) in nabu when computing the extended sino width for half-tomo:
import numpy as np
from nabu.reconstruction.sinogram import get_extended_sinogram_width, SinoBuilder
nproj = 540
nx = 640
cor = 144.89 # Works with 144.49 or 145
sino =np.zeros((nproj,1,nx), dtype=np.float32)
sino_builder = SinoBuilder(radios_shape=(nproj, 1, nx), rot_center=cor, halftomo=True)
sino_builder.get_sinos(sino)
results in:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[1], line 12
8 sino =np.zeros((nproj,1,nx), dtype=np.float32)
10 sino_builder = SinoBuilder(radios_shape=(nproj, 1, nx), rot_center=cor, halftomo=True)
---> 12 sino_builder.get_sinos(sino)
File ~/.conda/envs/pynx-devel-py311-x86/lib/python3.11/site-packages/nabu/reconstruction/sinogram.py:193, in SinoBuilder.get_sinos(self, radios, output)
191 def get_sinos(self, radios, output=None):
192 if self.halftomo:
--> 193 return self._get_sinos_halftomo(radios, output=output)
194 else:
195 return self._get_sinos_simple(radios, output=output)
File ~/.conda/envs/pynx-devel-py311-x86/lib/python3.11/site-packages/nabu/reconstruction/sinogram.py:188, in SinoBuilder._get_sinos_halftomo(self, radios, output)
186 for i in range(n_z):
187 sino = self._get_sino_simple(radios, i)
--> 188 output[i] = self._get_sino_halftomo(sino)
189 return output
ValueError: could not broadcast input array from shape (270,990) into shape (270,991)
Issue seems to be that get_extended_sinogram_width()
can compute an odd width, whereas convert_halftomo()
will use extended_width // 2 *2
for the shape.
This makes my half-tomo reconstructions fail when the fractional value of the CoR is within [0.5;1[
Edited by Vincent Favre-Nicolin