Home > data-access > cIDs.m

cIDs

PURPOSE ^

Will list subjects in a particular experiment

SYNOPSIS ^

function [subs, parttable, paths] = cIDs(IDs, flagDerived)

DESCRIPTION ^

 Will list subjects in a particular experiment
 IDs can be either expIDs or subIDs
 If IDs = {43, [4301, 4302]}, it will return all subjects in 43 except 4301
 and 4302
 parttable will return the rows in subject_table.txt on multiwork
 paths will return the full path to the derived folder of each subject
 if flagDerived is 1, adds 'derived' to subject root directory in paths output

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [subs, parttable, paths] = cIDs(IDs, flagDerived)
0002 % Will list subjects in a particular experiment
0003 % IDs can be either expIDs or subIDs
0004 % If IDs = {43, [4301, 4302]}, it will return all subjects in 43 except 4301
0005 % and 4302
0006 % parttable will return the rows in subject_table.txt on multiwork
0007 % paths will return the full path to the derived folder of each subject
0008 % if flagDerived is 1, adds 'derived' to subject root directory in paths output
0009 
0010 if iscell(IDs)
0011     without = IDs{2};
0012     IDs = IDs{1};
0013 else
0014     without = [];
0015 end
0016 
0017 if ~exist('IDs', 'var') || isempty(IDs)
0018     error('Must specify subject list or experiment list');
0019 end
0020 
0021 if ischar(IDs) && strcmp(IDs, 'all')
0022     IDs = [12 14 17 29 32 34 35 39 41 43 44 49 70 71 72 73 74 75];
0023 end
0024 
0025 if ~exist('flagDerived', 'var') || isempty(flagDerived)
0026     flagDerived = 1;
0027 end
0028     
0029 
0030 table = read_subject_table();
0031 log = table(:,2) > 9;
0032 table = table(log,:);
0033 
0034 subwithout = ismember(table(:,1), without);
0035 expwithout = ismember(table(:,2), without);
0036 
0037 % to retain correct ordering
0038 parttable = cell(numel(IDs), 1);
0039 for i = 1:numel(IDs)
0040     sublog = ismember(table(:,1), IDs(i));
0041     explog = ismember(table(:,2), IDs(i));
0042     log = (sublog | explog) & ~(subwithout | expwithout);
0043     parttable{i,1} = table(log,:);
0044 end
0045 parttable = vertcat(parttable{:});
0046 % sublog = ismember(table(:,1), IDs);
0047 % explog = ismember(table(:,2), IDs);
0048 % subwithout = ismember(table(:,1), without);
0049 % expwithout = ismember(table(:,2), without);
0050 % log = (sublog | explog) & ~(subwithout | expwithout);
0051 %
0052 % parttable = table(log, :);
0053 
0054 subs = parttable(:,1);
0055 
0056 % if ~isequal(subs, unique(subs))
0057 %     error('subjects and experiments in subject_table.txt must be listed in ascending order, please notify sbf@umail.iu.edu');
0058 % end
0059 
0060 paths = cell(size(parttable,1), 1);
0061 fs = filesep();
0062 root = get_multidir_root;
0063 if flagDerived
0064     derived = ['derived' fs];
0065 else
0066     derived = '';
0067 end
0068 for t = 1:size(parttable,1)
0069     tmp = parttable(t,:);
0070     path = sprintf('%sexperiment_%d%sincluded%s__%d_%d%s%s%s', root, tmp(2), fs, fs, tmp(3), tmp(4), fs, derived);
0071     paths{t,1} = path;
0072 end
0073 
0074 end

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005