Importing .acq dataformat

Vladimir Litvak v.litvak at ION.UCL.AC.UK
Sun Dec 30 10:49:26 CET 2007


Hi Kenton,
 
There is no need to initialize a matrix with 21 columns if you only have
6 channels. You can only have 6 columns and if the labels are correct,
Fieldtrip will know how to handle it. To do what you want you might find
the following functions useful. 1) data2raw(), raw2data() (they are in
fieldtrip/private subdirectory so to use them you need to change the
name ‘private’ to something else, like ‘private1’ and add it to your
path). With these functions you can convert a raw struct with cell
arrays to a timelock-like struct with a multidimensional array that is
much easier to handle. You can then manipulate it any way you want and
convert the result back to raw if necessary. 2) appenddata()  That might
be even simpler. You just create a new raw struct with the additional
channels and then append it to your first struct. 
 
Don’t be so sure that if your source is in ACC the best way to go about
localizing it would be to put a lot of electrodes in the front of the
head. Since it’s a deep source that would be hard to localize anyway and
probably projects strongly to the whole scalp you would need good
coverage of the whole head and in particular lower half of the head,
which is not usually covered in standard montages, but more people now
realize that it should be. 
 
You might find additional useful tips in Clin Neurophysiol. 2004
Oct;115(10):2195-222. EEG source imaging. Michel et al.
 
When you feel more confident with Matlab, Fieldtrip and your data
perhaps you could contribute back to the community by implementing a
reader for your data format in the standard conforming to Fieldtrip
fileio module HYPERLINK
"http://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:development
:fileio"http://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:deve
lopment:fileio . This will be helpful for anyone who wants to read the
.acq format into Fieldtrip and also other packages that also use this
module.
 
Good luck,
 
Vladimir
 
-----Original Message-----
From: kentonhokanson at gmail.com [mailto:kentonhokanson at gmail.com] On
Behalf Of Kenton Hokanson
Sent: Friday, December 28, 2007 11:26 PM
To: Vladimir Litvak
Subject: Re: [FIELDTRIP] Importing .acq dataformat
 
Hi Vladimir,

Thanks a lot for all the advice and the other options.  Following them
up has been very informative.  I've spent some time working through the
MATLAB help file and the tutorials, and things are working well through
topoplotER.m.  More importantly, we're going to try to add some
electrodes.  We're interested mainly in one component which we believe
will come from the ACC, so we'll focus on frontal electrodes and see how
good we can get.  I appreciate your candor through all this.  If I could
impose on you with one last question, I'd be grateful for a bit of help
- 

The script I've put together to convert our data file into trial
matrices looks like the following, where the trialK structure reads the
trial start (.KS) and end (.KE) samples from an excel file, and they're
then used to define the range of cells which are imported from the data
file (data_all) and put into channels in the trial matrix.  So, for
trial 1, I start with T1 (a matrix of zeros, 4001samples x 21channels),
then paste the six data channels (starting at the trialK.KS(1)
start-point until the trialK.KE(1) end-point) into their appropriate
columns according to the EEG1020.LAY file, then transpose the matrix to
form the trial matrix and clear the matrix used to create it.  This
process repeats for each trial.  It works fine, but if I were to change
anything (for example, to add more channels), I would have to insert
that line, with its appropriate trial number, in each of the 200 trials.
I was wondering if there was a way to condense this, perhaps by changing
the trial number  (N wherever it appears in the form (N) or TN) to be
defined by each cell in a vector I defined or by creating some sort of
index in a cell array.  I've thought about it, but I'm stumped again and
would appreciate any streamlining advice. 

trialK.KS = xlsread('C:\Documents and Settings\Kenton
Hokanson\Desktop\JESS_ALLTRIALS_XLS.xls', 1, 'E2:E82');
trialK.KE = xlsread('C:\Documents and Settings\Kenton
Hokanson\Desktop\JESS_ALLTRIALS_XLS.xls', 1, 'F2:F82'); 

T1 = [];
T1(1:4001,1:21) = 0; %Set all channels in EEG1020.LAY to zero
T1(1:4001,5)=data_all(trialK.KS(1):trialK.KE(1),5); %F3
T1(1:4001,6)=data_all(trialK.KS(1):trialK.KE(1),6); %Fz
T1(1:4001,7)=data_all( trialK.KS(1):trialK.KE(1),7); %F4
T1(1:4001,10)=data_all(trialK.KS(1):trialK.KE(1),4); %C3
T1(1:4001,11)=data_all(trialK.KS(1):trialK.KE(1),3); %Cz
T1(1:4001,12)=data_all(trialK.KS(1):trialK.KE(1),8); %C4
TrialT1 = T1'; 
clear T1

T2 = [];
T2(1:4001,1:21) = 0;
T2(1:4001,5)=data_all(trialK.KS(2):trialK.KE(2),5);
T2(1:4001,6)=data_all(trialK.KS(2):trialK.KE(2),6);
T2(1:4001,7)=data_all(trialK.KS(2):trialK.KE(2),7);
T2(1:4001,10)=data_all(trialK.KS(2):trialK.KE(2),4);
T2(1:4001,11)=data_all(trialK.KS(2):trialK.KE(2),3);
T2(1:4001,12)=data_all(trialK.KS(2):trialK.KE(2),8);
TrialT2 = T2';
clear T2
...

Thanks again, Vladimir, and I'll certainly understand if you don't have
time to address this.  All the best,
Kenton
On Dec 25, 2007 3:24 PM, Vladimir Litvak < HYPERLINK
"mailto:v.litvak at ion.ucl.ac.uk"v.litvak at ion.ucl.ac.uk> wrote:
If all you have are 6 channels, you shouldn't waste your time. To get a
meaningful localization you would need at least 18 and even then it'd be
quite imprecise. What you should understand is that Fieldtrip has no GUI
so you shouldn't expect any fancy windows to open or something magical
happen with your data. Most functions require inputs so dragging them to
the command line won't do much. 
 
Your second attempt is closer to the truth. It'll probably even work if
you start with cfg=[]; 
 
So the bottom line is if you don't have more channels, just drop it.
Even if you do, perhaps you should consider alternatives to Fieldtrip
that will be simpler for you to use. BESA (HYPERLINK
"http://www.besa.de/" \nwww.besa.de) is nice software that does source
localization and has extensive GUI, but it's quite expensive. You can
also look at EEGLAB (Google it). This is a free package which is simpler
to use than Fieldtrip, but it only does source localization in very
specific context that might not be suitable for you. 
 
If you are determined to stick with Fieldtrip, you should master basic
Matlab programming and do the relevant tutorials from Fieldtrip website.
I'm afraid there are no shortcuts here. The simplest way to get started
is take one of the tutorial scripts and adapt it to your needs. But for
this you should understand what you are doing. 
 
For timelockanalysis see if the empty cfg works and then look in the
header of timelockanalysis.m for different options you can put in the
cfg and go from there. You can look at HYPERLINK
"http://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:documentati
on:tutorial:eventrelatedaveraging"
\nhttp://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:documentat
ion:tutorial:eventrelatedaveraging starting with 'Averaging the
time-locked data'. 
 
Good luck,
 
Vladimir 
 
-----Original Message-----
From: HYPERLINK "mailto:kentonhokanson at gmail.com"
\nkentonhokanson at gmail.com [mailto:HYPERLINK
"mailto:kentonhokanson at gmail.com" \nkentonhokanson at gmail.com] On Behalf
Of Kenton Hokanson
Sent: Tuesday, December 25, 2007 10:06 PM
To: Vladimir Litvak
Subject: Re: [FIELDTRIP] Importing .acq dataformat
 
Hi, Vladimir,
My ultimate goal would be source localization.  The two trials come from
a data file of about 150 trials, which are all four second windows where
the sample at 2.001 seconds is a stimulus.  When we average the trials,
soon after the stimulus there is a clear and reliable deflection; we
would like to localize the source of the deflection.  The software
package we're using (AcqKnowledge) can filter, average, etc, but has no
localization program. 

So, having set up the data structure, I would think my next step should
be the TIMELOCKANLYSIS program.  I'm such a novice, though, I haven't
figured out the proper way to run it at all, and each of my attempts
generates a new error message.  Graphically dragging the program into
the command window generates 

>> run('C:\Program
Files\MATLAB71\work\fieldtrip-lite-20071210\fieldtrip-lite-20071210\time
lockanalysis.m')
??? Error using ==> run
Input argument "data" is undefined.

while entering the function listed at the top of the program ([timelock]
= timelockanalysis(cfg, data)) results in 
??? Undefined function or variable 'cfg'.

How far off base am I?  Thanks so much for the reply, it's a relief to
have a chance to actually make some progress. 

Best,
Kenton
On Dec 25, 2007 1:27 PM, Vladimir Litvak <HYPERLINK
"mailto:v.litvak at ion.ucl.ac.uk" \nv.litvak at ion.ucl.ac.uk> wrote:
Hi,
 
I'd drop the EEG_ part in the labels, but other then that your struct
seems OK. The question it what is it you are trying to do and what do
you mean by 'doesn't appear to be usable for anything' ?
 
Best,
 
Vladimir 
 
-----Original Message-----
From: FieldTrip discussion list [mailto:HYPERLINK
"mailto:FIELDTRIP at NIC.SURFNET.NL" \nFIELDTRIP at NIC.SURFNET.NL] On Behalf
Of Kenton Hokanson
Sent: Tuesday, December 25, 2007 8:07 PM
To: HYPERLINK "mailto:FIELDTRIP at NIC.SURFNET.NL"
\nFIELDTRIP at NIC.SURFNET.NL
Subject: [FIELDTRIP] Importing .acq dataformat
 
Hi everyone,
Sorry, this is a rather basic yet lengthy question, but I've been
working on my own for some time and am totally stumped.  If there exists
a more appropriate way to get an answer to this question than to email
the entire list, please let me know; otherwise, please forgive my
inexperience! 
I'm trying to use FieldTrip to analyze EEG data recorded using BioPac's
"AcqKnowledge" data acquisition program (data files are saved with
extension .acq).  This is not a FieldTrip-compatible format, but using
the FT FAQ ( HYPERLINK
"http://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:dataformat"
\nhttp://www2.ru.nl/fcdonders/fieldtrip/doku.php?id=fieldtrip:dataformat
) I found the following information for importing my dataformat. 
"Alternatively, if you already are able to read the data into Matlab,
you can reformat that data within Matlab into a datastructure that is
compatible with FieldTrip. Raw data that is comparable with the output
of preprocessing should consist of a structure with the fields 
data.label   % cell-array containing strings, Nchan X 1













data.fsample % sampling frequency in Hz, single number













data.trial   % cell-array containing a data matrix for each trial (1 X
Ntrial), each data matrix is Nchan X Nsamples 
 
 














data.time    % cell-array containing a time axis for each trial (1 X
Ntrial), each time axis is a 1 X Nsamples vector"
I'm able to save my data file as a single MATLAB matrix of dimensions
NSamples x NChannels (20073x10).  Using my knowledge of the timestamps
of events within the data file, I divided it up into two trials.  Each
trial is 4001 samples long, and there are six channels that I want to
analyze, so I've pasted that data into smaller matrices (Trial1 and
Trial2) each with dimensions 6 x 4001.  Having done this, I input the
following: 

data.label = {'EEG_CZ' 'EEG_C3' 'EEG_F3' 'EEG_FZ' 'EEG_F4' 'EEG_C4'}
data.fsample = 1000
data.trial = {Trial1 Trial2}
data.time = {1:4001 1:4001} 

Here's the output those commands generate:

data = 

      label: {'EEG_CZ'  'EEG_C3'  'EEG_F3'  'EEG_FZ'  'EEG_F4'
'EEG_C4'} 
    fsample: 1000
      trial: {[6x4001 double]  [6x4001 double]}
       time: {[1x4001 double]  [1x4001 double]}

It would seem to me that I have created the datastructure defined on the
FAQ site.  However, the structure doesn't appear to be usable for
anything (my guess is that a cfg structure is also necessary, but I
haven't found how to create one that is functionally identical to the
output of preprocessing, define_trials, any of the read_xxx programs
from fileio)...I don't know where to begin!  I'd very much appreciate
any help I could get.  Thanks, very happy holidays. 

Best,
Kenton Hokanson
----------------------------------
The aim of this list is to facilitate the discussion between users of
the FieldTrip toolbox, to share experiences and to discuss new ideas for
MEG and EEG analysis.
HYPERLINK "http://listserv.surfnet.nl/archives/fieldtrip.html"
\nhttp://listserv.surfnet.nl/archives/fieldtrip.html 
HYPERLINK "http://www.ru.nl/fcdonders/fieldtrip/"
\nhttp://www.ru.nl/fcdonders/fieldtrip/
 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.8/1195 - Release Date:
24/12/2007 11:19
 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.8/1195 - Release Date:
24/12/2007 11:19
 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.8/1195 - Release Date:
24/12/2007 11:19
 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.8/1195 - Release Date:
24/12/2007 11:19
 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.516 / Virus Database: 269.17.12/1202 - Release Date:
29/12/2007 13:27

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.17.12/1202 - Release Date:
29/12/2007 13:27
 

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20071230/6e402bdf/attachment-0002.html>


More information about the fieldtrip mailing list