loading new data files into the tfviewerx

212 views
Skip to first unread message

Aner Weiss

unread,
Dec 21, 2017, 2:40:59 PM12/21/17
to AnalyzingNeuralTimeSeriesData
Hi Mike,

 I am trying to use the tfviewerx with my own eeg data files.

However in the input parameters, I dont seem to recognize the last param chanloc- How is this created?

Thanks for your amazing book.

Best
Aner

Mike X Cohen

unread,
Dec 21, 2017, 2:49:25 PM12/21/17
to analyzingneura...@googlegroups.com
Hi Aner. That chanlocs structure is EEGlab format. You'll need to eeglab toolbox (free download for MATLAB) in order to convert whatever your existing EEG channel locations format is into the eeglab format. If you need any help with it, let me know. I'm not an expert eeglab user, but I might be able to help.

Mike



--
You received this message because you are subscribed to the Google Groups "AnalyzingNeuralTimeSeriesData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzingneuraltimeseriesdata+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/analyzingneuraltimeseriesdata.
For more options, visit https://groups.google.com/d/optout.



--
Mike X Cohen, PhD
New online courses: mikexcohen.com

Aner Weiss

unread,
Dec 21, 2017, 3:36:25 PM12/21/17
to analyzingneura...@googlegroups.com
Thanks Mike!!

I've already downloaded eeglab, however I have no idea how to create this parameter (I am completely new to eeg as well).
I have a data matrix containing of 16 eeg columns, and thats it. And I know the electrode names. Do you have a mat file with this variable so I can see how it looks like and how to create it (even artificially?)

Many thanks,
Aner

--
You received this message because you are subscribed to a topic in the Google Groups "AnalyzingNeuralTimeSeriesData" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/analyzingneuraltimeseriesdata/9P-r8w3SiZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to analyzingneuraltimeseriesdata+unsub...@googlegroups.com.


--
Thanks,

Aner Weiss
R&D Biomedical Manager
Brain1 Innovation Ltd
M: +972-528-335288
Skype: anerweiss

Mike X Cohen

unread,
Dec 21, 2017, 3:53:26 PM12/21/17
to analyzingneura...@googlegroups.com
Hi Aner. Actually, if you're such a beginner to eeglab, you might want to go through some intro-eeglab tutorials. If you plan on continuing with EEG/MEG/LFP analyses, then it's pretty useful to have at least a decent grasp of how to use eeglab.

There are some on the eeglab website, and I'm sure there are also some on youtube. Maybe someone else on this list can recommend an eeglab tutorial? 

In general, you'll want to use the eeglab GUI to import your data and the electrode names. Assuming they are standard EEG labels, eeglab will be able to guess appropriate channel locations and put those into the EEG.chanlocs structure.

Mike



Aner Weiss

unread,
Dec 22, 2017, 6:18:16 AM12/22/17
to analyzingneura...@googlegroups.com
ok thanks. I'll try to find a tutorial describing how to create this chanloc variable.

But isn't the whole point of your book to guide us in developing our own eeg analysis matlab code without having to be dependant on any ready made toolbox such as eeglab? (I am an experienced matlab user but completely new to eeg analysis)(by the way our data is generated by the gtec system- and their end user GUI is quite limiting as well- I want freedom in my analysis!!!)

Thanks,
Aner

Mike X Cohen

unread,
Dec 22, 2017, 6:33:46 AM12/22/17
to analyzingneura...@googlegroups.com
Yeah, but there is a bit of a balance. I think it's important to understand what happens to your data and to have the freedom and ability to do the analyses you think are best, but that doesn't mean reinventing all the wheels from scratch.

You'll notice that I don't use eeglab functions for data analysis, but I like the eeglab data format. The point of your question is how to get the chanlocs structure that tfviewerx expects. You can write code for creating that structure without the eeglab toolbox, and if you want to do that, then by all means, go for it. But I would prefer to let eeglab do that conversion. It's really just housekeeping work, and doesn't impact how you analyze your data. gtec is a standard system, and I'd guess that eeglab has a plug-in to convert gtec channel labels into standard XYZ locations.

My suggestion for going through an eeglab tutorial is that if you will work with data in eeglab format, then it's useful to have familiarity with the eeglab toolbox. It's a nice toolbox and you might want to use it for other housekeeping things, like data scrolling, epoching, ICA, etc. I would make the same recommendation for fieldtrip if you wanted to use fieldtrip-format data. Knowing how to use an open-source MATLAB toolbox doesn't mean you need to restrict yourself to using their analysis functions.

Finally, just to clarify -- I am not opposed to using toolboxes for data analysis. It's important (1) to understand what those toolboxes are doing with your data, and (2) to realize that analysis toolboxes are typically built by one group to implement the analyses that they find most relevant for their research. 

Mike


Aner Weiss

unread,
Dec 22, 2017, 8:20:47 AM12/22/17
to analyzingneura...@googlegroups.com
Hi Mike,

Thanks for the advice- Indeed it will be helpful of I learn eeglab as well.

I found some tutorials on opening chanloc structure in matlab from a sample .loc file that eeglab provides, and was able to create a chanloc structure:

However the tfviewerx GUI still doesnt work with my data. Perhaps my EEG data matrix is not in the correct format (I have a 2D matrix and your code requires a 3D matrix [channels X frequency X time matrix] and I am not sure what the 3rd frequency dimension stands for)

I think my question is this:

%    USAGE:
% tfviewerx(time,freq,DATA,chanlocs[,title]);
%
%    time     : vector of time points
%    freq     : vector of frequencies (e.g., of wavelet convolution)
%    DATA     : channels X frequency X time matrix
%    chanlocs : eeglab chanlocs structure
%    title    : (optional) string title for figure

All these variables are loaded into matlab, right? from which file format should I load them to matlab? (I see that eeglab has a .set format (+.loc file for channel locations) but i'm not sure how to access its data+variables from matlab, my gtec system can create a hdf5 or text firmat, etc)

Or in other words: I have some eeglab sample data. How can I make the tfviewerx access it?

thanks!
Aner

Mike X Cohen

unread,
Dec 22, 2017, 8:27:09 AM12/22/17
to analyzingneura...@googlegroups.com
tfviewerx is indeed designed for 3D data resulting from a time-frequency analysis over multiple channels. If you have 2D data, you might want to use erpviewerx. Both of these tools are designed for task-related data. If you want to scroll through the continuous data, you might want to use the eeglab viewer.

If you like, you can send me a .mat file that contains a sample of your data and the MATLAB code so I can have a look directly. (You could also send it to me directly -- off-list -- if you prefer.)

Mike


Aner Weiss

unread,
Dec 22, 2017, 9:10:32 AM12/22/17
to analyzingneura...@googlegroups.com
Thanks!!!! Attached is my hdf5 data file, and m functions to read it (test_eeg is the main function and it uses the 2 other ghdf.... functions).
ghdf5read.m
ghdf5fileimport.p
RecordSession_2017.11.06_13.19.43.hdf5
test_eeg.m

Mike X Cohen

unread,
Dec 22, 2017, 10:25:15 AM12/22/17
to analyzingneura...@googlegroups.com
You could use erpviewerx for this. You would need to transpose the data so it's channels x time. You should also detrend or demean each channel. If you don't have an intrinsic time vector, you could create one as 
timevec = (0:length(eeg)-1)/fs;

It looks like you have a snippet of raw data. It might be easier to look at the data like this:
plot(timevec,bsxfun(@plus,detrend(eeg),(1:16)*2))

But if this is just a piece of a much longer continuous dataset, then I recommend going for the eeglab viewer. erpviewerx is designed for task-related data with ~1-2 seconds.

Hope that helps,
Mike


Aner Weiss

unread,
Dec 24, 2017, 3:02:58 AM12/24/17
to analyzingneura...@googlegroups.com

Hi Mike,

Thanks for the support!!! I'm Still working on making it operate on my data (-:

I am simply reading your book chapter by chapter and trying out all of your tools to see how they work on my data. But I guess I have to learn eeglab first.

Is DATA variable a spectrogram?   ( DATA     : channels X frequency X time matrix)

If you have some example sample datas file with the relevant variables (ie chanloc etc) that I can run with tfviewerx and erpviewer GUIs from the matlab command line in order to gain more intuition on the inputs, it will be great. 

Anyway, thanks for the support! I'm now moving on to chapter 5!!!

Thanks,
Aner

Mike X Cohen

unread,
Dec 24, 2017, 6:23:59 AM12/24/17
to analyzingneura...@googlegroups.com
Yes, DATA is the spectrogram per channel. The goal of tfviewerx is to be able to view a 3D cube of data, where the dimensions are channel, time, and frequency. 

If you call tfviewerx with no inputs, it should automatically load a sample results matrix that you can look at. As for an example of the eeglab format and chanlocs structure, you can import the sample dataset that comes with the code. It's called sampleEEGdata.mat, and EEG.chanlocs contains the channel locations in eeglab format.

Mike


Aner Weiss

unread,
Dec 24, 2017, 8:33:53 AM12/24/17
to analyzingneura...@googlegroups.com
tfviewerx(EEG.times,1:4:128,EEG.data,EEG.chanlocs[]);

Aner Weiss

unread,
Dec 24, 2017, 8:43:30 AM12/24/17
to analyzingneura...@googlegroups.com
Great, thanks!

So I loaded the eeg sample data sampleEEGdata.mat into the EEG variable in matlab, and called the tfviewerc like this:
 tfviewerx(EEG.times,linspace(0,128,128),EEG.data,EEG.chanlocs);

However I got the error "something went wrong with time..." probably because of the frequency vector?  What would you expect to put in the frequency vector ? (the srate is 256)


And for another issue- I bought your book from MIT press using the Adobe digital acsm file. I read it from my 1st (work) pc with an unauthorized user but later got an error when trying to open it from a 2nd (home) pc. I then went back to the 1st pc and tried to authorize it from my adobe account- and now the original acsm book file is locked on both pcs!!!! From searching all forums and adobe website this seems to be an adobe issue and they dont seem to help solve it- they state that its irreversible (i;ve spent a few hours on trying to activate and deactivate my adobe account). Is it possible for you to send me the book in pdf format (instead of having to re-purchase it)? Of course I will be the only one reading it- and I would not distribute it to anyone.

Many thanks
and best wishes
Aner 

Mike X Cohen

unread,
Dec 24, 2017, 4:29:50 PM12/24/17
to analyzingneura...@googlegroups.com
The sample EEG data are raw data. You would need to compute a time-frequency decomposition first. It's great that you are so enthusiastic about it, but I think the tfviewerx is probably best explored after chapter 18 ;)

As for the book license issue, that sounds frustrating, but I'm not sure I can help with it. I have to admit, I don't even know what an Adobe acsm file is. I guess to contact MIT Press about it. This sounds like it would be a common problem and I would think there should be a way to reset it or something.

Mike


Aner Weiss

unread,
Dec 25, 2017, 5:30:42 AM12/25/17
to analyzingneura...@googlegroups.com
ok, thanks. The EEG is a 3D matrix of 64X640X99. I'm guessing 64 is the number of elecrtodes, 640 is the time vector, so 99 is not frequency?? (I see another structure of epoch which is 99 in size?)

OK - i'll wait patiently until after chapter 18 (and until resolving this annoying adobe issue).

Thanks (-:

Mike X Cohen

unread,
Dec 25, 2017, 5:54:29 AM12/25/17
to analyzingneura...@googlegroups.com
99 trials, or repetitions of the same experiment event.
Reply all
Reply to author
Forward
0 new messages