Closed SezanMert closed 2 years ago
Thank you for the very detailed issue description, sample data, and code to reproduce! Using your code, I see the same thing on my system.
To me it seems like line 202 is OK though. I ran your example interactively in ipython --pdb
and (after hitting u
several times to reach the right stack level) I see this:
ipdb> p n_freqs
7
ipdb> p conn.shape
(1, 78, 7, 12000)
So it looks like conn
has the correct shape. I think rather the problem is line 223, where the xarray container is initialized with conn
data, where instead of freqs=freqs
it should probably say freqs=f_vec
. For me, changing that in the source code makes your example run without error; can you try it locally (and run on your real data, not the created_sample
) and see if the results look sensible?
If that works, would you be up for opening a Pull Request that implements this proposed fix?
Thank you for your kind reply! I also thought that line 223, EpochSpectroTemporalConnectivity object creation was faulty. And yes, changing freqs=f_vec indeed solved the problem. Thank you for your time. I am going to open a Pull Request now.
Closed by #98
I have a one-minute-long 12-channel intracerebral EEG data. It is a single epoch, single-trial data and has no event markers. It is simply a measurement taken from a sleeping patient for a minute. I wanted to compute the time-resolved coherence of channels pairwise. For the time-frequency decomposition, I used Continuous Morlet Wavelet Transform. I wanted to obtain the coherence for specific frequency bands, so I used foi parameter of this function. I encountered the following error:
When I trace back in the error log, and tried to understand how time.py works, I saw that the function computes the spectral connectivity (inside for loop in line 214). However, once it creates an EpochSpectroTemporalConnectivity object from the result (in line 223), it gives the dimension error that is seen at the end of the error log.
I believe the reason for this error is this: In time.py, line 202, variable “conn” is initialized as a zeros numpy array of size n_epochs x n_pairs x n_freqs x len(times). Here, n_freqs is defined as the frequencies of interest. In my case, its length is equal to 7. But, later on, at line 223, to create “EpochSpectroTemporalConnectivity” class object, “freq” parameter given to the object is equal to the frequencies of the time-frequency decomposition. In my case, the length of it is equal to 63. I think, once the connectivity is computed for the frequencies of interest, the frequencies given to the “EpochSpectroTemporalConnectivity” class object should have been the freqeuncies of interest, rather than the decomposition frequencies.
I am using,
I have created a sample edf file to put here a working example. Inside the created edf file, I have put a single frequency sine wave of same number of samples of the original data and I made sure that the same error occurs for both the original and created sample data. And here is my working minimal code:
created_sample.zip