-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectgroups.m
35 lines (26 loc) · 1.17 KB
/
selectgroups.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
%Select age groups
subinfo = open('/home/sellug/wrkgrp/Selma/subinfo.mat');
CBUID = cellfun(@(x) str2double(x(4:end)), subinfo.CBUID);
% Remove the first 2 characters from var2
CCID = cellfun(@(x) str2double(x(3:end)), subinfo.CCID);
% Combine all variables into a matrix
subinfo = [CBUID', CCID, subinfo.age];
[~,idx] = sort(subinfo(:,3)); %sort on age
sortinfo = subinfo(idx,:);
n = [(zeros(1,1)+16),(zeros(1,33)+17)]; %number of subjects per group, in this case 1 group of 16 and 33 groups of 17
grs = (1:34); %number of groups
gr = repelem(grs, n)';
info = [sortinfo(:,1:3),gr];
info_CBU_age_group = sortrows(info, 1); %sort back on CBUid
[mean,std,min,max] = grpstats(info(:,3),info(:,4),{"mean","std","min","max"});
%get which CBUIDs are in each group
for i = 1:length(grs)
IDs=info(info(:,4)==i); %CHECK WHICH COLUMN
groupIDs{i} = IDs;
end
save('/home/sellug/wrkgrp/Selma/ids_34x577.mat', 'groupIDs')
save('/home/sellug/wrkgrp/Selma/CamCAN_movie/subinfo_CBU_age_group.mat', 'info_CBU_age_group')
% now save groupIDs for 1 group of all participants
ID_all = info_CBU_age_group(:,1);
groupIDs = {ID_all};
save('/home/sellug/wrkgrp/Selma/CamCAN_movie/ids_1x577.mat', 'groupIDs')