| Converting BrainWare *.f32 and eyetracker *.etd to Unitret datafile | ![]() |
The BrainWare (BW) exports data (spikes and stimulus parameters) in binary *.f32 file NOT in chronological order - instead, it sorts it according to stimulus conditions (datasets) and repetitions:
1st dataset 1st repetition 2nd repetition ... 2nd dataset ... ...If there is more than one batch/record in the file, even though the stimulus remained the same, BrainWare will consider it as a new dataset.
Eyetracker data, however, is written in chronological order:
1st trial 2nd trial ...This complicates the synchronization of BW and eyetracker data, especially in cases when more than one batch is saved to the file, the batches are different in size (#conditions) and/or #repetitions for each condition, and the order of presentation in the batch was random.
The conver.m routine can deal with all these difficulties using the following algorithm:
1. The eyetracker data is read to structure array etdata(ind, rep), where ind is the sequential number of
row in StimulusGrid (corresponding to the number of stimulus condition if file contains only one batch),
and rep is the number of repetitions for this index in the file
(again, for one batch it would be the number of repetitions for "ind" stimulus condition).
Note that this array can have empty members, for example (0372_001.a18):
ind/rep 1 2 3 4 1 x x x x* 2 x x x x* 3 x x x 4 x x x x' 5 x 6 x 7 xIn the example above, we have 3 batches:
In order to correctly assign eyetracker trial to its corresponding spike and stimulus data, we keep track of last selected rep for each ind (last_rep_taken), and select etdata trial bases on last_rep_taken and ind that is obtained from BW data(numset).stim(1):
...
nusc = length(unique(inds)); % number of unique stimulus conditions
...
last_rep_taken = ones(1,nusc);
for numset = 1:numsets,
for sweep = 1:size(data(numset).sweep,2),
...
n = data(numset).stim(1);
s = last_rep_taken(n);
last_rep_taken(n) = last_rep_taken(n)+1;
etdata(n,s)...
See conver.m for more details.