-
Notifications
You must be signed in to change notification settings - Fork 2
/
xcorrpairlist.m
60 lines (48 loc) · 1.69 KB
/
xcorrpairlist.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [ minseg ] = xcorrpairlist( stalist, staseg, component )
%XCORRPAIRLIST Summary of this function goes here
% Detailed explanation goes here
pairlist_name = 'pair';
num_stalist = numel(stalist);
pairlist = cellfun(...
@strcat, ...
repmat({pairlist_name}, 1, num_stalist), ...
repmat({'_'}, 1, num_stalist), ...
num2cell(component), ...
'UniformOutput', false);
[pathstr, ~, ~] = cellfun(@fileparts, stalist, 'UniformOutput', false);
pairlist = cellfun(@fullfile, pathstr, pairlist, 'UniformOutput', false);
stalistID = cellfun(@fopen, stalist, repmat({'r'}, 1, num_stalist));
stasegID = fopen(staseg, 'r');
seginfo = fscanf(stasegID, '%d');
stalistinfo = ...
cellfun(...
@textscan, num2cell(stalistID), repmat({'%s'}, 1, num_stalist), ...
'UniformOutput', false);
arrayfun(@fclose, stalistID);
fclose(stasegID);
stalistinfo = vertcat(stalistinfo{:});
stalistinfo = horzcat(stalistinfo{:});
[total_file, ~] = size(stalistinfo);
minseg = min(seginfo(1: end - 1));
pair = cell(minseg * seginfo(end), num_stalist);
sel_bool = zeros(total_file, 1);
sel_bool(1: minseg) = 1;
for ii = 2: seginfo(end)
bd = sum(seginfo(1: ii - 1));
sel_bool(bd + 1: bd + minseg) = 1;
end
pair(:, :) = stalistinfo(sel_bool == 1, :);
num_pair = nchoosek(seginfo(end), 2);
pairlistID = cellfun(@fopen, pairlist, repmat({'w'}, 1, num_stalist));
for ii = 1: num_stalist
for jj = 1: minseg
pairname = nchoosek(pair(jj: minseg: end, ii), 2);
cellfun(...
@fprintf, ...
num2cell(ones(num_pair, 1) * pairlistID(ii)), ...
repmat({'%s %s\n'}, num_pair, 1), ...
pairname(:, 1), pairname(:, 2));
end
end
arrayfun(@fclose, pairlistID);
end