From 2b7e90b5a31ace1fe795e6d5614dab7c8a165c1c Mon Sep 17 00:00:00 2001 From: raltodo Date: Tue, 8 Jul 2025 17:27:31 -0400 Subject: [PATCH] KiloSortMetadata channelInds fix Solves the channel indexing issue caused by rez.ops.kcoords and rez.ops.chanMap having different lengths, making the indexes wrong. --- calc_CellMetrics/loadKiloSortMetadata.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/calc_CellMetrics/loadKiloSortMetadata.m b/calc_CellMetrics/loadKiloSortMetadata.m index 2e1a3880..d227c0e6 100644 --- a/calc_CellMetrics/loadKiloSortMetadata.m +++ b/calc_CellMetrics/loadKiloSortMetadata.m @@ -22,8 +22,9 @@ session.extracellular.nChannels = rez.ops.NchanTOT; kcoords_ids = unique(rez.ops.kcoords); session.extracellular.nElectrodeGroups = numel(kcoords_ids); + goodChanIDs = find(rez.connected); for i = 1:numel(kcoords_ids) - session.extracellular.electrodeGroups.channels{i} = rez.ops.chanMap(find(rez.ops.kcoords == kcoords_ids(i))); + session.extracellular.electrodeGroups.channels{i} = rez.ops.chanMap(goodChanIDs(find(rez.ops.kcoords == kcoords_ids(i)))); if size(session.extracellular.electrodeGroups.channels{i},1)>1 session.extracellular.electrodeGroups.channels{i} = session.extracellular.electrodeGroups.channels{i}'; end