Update Nov 12, 2013: You can now escape the evil (Carbon-based) clutches of Net Station and do everything within Matlab/FieldTrip, including but not limited to: filtering, event segmentation, artifact detection/rejection, ICA component rejection, and analysis. All that is required is writing your own trial segmentation function as described here. This obviates some of what is described below, including using the ERP PCA toolkit for ICA. Contact me for more information if you are interested, as it may take me a while to update this documentation.
This toolkit contains MATLAB functions and scripts that I've written for importing and analyzing EEG data with FieldTrip. The main goal is to provide wrapper functions for quickly and easily running analyses and making plots in the way that I've determined has been fruitful for using FieldTrip.
I've set up the functions to import and process Net Station data; they don't currently deal with other formats, but it should relatively easy to modify mat-mvm to import anything that FieldTrip can import. Also included are scripts for using PyEPL-based experimental data in the context of Net Station and FieldTrip, dealing with Net Station files, interfacing with the ERP PCA Toolkit, running statistics, running ICA blink correction, ANOVAs, and more. There are other scripts as well, many of which are specific to my experiments
The toolkit has been tuned for my workflow, and so I can't guarantee how well they will work for others, but I wanted to put them out there so I can keep track of them in a version control system and so that others can use them. I would enjoy hearing feedback that anyone might have.
See the StartingOut page in the Wiki tab to get started.
Some functions may not be documented particularly well, and that's because I haven't gotten around to doing that yet. Hopefully the more important functions are documented in the function header, accessible with the 'help' command in MATLAB.
The Functions page has a brief overview of some of the most useful functions to use after you get your data in FieldTrip format.
If you have any questions, please email me. You can find my email address on the project homepage under the members section.
Some functions, like a few in the mat-mvm/stat/rmaov directory, have been downloaded from the MATLAB File Exchange and modified, and they are included because I use them. The original download URL and copyright information is contained in those files, which are covered under the Simplified BSD License. The Simplified BSD License is GPL-compatible, and thus these files can be included here.
I am a graduate student in Tim Curran's lab in the Department of Psychology and Neuroscience at the University of Colorado Boulder.
NB: As noted on the main page, I now do all my processing and analysis within Matlab/FieldTrip, so many of the instructions below are out of date. See mat-mvm/space/space_ft_seg_tla.m and the accompanying mat-mvm/space/space_trialfun.m for examples of the new workflow.
In order to generalize to other experiments, things may need to change, but may not. To get trial metadata during segmentation (which gets put in the trialinfo field by FieldTrip), you will need to either have .evt files exported from your Net Station recordings, events.mat files created from other behavioral data, and/or other ways of reading behavioral data that might need to get built in to seg2ft or ideally would get put in your trialfun function. An example of event file creation can be found at another one of my projects, [https://github.com/warmlogic/expertTrain expertTrain], an experiment framework that started as an expertise training experiment but has grown. See expertTrain/analysis/space_createEvents.m for an example of event creation.
These tools are essentially wrapper functions that I've written for using the FieldTrip toolbox with data recorded in Net Station. You'll need to download FieldTrip, and possibly the ERP PCA Toolkit and EEGLAB. For initial behavioral data processing, I also use some functions contained in the Kahana lab's [http://memory.psych.upenn.edu/Software eeg_toolbox]; this will likely only apply to you if you use PyEPL for your experiments.
A few subfolders in mat-mvm (excluding data, eeg, eptoolkit, ft_general, netstation, stat, utilities, etc.) hold experiment-specific scripts. Given the lack of anything resembling a tutorial, it would behoove you to explore (one of) these directories. Read the details below before starting.
kahn2
scripts, though note that these are set up for a particular file/directory setup that I did not create.EGIS
or raw
(a.k.a. sbin
, for simple binary). EGIS
loads faster.EGIS
or sbin
/raw
file, with the subject number at the beginning of each filename.
mm_ft_setSaveDirs.m
.Sub001
to the beginning of the segment name, but you should check on this. Error checking code in seg2ft.m
will tell you the available segment names if you have input the wrong ones.*_ftprocess_*.m
.To get started in analyzing your data:
create_ft_struct.m
, seg2ft.m
, and process_ft_data.m
. They have extensive help sections that you can view with the 'help' command in MATLAB. The help sections may not explain all of the options (yet), so feel free to peruse the top of the code for some of these.mat-mvm/soco/soco_ft_seg_tla.m
or mat-mvm/tnt/tnt_ft_seg_pow.m
, but note that they may not be tuned for your experiment and all options may not be present.
Here's how I preprocessed my data at one point (it has since changed a bit):
See the Functions section.
To automatically add mat-mvm to your path, put this in ~/Documents/MATLAB/startup.m:
myMatlabDir = fullfile(getenv('HOME'),'Documents','MATLAB');
addpath(genpath(fullfile(myMatlabDir,'mat-mvm')));
To remove version control (.git, .svn, and CVS) directories from your path (I don't know if they would cause any conflicts, but I do this anyway), put this in ~/Documents/MATLAB/startup.m:
%% remove version control directories from path (.git, .svn, CVS)
entries = regexp(path, ['[^',pathsep,']*',pathsep], 'match');
% find the version control entries
vc_entries = cell2mat(cellfun(@(x) ~isempty(strfind(x,'.git')) | ~isempty(strfind(x,'.svn')) | ~isempty(strfind(x,'CVS')), entries, 'UniformOutput', false));
% remove them
rmpath(sprintf(repmat('%s',1,sum(vc_entries)),entries{vc_entries}));
Be sure to read the StartingOut section above before jumping in too deep.
NB: Functions are usually suffixed with ER for ERP data (Event Related) and TFR for time–frequency data (TF Representation). This is adopted from the typical FieldTrip function naming convention.
mm_ft_simpleplotER: An extremely simple function for plotting ERP data
mm_ft_plotER and mm_ft_plotTFR: The most basic grand average plotting functions
mm_ft_subjplotER and mm_ft_subjplotTFR: Plot individual subjects
mm_ft_contrastER and mm_ft_contrastTFR: Plot condition contrasts
mm_ft_clusterplotER and mm_ft_clusterplotTFR: Plot non-parametric statistical clustering results
mm_ft_ttestER and mm_ft_ttestTFR: Run t-tests, comparing two conditions
mm_ft_rmaov2ER, mm_ft_rmaov2TFR, mm_ft_rmaov33ER, and mm_ft_rmaov33TFR: Run ANOVAs comparing multiple conditions, ROIs, and time windows.
mm_ft_clusterstatER and mm_ft_clusterstatTFR: Run non-parametric statistical clustering
mm_ft_corr_dprimeER: Run correlations between ERP voltage and d'. You could probably input other data besides d'.
There are many other functions, mostly for bookkeeping and getting your data ready to analyze. Check out some of the experiment scripts for examples.
For example, check out send_gmail, which will send you an email (via your gmail account) when processing is done. !ProTip: use Cmd-Enter or Cmd-Shift-Enter to run sections of a script that has been divided up using cell notation (%%) to start your processing, and then follow that up with an email call to let you know when it's done.