0001
0002
0003
0004
0005
0006
0007
0008 data = 'd:\matlab\brainstorm_v1\studies\';
0009
0010 cd(data);
0011
0012 datapath = pwd;
0013
0014
0015 sample_rate = 2.5;
0016 epoch_start = -200;
0017 epoch_end = 1500;
0018 points = 681;
0019
0020
0021
0022 timeArray = meshgrid(epoch_start:sample_rate:epoch_end,1)';
0023 timeNonZero = find(timeArray);
0024 timeZero = find(timeArray == 0);
0025
0026
0027 for g = {'c','p'},
0028
0029 if strcmp(g,'c'),
0030
0031 for s = 1:10,
0032
0033 sdir = sprintf('%s%02d',char(g),s);
0034 cd(sdir)
0035
0036 for c = {'o','oac','oat','ouc','out','t','tac','tad','tat','tuc','tud','tut'},
0037
0038 file = sprintf('%s%02d%s.dat',char(g),s,char(c));
0039 volt = sprintf('%s%02d%s', char(g),s,char(c));
0040
0041 channelfile = sprintf('%s%02d_channel.mat',char(g),s)
0042 if exist(channelfile) == 2,
0043 load(channelfile,'Channel')
0044 channelfile = sprintf('%s%02d_%s_volts_channel.mat',char(g),s,char(c))
0045 save(channelfile,'Channel')
0046 clear Channel
0047 end
0048
0049 if ~exist(volt,'var')
0050
0051 fprintf('loading ascii %s\n',file);
0052 load(file);
0053
0054
0055 V = eval(volt)';
0056 InterpZero = interp1( timeArray(timeNonZero), V, 0, 'cubic' );
0057 V = [V(1:timeZero-1,:); InterpZero; V(timeZero:end,:)];
0058 eval(strcat(volt,' = V'';'));
0059
0060
0061
0062 data.Time = timeArray' ./ 1000;
0063 data.F = eval(volt) ./ 10^6;
0064
0065
0066
0067
0068 fileprefix = sprintf('%s%02d_%s_volts',char(g),s,char(c));
0069 eeg_write_brainstorm(fileprefix,data);
0070
0071 else
0072 fprintf('Already loaded %s\n',file);
0073 end
0074
0075
0076 end
0077 cd ..
0078 end
0079
0080 else
0081
0082 for s = [2 4:9],
0083
0084 sdir = sprintf('%s%02d',char(g),s);
0085 cd(sdir)
0086
0087 for c = {'o','oac','oat','ouc','out','t','tac','tad','tat','tuc','tud','tut'},
0088
0089 file = sprintf('%s%02d%s.dat',char(g),s,char(c));
0090 volt = sprintf('%s%02d%s', char(g),s,char(c));
0091
0092 channelfile = sprintf('%s%02d_channel.mat',char(g),s)
0093 if exist(channelfile) == 2,
0094 load(channelfile,'Channel')
0095 channelfile = sprintf('%s%02d_%s_volts_channel.mat',char(g),s,char(c))
0096 save(channelfile,'Channel')
0097 clear Channel
0098 end
0099
0100 if ~exist(volt,'var')
0101 fprintf('loading ascii %s\n',file);
0102 load(file);
0103
0104
0105 V = eval(volt)';
0106 InterpZero = interp1( timeArray(timeNonZero), V, 0, 'cubic' );
0107 V = [V(1:timeZero-1,:); InterpZero; V(timeZero:end,:)];
0108 eval(strcat(volt,' = V'';'));
0109
0110
0111
0112 data.Time = timeArray' ./ 1000;
0113 data.F = eval(volt) ./ 10^6;
0114
0115
0116
0117
0118 fileprefix = sprintf('%s%02d_%s_volts',char(g),s,char(c));
0119 eeg_write_brainstorm(fileprefix,data);
0120
0121 else
0122 fprintf('Already loaded %s\n',file);
0123 end
0124
0125 end
0126 cd ..
0127 end
0128 end
0129 end
0130 clear timeZero timeNonZero g c file volt V InterpZero