Python Forum
Cross-correlation between 2 planes in a 3D array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cross-correlation between 2 planes in a 3D array
#1
Hello Python forum
I am trying create a 2D out that is the cross correlation between y-z planes
[Image: solSgIF.png]

I wrote this code, which doesn't work
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]) 
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.

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
Reply
#2
Dear Mark,

I think I know the source of this problem. I have an identical problem now. Did you find any solution to this problem?
If so, could you share? I would be eternally grateful.

Kind regards,
mats_snaps
Reply
#3
Hi Mat_snaps

Unfortunately I couldn't figure it out, so I just gave up on it. If you figure it out you are very welcome to post your solution :)!

BR Mark
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Correlation Coefficents with different Time Ranges giaco__mar 0 849 Sep-28-2022, 02:03 PM
Last Post: giaco__mar
  do you know a code that will print all correlation values using numpty and panda? crispybluewaffle88 1 2,444 Mar-06-2019, 12:45 PM
Last Post: scidam
  Help with correlation coefficient mattjb84 7 4,930 Jun-29-2018, 09:56 PM
Last Post: Larz60+
  Pandas dataframe: sum of exponentially weighted correlation matrices per row vvvcvvcv 1 3,261 May-29-2018, 01:09 AM
Last Post: scidam
  Mistake by correlation (x, y) Jack_Sparrow 2 2,723 May-10-2018, 02:23 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020