-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert mne epochs to psd #4
Conversation
The code was taken from the mne-python tutorial DW authored: https://git.io/JZyTQ The differences are: - some blank lines in function definitions disappeared (not sure how that happened), - an extra blank line between text and the `contents` directive (that is how Sphinx likes it), - two internal mne-python docs cross-links removed.
The difference is that psd is in 1/Hz units. For plain Fourier transform this means that psd = power / sfreq
Obviously, mne uses numpy's (well, maybe scipy's) fft under the hood. This way, we don't rely on mne for something that simple.
I renamed `from_mne_epochs` to `psd_from_mne_epochs` but didn't update the tutorial.
Hello @kalenkovich! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-07-20 15:05:33 UTC |
hi @kalenkovich , finally came to look into the code :) some points/questions:
so far for now, i think these are some initial things to discuss :) |
Thank you for taking a look, @dominikwelke!
I think we can deal with it once the need arises. Right now, I don't see the necessity for such a class. I do, however, see problems that can arise from different spectra getting out of sync. We can safeguard against this probably but I would rather get into it when and if we need it for some use. At this point, I would leave it at that. As a future step, I would think it would be great to have a tutorial with a full-fledged analysis where we would see whether combining spectra under a single object would benefit clarity or muddy it. Now that we are doing are own thing we have more freedom than with the mne-python tutorial.
I don't think this is necessary at all. Continuous data = single-epoch data. Again, I don't mind if we add it later but later - once we see that it helps the user/coder.
That makes sense. I think this function should evolve into something more general like
I think we have a different understanding of what a class function is. In Python, such a function is not bound to an instance and it can't change the inner data of an object even if you call it from an instance and not from the class. That is why the first argument is traditionally referred to as This is very similar to how, for example, We could, of course, move this function up to the module level but I am pretty sure the current way is the clearest one.
I would use an instance method called something like I certainly don't think this should be a class method. I think we are probably using different terminologies. As for the module-level method, I think it only makes logical sense if we reuse such a function in different classes. For now, I think its best placement is as an instance method. Let's get back to this in a separate issue. |
ok
yes, sounds good
you got me wrong. sure, continuous = single epoch = 2d data, but multi epoch data is 3d and some methods have to know about this. of course this can all be handled implicitly by the method checking dimensionality of the data, but maybe its easier to know about it, because a 3rd dimension might potentially also come from somewhere else (e.g. multiple subject continuous data). but sure, we can also take care of it once such a problem arises..
apparently :)
yes, and this i personally find this API suboptimal and quite confusing. not sure there is right or wrong, it's just our design decision..
yes, sounds good. sorry again for the mixed up terminology :) |
@kalenkovich sorry for the late reply. mauscript deadlines.. |
I think multi-subject continuous data is unlikely to fit into one array because that would necessitate having the number of samples for each subject. On the other hand, I am all for having explicit information about the axes/dimensions. I would, however, prefer to keep this information as instance attributes instead of type. So, something like Of course, none of the above means that we won't need a special class for spectra derived from continuous data - we might. But for now, the only difference would be the class name so I think this can wait.
Oh, yeah! This is probably different in different programming languages. In Python, class methods are almost the same as static methods except that they can refer to the class itself without using its name, This way, if A.do is a class method that creates an instance of A and B is a subclass of A, then B.do will create an instance of B. And what you described is called an instance method.
Oh, alright! Honestly, to me, That being said, I see your point that it might be confusing to import a class explicitly. I've seen people working with Python who don't quite know what a class is. I mean, they do in abstract, but having a class object like |
Done! |
lgtm and finishes without errors..
sounds good. should we do it here or in another PR?
i didnt use xarray before.. sounds convenient, but it comes with additional dependencies: xarray itself, pandas(, setuptools) and further optional ones if we want to use some functionalities. plus it only works with python 3.7+. not sure if any of these would be a major problem, but if it's just a minimal advantage over plain ndarrays we might pass.. is there more than the labels that we could benefit from, down the line? |
Let's do it separately, I'll create an issue so that we don't forget about it.
I think you are right, there is not much benefit at this point. |
Should I merge then? |
Yes, go ahead :)
Am 28. Juli 2021, 17:56, um 17:56, Zhenya ***@***.***> schrieb:
…Should I merge then?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#4 (comment)
|
I copied the frequency tagging tutorial from
mne
and moved the power-calculating code tofreqtag.spectrum.Spectrum.psd_from_mne_epochs
. I then rewrote the code so that it does not usemne
but usesnumpy
'sfft
instead.