Kilosort icon indicating copy to clipboard operation
Kilosort copied to clipboard

whitening_mat.npy problem

Open blinklab opened this issue 3 years ago • 2 comments

In kilosort 2.0, the whitening_mat.npy file contains the real whitening matrix: whiteningMatrix = rez.Wrot/rez.ops.scaleproc; The inverse of this matrix is used to compute the template amplitude using this code whiteningMatrixInv = whiteningMatrix^-1;

% here we compute the amplitude of every template...

% unwhiten all the templates
tempsUnW = zeros(size(templates));
for t = 1:size(templates,1)
    tempsUnW(t,:,:) = squeeze(templates(t,:,:))*whiteningMatrixInv;
end

% The amplitude on each channel is the positive peak minus the negative
tempChanAmps = squeeze(max(tempsUnW,[],2))-squeeze(min(tempsUnW,[],2));

By contrast, in kilosort 2.5 and kilosort 3.0, the whitening_mat.npy only contains a diagonal matrix that not correspond with the real whitening matrix used in the code: whiteningMatrix = eye(size(rez.Wrot)) / rez.ops.scaleproc;

Which one is the reason to introduce this change in the code?.

blinklab avatar Jun 07 '22 19:06 blinklab

I don't think this is right, could you please send the line numbers?

marius10p avatar Jun 27 '22 12:06 marius10p

@marius10p

I have a same issue.

After kilosort 2.5 and 3.0 (not 2.0), the whitening_mat.npy contains diagonal matrix. For that reason, I cannot get template amplitude.

whitening matrix

Are there any changes in calculating a template amplitude at kilosort 2.5 and 3.0?

SEONGGAP avatar Jul 06 '22 03:07 SEONGGAP

I don't think this is right, could you please send the line numbers?

I think it was last updated here in rezToPhy and inherited by rezToPhy2, so "whitening_mat.npy" and "whitening_mat_inv.npy" do not contain the real matrices. Is there much significance to this change @marius10p ? https://github.com/MouseLand/Kilosort/blob/ad462bd78010f1f872fffefa2cfe31e649361da2/utils/rezToPhy.m#L69-L71

zhengyangwang avatar Mar 28 '23 18:03 zhengyangwang

might this discussion be related to this issue?

JoeZiminski avatar Sep 18 '23 17:09 JoeZiminski