Hello

Iâ€™m a person who is studying brain waves.

I have a question about the **envelope_correlation()** function of mne_connectivity.

use this function with (orthogonalize=â€śpairwiseâ€ť, log=True, absolute=True)

```
def envelope_correlation(data, names=None,
orthogonalize="pairwise",
log=False, absolute=True, verbose=None):
for ei, epoch_data in enumerate(data):
data_mag = np.abs(epoch_data)
data_conj_scaled = epoch_data.conj()
data_conj_scaled /= data_mag
if log:
data_mag *= data_mag
np.log(data_mag, out=data_mag)
# subtract means
data_mag_nomean = data_mag - np.mean(data_mag, axis=-1, keepdims=True)
# compute variances using linalg.norm (square, sum, sqrt) since mean=0
data_mag_std = np.linalg.norm(data_mag_nomean, axis=-1)
data_mag_std[data_mag_std == 0] = 1
corr = np.empty((n_nodes, n_nodes))
# loop over each signal in this specific epoch
# which is now (n_signals, n_times) and compute envelope
for li, label_data in enumerate(epoch_data):
if orthogonalize is False: # the new code
label_data_orth = data_mag[li]
label_data_orth_std = data_mag_std[li]
else:
label_data_orth = (label_data * data_conj_scaled).imag
np.abs(label_data_orth, out=label_data_orth)
# protect against invalid value -- this will be zero
# after (log and) mean subtraction
label_data_orth[li] = 1.
if log:
label_data_orth *= label_data_orth
np.log(label_data_orth, out=label_data_orth)
label_data_orth -= np.mean(label_data_orth, axis=-1,
keepdims=True)
label_data_orth_std = np.linalg.norm(label_data_orth, axis=-1)
label_data_orth_std[label_data_orth_std == 0] = 1
# correlation is dot product divided by variances
corr[li] = np.sum(label_data_orth * data_mag_nomean, axis=1)
corr[li] /= data_mag_std
corr[li] /= label_data_orth_std
if orthogonalize:
# Make it symmetric (it isn't at this point)
if absolute:
corr = np.abs(corr)
corr = (corr.T + corr) / 2.
```

What Iâ€™m curious about in the code above is the variable assigned to the **corr[li]** in the **label data** for statement.

```
corr[li] = np.sum(label_data_orth * data_mag_nomean, axis=1)
```

For example, letâ€™s say the shape of **input data** is (30,19,5000). (epoch, node, time)

Then, the **epoch data** variable has shape (19,5000).

and **data_mag** , **data_mag_nomean**, **data_mag_std** also has shape (19,5000).

```
for li, label_data in enumerate(epoch_data):
```

And after this code,

**label_data_orth** is an orthogonal signal of 19 channels for label_data.

What Iâ€™m curious about here is

In this code, to calculate the Pearson correlation,

**np.sum(label_data_orth * data_mag_nomean, axis=1)** was used.

I wonder why **data_mag_nomean** is included instead of **data_mag_nomean[li]**.

Shouldnâ€™t **corr[li]** contain **19 orthologized signals of label_data** and **label_data**?

If thereâ€™s anything I misunderstood, please tell me.

Thank you.