Skip to content

Commit

Permalink
Reporting last changes from @pompolas PR #13
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Apr 29, 2022
1 parent ae9cd96 commit d55a3b8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
9 changes: 5 additions & 4 deletions toolbox/process/functions/process_convert_raw_to_lfp.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
% Template structure for the creation of the output raw file
sFileTemplate = sFileIn;
sFileTemplate.prop.sfreq = LFP_fs;
sFileTemplate.prop.times = [0, (nTimeOut-1) ./ LFP_fs];
sFileTemplate.prop.times = [newTimeVector(1), newTimeVector(end)];
sFileTemplate.header.sfreq = LFP_fs;
sFileTemplate.header.nsamples = nTimeOut;
% Convert events to new sampling rate
Expand Down Expand Up @@ -231,7 +231,8 @@
% Get channel name from electrode file name
[tmp, ChannelName] = fileparts(ElecFile);
ChannelName = strrep(ChannelName, 'raw_elec_', '');
data = BayesianSpikeRemoval(ChannelName, data, sr, sFileIn, ChannelMat, cleanChannelNames);
data = BayesianSpikeRemoval(ChannelName, data, sr, sFileIn, ChannelMat, cleanChannelNames, BandPass);
data = data';
end
% Band-pass filter
data = bst_bandpass_hfilter(data, sr, BandPass(1), BandPass(2), 0, 0);
Expand All @@ -242,7 +243,7 @@

%% ===== BAYESIAN SPIKE REMOVAL =====
% Reference: https://www.ncbi.nlm.nih.gov/pubmed/21068271
function data_derived = BayesianSpikeRemoval(ChannelName, data, Fs, sFile, ChannelMat, cleanChannelNames)
function data_derived = BayesianSpikeRemoval(ChannelName, data, Fs, sFile, ChannelMat, cleanChannelNames, BandPass)
% Assume that a spike lasts 3ms
nSegment = round(Fs * 0.003);
Bs = eye(nSegment); % 60x60
Expand Down Expand Up @@ -275,7 +276,7 @@
% from spktimes to obtain the start times of the spikes

if mod(length(data),2)~=0
data_temp = [data;0];
data_temp = [data 0]';
g = fitLFPpowerSpectrum(data_temp,BandPass(1),BandPass(2),sFile.prop.sfreq);
S = zeros(length(data_temp),1);
iSpk = round(spkSamples - nSegment/2);
Expand Down
2 changes: 1 addition & 1 deletion toolbox/process/functions/process_noise_correlation.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
end
end
% If no neuron was found
if isempty(neuronLabels)
if isempty(uniqueNeurons)
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
return;
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function varargout = process_psth_per_electrode( varargin )
% PROCESS_PSTH_PER_ELECTRODE: Computes the PSTH per electrode.
function varargout = process_psth_per_channel( varargin )
% PROCESS_PSTH_PER_CHANNEL: Computes the PSTH per channel.

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

Expand Down Expand Up @@ -34,7 +34,7 @@
%% ===== GET DESCRIPTION =====
function sProcess = GetDescription()
% Description the process
sProcess.Comment = 'PSTH per electrode';
sProcess.Comment = 'PSTH per channel';
sProcess.FileTag = 'raster';
sProcess.Category = 'File';
sProcess.SubGroup = 'Electrophysiology';
Expand Down
2 changes: 1 addition & 1 deletion toolbox/process/functions/process_psth_per_neuron.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
end
end
% If no neuron was found
if isempty(neuronLabels)
if isempty(labelsNeurons)
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
return;
end
Expand Down
2 changes: 1 addition & 1 deletion toolbox/process/functions/process_rasterplot_per_neuron.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
end
end
% If no neuron was found
if isempty(neuronLabels)
if isempty(labelsNeurons)
bst_report('Error', sProcess, sCurrentInputs(1), 'No neurons/spiking events detected.');
return;
end
Expand Down
4 changes: 2 additions & 2 deletions toolbox/process/functions/process_spike_triggered_average.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
end
end
% Divide by total number of averages
STA_single_neuron = (STA_single_neuron./divideBy)';
STA_single_neuron = (STA_single_neuron./divideBy);
% std_single_neuron = sqrt(std_single_neuron./(divideBy - size(all_labels,2)));

% Get meaningful label from neuron name
Expand All @@ -179,7 +179,7 @@
% ===== SAVE FILE =====
% Prepare output file structure
FileMat = db_template('datamat');
FileMat.F = STA_single_neuron';
FileMat.F = STA_single_neuron;
FileMat.Time = time_segmentAroundSpikes;
% FileMat.Std = 2 .* std_single_neuron; % MULTIPLY BY 2 TO GET 95% CONFIDENCE (ASSUMING NORMAL DISTRIBUTION)
FileMat.Comment = ['Spike Triggered Average: ' str_remove_parenth(DataMats{1}.Comment) ' (' better_label ')'];
Expand Down
7 changes: 6 additions & 1 deletion toolbox/process/functions/process_spikesorting_kilosort.m
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,12 @@ function ImportKilosortEvents(sFile, ChannelMat, parentPath, rez)
index = index + 1;
end
end
events = [events events_spikes];

if ~isempty(existingEvents)
events = [events events_spikes];
else
events = events_spikes;
end

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

Expand Down

0 comments on commit d55a3b8

Please sign in to comment.