csn-le / wave_clus

A fast and unsupervised algorithm for spike detection and sorting using wavelets and super-paramagnetic clustering
127 stars 66 forks source link

Error using ones NaN and Inf not Allowed (Small Inconvenience) #178

Closed slassers closed 4 years ago

slassers commented 4 years ago

Hi! I am fairly new to this program and the world of spike sorting so my following question may be at a novice level. So any help you can provide would be greatly appreciated! I am working with microelectrode data from an MCS machine so I have to convert the data to a .mat format in order to use it with this program. For some reason when I try to use the GUI to run some channels it gives me the following error message in my MATLAB terminal:

WaveClusGuiErrorMessage

When I run the function 'Get_spikes' it gives me a message that 0 of 1 'spikes' files are done. However, it seems to generate a myfile_spikes.mat file. This file then can be opened in the GUI.

I realize that this is only a small inconvenience to myself, but I just want to make sure that this doesn't have anything to with the integrity/quality of my data that could affect the results.

Thank you so much for reading and have a good one!

ferchaure commented 4 years ago

Hi, It's a quite odd case, both ways load data in almost the same way. How do you run Get_spikes? using the 'par' argument? Are you using polytrodes or single channels?

0 of 1 'spikes' files are done. That is just the operative system been slow when asked if the spikes files were created.

slassers commented 4 years ago

Hi! Thanks for getting back to me. When I run Get_spike I just put the name of the file I am using in as a string without a 'par' input. I have edited the parameters through the "Set parameters" button but have only changed the sampling rate from 30,000 to 40,000 Hz. For the error shown above I was only using single channel.

slassers commented 4 years ago

Additionally, running a batch of files from a txt file or running Get_spikes_pol doesn't yield any errors.

ferchaure commented 4 years ago

We find this issue before here. We suppose that's related to Windows 10 (and/or maybe some versions of Matlab).

I guess (I didn't have the opportunity to check myself) that is related to the way Matlab look for the size of the variables. If you have time and want to check, put a breakpoint on line 47 of _mat_wcreader.m and tell me the value of _datainfo.size maybe we can find what is exactly happening

In any case, you can trust your results. If you want to be extra careful check that the value on par.sr is the same value you set on set_parameters.

slassers commented 4 years ago

Awesome! Thank you! That's good to know! Looking at the size, I have a [1,200000] vector. This is the same size as the data set I loaded in.

ferchaure commented 4 years ago

Ok, then I don't know why it's failing. could you check the value of obj.max_segments as well? and if it's Nan or Inf check which element of the line 47-48 is zero or nan?

slassers commented 4 years ago

max_segments is not Nan or Inf, it is actually just empty. However, obj.min_index is Nan. On line 38 obj.min_index = floor(par.tmin * obj.sr); My par.tmin is Nan which I assume this is where this error is coming from? This is weird because in the set_parameters file, par.tmin is set to 0. So I am uncertain where the NaN is coming from. I have attached some screenshots.

Also thank you for your quick responses and apologies for my delayed ones! I've been going back and forth between things.

image image image

ferchaure commented 4 years ago

thank you so much! It looks like wave_clus is finding an older times or spikes file in that folder or in your Matlab path and it loads the parameters from it. Then it tries to complete the information using those old parameters with the raw data and got that error. Could you check that you don't have an old wave_clus file (times_filename.mat or filename_spikes.mat) in your path?

I will add a quick workaround for these cases on the next commit

slassers commented 4 years ago

Thank you!!! That was exactly what was happening. I had wave_clus 2.0 originally installed from the University of Leicester's website. Everything is working as it should be right now!