twocan.multi_channel_corr

twocan.multi_channel_corr(source: ndarray, target: ndarray) ndarray[source]

Calculate correlation coefficients between all pairs of channels from two images.

This function computes the Pearson correlation coefficient between every channel in the source image and every channel in the target image. The images are first normalized (z-scored) channel-wise before correlation calculation.

Parameters:
  • source (np.ndarray) – Source image array of shape (n_channels_1, n_pixels). Each row represents a flattened channel.

  • target (np.ndarray) – Target image array of shape (n_channels_2, n_pixels). Each row represents a flattened channel.

Returns:

Correlation matrix of shape (n_channels_1, n_channels_2). Element (i, j) contains the correlation between source channel i and target channel j.

Return type:

np.ndarray

Notes

The function assumes the input arrays have the same number of pixels (same second dimension). Channels are normalized to have zero mean and unit standard deviation before correlation calculation.