function [r_result, obj] = ReadSpikesFromNextChannel(obj) % palauttaa seuraavan kanavan indexes & waves etc % onko viel? elektrodeita, jotka pit?isi lukea if obj.file_finished &&...% jos oli viimeinen tai eka kanava obj.last_file >= length(obj.files) % ja jos ei ole tiedostoja jotka pit?isi lukea Finalcsv=sortrows(obj.T, 2); thefilename=strsplit(obj.getCurrentFile(), '.'); thefilename=thefilename{1}; writetable(Finalcsv, strcat(thefilename,'_', 'spikes.csv')); disp('All files have been read from!'); r_result = []; else % ei ole eka tai vika kanava, tai on tiedostoja joista pit?isi lukea % Tarvitseeko avata uusi tiedosto if obj.file_finished&&... obj.last_file>0 Finalcsv=sortrows(obj.T, 2); thefilename=strsplit(obj.getCurrentFile(), '.'); thefilename=thefilename{1}; writetable(Finalcsv, strcat(thefilename,'_', 'spikes.csv')); obj.T=table; %zeroing the table obj = obj.OpenNewFile(); end if obj.file_finished obj = obj.OpenNewFile(); %( obj.files(obj.last_file+1) ); end %Reading the channel [r_result.error,m_data, r_result.duration, r_result.chlabel] = obj.ReadAxionChannel(); %disp(r_result.chlabel) obj = obj.SiirraOsoittimetSeuraavaan(); if ~r_result.error % check if the channel is behaving properly or if is noisy obj.spkdetconf.par.sr = obj.samplerate; [r_result.indexes, r_result.spikes, r_result.threshold, ~, r_result.noise, ~] = DetectSpikes_Amp(m_data, obj.spkdetconf); Time=r_result.indexes; Channel=string(repmat(r_result.chlabel, numel(r_result.indexes),1)); %repeating the channel label as many times %as the number %of the detected spikes. (For the table creation) TT=table(Channel, Time); obj.T=[obj.T; TT]; end end end