Load a volume as a python numpy array#

on the following script we expect a link sharing the ‘volume’ information exists between a tomwer widget (cast volume, nabu volume reconstruction, …) and a Python script widget.

# what is pass through the link is an instance of a volume.
volume = in_volume
# the documentation of the tomoscan volume (and API) is available here: https://tomotools.gitlab-pages.esrf.fr/tomoscan/tutorials/volume.html
# the volume data can be obtained as a numpy array from volume.data
# print(volume.data)
# the volume metadata can be obtained as a dict from volume.metadata
# print(volume.metadata)
# but at this stage most of the time it will be empty. Because the data is on disk and not load in memory.
# to load it in memory we must call
volume.load()
print("data shape is", volume.data.shape)
print("metadata are", volume.metadata)

# note: if you want to browse the data avoiding loading it all in memory there is some utils function in the volume API like `browse_slices` that could help you.