AugustineY07 / Neuron_Tracking

9 stars 1 forks source link

linprog error #6

Open nadine-saluti opened 2 months ago

nadine-saluti commented 2 months ago

Hi, I'm trying to use your code on my data. I have chronic electrophysiological recordings from a 64-channel linear probe, which I sort using Kilosort 2.0 and curate with phy. I then create the mean waveforms file with spike-interface.

I was able to use your code on my data, but the spike shapes looked very weird (and not like in Phy). Here's an example: image_2024_08_05T14_30_09_478Z

So then I re-extracted the mean waveforms, but now I'm running into a different error:

Error using linprog (line 382) LINPROG stopped because some coefficients in the objective or constraint matrices are NaN.

Error in emd_nt (line 80) [x, fval] = linprog(f, A, b, Aeq, beq, lb);

Error in EMD_unit_match (line 66) [x, fval, C] = emd_nt(f1, f2, w1, w2, mw1, mw2, chan_pos, dim_mask, l2_weight, xStep, zStep, @weighted_gdf_nt);

Error in NT_main (line 29) output = EMD_unit_match(input,output,'pre');

Error in Copy_of_Example_run (line 122) NT_main(input, mwf1, mwf2);

Do you know what might cause this?

nadine-saluti commented 1 month ago

I fixed both issues. The weird waveforms issue was easy to fix. It happened because the waveform matrix from spike-interface was nClusters x nSamples x nChannels, but the code assumes it as nClusters x nChannels x nSamples. So, I just used the function permute.

For the second issue, I found that what was happening is that if there are no valid comparisons between two units (when trying to calculate the Euclidean distance) in the function calcCenteredCorrL2, the variable centL2 = cl2/nSite will be NaN because nSite stays = 0. I just added a line: if nSite = 0, then centL2 = 1 (and centCorr = 1).

AugustineY07 commented 1 month ago

Hi,

Sorry for the late reply and I’m glad it worked out.

You are right that I used nClusters nChannels nSamples usually, and I should have mentioned that in the comment or main function.

Regards, Augustine

On Aug 15, 2024, at 11:40 AM, nadine-saluti @.***> wrote:



I fixed both issues. The weird waveforms issue was easy to fix. It happened because the waveform matrix from spike-interface was nClusters x nSamples x nChannels, but the code assumes it as nClusters x nChannels x nSamples. So, I just used the function permute.

For the second issue, I found that what was happening is that if there are no valid comparisons between two units (when trying to calculate the Euclidean distance) in the function calcCenteredCorrL2, the variable centL2 = cl2/nSite will be NaN because nSite stays = 0. I just added a line: if nSite = 0, then centL2 = 1 (and centCorr = 1).

— Reply to this email directly, view it on GitHubhttps://github.com/AugustineY07/Neuron_Tracking/issues/6#issuecomment-2290979090, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKODSONH6RVHCTKEL6KJT4DZRRZSRAVCNFSM6AAAAABMCKKNGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJQHE3TSMBZGA. You are receiving this because you are subscribed to this thread.Message ID: @.***>