Home > data-access > get_long_subjects.m

get_long_subjects

PURPOSE ^

[charlene, Aug 2014]

SYNOPSIS ^

function out = get_long_subjects(data_type, experiment)

DESCRIPTION ^

 [charlene, Aug 2014] 
 GET_LONG_SUBJECTS returns a list of multiLONG subjects that have data in that particular modality.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % [charlene, Aug 2014]
0002 % GET_LONG_SUBJECTS returns a list of multiLONG subjects that have data in that particular modality.
0003 
0004 % USAGE:
0005 %   get_long_subjects(DATA_TYPE, EXP_ID)
0006 
0007 % INPUT:
0008 %   data_type (case insensitive):
0009 %       'Multi', 'MultiSleep', 'MCDI', 'Motor', 'Word', 'WordSleep', 'Book', 'SES', 'CBQ'.
0010 %   experiment (optional):
0011 %       70 (9 months), 71 (12 months), 72 (15 months), 73 (18 months), 74 (21 months), 75 (24 months)...
0012 %       Default return, if experiment input is not entered, is for all experiments.
0013 
0014 % Examples:
0015 %   get_long_subjects('multi') returns all multilong subjects that have 'multi' data
0016 %   get_long_subjects('multi', 70) returns all multilong subjects in experiment 70 that have 'multi' data.
0017 %   get_long_subjects('multi', [70 71]) returns all multilong subjects in experiment 70 and 71 that have 'multi' data.
0018 %   get_long_subjects({'multi', 'word', 'mcdi'}) returns all multilong
0019 %   subjects that have data in all three modalities.
0020 
0021 function out = get_long_subjects(data_type, experiment) 
0022 
0023 % change directory, look for relevant csv file, and read in the data.
0024 csv = fullfile(get_multidir_root, '\multilong_docs\multilong_master_subject_table.csv');
0025 SubTableData = dlmread(csv, ',', 1, 0);
0026 
0027 % match the file's column names to the input. find all the rows where there
0028 % is available data for that subject for that particular data type,
0029 % then lget the global and subject ids that correspond with each of them.
0030 headers = get_csv_headers(csv);
0031 findcolumns = ismember(lower(headers), lower(data_type));
0032 columnNums = find(findcolumns(1,:) == 1); 
0033 want = SubTableData(:,columnNums);
0034 has_modality = all(want,2);
0035 rows = find(has_modality == 1);
0036 sublist = SubTableData(rows, [2,3]);
0037 
0038 % default to subjects in all multiLONG experiments if no exp input is given
0039 if ~exist('experiment', 'var') || isempty(experiment)
0040     experiment = [70 71 72 73 74 75]; % add additional experiments when applicable
0041 end 
0042 
0043 % otherwise, filter results based on experiment number entered.
0044 log = ismember(sublist(:,1), experiment);
0045 sublist = sublist(log, :);
0046 
0047 % sublist is now in two columns - experiment id & global id. append them together.
0048 for i = 1:length(sublist)
0049     expid = sublist(i,1);
0050     longid = sublist(i,2);
0051     id = sprintf('%d%02d', expid, longid);
0052     id = str2num(id);
0053     out(i,1) = id;
0054 end
0055

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005