-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathclassiLoad.m
More file actions
113 lines (83 loc) · 2.71 KB
/
classiLoad.m
File metadata and controls
113 lines (83 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function [classiObj msg]=classiLoad(filename)
msg=[];
if nargin==0
[file,path] = uigetfile('*classification*.mat','Select a classification object (i.e. a XXXXX_classification.mat file)',pwd);
if isequal(file,0)
disp('User selected Cancel')
classiObj=[];
return;
else
if ~contains(file, 'classification')
warndlg('The selected file does not appear to be a classification file.', 'Warning');
classiObj = [];
return;
end
disp(['User selected ', fullfile(path, file)]);
filename=fullfile(path, file);
end
end
if isnumeric(filename) % loads classi from repository
list=listRepositoryClassi;
if numel(list)==0
classiObj=[];
return;
end
disp(list)
prompt='Please enter the number associated with the classification you wish to set from the repository ? (Default:1): ';
classitype= input(prompt);
if numel(classitype)==0
classitype=1;
end
filename=listRepositoryClassi(classitype);
end
[path,file,ext]=fileparts(filename);
%filename
abspath=what(path);
abspath=abspath.path;
filename=fullfile(abspath,[file ext]);
load(filename);
path=abspath;
if ~isa(classiObj,'classi')
msg='This file does not correspond to a classification object';
disp('This file does not correspond to a classification object');
classiObj=[];
return;
end
% check if processor is already open in the workspace
varlist=evalin('base','who');
for i=1:numel(varlist)
if strcmp(varlist{i},'ans')
continue;
end
tmp=evalin('base',varlist{i});
if isa(tmp,'classi')
% check path & filenemae
% path,file
% a=tmp.path, b=tmp.strid
if strcmp(path,tmp.path(1:end-1)) & strcmp(file, [tmp.strid '_classification']) % var exists already
msg=['Classification is already in the workspace under the var name:' varlist{i} '; I will take take this classifier as loaded...'];
disp(msg);
classiObj=tmp;
return
end
end
end
if isunix || ismac
classiObj.setPath([path '/'],file); % adjust path
else
classiObj.setPath([path '\'],file); % adjust path
end
% --- normalize run paths (old projects may have ABS stored) ---
try
if isprop(classiObj,'run')
% Never trust "active" state after reload
if isstruct(classiObj.run) && isfield(classiObj.run,'active')
classiObj.run.active = false;
end
classiObj.runNormalizePaths();
end
catch
end
msg=['Classification was loaded with this path:' path];
classiObj.log(['Classi was loaded with this path:' path],'Creation');
disp(['Successfully loaded classification ' fullfile(path,[file '.mat']) '!']);