-
Notifications
You must be signed in to change notification settings - Fork 14
/
ImportJRClusSortInfo.m
33 lines (26 loc) · 1.15 KB
/
ImportJRClusSortInfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function clusterInfo = ImportJRClusSortInfo(filename, startRow, endRow)
% import JRCLus cluster info (spike time, cluster #, max site#) from csv
% file
%% Initialize variables.
delimiter = ',';
if nargin<=2
startRow = 1;
endRow = inf;
end
%% Format for each line of text:
formatSpec = '%f%f%f%[^\n\r]';
%% Open the text file.
fileID = fopen(filename,'r');
%% Read columns of data according to the format.
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for block=2:length(startRow)
frewind(fileID);
dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow(block)-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
for col=1:length(dataArray)
dataArray{col} = [dataArray{col};dataArrayBlock{col}];
end
end
%% Close the text file.
fclose(fileID);
%% Create output variable
clusterInfo = table(dataArray{1:end-1}, 'VariableNames', {'timeStamps','clusterNum','bestSite'});