0001 function PRT = prt_load(fname,flag)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 try
0017 load(fname)
0018 catch
0019 beep
0020 disp('Could not load file')
0021 PRT = [];
0022 return
0023 end
0024
0025 if nargin<2
0026 flag = 0;
0027 end
0028
0029
0030 prtdir = fileparts(fname);
0031
0032
0033
0034 if isfield(PRT,'fas') && ~isempty(PRT.fas)
0035 ind = [];
0036 for i=1:length(PRT.fas)
0037
0038 if ~isempty(PRT.fas(i).dat)
0039 fa_name=PRT.fas(i).dat.fname;
0040 if ~ispc
0041 fname = strrep(fname,'\',filesep);
0042 end
0043 [fadir,fan,faext] = fileparts(fa_name);
0044 if ~strcmpi(fadir,prtdir)
0045 if ~exist(fullfile(prtdir,[fan,faext]),'file')
0046 beep
0047 disp(['No feature set named ',fan,' found in the PRT directory'])
0048 disp('Information linked to that feature set is deleted')
0049 disp('Computing the weights or using non-kernel methods using that feature set won''t be permitted')
0050 else
0051 PRT.fas(i).dat.fname = fullfile(prtdir,[fan,faext]);
0052 ind = [ind,i];
0053 end
0054 else
0055 ind = [ind,i];
0056 end
0057 elseif isempty(PRT.fas(i).dat) && ~isempty(PRT.fas(i).mod_name)
0058 ind = [ind,i];
0059 end
0060 end
0061 if isempty(ind)
0062 PRT = rmfield(PRT,'fas');
0063 PRT = rmfield(PRT,'fs');
0064 elseif length(ind)~=i
0065
0066
0067 PRT.fas = PRT.fas(ind);
0068 end
0069 end
0070
0071
0072 if flag==1
0073 [PRT,flag] = prt_struct(PRT,prtdir);
0074 if ~flag
0075 error('prt_load:EssentialFieldsMissing',['Essentials fields are missing. ',...
0076 'This PRT cannot be used. Data and Design should be started from scratch'])
0077 end
0078 end
0079
0080
0081 save([prtdir,filesep,'PRT.mat'],'PRT')