


Function to load the PRT.mat and check its integrity regarding the kernels and feature sets that it is supposed to contain. Updates the set feature name if needed. input : name of the PRT.mat, path included output : PRT structure updated _______________________________________________________________________ Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory


0001 function PRT = prt_load(fname) 0002 0003 % Function to load the PRT.mat and check its integrity regarding the 0004 % kernels and feature sets that it is supposed to contain. Updates the set 0005 % feature name if needed. 0006 % 0007 % input : name of the PRT.mat, path included 0008 % 0009 % output : PRT structure updated 0010 %_______________________________________________________________________ 0011 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory 0012 0013 % Written by J. Schrouff 0014 % $Id: prt_load.m 529 2012-05-17 08:09:25Z schrouff $ 0015 0016 try 0017 load(fname) 0018 catch 0019 beep 0020 disp('Could not load file') 0021 PRT=[]; 0022 return 0023 end 0024 0025 %get path 0026 prtdir=fileparts(fname); 0027 0028 %for each feature set, check that the corresponding .dat is present in the 0029 %same directory and update the name of the file array if needed 0030 if isfield(PRT,'fas') && ~isempty(PRT.fas) 0031 ind=[]; 0032 for i=1:length(PRT.fas) 0033 %get the name of the file array 0034 if ~isempty(PRT.fas(i).dat) 0035 fa_name=PRT.fas(i).dat.fname; 0036 [fadir,fan,faext]=fileparts(fa_name); 0037 if ~strcmpi(fadir,prtdir) %directories of PRT and feature set are different 0038 if ~exist([prtdir,filesep,fan,faext],'file') %no feature set found 0039 beep 0040 disp(['No feature set named ',fan,' found in the PRT directory']) 0041 disp('Information linked to that feature set is deleted') 0042 disp('Computing the weights or using non-kernel methods using that feature set won''t be permitted') 0043 else %file exists but under the new directory 0044 PRT.fas(i).dat.fname=[prtdir,filesep,fan,faext]; 0045 ind=[ind,i]; 0046 end 0047 else 0048 ind=[ind,i]; 0049 end 0050 end 0051 end 0052 if isempty(ind) 0053 PRT=rmfield(PRT,'fas'); 0054 PRT=rmfield(PRT,'fs'); 0055 elseif length(ind)~=i 0056 %When a model comports the modality of the deleted fas, get rid of 0057 %the corresponding fs and model 0058 PRT.fas=PRT.fas(ind); 0059 end 0060 end 0061 0062 save([prtdir,filesep,'PRT.mat'],'PRT') 0063 0064 0065 0066 0067 0068 0069 0070