import bva time-freq data
Stephan Bickel, Anatomisches Inst.
stephan.bickel at ANATOM.UNIZH.CH
Wed Jul 26 17:28:54 CEST 2006
Hi Robert,
thank you very much for your response and for fixing the bug. Reading in the
trial information works fine now. Unfortunately I encounter another problem
when I want to read in the data with preprocessing. I wonder if it is yet
possible to read in time-frequency data from bva-dat files?
Sorry for bothering you again and thank you very much in advance.
Stephan
So when I do:
cfg = [];
cfg.dataset = 'WT_all_ft_test.vhdr'
cfg.trialdef.eventtype = 'Time 0'
cfg.trialdef.prestim = 0.5000
cfg.trialdef.poststim = 1
cfg = definetrial(cfg)
cfg.datafile = 'WT_all_ft_test.dat';
cfg.channel = 'all';
[raw] = preprocessing(cfg)
I get:
cfg =
dataset: 'WT_all_ft_test.vhdr'
trialdef: [1x1 struct]
datafile: 'WT_all_ft_test.dat'
headerfile: 'WT_all_ft_test.vhdr'
trialfun: 'trialfun_general'
event: [1x2 struct]
trl: [1 750 -250]
version: [1x1 struct]
channel: 'all'
retaining exist trial definition
retaining exist event information
found 2 events
created 1 trials
rejected 0 trials completely
rejected 0 trials partially
resulting 1 trials
reading and preprocessing
reading and preprocessing trial 1 from 1
??? Subscripted assignment dimension mismatch.
Error in ==> fieldtrip-20060725\private\read_brainvision_eeg at 65
dat(line,:) = str2num(str);
Error in ==> fieldtrip-20060725\private\read_data at 239
dat = read_brainvision_eeg(filename, hdr, begsample, endsample);
Error in ==> read_fcdc_data at 49
[dat] = read_data(varargin{:});
Error in ==> preprocessing at 366
dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample, rawindx,
iscontinuous);
On Wed, 26 Jul 2006 09:46:59 +0200
Robert Oostenveld <r.oostenveld at FCDONDERS.RU.NL> wrote:
> Hi Stephan,
>
> On 25 Jul 2006, at 17:39, Stephan Bickel wrote:
>> I try to import brainvision analyzer dat files of wavelet time-
>> frequency
>> decompositions into fieldtrip. I exported an average file, so it
>> consists
>> only of a single segment. However I have some problems with it I am
>> not sure
> ...
>> cfg.trialdef.trgfile = 'c:\HumanEEG_data\Vision_Exports
>> \WT_all_ft_test.vmrk';
>> cfg.trialdef.stim = 'New Segment';
>> %cfg.trialdef.segment = 'yes';
>> cfg.trialdef.timezero = 'yes';
>> % cfg.trialdef.eventtype = 'Time 0';
>
> In general I would recommend to use the trialfun_general instead of the
>trialfun_brainvision (but the latter should also work). The
> trialfun_general was written later and will work for any dataformat that
>is supported by read_fcdc_event, the trialfun_brainvision is only there to
>support old scripts (i.e. scripts that predate the read_fcdc_event
>function).
>
> If not specified manually as trialfun, the trialfun_general or
> trialfun_brainvision is selected automatically based on the cfg settings.
>In your case you could do
> cfg.trialdef.eventtype = 'New Segment' or 'Time 0'
> cfg.trialdef.prestim = number, latency in seconds (optional)
> cfg.trialdef.poststim = number, latency in seconds (optional)
> See teh help of DEFINETRIAL.
>
> But in your case this is not the problem. The problem lies in
>> cfg.trialdef.prestim = 0.500;
>> cfg.trialdef.poststim = 1.600;
>
> If I do
> event = read_fcdc_event('WT_all_ft_test.vmrk')
> then I see that
>
> >> event(1)
> ans =
> type: 'New Segment'
> value: '1'
> sample: 1
> duration: 0
> offset: []
>
> >> event(2)
> ans =
> type: 'Time 0'
> value: '251'
> sample: 1
> duration: 0
> offset: []
>
> The 'New Segment' event is at sample 1, hence you cannot select a 500ms
>pre-stimulus window before it (you cannot read before the beginning of the
>data). The alternative 'Time 0' event is also at sample 1. It specifies a
>value of 251, which surprises me. I would expect that event to be present
>at sample 251.
>
> Reading the marker file with a text editor, I see (abbreviated) the
> explanation
> Mk<number>=<Type>,<Description>,<Position>,<Size>,
> <Channelnumber>,<Date>
> and the markers
> Mk1=New Segment,,1,1,0,00000000000000000000
> Mk2=Time 0,,251,1,0
> So Mk2 should indeed be at sample 251.
>
> With the matlab debugger in the private/read_event.m file (around line
>164) I notice that the problem lies in the missing value of the second
>field, i.e.
> Mk2=Time 0,,251,1,0
> is interpreted as
> Mk2=Time 0,251,1,0 (one comma less)
> All fields are shifted by one, resulting in the sample number being
> interpreted as the description (i.e. value).
>
> I have fixed it in read_event, by replacing line 151 from
> tok = tokenize(line, '=');
> into
> tok = tokenize(line, '=', 0); % do not squeeze repetitions of the
> seperator
> and by replacing line 157 from
> tok = tokenize(tok{2}, ',');
> into
> tok = tokenize(tok{2}, ',', 0); % do not squeeze repetitions of
> the seperator
> i.e. both calls to the tokenize function now use the third argument. You
>can apply the same change to your copy, but please check that you have an
>up to date version of tokenize that accepts 3 input arguments (tokenize is
>in private as well). I will include the bug fix in the upcoming nightly
>release of FieldTrip. Better upgrade tomorrow to the latest FT version
>from the FTP server.
>
> I think that sofar it was not noticed since people here at the Donders
>typically use triggers as markers in their Brainvision data, and in case
>of triggers the second field would not be empty.
>
> If I now do
> cfg = [];
> cfg.dataset = 'WT_all_ft_test.vhdr'
> cfg.trialdef.eventtype = 'Time 0'
> cfg.trialdef.prestim = 0.5000
> cfg.trialdef.poststim = 1
> cfg = definetrial(cfg)
> I get
> evaluating trialfunction 'trialfun_general'
> found 2 events
> created 1 trials
> cfg =
> dataset: 'WT_all_ft_test.vhdr'
> trialdef: [1x1 struct]
> datafile: []
> headerfile: 'WT_all_ft_test.vhdr'
> trialfun: 'trialfun_general'
> event: [1x2 struct]
> trl: [1 750 -250]
> version: [1x1 struct]
> which is correct. The trial (cfg.trl) runs from sample 1 to sample 750 in
>the data file, and the first sample of that trial corresponds with time
>cfg.trl(1,3)/fsample=-0.500 seconds.
>
> Thanks for reporting the bug,
> Robert
More information about the fieldtrip
mailing list