Skip to content

Commit 37c5e46

Browse files
committed
bug fix: multi-kilosort 'kilosortGroup'
1 parent 61e7b5b commit 37c5e46

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

preProcessing/preprocessSession.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,17 @@ function runRemoveNoise(basepath, basename, session)
398398
function runKiloSort(nKilosortRuns, kiloShankSplit, session, SSD_path, clean_rez_params, cleanRez)
399399
if nKilosortRuns > 1 % if more than one Kilosort cycle desired, break the shanks down into the desired number of kilosort runs
400400
shanks = session.extracellular.spikeGroups.channels;
401+
401402
if isempty(kiloShankSplit)
402-
kilosortGroup = ceil(((1:length(shanks)) / nKilosortRuns));
403+
nShanks = numel(shanks);
404+
kilosortGroup = zeros(1, nShanks);
405+
406+
% Divide shanks into nearly equal groups
407+
edges = round(linspace(0, nShanks, nKilosortRuns+1));
408+
409+
for i = 1:nKilosortRuns
410+
kilosortGroup(edges(i)+1:edges(i+1)) = i;
411+
end
403412
else
404413
kilosortGroup = kiloShankSplit;
405414
nKilosortRuns = max(kiloShankSplit);
@@ -417,6 +426,8 @@ function runKiloSort(nKilosortRuns, kiloShankSplit, session, SSD_path, clean_rez
417426
load(fullfile(kilosortFolder, 'rez.mat'), 'rez');
418427
CleanRez(rez, 'savepath', kilosortFolder, clean_rez_params{:});
419428
end
429+
% remove chanMap so it doesn't mess up the next run
430+
delete(fullfile(basepath, 'chanMap.mat'))
420431
end
421432
end
422433
else
@@ -430,4 +441,4 @@ function runKiloSort(nKilosortRuns, kiloShankSplit, session, SSD_path, clean_rez
430441
end
431442

432443
end
433-
end
444+
end

0 commit comments

Comments
 (0)