scallops.codebook.image_to_codes

scallops.codebook.image_to_codes(array)

Reshape a 5-dimensional array of shape (t, c, z, y, x) to a 2-dimensional array of shape (z+y+x, t+c).

Parameters:

array (DataArray) – The input 5-dimensional array representing images. Dimensions: (t, c, z, y, x).

Returns:

Reshaped 2-dimensional array of shape (z+y+x, t+c).

Example:

Return type:

ndarray

import xarray as xr
import numpy as np
from scallops.codebook import image_to_codes

# Create a synthetic DataArray
image_shape = (3, 4, 5, 100, 100)  # (t, c, z, y, x)
imagestack = xr.DataArray(
    np.random.rand(*image_shape), dims=("t", "c", "z", "y", "x")
)

# Reshape the 5D array to a 2D array
reshaped_array = image_to_codes(imagestack)