Home > vbmeg > demo > test_scripts > sbi > sbi_sensor_check.m

sbi_sensor_check

PURPOSE ^

sensor_check(sqddat,sysids,resultfile)

SYNOPSIS ^

function sbi_sensor_check(sqddat,sysids,outfile)

DESCRIPTION ^

sensor_check(sqddat,sysids,resultfile)
sqddat : SBI directory
sysids : cell matrix data ID   e.x. {'100012a' '100012b'}
outfile :  indexes of sensors actived in only some sessions
           if not defined, not output result file.

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sbi_sensor_check(sqddat,sysids,outfile)
0002 %sensor_check(sqddat,sysids,resultfile)
0003 %sqddat : SBI directory
0004 %sysids : cell matrix data ID   e.x. {'100012a' '100012b'}
0005 %outfile :  indexes of sensors actived in only some sessions
0006 %           if not defined, not output result file.
0007 %
0008 % Copyright (C) 2011, ATR All Rights Reserved.
0009 % License : New BSD License(see VBMEG_LICENSE.txt)
0010 
0011 Nid = length(sysids);
0012 
0013 for i = 1:Nid
0014   [okix{i},chname{i},chname0] = readSBI_sensor(sqddat,sysids{i});
0015 end
0016 
0017 NsensorAll = 201;
0018 Check = zeros(Nid,NsensorAll);
0019 for i = 1:Nid
0020   Check(i,okix{i}) = 1;
0021 end
0022 
0023 %find partially off sensor
0024 Check_R = sum(Check,1);
0025 bad_sensor_ix = find(Check_R>0 & Check_R<Nid); %global index
0026 
0027 %if no problem, end.
0028 if ~length(bad_sensor_ix)
0029   disp('Sensors condition is OK over the all sessions.')
0030   return;
0031 end
0032 
0033 N_bad_sensor  = length(bad_sensor_ix);
0034 Bad_sensor = cell(Nid,1);
0035 for i = 1:N_bad_sensor
0036   %find active sensors in only some sessions
0037   session_ix{i} = find(Check(:,bad_sensor_ix(i))==1);
0038   %bad session and sensor
0039   for j = 1:length(session_ix{i})
0040     Bad_sensor{session_ix{i}(j)} =...
0041     [Bad_sensor{session_ix{i}(j)} find(okix{session_ix{i}(j)}==bad_sensor_ix(i) )];
0042   end
0043 end
0044 
0045 fprintf('Extra Sensor\n');
0046 for i = 1:Nid
0047   if ~isempty(Bad_sensor{i})
0048     fprintf(['Session ',num2str(i),' : "',sysids{i},'"\n']);
0049     for j = 1:length(Bad_sensor{i})
0050       fprintf(num2str(Bad_sensor{i}(j)));
0051       fprintf('\n');
0052     end
0053   end
0054 end
0055 
0056 %output file
0057 if nargin==3
0058   fid = fopen(outfile,'w');
0059   for i = 1:Nid
0060     if ~isempty(Bad_sensor{i})
0061       fprintf(fid,['Session ',num2str(i),' : "',sysids{i},'"\n']);
0062       for j = 1:length(Bad_sensor{i})
0063     fprintf(fid,num2str(Bad_sensor{i}(j)));
0064     fprintf(fid,'\n');
0065       end
0066     end
0067   end
0068   fclose(fid);
0069 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005