forked from sccn/roiconnect
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NGNetworkROIs_to_BA.m
40 lines (35 loc) · 1.42 KB
/
NGNetworkROIs_to_BA.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
clear
allAreas = readtable('NGNetworkROIs_area_definition_v2.txt', 'delimiter', char(9));
networks = readtable('NGNetworkROIs_v4.txt', 'delimiter', char(9));
networksNew = networks;
networksNew(2:end,:) = [];
networkNames = fieldnames(networks);
allAreasNames = fieldnames(allAreas);
allAreasNames = allAreasNames(1:end-3);
for iNet = 1:length(networkNames)-3
count = 1;
areas = networks.(networkNames{iNet});
addAreaList = {};
% get the list of areas
for iArea = 1:length(areas)
areaNameTmp = areas{iArea};
if ~isempty(areaNameTmp)
if areaNameTmp(end) ~= 'L' && areaNameTmp(end) ~= 'R'
areaNameTmp1 = [ areaNameTmp '_R' ];
areaNameTmp2 = [ areaNameTmp '_L' ];
colPos1 = strmatch(areaNameTmp1, allAreasNames, 'exact');
colPos2 = strmatch(areaNameTmp2, allAreasNames, 'exact');
addAreaList = { addAreaList{:} allAreas{:,colPos1}{:} allAreas{:,colPos2}{:} };
else
colPos = strmatch(areaNameTmp, allAreasNames, 'exact');
addAreaList = { addAreaList{:} allAreas{:,colPos}{:} };
end
end
end
% write the list of areas
addAreaList(cellfun(@isempty, addAreaList)) = [];
for iArea = 1:length(addAreaList)
networksNew(iArea,iNet) = { addAreaList{iArea} };
end
end
writetable(networksNew, 'BANetworkROIs_v4.txt', 'delimiter', char(9));