Skip to content

Commit d55a3b8

Browse files
committed
Reporting last changes from @pompolas PR #13
#13
1 parent ae9cd96 commit d55a3b8

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

toolbox/process/functions/process_convert_raw_to_lfp.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
% Template structure for the creation of the output raw file
173173
sFileTemplate = sFileIn;
174174
sFileTemplate.prop.sfreq = LFP_fs;
175-
sFileTemplate.prop.times = [0, (nTimeOut-1) ./ LFP_fs];
175+
sFileTemplate.prop.times = [newTimeVector(1), newTimeVector(end)];
176176
sFileTemplate.header.sfreq = LFP_fs;
177177
sFileTemplate.header.nsamples = nTimeOut;
178178
% Convert events to new sampling rate
@@ -231,7 +231,8 @@
231231
% Get channel name from electrode file name
232232
[tmp, ChannelName] = fileparts(ElecFile);
233233
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';
235236
end
236237
% Band-pass filter
237238
data = bst_bandpass_hfilter(data, sr, BandPass(1), BandPass(2), 0, 0);
@@ -242,7 +243,7 @@
242243

243244
%% ===== BAYESIAN SPIKE REMOVAL =====
244245
% 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)
246247
% Assume that a spike lasts 3ms
247248
nSegment = round(Fs * 0.003);
248249
Bs = eye(nSegment); % 60x60
@@ -275,7 +276,7 @@
275276
% from spktimes to obtain the start times of the spikes
276277

277278
if mod(length(data),2)~=0
278-
data_temp = [data;0];
279+
data_temp = [data 0]';
279280
g = fitLFPpowerSpectrum(data_temp,BandPass(1),BandPass(2),sFile.prop.sfreq);
280281
S = zeros(length(data_temp),1);
281282
iSpk = round(spkSamples - nSegment/2);

toolbox/process/functions/process_noise_correlation.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
end
7979
end
8080
% If no neuron was found
81-
if isempty(neuronLabels)
81+
if isempty(uniqueNeurons)
8282
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
8383
return;
8484
end

toolbox/process/functions/process_psth_per_electrode.m renamed to toolbox/process/functions/process_psth_per_channel.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function varargout = process_psth_per_electrode( varargin )
2-
% PROCESS_PSTH_PER_ELECTRODE: Computes the PSTH per electrode.
1+
function varargout = process_psth_per_channel( varargin )
2+
% PROCESS_PSTH_PER_CHANNEL: Computes the PSTH per channel.
33

4-
% It displays the binned firing rate on each electrode (of only the first
5-
% neuron on each electrode if multiple have been detected). This can be nicely
4+
% It displays the binned firing rate on each channel (of only the first
5+
% neuron on each channel if multiple have been detected). This can be nicely
66
% visualized on the cortical surface if the positions of the electrodes
77
% have been set, and show real time firing rate.
88

@@ -34,7 +34,7 @@
3434
%% ===== GET DESCRIPTION =====
3535
function sProcess = GetDescription()
3636
% Description the process
37-
sProcess.Comment = 'PSTH per electrode';
37+
sProcess.Comment = 'PSTH per channel';
3838
sProcess.FileTag = 'raster';
3939
sProcess.Category = 'File';
4040
sProcess.SubGroup = 'Electrophysiology';

toolbox/process/functions/process_psth_per_neuron.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
end
9393
end
9494
% If no neuron was found
95-
if isempty(neuronLabels)
95+
if isempty(labelsNeurons)
9696
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
9797
return;
9898
end

toolbox/process/functions/process_rasterplot_per_neuron.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
end
8383
end
8484
% If no neuron was found
85-
if isempty(neuronLabels)
85+
if isempty(labelsNeurons)
8686
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
8787
return;
8888
end

toolbox/process/functions/process_spike_triggered_average.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
end
166166
end
167167
% Divide by total number of averages
168-
STA_single_neuron = (STA_single_neuron./divideBy)';
168+
STA_single_neuron = (STA_single_neuron./divideBy);
169169
% std_single_neuron = sqrt(std_single_neuron./(divideBy - size(all_labels,2)));
170170

171171
% Get meaningful label from neuron name
@@ -179,7 +179,7 @@
179179
% ===== SAVE FILE =====
180180
% Prepare output file structure
181181
FileMat = db_template('datamat');
182-
FileMat.F = STA_single_neuron';
182+
FileMat.F = STA_single_neuron;
183183
FileMat.Time = time_segmentAroundSpikes;
184184
% FileMat.Std = 2 .* std_single_neuron; % MULTIPLY BY 2 TO GET 95% CONFIDENCE (ASSUMING NORMAL DISTRIBUTION)
185185
FileMat.Comment = ['Spike Triggered Average: ' str_remove_parenth(DataMats{1}.Comment) ' (' better_label ')'];

toolbox/process/functions/process_spikesorting_kilosort.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,12 @@ function ImportKilosortEvents(sFile, ChannelMat, parentPath, rez)
496496
index = index + 1;
497497
end
498498
end
499-
events = [events events_spikes];
499+
500+
if ~isempty(existingEvents)
501+
events = [events events_spikes];
502+
else
503+
events = events_spikes;
504+
end
500505

501506
save(fullfile(parentPath,'events_UNSUPERVISED.mat'),'events')
502507

0 commit comments

Comments
 (0)