Home > data-utility > delete_variables.m

delete_variables

PURPOSE ^

SYNOPSIS ^

function delete_variables(IDs, var_list)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function delete_variables(IDs, var_list)
0002 subs = cIDs(IDs);
0003 
0004 if ~iscell(var_list)
0005     var_list = {var_list};
0006 end
0007 
0008 fprintf('subjects:\n');
0009 disp(subs)
0010 fprintf('variables:\n')
0011 disp(var_list)
0012 x = input('You will delete the above variables, continue? (y/n) : ', 's');
0013 if strcmp(x, 'y')
0014     request_IU_username();
0015     user = getenv('IU_username');
0016     for s = 1 : numel(subs)
0017         dirpart = get_subject_dir(subs(s));
0018         dir = [dirpart '/derived/'];
0019         for f = 1 : numel(var_list)
0020             if exist([dir var_list{f} '.mat'], 'file')
0021                 fprintf('found file for subject %d\n', subs(s))
0022                 if is_core_variable(var_list{f})
0023                     if ~is_core_member(user)
0024                         warning('Not authorized to remove variable, please contact Chen');
0025                         continue;
0026                     end
0027                 end
0028                 backup_variables(subs(s), var_list{f});
0029                 delete([dir var_list{f} '.mat']);
0030             else
0031                 fprintf('%s not found for subject %d\n', var_list{f}, subs(s));
0032             end
0033         end
0034     end
0035 end

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005