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

Can't read the .bin file with error: Index exceeds the number of array elements. Index must not exceed 4. #501

Closed
AmaranthCao opened this issue May 16, 2022 · 5 comments · Fixed by #595

Comments

@AmaranthCao
Copy link

Hello,
I am using KS to analyze my data from tetrode recording, and meet the error with: Index exceeds the number of array elements. Index must not exceed 4.

I used following code to create my .bin file(samples is a 4xN matrix, which is my[nchannel x ntimepoints] matrix):
dat = int16(samples.*1e6);
fidout = fopen("samplestry0517.bin","w")
fwrite(fidout,dat(:),'*int16');
fclose(fidout);

and my probe layout is bellow:
X-coordinates of each sites:
ones(4,1)
Y-coordinates of each sites:
1:4
ChannelMap:
1:4
and the other 2 rows are blank;

and when I input my file and create new probe layout, it return with following errors:

Index exceeds the number of array elements. Index must not exceed 4.
Error ksGUI/updateDataView (line 891)
Dat = datAll (obj) P.c hanMap. ChanMap (chList), :);
Error ksGUI/computeWhitening (line 782)
Obj. UpdateDataView;
Error ksGUI/updateProbeView (line 1222)
Obj.com puteWhitening ()
Error ksGUI> @(,)obj.updateProbeView('reset') (line 273)
'Callback' @ (~, ~) obj. UpdateProbeView (' reset '));

Error calculating UIControl Callback.

Could anyone please support any kind of help? Thanks a lot!

@GrimmSnark
Copy link

So if you are using the GUI to run kilosort I think it by default tries to display 8 channels in the probe view and the data window. Your data not having enough channels may cause it to crash. I had something similar happen to me, and had to use the 'old' script method to run kilosort on my data.

@AmaranthCao
Copy link
Author

Thanks a lot for your help! Could you please supply your code to transfer your tetrode ep file to .bin file? I guess I have some wrongs with .bin file transformation. When I doubled my date to 8 channels and rearrange a 8 channel probe map, I met a new error: Index exceeds the number of array elements. Index must not exceed 8...

Thanks again for your help!

@GrimmSnark
Copy link

Here is my code snippet for reading and writing the data into the .bin file. My data is saved per channel in individual files. Hope this helps!

% read in files and convert to mV

for chan = 1:length(fileList)

    % open and read file
    f=fopen(fileList(chan),'r');
    d=fread(f,'int16');
    d = d';
    fclose(f);
    
    trace_uV = d * 1/6400/3000*1e6; % uV conversion
    
    % place into matrix
    grandTraces(chan,:) = trace_uV;

end

% save the files
fid = fopen([kilosortFolder,'/','raw.bin'], 'w');
fwrite(fid, grandTraces, 'int16');
fclose(fid);

@AmaranthCao
Copy link
Author

Thanks a lot! Really helpful.

@marius10p
Copy link
Contributor

Please reopen if necessary.

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.

3 participants