|
172 | 172 | % Template structure for the creation of the output raw file |
173 | 173 | sFileTemplate = sFileIn; |
174 | 174 | sFileTemplate.prop.sfreq = LFP_fs; |
175 | | - sFileTemplate.prop.times = [0, (nTimeOut-1) ./ LFP_fs]; |
| 175 | + sFileTemplate.prop.times = [newTimeVector(1), newTimeVector(end)]; |
176 | 176 | sFileTemplate.header.sfreq = LFP_fs; |
177 | 177 | sFileTemplate.header.nsamples = nTimeOut; |
178 | 178 | % Convert events to new sampling rate |
|
231 | 231 | % Get channel name from electrode file name |
232 | 232 | [tmp, ChannelName] = fileparts(ElecFile); |
233 | 233 | ChannelName = strrep(ChannelName, 'raw_elec_', ''); |
234 | | - data = BayesianSpikeRemoval(ChannelName, data, sr, sFileIn, ChannelMat, cleanChannelNames); |
| 234 | + data = BayesianSpikeRemoval(ChannelName, data, sr, sFileIn, ChannelMat, cleanChannelNames, BandPass); |
| 235 | + data = data'; |
235 | 236 | end |
236 | 237 | % Band-pass filter |
237 | 238 | data = bst_bandpass_hfilter(data, sr, BandPass(1), BandPass(2), 0, 0); |
|
242 | 243 |
|
243 | 244 | %% ===== BAYESIAN SPIKE REMOVAL ===== |
244 | 245 | % Reference: https://www.ncbi.nlm.nih.gov/pubmed/21068271 |
245 | | -function data_derived = BayesianSpikeRemoval(ChannelName, data, Fs, sFile, ChannelMat, cleanChannelNames) |
| 246 | +function data_derived = BayesianSpikeRemoval(ChannelName, data, Fs, sFile, ChannelMat, cleanChannelNames, BandPass) |
246 | 247 | % Assume that a spike lasts 3ms |
247 | 248 | nSegment = round(Fs * 0.003); |
248 | 249 | Bs = eye(nSegment); % 60x60 |
|
275 | 276 | % from spktimes to obtain the start times of the spikes |
276 | 277 |
|
277 | 278 | if mod(length(data),2)~=0 |
278 | | - data_temp = [data;0]; |
| 279 | + data_temp = [data 0]'; |
279 | 280 | g = fitLFPpowerSpectrum(data_temp,BandPass(1),BandPass(2),sFile.prop.sfreq); |
280 | 281 | S = zeros(length(data_temp),1); |
281 | 282 | iSpk = round(spkSamples - nSegment/2); |
|
0 commit comments