May-07-2018, 10:23 AM
Hello Python forum
I am trying create a 2D out that is the cross correlation between y-z planes
![[Image: solSgIF.png]](https://i.imgur.com/solSgIF.png)
I wrote this code, which doesn't work
If you are familiar with any of these two functions, please, could you tell me what I am doing wrong?
Or if you think there is a better way/easier way I would appreciate that too.
BR Mark
I am trying create a 2D out that is the cross correlation between y-z planes
![[Image: solSgIF.png]](https://i.imgur.com/solSgIF.png)
I wrote this code, which doesn't work
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import numpy as np from scipy import signal import scipy as ssc np.random.seed( 0 ) data = np.random.rand( 32 , 32 , 8192 ) #z, y, x = data[:,0,0],data[0,:,0],data[0,0,:] z = data[:, 0 ,:] y = data[ 0 ,:,:] Cyz = np.ones(( 32 , 32 )) Cyz1 = np.ones(( 32 , 32 )) #allocating matrix for i in range ( 32 ): Cyz[i,i] = np.corrcoef(y[i,i],z[i,i]) # cross correlation for i in range ( 32 ): Cyz1[i,i] = ssc.signal.correlate2d(y[i,i],z[i,i]) |
Or if you think there is a better way/easier way I would appreciate that too.
Error:Traceback (most recent call last):
File "<ipython-input-33-dd850ca77ad0>", line 2, in <module>
Cyz[i,i] = np.corrcoef(y[i,i],z[i,i]) # cross correlation
ValueError: setting an array element with a sequence.
Thank you! BR Mark