function oasis_get_xnat(ss, od, N, agargs) % get_oasis(ss, od) % get_oasis(ss, od, N) % get_oasis(ss, od, N, agargs) % Example: % ss = 'spreadsheet.csv' % od = '../output_directory/' % N = 30; % (gets all subjects if N left out or inf) % agargs = '-proc'; % optional ArcGet arguments, e.g. get processed only arcget = 'ArcGet -host www.oasis-brains.org -u guest -p guest'; % NB: seems it must be in current dir to find java libs if ~exist('od', 'var') || isempty(od) od = '../data/oasis/tmp'; % can include relative or full path end if ~exist('ss', 'var') || isempty(ss) ss = 'oasis_subset.csv'; end if ~exist('N', 'var') N = inf; end if ~exist('agargs', 'var') agargs = ''; end [H C] = oasis_read_csv(ss); sessions = []; for col = 1:length(H) if strcmpi(H{col}, 'MR Session') sessions = C{col}; break; end end if isempty(sessions) error('oasis_get_xnat:spreadsheet', ... 'failed to find session column in spreadsheet %s', ss) end N = min(N, numel(sessions)); for n = 1:N id2 = sessions{n}; id1 = regexprep(id2, 'MR2$', 'MR1'); if ~strcmpi(id1, id2) % must be reliability data, get both cmd = sprintf('%s %s -o %s -s %s -s %s', ... arcget, agargs, od, id1, id2); else % must be cross-sectional data, get just first cmd = sprintf('%s %s -o %s -s %s', arcget, agargs, od, id1); end display(cmd) [status stdout] = system(cmd); if status ~= 0 warning('oasis_get_xnat:arcget', stdout) end end