Skip to content

Commit

Permalink
Added skip if all channels in a run excluded to prevent error in kilo…
Browse files Browse the repository at this point in the history
…sort
  • Loading branch information
AntonioFR8 committed Mar 3, 2023
1 parent d4e068f commit ee3da40
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions preProcessing/preprocessSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,18 @@ function preprocessSession(varargin)
kilosortGroup = ceil(((1:length(shanks))/nKilosortRuns));
for i=1:nKilosortRuns
channels = cat(2,shanks{kilosortGroup==i});
excludeChannels = [];
excludeChannels = find(~ismember((1:session.extracellular.nChannels),channels));
excludeChannels = cat(2,excludeChannels,session.channelTags.Bad.channels);
excludeChannels = unique(excludeChannels);
kilosortFolder = KiloSortWrapper('SSD_path',SSD_path,'rejectchannels',excludeChannels);
if cleanRez
load(fullfile(kilosortFolder,'rez.mat'),'rez');
CleanRez(rez,'savepath',kilosortFolder);
if (length(excludeChannels)==session.extracellular.nChannels)
warning(['Run number ' num2str(i) ' excluded, moving on']);
else
kilosortFolder = KiloSortWrapper('SSD_path',SSD_path,'rejectchannels',excludeChannels);
if cleanRez
load(fullfile(kilosortFolder,'rez.mat'),'rez');
CleanRez(rez,'savepath',kilosortFolder);
end
end
end
else
Expand Down

0 comments on commit ee3da40

Please sign in to comment.