Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with whitening when electrode locations are duplicated #567

Closed
magland opened this issue Oct 5, 2023 · 1 comment · Fixed by #595
Closed

issue with whitening when electrode locations are duplicated #567

magland opened this issue Oct 5, 2023 · 1 comment · Fixed by #595

Comments

@magland
Copy link

magland commented Oct 5, 2023

I realize it should never happen that two electrodes have identical location. However, unless I am making an error in reading the data file, I have come across an example of this in an IBL dataset on the DANDI archive. I still need to double check and confirm that this is the case.

But in any event, here's what happens when you have a duplicated location - and I think this is something that should be fixed.

Here's the relevant code

function Wrot = whiteningLocal(CC, yc, xc, nRange)
% function to perform local whitening of channels
% CC is a matrix of Nchan by Nchan correlations
% yc and xc are vector of Y and X positions of each channel
% nRange is the number of nearest channels to consider
Wrot = zeros(size(CC,1), size(CC,1));
for j = 1:size(CC,1)
ds = (xc - xc(j)).^2 + (yc - yc(j)).^2;
[~, ilocal] = sort(ds, 'ascend');
ilocal = ilocal(1:nRange); % take the closest channels to the primary channel. First channel in this list will always be the primary channel.
wrot0 = whiteningFromCovariance(CC(ilocal, ilocal));
Wrot(ilocal, j) = wrot0(:,1); % the first column of wrot0 is the whitening filter for the primary channel
end

Note the comment "First channel in this list will always be the primary channel." This is not the case when you have duplicates. And so what ends up happening is that two rows (or maybe columns) of the whitening matrix end up being identical. This in turn causes two channels to be identical signal in the filtered data. And this causes a problem with detection where all spikes are considered non-isolated. Finally this in turn causes the crash of #566

@magland
Copy link
Author

magland commented Oct 5, 2023

As a follow-up. It seems the IBL dataset is actually okay... you just need to read the rel_x, rel_y fields from the NWB file and not the x, y, z. Still investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant