Christoph Budziszewski commited on 2009-01-21 16:34:25
Zeige 101 geänderte Dateien mit 31509 Einfügungen und 15 Löschungen.
git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@112 83ab2cfd-5345-466c-8aeb-2b2739fb922d
| ... | ... |
@@ -0,0 +1,100 @@ |
| 1 |
+function classify(varargin) |
|
| 2 |
+ |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+switch nargin |
|
| 6 |
+ case 1 |
|
| 7 |
+ paramModel = varargin{1};
|
|
| 8 |
+ % PROJECT_BASE_PATH = 'D:\Analyze\Stimolos'; |
|
| 9 |
+ PROJECT_BASE_PATH = 'D:\Analyze\Choice\24pilot'; |
|
| 10 |
+ PROJECT_RESULT_PATH = 'results\SPM.mat'; |
|
| 11 |
+ otherwise |
|
| 12 |
+ error('spmtoolbox:SVMCrossVal:arginError','Please Specify action and parameter model');
|
|
| 13 |
+end |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+ % common params |
|
| 17 |
+ calculateParams = struct; |
|
| 18 |
+ calculateParams.smoothed = getDouble(paramModel.txtSmoothed); |
|
| 19 |
+ |
|
| 20 |
+ calculateParams.frameShiftStart = getDouble(paramModel.txtFrameShiftStart); % -20; |
|
| 21 |
+ calculateParams.frameShiftEnd = getDouble(paramModel.txtFrameShiftEnd); %15; |
|
| 22 |
+ calculateParams.decodeDuration = getDouble(paramModel.txtFrameShiftDur); |
|
| 23 |
+ calculateParams.psthStart = getDouble(paramModel.txtPSTHStart); % -25; |
|
| 24 |
+ calculateParams.psthEnd = getDouble(paramModel.txtPSTHEnd); % 20; |
|
| 25 |
+ calculateParams.baselineStart = getDouble(paramModel.txtBaselineStart); % -22; |
|
| 26 |
+ calculateParams.baselineEnd = getDouble(paramModel.txtBaselineEnd); % -20; |
|
| 27 |
+ |
|
| 28 |
+ calculateParams.svmargs = get(paramModel.txtSVMopts,'String'); |
|
| 29 |
+ calculateParams.sessionList = 1:3; |
|
| 30 |
+ |
|
| 31 |
+ classStruct = parseClassDef(paramModel); |
|
| 32 |
+ |
|
| 33 |
+ |
|
| 34 |
+ calculateParams.labelMap = LabelMap(classStruct.labelCells , classStruct.conditionCells, 'auto'); % LabelMap({'<','>','<+<','>+>','<+>','>+<'},{-2,-1,1,2,3,4}); 0 is autolabel
|
|
| 35 |
+ calculateParams.classList = getClasses(calculateParams.labelMap); |
|
| 36 |
+ calculateParams.eventList = classStruct.eventMatrix; %[9,11,13; 10,12,14]; |
|
| 37 |
+% calculateParams.eventList = getPSTEventMatrix(calculateParams.labelMap); |
|
| 38 |
+ |
|
| 39 |
+ subjectSelection = getSubjectIDString(paramModel); |
|
| 40 |
+ decode = struct; |
|
| 41 |
+ decode.decodePerformance = []; |
|
| 42 |
+ decode.rawTimeCourse = []; |
|
| 43 |
+ |
|
| 44 |
+ for subjectCell = subjectSelection |
|
| 45 |
+ SubjectID = cell2mat(subjectCell); |
|
| 46 |
+ namehelper = strcat('s',SubjectID); %Vars can not start with numbers.
|
|
| 47 |
+ |
|
| 48 |
+ display('loading SPM.mat ...');
|
|
| 49 |
+ spm = load(fullfile(PROJECT_BASE_PATH,SubjectID,PROJECT_RESULT_PATH)); |
|
| 50 |
+ display('... done.');
|
|
| 51 |
+ |
|
| 52 |
+ %% calculate |
|
| 53 |
+ calculateParams.(namehelper).des = spm.SPM; |
|
| 54 |
+ calculateParams.(namehelper).voxelList = parseVoxelList(paramModel,SubjectID); |
|
| 55 |
+ assignin('base','calculateParams',calculateParams);
|
|
| 56 |
+ |
|
| 57 |
+ display(sprintf('calculating cross-validation performance time-shift for Subject %s. Please Wait. ...',SubjectID));
|
|
| 58 |
+ display('switching off all warnings');
|
|
| 59 |
+ warning_state = warning('off','all');
|
|
| 60 |
+ display('calculating ...');
|
|
| 61 |
+ decode.(namehelper) = calculateDecodePerformance(calculateParams,SubjectID); |
|
| 62 |
+ display('... done');
|
|
| 63 |
+ display('restoring warnings');
|
|
| 64 |
+ warning(warning_state); |
|
| 65 |
+ |
|
| 66 |
+ decode.decodePerformance = [decode.decodePerformance decode.(namehelper).decodePerformance]; |
|
| 67 |
+ decode.rawTimeCourse = [decode.rawTimeCourse decode.(namehelper).rawTimeCourse]; |
|
| 68 |
+ |
|
| 69 |
+ assignin('base','decode',decode);
|
|
| 70 |
+ end |
|
| 71 |
+ |
|
| 72 |
+ display('Finished calculations.');
|
|
| 73 |
+ display('Plotting...');
|
|
| 74 |
+ |
|
| 75 |
+ plotParams = struct; |
|
| 76 |
+ plotParams.psthStart = calculateParams.psthStart; |
|
| 77 |
+ plotParams.psthEnd = calculateParams.psthEnd; |
|
| 78 |
+ plotParams.nClasses = length(calculateParams.classList); |
|
| 79 |
+ |
|
| 80 |
+ plotParams.frameShiftStart = calculateParams.frameShiftStart; |
|
| 81 |
+ plotParams.frameShiftEnd = calculateParams.frameShiftEnd; |
|
| 82 |
+ plotParams.decodePerformance = decode.decodePerformance; |
|
| 83 |
+ plotParams.rawTimeCourse = decode.rawTimeCourse; |
|
| 84 |
+ |
|
| 85 |
+ if numel(subjectSelection) == 1 |
|
| 86 |
+ plotParams.SubjectID = SubjectID; |
|
| 87 |
+ else |
|
| 88 |
+ plotParams.SubjectID = 'Multiple'; |
|
| 89 |
+ end |
|
| 90 |
+ |
|
| 91 |
+ plotParams.smoothed = boolToYesNoString(calculateParams.smoothed); |
|
| 92 |
+ |
|
| 93 |
+ |
|
| 94 |
+ assignin('base','plotParams',plotParams);
|
|
| 95 |
+% plotDecodePerformance(params.psthStart,params.psthEnd,params.nClasses,decode.decodeTable,params.frameShiftStart,params.frameShiftEnd,decode.rawTimeCourse); |
|
| 96 |
+ plotDecodePerformance(plotParams); |
|
| 97 |
+ |
|
| 98 |
+ display('all done.');
|
|
| 99 |
+ |
|
| 100 |
+ end |
|
| 0 | 101 |
\ No newline at end of file |
| ... | ... |
@@ -0,0 +1,103 @@ |
| 1 |
+function plotDecodePerformance(varargin) |
|
| 2 |
+% plotDecodePerformance(timeline,decodePerformance,nClasses,rawData) |
|
| 3 |
+ |
|
| 4 |
+PSTH_AXIS_MIN = -1; |
|
| 5 |
+PSTH_AXIS_MAX = 1; |
|
| 6 |
+ |
|
| 7 |
+switch nargin |
|
| 8 |
+ |
|
| 9 |
+ case 1 |
|
| 10 |
+ inputStruct = cell2mat(varargin(1)); |
|
| 11 |
+ |
|
| 12 |
+ psthStart = inputStruct.psthStart; |
|
| 13 |
+ psthEnd = inputStruct.psthEnd; |
|
| 14 |
+ nClasses = inputStruct.nClasses; |
|
| 15 |
+ decodePerformance = inputStruct.decodePerformance; |
|
| 16 |
+ frameStart = inputStruct.frameShiftStart; |
|
| 17 |
+ frameEnd = inputStruct.frameShiftEnd; |
|
| 18 |
+ psth = inputStruct.rawTimeCourse; |
|
| 19 |
+ SubjectID = inputStruct.SubjectID; |
|
| 20 |
+ smoothed = inputStruct.smoothed; |
|
| 21 |
+ |
|
| 22 |
+ otherwise |
|
| 23 |
+ error('spmtoolbox:SVMCrossVal:plotDecodePerformance:WrongArgument','Wrong Arguments');
|
|
| 24 |
+end |
|
| 25 |
+ |
|
| 26 |
+ f = figure; |
|
| 27 |
+ subplot(2,1,1); |
|
| 28 |
+ hold on; |
|
| 29 |
+ for voxel = 1:size(psth,2) |
|
| 30 |
+ for label = 1:size(psth{voxel},2)
|
|
| 31 |
+ psthData = []; |
|
| 32 |
+ for timepoint = 1:size(psth{voxel}{label},2)
|
|
| 33 |
+ psthData = nanmean(psth{voxel}{label});
|
|
| 34 |
+ end |
|
| 35 |
+ plot(psthStart:psthEnd,psthData,[colorChooser(voxel), lineStyleChooser(label)]); |
|
| 36 |
+ end |
|
| 37 |
+ end |
|
| 38 |
+ axis([psthStart psthEnd PSTH_AXIS_MIN PSTH_AXIS_MAX]) |
|
| 39 |
+ hold off |
|
| 40 |
+ |
|
| 41 |
+ subplot(2,1,2) |
|
| 42 |
+ hold on; |
|
| 43 |
+ |
|
| 44 |
+ chanceLevel = 100/nClasses; |
|
| 45 |
+ goodPredictionLevel = chanceLevel*1.5; |
|
| 46 |
+ plot([psthStart psthEnd],[chanceLevel chanceLevel],'r'); |
|
| 47 |
+ plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'g'); |
|
| 48 |
+ axis([psthStart psthEnd 0 100]) |
|
| 49 |
+ |
|
| 50 |
+ plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b'); |
|
| 51 |
+ PLOT_STD_ERR = 1; |
|
| 52 |
+ PLOT_CLASS_PERFORMANCE = 1; |
|
| 53 |
+ if PLOT_STD_ERR |
|
| 54 |
+ se = myStdErr(decodePerformance,2); |
|
| 55 |
+ plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); |
|
| 56 |
+ plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); |
|
| 57 |
+ end |
|
| 58 |
+ if PLOT_CLASS_PERFORMANCE |
|
| 59 |
+ for c = 1:nClasses |
|
| 60 |
+ plot(frameStart:frameEnd, decodePerformance() ,[colorChooser(c+2) '-']); |
|
| 61 |
+ end |
|
| 62 |
+ end |
|
| 63 |
+ |
|
| 64 |
+ |
|
| 65 |
+ hold off; |
|
| 66 |
+ |
|
| 67 |
+ title = sprintf('Subject %s, over %g voxel, smoothed %s',SubjectID,size(psth,2),smoothed);
|
|
| 68 |
+ set(f,'Name',title); |
|
| 69 |
+ display(sprintf('%s',title));
|
|
| 70 |
+ |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
+end |
|
| 74 |
+ |
|
| 75 |
+ |
|
| 76 |
+function color = colorChooser(n) |
|
| 77 |
+ switch (mod(n,8)) |
|
| 78 |
+ case 0 |
|
| 79 |
+ color = 'y'; |
|
| 80 |
+ case 1 |
|
| 81 |
+ color = 'r'; |
|
| 82 |
+ case 2 |
|
| 83 |
+ color = 'b'; |
|
| 84 |
+ case 3 |
|
| 85 |
+ color = 'g'; |
|
| 86 |
+ otherwise |
|
| 87 |
+ color = 'k'; |
|
| 88 |
+ end |
|
| 89 |
+end |
|
| 90 |
+ |
|
| 91 |
+function style = lineStyleChooser(n) |
|
| 92 |
+switch(mod(n,4)) |
|
| 93 |
+ case 0 |
|
| 94 |
+ style = '--'; |
|
| 95 |
+ case 1 |
|
| 96 |
+ style = '-'; |
|
| 97 |
+ case 2 |
|
| 98 |
+ style = ':'; |
|
| 99 |
+ case 3 |
|
| 100 |
+ style = '-.'; |
|
| 101 |
+end |
|
| 102 |
+end |
|
| 103 |
+ |
| ... | ... |
@@ -43,14 +43,28 @@ end |
| 43 | 43 |
|
| 44 | 44 |
chanceLevel = 100/nClasses; |
| 45 | 45 |
goodPredictionLevel = chanceLevel*1.5; |
| 46 |
- plot([psthStart psthEnd],[chanceLevel chanceLevel],'r'); |
|
| 47 |
- plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'g'); |
|
| 46 |
+ plot([psthStart psthEnd],[chanceLevel chanceLevel],'k:'); |
|
| 47 |
+ plot([psthStart psthEnd],[goodPredictionLevel goodPredictionLevel],'k:'); |
|
| 48 | 48 |
axis([psthStart psthEnd 0 100]) |
| 49 | 49 |
|
| 50 |
+ |
|
| 51 |
+ PLOT_EXTRAS = 'class performance' |
|
| 52 |
+ |
|
| 53 |
+ switch PLOT_EXTRAS |
|
| 54 |
+ case 'stderr' |
|
| 50 | 55 |
plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b'); |
| 56 |
+ |
|
| 51 | 57 |
se = myStdErr(decodePerformance,2); |
| 52 | 58 |
plot(frameStart:frameEnd, mean(decodePerformance,2)+se ,'b:'); |
| 53 | 59 |
plot(frameStart:frameEnd, mean(decodePerformance,2)-se ,'b:'); |
| 60 |
+ case 'class performance' |
|
| 61 |
+ for c = 1:size(decodePerformance,2) |
|
| 62 |
+ plot(frameStart:frameEnd, decodePerformance(:,c) ,[colorChooser(mod(c,nClasses)+3) '-']); |
|
| 63 |
+ end |
|
| 64 |
+ |
|
| 65 |
+ plot(frameStart:frameEnd, mean(decodePerformance,2) ,'b','LineWidth',2); |
|
| 66 |
+ |
|
| 67 |
+ end |
|
| 54 | 68 |
|
| 55 | 69 |
|
| 56 | 70 |
hold off; |
| ... | ... |
@@ -67,13 +81,17 @@ end |
| 67 | 81 |
function color = colorChooser(n) |
| 68 | 82 |
switch (mod(n,8)) |
| 69 | 83 |
case 0 |
| 70 |
- color = 'y'; |
|
| 71 |
- case 1 |
|
| 72 | 84 |
color = 'r'; |
| 85 |
+ case 1 |
|
| 86 |
+ color = 'g'; |
|
| 73 | 87 |
case 2 |
| 74 | 88 |
color = 'b'; |
| 75 | 89 |
case 3 |
| 76 |
- color = 'g'; |
|
| 90 |
+ color = 'c'; |
|
| 91 |
+ case 4 |
|
| 92 |
+ color = 'm'; |
|
| 93 |
+ case 5 |
|
| 94 |
+ color = 'y'; |
|
| 77 | 95 |
otherwise |
| 78 | 96 |
color = 'k'; |
| 79 | 97 |
end |
| ... | ... |
@@ -59,33 +59,38 @@ maxPerformance = -inf; |
| 59 | 59 |
svmlabel = svmlabel(rndindex); |
| 60 | 60 |
end |
| 61 | 61 |
|
| 62 |
- SVM_METHOD = 2; |
|
| 62 |
+ SVM_METHOD = 'class performance' |
|
| 63 | 63 |
switch SVM_METHOD; |
| 64 |
- case 1 |
|
| 64 |
+ case 'libsvm crossval' |
|
| 65 | 65 |
performance = svmtrain(svmlabel, svmdata, svmargs); |
| 66 | 66 |
|
| 67 | 67 |
minPerformance = min(minPerformance,performance); |
| 68 | 68 |
maxPerformance = max(maxPerformance,performance); |
| 69 | 69 |
|
| 70 | 70 |
decodePerformance = [decodePerformance; performance]; |
| 71 |
- case 2 |
|
| 71 |
+ case 'class performance' |
|
| 72 | 72 |
newsvmopt = killCrossvalOpt(svmargs); |
| 73 | 73 |
|
| 74 | 74 |
model = svmtrain(svmlabel,svmdata,newsvmopt); |
| 75 | 75 |
classperformance = []; |
| 76 | 76 |
for class = unique(svmlabel)'; |
| 77 |
-% assignin('base','uniquelabel',unique(svmlabel));
|
|
| 78 |
-% assignin('base','class',class);
|
|
| 79 |
-% assignin('base','svmlabel',svmlabel);
|
|
| 77 |
+ |
|
| 80 | 78 |
filterindex = find(class == svmlabel); |
| 81 |
- testing_label = svmlabel(filterindex) |
|
| 82 |
- testing_data = svmdata(filterindex) |
|
| 83 |
- [plabel accuracy dvalue] = svmpredict(testing_label,testing_data,model,'') |
|
| 84 |
-% assignin('base','accuracy',accuracy);
|
|
| 79 |
+ testing_label = svmlabel(filterindex); |
|
| 80 |
+ testing_data = svmdata(filterindex); |
|
| 81 |
+ [plabel accuracy dvalue] = svmpredict(testing_label,testing_data,model,''); |
|
| 82 |
+ |
|
| 85 | 83 |
classperformance = [classperformance accuracy(1)]; |
| 86 | 84 |
end |
| 87 | 85 |
decodePerformance = [decodePerformance; classperformance]; |
| 88 | 86 |
|
| 87 |
+ case 'som training' |
|
| 88 |
+ display('SOM TRAINING');
|
|
| 89 |
+ addpath 'somtoolbox2'; |
|
| 90 |
+ sD = som_data_struct(svmdata); |
|
| 91 |
+ assignin('base','sD',sD);
|
|
| 92 |
+ sM = som_make(sD,'msize', [3 4],'lattice', 'rect'); |
|
| 93 |
+ |
|
| 89 | 94 |
end |
| 90 | 95 |
|
| 91 | 96 |
end |
| ... | ... |
@@ -0,0 +1,196 @@ |
| 1 |
+% SOM Toolbox |
|
| 2 |
+% Version 2.0beta, May 30 2002 |
|
| 3 |
+% |
|
| 4 |
+% Copyright 1997-2000 by |
|
| 5 |
+% Esa Alhoniemi, Johan Himberg, Juha Parhankangas and Juha Vesanto |
|
| 6 |
+% Contributed files may contain copyrights of their own. |
|
| 7 |
+% |
|
| 8 |
+% SOM Toolbox comes with ABSOLUTELY NO WARRANTY; for details |
|
| 9 |
+% see License.txt in the program package. This is free software, |
|
| 10 |
+% and you are welcome to redistribute it under certain conditions; |
|
| 11 |
+% see License.txt for details. |
|
| 12 |
+% |
|
| 13 |
+% |
|
| 14 |
+% Demos |
|
| 15 |
+% |
|
| 16 |
+% som_demo1 SOM Toolbox demo 1: basic properties |
|
| 17 |
+% som_demo2 SOM Toolbox demo 2: basic usage |
|
| 18 |
+% som_demo3 SOM Toolbox demo 3: visualization |
|
| 19 |
+% som_demo4 SOM Toolbox demo 4: data analysis |
|
| 20 |
+% |
|
| 21 |
+% Creation of structs |
|
| 22 |
+% |
|
| 23 |
+% som_set create & set (& check) values to structs |
|
| 24 |
+% som_info print out information on a given struct |
|
| 25 |
+% som_data_struct create & initialize a data struct |
|
| 26 |
+% som_map_struct create & initialize a map struct |
|
| 27 |
+% som_topol_struct create & initialize a topology struct |
|
| 28 |
+% som_train_struct create & initialize a train struct |
|
| 29 |
+% som_clstruct create a cluster struct |
|
| 30 |
+% som_clset set properties in a cluster struct |
|
| 31 |
+% som_clget get stuff from a cluster struct |
|
| 32 |
+% |
|
| 33 |
+% Struct conversion and file I/O |
|
| 34 |
+% |
|
| 35 |
+% som_vs1to2 converts a version 1.0 struct to version 2.0 struct |
|
| 36 |
+% som_vs2to1 converts a version 2.0 struct to version 1.0 struct |
|
| 37 |
+% som_read_data reads a (SOM_PAK format) ASCII data file |
|
| 38 |
+% som_write_data writes a SOM_PAK format codebook file |
|
| 39 |
+% som_write_cod writes a SOM_PAK format data file |
|
| 40 |
+% som_read_cod reads a SOM_PAK format codebook file |
|
| 41 |
+% |
|
| 42 |
+% Data preprocessing |
|
| 43 |
+% |
|
| 44 |
+% som_normalize normalize data set |
|
| 45 |
+% som_denormalize denormalize data set |
|
| 46 |
+% som_norm_variable (de)normalize one variable |
|
| 47 |
+% preprocess preprocessing GUI |
|
| 48 |
+% |
|
| 49 |
+% Initialization and training functions |
|
| 50 |
+% |
|
| 51 |
+% som_make create, initialize and train a SOM |
|
| 52 |
+% som_randinit random initialization algorithm |
|
| 53 |
+% som_lininit linear initialization algorithm |
|
| 54 |
+% som_seqtrain sequential training algorithm |
|
| 55 |
+% som_batchtrain batch training algorithm |
|
| 56 |
+% som_gui SOM initialization and training GUI |
|
| 57 |
+% som_prototrain a simple version of sequential training: easy to modify |
|
| 58 |
+% |
|
| 59 |
+% Clustering algorithms |
|
| 60 |
+% |
|
| 61 |
+% som_kmeans k-means algorithm (was earlier kmeans) |
|
| 62 |
+% kmeans_clusters try and evaluate several k-means clusterings |
|
| 63 |
+% neural_gas neural gas vector quantization algorithm |
|
| 64 |
+% som_linkage hierarchical clustering algorithms |
|
| 65 |
+% som_cllinkage hierarchical clustering of SOM |
|
| 66 |
+% som_dmatminima local minima from distance (or U-) matrix |
|
| 67 |
+% som_dmatclusters distance (or U-) matrix based clustering |
|
| 68 |
+% som_clspread spreads clusters to unassinged map units |
|
| 69 |
+% som_cldist calculate distances between clusters |
|
| 70 |
+% som_gapindex gap validity index of clustering |
|
| 71 |
+% db_index Davies-Bouldin validity index of clustering |
|
| 72 |
+% |
|
| 73 |
+% Supervised/classification algorithms |
|
| 74 |
+% |
|
| 75 |
+% som_supervised supervised SOM algorithm |
|
| 76 |
+% lvq1 LVQ1 algorithm |
|
| 77 |
+% lvq3 LVQ3 algorithm |
|
| 78 |
+% knn k-NN classification algorithm |
|
| 79 |
+% knn_old k-NN classification algorithm (old version) |
|
| 80 |
+% |
|
| 81 |
+% SOM error measures |
|
| 82 |
+% |
|
| 83 |
+% som_quality quantization and topographic error of SOM |
|
| 84 |
+% som_distortion SOM distortion measure |
|
| 85 |
+% som_distortion3 elements of the SOM distortion measure |
|
| 86 |
+% |
|
| 87 |
+% Auxiliary functions |
|
| 88 |
+% |
|
| 89 |
+% som_bmus calculates BMUs for given data vectors |
|
| 90 |
+% som_eucdist2 pairwise squared euclidian distances between vectors |
|
| 91 |
+% som_mdist calculates pairwise distances between vectors |
|
| 92 |
+% som_divide extract subsets of data based on map |
|
| 93 |
+% som_label give labels to map units |
|
| 94 |
+% som_label2num rcodes string data labels to interger class labels |
|
| 95 |
+% som_autolabel automatically labels the SOM based on given data |
|
| 96 |
+% som_unit_coords calculates coordinates in output space for map units |
|
| 97 |
+% som_unit_dists distances in output space between map units |
|
| 98 |
+% som_unit_neighs units in 1-neighborhood for each map unit |
|
| 99 |
+% som_neighborhood calculates neighborhood matrix for the given map |
|
| 100 |
+% som_neighbors calculates different kinds of neighborhoods |
|
| 101 |
+% som_neighf calculates neighborhood function values |
|
| 102 |
+% som_select GUI for manual selection of map units |
|
| 103 |
+% som_estimate_gmm create Gaussian mixture model on top of SOM |
|
| 104 |
+% som_probability_gmm evaluate Gaussian mixture model |
|
| 105 |
+% som_ind2sub from linear index to subscript index |
|
| 106 |
+% som_sub2ind from subscript index to linear index |
|
| 107 |
+% som_ind2cod from linear index to SOM_PAK linear index |
|
| 108 |
+% som_cod2ind from SOM_linear index to SOM_PAK linear index |
|
| 109 |
+% nanstats mean, std and median which ignore NaNs |
|
| 110 |
+% som_modify_dataset add, remove, or extract samples and components |
|
| 111 |
+% som_fillnans fill NaNs in a data set based on given SOM |
|
| 112 |
+% som_stats statistics of a data set |
|
| 113 |
+% som_drmake calculate descriptive rules for a cluster |
|
| 114 |
+% som_dreval evaluate descriptive rules for a cluster |
|
| 115 |
+% som_drsignif rule significance measures |
|
| 116 |
+% |
|
| 117 |
+% Using SOM_PAK from Matlab |
|
| 118 |
+% |
|
| 119 |
+% som_sompaktrain uses SOM_PAK to train a map |
|
| 120 |
+% sompak_gui GUI for using SOM_PAK from Matlab |
|
| 121 |
+% sompak_init call SOM_PAK's initialization programs from Matlab |
|
| 122 |
+% sompak_init_gui GUI for using SOM_PAK's initialization from Matlab |
|
| 123 |
+% sompak_rb_control an auxiliary function for sompak_*_gui functions. |
|
| 124 |
+% sompak_sammon call SOM_PAK's Sammon program from Matlab |
|
| 125 |
+% sompak_sammon_gui GUI for using SOM_PAK's Sammon program from Matlab |
|
| 126 |
+% sompak_train call SOM_PAK's training program from Matlab |
|
| 127 |
+% sompak_train_gui GUI for using SOM_PAK's training program from Matlab |
|
| 128 |
+% |
|
| 129 |
+% Visualization |
|
| 130 |
+% |
|
| 131 |
+% som_show basic visualization |
|
| 132 |
+% som_show_add add labels, hits and trajectories |
|
| 133 |
+% som_show_clear remove extra markers |
|
| 134 |
+% som_recolorbar refresh/reconfigure colorbars |
|
| 135 |
+% som_show_gui GUI for using som_show and associated functions |
|
| 136 |
+% som_grid visualization of SOM grid |
|
| 137 |
+% som_cplane component planes and U-matrices |
|
| 138 |
+% som_barplane bar chart visualization of map |
|
| 139 |
+% som_pieplane pie chart visualization of map |
|
| 140 |
+% som_plotplane plot chart visualization of map |
|
| 141 |
+% som_trajectory launches a GUI for presenting comet-trajectories |
|
| 142 |
+% som_dendrogram visualization of clustering tree |
|
| 143 |
+% som_plotmatrix pairwise scatter plots and histograms |
|
| 144 |
+% som_order_cplanes order and visualize the component planes |
|
| 145 |
+% som_clplot plots of clusters (based on cluster struct) |
|
| 146 |
+% som_projections_plot projections plots (see som_projections) |
|
| 147 |
+% som_stats_plot plots of statistics (see som_stats) |
|
| 148 |
+% |
|
| 149 |
+% Auxiliary functions for visualization |
|
| 150 |
+% |
|
| 151 |
+% hits calculates hits, or sum of values for each map unit |
|
| 152 |
+% som_hits calculates the response of data on the map |
|
| 153 |
+% som_umat calculates the U-matrix |
|
| 154 |
+% cca curvilinear component analysis projection algorithm |
|
| 155 |
+% pcaproj principal component projection algorithm |
|
| 156 |
+% sammon Sammon's mapping projection algorithm |
|
| 157 |
+% som_connection connection matrix for map |
|
| 158 |
+% som_vis_coords map unit coordinates used in visualizations |
|
| 159 |
+% som_colorcode create color coding for map/2D data |
|
| 160 |
+% som_bmucolor colors of the BMUs from a given map color code |
|
| 161 |
+% som_normcolor simulate indexed colormap |
|
| 162 |
+% som_clustercolor color coding which depends on clustering structure |
|
| 163 |
+% som_kmeanscolor color coding according to k-means clustering |
|
| 164 |
+% som_kmeanscolor2 a newer version of the som_kmeanscolor function |
|
| 165 |
+% som_fuzzycolor a fuzzy color coding |
|
| 166 |
+% som_coloring a SOM-based color coding |
|
| 167 |
+% som_projections calculates a default set of projections |
|
| 168 |
+% |
|
| 169 |
+% Report generation stuff |
|
| 170 |
+% |
|
| 171 |
+% som_table_struct creates a table struct |
|
| 172 |
+% som_table_modify modifies a table struct |
|
| 173 |
+% som_table_print print a table in various formats |
|
| 174 |
+% rep_utils various utilities for printing report elements |
|
| 175 |
+% som_stats_table a table of data set statistics |
|
| 176 |
+% som_stats_report report on data set statistics |
|
| 177 |
+% |
|
| 178 |
+% Low level routines used by visualization functions |
|
| 179 |
+% |
|
| 180 |
+% vis_patch defines hexagonal and rectangular patches |
|
| 181 |
+% vis_som_show_data returns UserData and subplot handles stored by som_show.m |
|
| 182 |
+% vis_valuetype used for type checks |
|
| 183 |
+% vis_footnote adds a movable text to the current figure |
|
| 184 |
+% vis_trajgui the actual GUI started by som_trajectory.m |
|
| 185 |
+% vis_PlaneAxisProperties set axis properties in visualization functions |
|
| 186 |
+% vis_footnoteButtonDownFcn callback function for vis_footnote.m |
|
| 187 |
+% vis_planeGetArgs converts topol struct to lattice, msize argument pair |
|
| 188 |
+% vis_show_gui_comp internal function used by som_show_gui.m |
|
| 189 |
+% vis_show_gui_tool internal function used by som_show_gui.m |
|
| 190 |
+% |
|
| 191 |
+% Other |
|
| 192 |
+% |
|
| 193 |
+% somtoolbox this file |
|
| 194 |
+% iris.data IRIS data set (used in demos) |
|
| 195 |
+% License.txt GNU General Public License |
|
| 196 |
+% Copyright.txt Copyright notice |
| ... | ... |
@@ -0,0 +1,55 @@ |
| 1 |
+COPYRIGHT |
|
| 2 |
+--------- |
|
| 3 |
+ |
|
| 4 |
+SOM Toolbox 2.0, a software library for Matlab 5 implementing the |
|
| 5 |
+Self-Organizing Map algorithm is Copyright (C) 1999 by Esa Alhoniemi, |
|
| 6 |
+Johan Himberg, Jukka Parviainen and Juha Vesanto. |
|
| 7 |
+ |
|
| 8 |
+This package is free software; you can redistribute it and/or |
|
| 9 |
+modify it under the terms of the GNU General Public License |
|
| 10 |
+as published by the Free Software Foundation; either version 2 |
|
| 11 |
+of the License, or any later version. |
|
| 12 |
+ |
|
| 13 |
+Note: only part of the files distributed in the package belong to the |
|
| 14 |
+SOM Toolbox. The package also contains contributed files, which may |
|
| 15 |
+have their own copyright notices. If not, the GNU General Public |
|
| 16 |
+License holds for them, too, but so that the author(s) of the file |
|
| 17 |
+have the Copyright. |
|
| 18 |
+ |
|
| 19 |
+This package is distributed in the hope that it will be useful, |
|
| 20 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 21 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 22 |
+GNU General Public License for more details. |
|
| 23 |
+ |
|
| 24 |
+You should have received a copy of the GNU General Public License |
|
| 25 |
+along with this package (file License.txt); if not, write to the Free |
|
| 26 |
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|
| 27 |
+02111-1307, USA. |
|
| 28 |
+ |
|
| 29 |
+ |
|
| 30 |
+LICENSING THE LIBRARY FOR PROPRIETARY PROGRAMS |
|
| 31 |
+---------------------------------------------- |
|
| 32 |
+ |
|
| 33 |
+As stated in the GNU General Public License (see License.txt) it is |
|
| 34 |
+not possible to include this software library in a commercial |
|
| 35 |
+proprietary program without written permission from the owners of the |
|
| 36 |
+copyright. If you wish to obtain such permission, you can reach us by |
|
| 37 |
+paper mail: |
|
| 38 |
+ |
|
| 39 |
+ SOM Toolbox team |
|
| 40 |
+ Laboratory of Computer and Information Science |
|
| 41 |
+ P.O.Box 5400 |
|
| 42 |
+ FIN-02015 HUT |
|
| 43 |
+ Finland |
|
| 44 |
+ Europe |
|
| 45 |
+ |
|
| 46 |
+and by email: |
|
| 47 |
+ |
|
| 48 |
+ somtlbx@mail.cis.hut.fi |
|
| 49 |
+ |
|
| 50 |
+ |
|
| 51 |
+ |
|
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+ |
|
| 55 |
+ |
| ... | ... |
@@ -0,0 +1,386 @@ |
| 1 |
+GNU GENERAL PUBLIC LICENSE |
|
| 2 |
+ |
|
| 3 |
+Version 2, June 1991 |
|
| 4 |
+ |
|
| 5 |
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
|
| 6 |
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
| 7 |
+ |
|
| 8 |
+Everyone is permitted to copy and distribute verbatim copies |
|
| 9 |
+of this license document, but changing it is not allowed. |
|
| 10 |
+ |
|
| 11 |
+------------------------------------------------------------------------ |
|
| 12 |
+ |
|
| 13 |
+Preamble |
|
| 14 |
+ |
|
| 15 |
+ The licenses for most software are designed to take away your |
|
| 16 |
+freedom to share and change it. By contrast, the GNU General Public |
|
| 17 |
+License is intended to guarantee your freedom to share and change free |
|
| 18 |
+software--to make sure the software is free for all its users. This |
|
| 19 |
+General Public License applies to most of the Free Software |
|
| 20 |
+Foundation's software and to any other program whose authors commit to |
|
| 21 |
+using it. (Some other Free Software Foundation software is covered by |
|
| 22 |
+the GNU Library General Public License instead.) You can apply it to |
|
| 23 |
+your programs, too. |
|
| 24 |
+ |
|
| 25 |
+ When we speak of free software, we are referring to freedom, not |
|
| 26 |
+price. Our General Public Licenses are designed to make sure that you |
|
| 27 |
+have the freedom to distribute copies of free software (and charge for |
|
| 28 |
+this service if you wish), that you receive source code or can get it |
|
| 29 |
+if you want it, that you can change the software or use pieces of it |
|
| 30 |
+in new free programs; and that you know you can do these things. |
|
| 31 |
+ |
|
| 32 |
+ To protect your rights, we need to make restrictions that forbid |
|
| 33 |
+anyone to deny you these rights or to ask you to surrender the rights. |
|
| 34 |
+These restrictions translate to certain responsibilities for you if you |
|
| 35 |
+distribute copies of the software, or if you modify it. |
|
| 36 |
+ |
|
| 37 |
+ For example, if you distribute copies of such a program, whether |
|
| 38 |
+gratis or for a fee, you must give the recipients all the rights that |
|
| 39 |
+you have. You must make sure that they, too, receive or can get the |
|
| 40 |
+source code. And you must show them these terms so they know their |
|
| 41 |
+rights. |
|
| 42 |
+ |
|
| 43 |
+ We protect your rights with two steps: (1) copyright the software, and |
|
| 44 |
+(2) offer you this license which gives you legal permission to copy, |
|
| 45 |
+distribute and/or modify the software. |
|
| 46 |
+ |
|
| 47 |
+ Also, for each author's protection and ours, we want to make certain |
|
| 48 |
+that everyone understands that there is no warranty for this free |
|
| 49 |
+software. If the software is modified by someone else and passed on, we |
|
| 50 |
+want its recipients to know that what they have is not the original, so |
|
| 51 |
+that any problems introduced by others will not reflect on the original |
|
| 52 |
+authors' reputations. |
|
| 53 |
+ |
|
| 54 |
+ Finally, any free program is threatened constantly by software |
|
| 55 |
+patents. We wish to avoid the danger that redistributors of a free |
|
| 56 |
+program will individually obtain patent licenses, in effect making the |
|
| 57 |
+program proprietary. To prevent this, we have made it clear that any |
|
| 58 |
+patent must be licensed for everyone's free use or not licensed at all. |
|
| 59 |
+ |
|
| 60 |
+ The precise terms and conditions for copying, distribution and |
|
| 61 |
+modification follow. |
|
| 62 |
+ |
|
| 63 |
+--------------------------------------------------------------------- |
|
| 64 |
+ |
|
| 65 |
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
|
| 66 |
+ |
|
| 67 |
+0. |
|
| 68 |
+ |
|
| 69 |
+This License applies to any program or other work which contains a |
|
| 70 |
+notice placed by the copyright holder saying it may be distributed |
|
| 71 |
+under the terms of this General Public License. The "Program", below, |
|
| 72 |
+refers to any such program or work, and a "work based on the Program" |
|
| 73 |
+means either the Program or any derivative work under copyright law: |
|
| 74 |
+that is to say, a work containing the Program or a portion of it, |
|
| 75 |
+either verbatim or with modifications and/or translated into another |
|
| 76 |
+language. (Hereinafter, translation is included without limitation in |
|
| 77 |
+the term "modification".) Each licensee is addressed as "you". |
|
| 78 |
+ |
|
| 79 |
+Activities other than copying, distribution and modification are not |
|
| 80 |
+covered by this License; they are outside its scope. The act of |
|
| 81 |
+running the Program is not restricted, and the output from the Program |
|
| 82 |
+is covered only if its contents constitute a work based on the |
|
| 83 |
+Program (independent of having been made by running the Program). |
|
| 84 |
+Whether that is true depends on what the Program does. |
|
| 85 |
+ |
|
| 86 |
+1. |
|
| 87 |
+ |
|
| 88 |
+You may copy and distribute verbatim copies of the Program's source |
|
| 89 |
+code as you receive it, in any medium, provided that you conspicuously |
|
| 90 |
+and appropriately publish on each copy an appropriate copyright notice |
|
| 91 |
+and disclaimer of warranty; keep intact all the notices that refer to |
|
| 92 |
+this License and to the absence of any warranty; and give any other |
|
| 93 |
+recipients of the Program a copy of this License along with the |
|
| 94 |
+Program. |
|
| 95 |
+ |
|
| 96 |
+You may charge a fee for the physical act of transferring a copy, and |
|
| 97 |
+you may at your option offer warranty protection in exchange for a fee. |
|
| 98 |
+ |
|
| 99 |
+2. |
|
| 100 |
+ |
|
| 101 |
+You may modify your copy or copies of the Program or any portion of |
|
| 102 |
+it, thus forming a work based on the Program, and copy and distribute |
|
| 103 |
+such modifications or work under the terms of Section 1 above, |
|
| 104 |
+provided that you also meet all of these conditions: |
|
| 105 |
+ |
|
| 106 |
+a) You must cause the modified files to carry prominent notices |
|
| 107 |
+ stating that you changed the files and the date of any change. |
|
| 108 |
+ |
|
| 109 |
+b) You must cause any work that you distribute or publish, that in |
|
| 110 |
+ whole or in part contains or is derived from the Program or any part |
|
| 111 |
+ thereof, to be licensed as a whole at no charge to all third parties |
|
| 112 |
+ under the terms of this License. |
|
| 113 |
+ |
|
| 114 |
+c) If the modified program normally reads commands interactively when |
|
| 115 |
+ run, you must cause it, when started running for such interactive use |
|
| 116 |
+ in the most ordinary way, to print or display an announcement |
|
| 117 |
+ including an appropriate copyright notice and a notice that there is |
|
| 118 |
+ no warranty (or else, saying that you provide a warranty) and that |
|
| 119 |
+ users may redistribute the program under these conditions, and telling |
|
| 120 |
+ the user how to view a copy of this License. (Exception: if the |
|
| 121 |
+ Program itself is interactive but does not normally print such an |
|
| 122 |
+ announcement, your work based on the Program is not required to print |
|
| 123 |
+ an announcement.) |
|
| 124 |
+ |
|
| 125 |
+These requirements apply to the modified work as a whole. If |
|
| 126 |
+identifiable sections of that work are not derived from the Program, |
|
| 127 |
+and can be reasonably considered independent and separate works in |
|
| 128 |
+themselves, then this License, and its terms, do not apply to those |
|
| 129 |
+sections when you distribute them as separate works. But when you |
|
| 130 |
+distribute the same sections as part of a whole which is a work based |
|
| 131 |
+on the Program, the distribution of the whole must be on the terms of |
|
| 132 |
+this License, whose permissions for other licensees extend to the |
|
| 133 |
+entire whole, and thus to each and every part regardless of who wrote |
|
| 134 |
+it. |
|
| 135 |
+ |
|
| 136 |
+Thus, it is not the intent of this section to claim rights or contest |
|
| 137 |
+your rights to work written entirely by you; rather, the intent is to |
|
| 138 |
+exercise the right to control the distribution of derivative or |
|
| 139 |
+collective works based on the Program. |
|
| 140 |
+ |
|
| 141 |
+In addition, mere aggregation of another work not based on the Program |
|
| 142 |
+with the Program (or with a work based on the Program) on a volume of |
|
| 143 |
+a storage or distribution medium does not bring the other work under |
|
| 144 |
+the scope of this License. |
|
| 145 |
+ |
|
| 146 |
+3. |
|
| 147 |
+ |
|
| 148 |
+You may copy and distribute the Program (or a work based on it, under |
|
| 149 |
+Section 2) in object code or executable form under the terms of |
|
| 150 |
+Sections 1 and 2 above provided that you also do one of the following: |
|
| 151 |
+ |
|
| 152 |
+a) Accompany it with the complete corresponding machine-readable |
|
| 153 |
+ source code, which must be distributed under the terms of Sections 1 |
|
| 154 |
+ and 2 above on a medium customarily used for software interchange; or, |
|
| 155 |
+ |
|
| 156 |
+b) Accompany it with a written offer, valid for at least three years, |
|
| 157 |
+ to give any third party, for a charge no more than your cost of |
|
| 158 |
+ physically performing source distribution, a complete machine-readable |
|
| 159 |
+ copy of the corresponding source code, to be distributed under the |
|
| 160 |
+ terms of Sections 1 and 2 above on a medium customarily used for |
|
| 161 |
+ software interchange; or, |
|
| 162 |
+ |
|
| 163 |
+c) Accompany it with the information you received as to the offer to |
|
| 164 |
+ distribute corresponding source code. (This alternative is allowed |
|
| 165 |
+ only for noncommercial distribution and only if you received the |
|
| 166 |
+ program in object code or executable form with such an offer, in |
|
| 167 |
+ accord with Subsection b above.) |
|
| 168 |
+ |
|
| 169 |
+The source code for a work means the preferred form of the work for |
|
| 170 |
+making modifications to it. For an executable work, complete source |
|
| 171 |
+code means all the source code for all modules it contains, plus any |
|
| 172 |
+associated interface definition files, plus the scripts used to |
|
| 173 |
+control compilation and installation of the executable. However, as a |
|
| 174 |
+special exception, the source code distributed need not include |
|
| 175 |
+anything that is normally distributed (in either source or binary |
|
| 176 |
+form) with the major components (compiler, kernel, and so on) of the |
|
| 177 |
+operating system on which the executable runs, unless that component |
|
| 178 |
+itself accompanies the executable. |
|
| 179 |
+ |
|
| 180 |
+If distribution of executable or object code is made by offering |
|
| 181 |
+access to copy from a designated place, then offering equivalent |
|
| 182 |
+access to copy the source code from the same place counts as |
|
| 183 |
+distribution of the source code, even though third parties are not |
|
| 184 |
+compelled to copy the source along with the object code. |
|
| 185 |
+ |
|
| 186 |
+4. |
|
| 187 |
+ |
|
| 188 |
+You may not copy, modify, sublicense, or distribute the Program except |
|
| 189 |
+as expressly provided under this License. Any attempt otherwise to |
|
| 190 |
+copy, modify, sublicense or distribute the Program is void, and will |
|
| 191 |
+automatically terminate your rights under this License. However, |
|
| 192 |
+parties who have received copies, or rights, from you under this |
|
| 193 |
+License will not have their licenses terminated so long as such |
|
| 194 |
+parties remain in full compliance. |
|
| 195 |
+ |
|
| 196 |
+5. |
|
| 197 |
+ |
|
| 198 |
+You are not required to accept this License, since you have not signed |
|
| 199 |
+it. However, nothing else grants you permission to modify or |
|
| 200 |
+distribute the Program or its derivative works. These actions are |
|
| 201 |
+prohibited by law if you do not accept this License. Therefore, by |
|
| 202 |
+modifying or distributing the Program (or any work based on the |
|
| 203 |
+Program), you indicate your acceptance of this License to do so, and |
|
| 204 |
+all its terms and conditions for copying, distributing or modifying |
|
| 205 |
+the Program or works based on it. |
|
| 206 |
+ |
|
| 207 |
+6. |
|
| 208 |
+ |
|
| 209 |
+Each time you redistribute the Program (or any work based on the |
|
| 210 |
+Program), the recipient automatically receives a license from the |
|
| 211 |
+original licensor to copy, distribute or modify the Program subject to |
|
| 212 |
+these terms and conditions. You may not impose any further |
|
| 213 |
+restrictions on the recipients' exercise of the rights granted herein. |
|
| 214 |
+You are not responsible for enforcing compliance by third parties to |
|
| 215 |
+this License. |
|
| 216 |
+ |
|
| 217 |
+7. |
|
| 218 |
+ |
|
| 219 |
+If, as a consequence of a court judgment or allegation of patent |
|
| 220 |
+infringement or for any other reason (not limited to patent issues), |
|
| 221 |
+conditions are imposed on you (whether by court order, agreement or |
|
| 222 |
+otherwise) that contradict the conditions of this License, they do not |
|
| 223 |
+excuse you from the conditions of this License. If you cannot |
|
| 224 |
+distribute so as to satisfy simultaneously your obligations under this |
|
| 225 |
+License and any other pertinent obligations, then as a consequence you |
|
| 226 |
+may not distribute the Program at all. For example, if a patent |
|
| 227 |
+license would not permit royalty-free redistribution of the Program by |
|
| 228 |
+all those who receive copies directly or indirectly through you, then |
|
| 229 |
+the only way you could satisfy both it and this License would be to |
|
| 230 |
+refrain entirely from distribution of the Program. |
|
| 231 |
+ |
|
| 232 |
+If any portion of this section is held invalid or unenforceable under |
|
| 233 |
+any particular circumstance, the balance of the section is intended to |
|
| 234 |
+apply and the section as a whole is intended to apply in other |
|
| 235 |
+circumstances. |
|
| 236 |
+ |
|
| 237 |
+It is not the purpose of this section to induce you to infringe any |
|
| 238 |
+patents or other property right claims or to contest validity of any |
|
| 239 |
+such claims; this section has the sole purpose of protecting the |
|
| 240 |
+integrity of the free software distribution system, which is |
|
| 241 |
+implemented by public license practices. Many people have made |
|
| 242 |
+generous contributions to the wide range of software distributed |
|
| 243 |
+through that system in reliance on consistent application of that |
|
| 244 |
+system; it is up to the author/donor to decide if he or she is willing |
|
| 245 |
+to distribute software through any other system and a licensee cannot |
|
| 246 |
+impose that choice. |
|
| 247 |
+ |
|
| 248 |
+This section is intended to make thoroughly clear what is believed to |
|
| 249 |
+be a consequence of the rest of this License. |
|
| 250 |
+ |
|
| 251 |
+8. |
|
| 252 |
+ |
|
| 253 |
+If the distribution and/or use of the Program is restricted in certain |
|
| 254 |
+countries either by patents or by copyrighted interfaces, the original |
|
| 255 |
+copyright holder who places the Program under this License may add an |
|
| 256 |
+explicit geographical distribution limitation excluding those |
|
| 257 |
+countries, so that distribution is permitted only in or among |
|
| 258 |
+countries not thus excluded. In such case, this License incorporates |
|
| 259 |
+the limitation as if written in the body of this License. |
|
| 260 |
+ |
|
| 261 |
+9. |
|
| 262 |
+ |
|
| 263 |
+The Free Software Foundation may publish revised and/or new versions |
|
| 264 |
+of the General Public License from time to time. Such new versions |
|
| 265 |
+will be similar in spirit to the present version, but may differ in |
|
| 266 |
+detail to address new problems or concerns. |
|
| 267 |
+ |
|
| 268 |
+Each version is given a distinguishing version number. If the Program |
|
| 269 |
+specifies a version number of this License which applies to it and |
|
| 270 |
+"any later version", you have the option of following the terms and |
|
| 271 |
+conditions either of that version or of any later version published by |
|
| 272 |
+the Free Software Foundation. If the Program does not specify a |
|
| 273 |
+version number of this License, you may choose any version ever |
|
| 274 |
+published by the Free Software Foundation. |
|
| 275 |
+ |
|
| 276 |
+10. |
|
| 277 |
+ |
|
| 278 |
+If you wish to incorporate parts of the Program into other free |
|
| 279 |
+programs whose distribution conditions are different, write to the |
|
| 280 |
+author to ask for permission. For software which is copyrighted by |
|
| 281 |
+the Free Software Foundation, write to the Free Software Foundation; |
|
| 282 |
+we sometimes make exceptions for this. Our decision will be guided by |
|
| 283 |
+the two goals of preserving the free status of all derivatives of our |
|
| 284 |
+free software and of promoting the sharing and reuse of software |
|
| 285 |
+generally. |
|
| 286 |
+ |
|
| 287 |
+NO WARRANTY |
|
| 288 |
+ |
|
| 289 |
+11. |
|
| 290 |
+ |
|
| 291 |
+BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
| 292 |
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT |
|
| 293 |
+WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER |
|
| 294 |
+PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, |
|
| 295 |
+EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
|
| 296 |
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
| 297 |
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
|
| 298 |
+PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME |
|
| 299 |
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
| 300 |
+ |
|
| 301 |
+12. |
|
| 302 |
+ |
|
| 303 |
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
| 304 |
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
| 305 |
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR |
|
| 306 |
+DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL |
|
| 307 |
+DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM |
|
| 308 |
+(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED |
|
| 309 |
+INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF |
|
| 310 |
+THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER |
|
| 311 |
+OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
|
| 312 |
+ |
|
| 313 |
+END OF TERMS AND CONDITIONS |
|
| 314 |
+ |
|
| 315 |
+----------------------------------------------------------------------- |
|
| 316 |
+ |
|
| 317 |
+How to Apply These Terms to Your New Programs |
|
| 318 |
+ |
|
| 319 |
+If you develop a new program, and you want it to be of the greatest |
|
| 320 |
+possible use to the public, the best way to achieve this is to make it |
|
| 321 |
+free software which everyone can redistribute and change under these |
|
| 322 |
+terms. |
|
| 323 |
+ |
|
| 324 |
+To do so, attach the following notices to the program. It is safest |
|
| 325 |
+to attach them to the start of each source file to most effectively |
|
| 326 |
+convey the exclusion of warranty; and each file should have at least |
|
| 327 |
+the "copyright" line and a pointer to where the full notice is found. |
|
| 328 |
+ |
|
| 329 |
+one line to give the program's name and an idea of what it does. |
|
| 330 |
+Copyright (C) 20<yy> <name of author> |
|
| 331 |
+ |
|
| 332 |
+This program is free software; you can redistribute it and/or modify |
|
| 333 |
+it under the terms of the GNU General Public License as published by |
|
| 334 |
+the Free Software Foundation; either version 2 of the License, or (at |
|
| 335 |
+your option) any later version. |
|
| 336 |
+ |
|
| 337 |
+This program is distributed in the hope that it will be useful, but |
|
| 338 |
+WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 339 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 340 |
+General Public License for more details. |
|
| 341 |
+ |
|
| 342 |
+You should have received a copy of the GNU General Public License |
|
| 343 |
+along with this program; if not, write to the Free Software |
|
| 344 |
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
| 345 |
+USA. |
|
| 346 |
+ |
|
| 347 |
+Also add information on how to contact you by electronic and paper mail. |
|
| 348 |
+ |
|
| 349 |
+If the program is interactive, make it output a short notice like this |
|
| 350 |
+when it starts in an interactive mode: |
|
| 351 |
+ |
|
| 352 |
+ Gnomovision version 69, Copyright (C) 20<yy> <name of author> |
|
| 353 |
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show |
|
| 354 |
+ w'. This is free software, and you are welcome to redistribute it |
|
| 355 |
+ under certain conditions; type `show c' for details. |
|
| 356 |
+ |
|
| 357 |
+The hypothetical commands `show w' and `show c' should show the |
|
| 358 |
+appropriate parts of the General Public License. Of course, the |
|
| 359 |
+commands you use may be called something other than `show w' and `show |
|
| 360 |
+c'; they could even be mouse-clicks or menu items--whatever suits your |
|
| 361 |
+program. |
|
| 362 |
+ |
|
| 363 |
+You should also get your employer (if you work as a programmer) or |
|
| 364 |
+your school, if any, to sign a "copyright disclaimer" for the program, |
|
| 365 |
+if necessary. Here is a sample; alter the names: |
|
| 366 |
+ |
|
| 367 |
+ Yoyodyne, Inc., hereby disclaims all copyright |
|
| 368 |
+ interest in the program `Gnomovision' |
|
| 369 |
+ (which makes passes at compilers) written |
|
| 370 |
+ by James Hacker. |
|
| 371 |
+ |
|
| 372 |
+ <signature of Ty Coon>, 1 April 1989 |
|
| 373 |
+ Ty Coon, President of Vice |
|
| 374 |
+ |
|
| 375 |
+This General Public License does not permit incorporating your program |
|
| 376 |
+into proprietary programs. If your program is a subroutine library, |
|
| 377 |
+you may consider it more useful to permit linking proprietary |
|
| 378 |
+applications with the library. If this is what you want to do, use |
|
| 379 |
+the GNU Library General Public License instead of this License. |
|
| 380 |
+ |
|
| 381 |
+FSF & GNU inquiries & questions to gnu@prep.ai.mit.edu. |
|
| 382 |
+ |
|
| 383 |
+Copyright notice above. |
|
| 384 |
+Free Software Foundation, Inc., |
|
| 385 |
+59 Temple Place - Suite 330, Boston, MA 02111, USA |
|
| 386 |
+ |
| ... | ... |
@@ -0,0 +1,282 @@ |
| 1 |
+function [P] = cca(D, P, epochs, Mdist, alpha0, lambda0) |
|
| 2 |
+ |
|
| 3 |
+%CCA Projects data vectors using Curvilinear Component Analysis. |
|
| 4 |
+% |
|
| 5 |
+% P = cca(D, P, epochs, [Dist], [alpha0], [lambda0]) |
|
| 6 |
+% |
|
| 7 |
+% P = cca(D,2,10); % projects the given data to a plane |
|
| 8 |
+% P = cca(D,pcaproj(D,2),5); % same, but with PCA initialization |
|
| 9 |
+% P = cca(D, 2, 10, Dist); % same, but the given distance matrix is used |
|
| 10 |
+% |
|
| 11 |
+% Input and output arguments ([]'s are optional): |
|
| 12 |
+% D (matrix) the data matrix, size dlen x dim |
|
| 13 |
+% (struct) data or map struct |
|
| 14 |
+% P (scalar) output dimension |
|
| 15 |
+% (matrix) size dlen x odim, the initial projection |
|
| 16 |
+% epochs (scalar) training length |
|
| 17 |
+% [Dist] (matrix) pairwise distance matrix, size dlen x dlen. |
|
| 18 |
+% If the distances in the input space should |
|
| 19 |
+% be calculated otherwise than as euclidian |
|
| 20 |
+% distances, the distance from each vector |
|
| 21 |
+% to each other vector can be given here, |
|
| 22 |
+% size dlen x dlen. For example PDIST |
|
| 23 |
+% function can be used to calculate the |
|
| 24 |
+% distances: Dist = squareform(pdist(D,'mahal')); |
|
| 25 |
+% [alpha0] (scalar) initial step size, 0.5 by default |
|
| 26 |
+% [lambda0] (scalar) initial radius of influence, 3*max(std(D)) by default |
|
| 27 |
+% |
|
| 28 |
+% P (matrix) size dlen x odim, the projections |
|
| 29 |
+% |
|
| 30 |
+% Unknown values (NaN's) in the data: projections of vectors with |
|
| 31 |
+% unknown components tend to drift towards the center of the |
|
| 32 |
+% projection distribution. Projections of totally unknown vectors are |
|
| 33 |
+% set to unknown (NaN). |
|
| 34 |
+% |
|
| 35 |
+% See also SAMMON, PCAPROJ. |
|
| 36 |
+ |
|
| 37 |
+% Reference: Demartines, P., Herault, J., "Curvilinear Component |
|
| 38 |
+% Analysis: a Self-Organizing Neural Network for Nonlinear |
|
| 39 |
+% Mapping of Data Sets", IEEE Transactions on Neural Networks, |
|
| 40 |
+% vol 8, no 1, 1997, pp. 148-154. |
|
| 41 |
+ |
|
| 42 |
+% Contributed to SOM Toolbox 2.0, February 2nd, 2000 by Juha Vesanto |
|
| 43 |
+% Copyright (c) by Juha Vesanto |
|
| 44 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 45 |
+ |
|
| 46 |
+% juuso 171297 040100 |
|
| 47 |
+ |
|
| 48 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 49 |
+%% Check arguments |
|
| 50 |
+ |
|
| 51 |
+error(nargchk(3, 6, nargin)); % check the number of input arguments |
|
| 52 |
+ |
|
| 53 |
+% input data |
|
| 54 |
+if isstruct(D), |
|
| 55 |
+ if strcmp(D.type,'som_map'), D = D.codebook; else D = D.data; end |
|
| 56 |
+end |
|
| 57 |
+[noc dim] = size(D); |
|
| 58 |
+noc_x_1 = ones(noc, 1); % used frequently |
|
| 59 |
+me = zeros(1,dim); st = zeros(1,dim); |
|
| 60 |
+for i=1:dim, |
|
| 61 |
+ me(i) = mean(D(find(isfinite(D(:,i))),i)); |
|
| 62 |
+ st(i) = std(D(find(isfinite(D(:,i))),i)); |
|
| 63 |
+end |
|
| 64 |
+ |
|
| 65 |
+% initial projection |
|
| 66 |
+if prod(size(P))==1, |
|
| 67 |
+ P = (2*rand(noc,P)-1).*st(noc_x_1,1:P) + me(noc_x_1,1:P); |
|
| 68 |
+else |
|
| 69 |
+ % replace unknown projections with known values |
|
| 70 |
+ inds = find(isnan(P)); P(inds) = rand(size(inds)); |
|
| 71 |
+end |
|
| 72 |
+[dummy odim] = size(P); |
|
| 73 |
+odim_x_1 = ones(odim, 1); % this is used frequently |
|
| 74 |
+ |
|
| 75 |
+% training length |
|
| 76 |
+train_len = epochs*noc; |
|
| 77 |
+ |
|
| 78 |
+% random sample order |
|
| 79 |
+rand('state',sum(100*clock));
|
|
| 80 |
+sample_inds = ceil(noc*rand(train_len,1)); |
|
| 81 |
+ |
|
| 82 |
+% mutual distances |
|
| 83 |
+if nargin<4 | isempty(Mdist) | all(isnan(Mdist(:))), |
|
| 84 |
+ fprintf(2, 'computing mutual distances\r'); |
|
| 85 |
+ dim_x_1 = ones(dim,1); |
|
| 86 |
+ for i = 1:noc, |
|
| 87 |
+ x = D(i,:); |
|
| 88 |
+ Diff = D - x(noc_x_1,:); |
|
| 89 |
+ N = isnan(Diff); |
|
| 90 |
+ Diff(find(N)) = 0; |
|
| 91 |
+ Mdist(:,i) = sqrt((Diff.^2)*dim_x_1); |
|
| 92 |
+ N = find(sum(N')==dim); %mutual distance unknown |
|
| 93 |
+ if ~isempty(N), Mdist(N,i) = NaN; end |
|
| 94 |
+ end |
|
| 95 |
+else |
|
| 96 |
+ % if the distance matrix is output from PDIST function |
|
| 97 |
+ if size(Mdist,1)==1, Mdist = squareform(Mdist); end |
|
| 98 |
+ if size(Mdist,1)~=noc, |
|
| 99 |
+ error('Mutual distance matrix size and data set size do not match');
|
|
| 100 |
+ end |
|
| 101 |
+end |
|
| 102 |
+ |
|
| 103 |
+% alpha and lambda |
|
| 104 |
+if nargin<5 | isempty(alpha0) | isnan(alpha0), alpha0 = 0.5; end |
|
| 105 |
+alpha = potency_curve(alpha0,alpha0/100,train_len); |
|
| 106 |
+ |
|
| 107 |
+if nargin<6 | isempty(lambda0) | isnan(lambda0), lambda0 = max(st)*3; end |
|
| 108 |
+lambda = potency_curve(lambda0,0.01,train_len); |
|
| 109 |
+ |
|
| 110 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 111 |
+%% Action |
|
| 112 |
+ |
|
| 113 |
+k=0; fprintf(2, 'iterating: %d / %d epochs\r',k,epochs); |
|
| 114 |
+ |
|
| 115 |
+for i=1:train_len, |
|
| 116 |
+ |
|
| 117 |
+ ind = sample_inds(i); % sample index |
|
| 118 |
+ dx = Mdist(:,ind); % mutual distances in input space |
|
| 119 |
+ known = find(~isnan(dx)); % known distances |
|
| 120 |
+ |
|
| 121 |
+ if ~isempty(known), |
|
| 122 |
+ % sample vector's projection |
|
| 123 |
+ y = P(ind,:); |
|
| 124 |
+ |
|
| 125 |
+ % distances in output space |
|
| 126 |
+ Dy = P(known,:) - y(noc_x_1(known),:); |
|
| 127 |
+ dy = sqrt((Dy.^2)*odim_x_1); |
|
| 128 |
+ |
|
| 129 |
+ % relative effect |
|
| 130 |
+ dy(find(dy==0)) = 1; % to get rid of div-by-zero's |
|
| 131 |
+ fy = exp(-dy/lambda(i)) .* (dx(known) ./ dy - 1); |
|
| 132 |
+ |
|
| 133 |
+ % Note that the function F here is e^(-dy/lambda)) |
|
| 134 |
+ % instead of the bubble function 1(lambda-dy) used in the |
|
| 135 |
+ % paper. |
|
| 136 |
+ |
|
| 137 |
+ % Note that here a simplification has been made: the derivatives of the |
|
| 138 |
+ % F function have been ignored in calculating the gradient of error |
|
| 139 |
+ % function w.r.t. to changes in dy. |
|
| 140 |
+ |
|
| 141 |
+ % update |
|
| 142 |
+ P(known,:) = P(known,:) + alpha(i)*fy(:,odim_x_1).*Dy; |
|
| 143 |
+ end |
|
| 144 |
+ |
|
| 145 |
+ % track |
|
| 146 |
+ if rem(i,noc)==0, |
|
| 147 |
+ k=k+1; fprintf(2, 'iterating: %d / %d epochs\r',k,epochs); |
|
| 148 |
+ end |
|
| 149 |
+ |
|
| 150 |
+end |
|
| 151 |
+ |
|
| 152 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 153 |
+%% clear up |
|
| 154 |
+ |
|
| 155 |
+% calculate error |
|
| 156 |
+error = cca_error(P,Mdist,lambda(train_len)); |
|
| 157 |
+fprintf(2,'%d iterations, error %f \n', epochs, error); |
|
| 158 |
+ |
|
| 159 |
+% set projections of totally unknown vectors as unknown |
|
| 160 |
+unknown = find(sum(isnan(D)')==dim); |
|
| 161 |
+P(unknown,:) = NaN; |
|
| 162 |
+ |
|
| 163 |
+return; |
|
| 164 |
+ |
|
| 165 |
+ |
|
| 166 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 167 |
+%% tips |
|
| 168 |
+ |
|
| 169 |
+% to plot the results, use the code below |
|
| 170 |
+ |
|
| 171 |
+%subplot(2,1,1), |
|
| 172 |
+%switch(odim), |
|
| 173 |
+% case 1, plot(P(:,1),ones(dlen,1),'x') |
|
| 174 |
+% case 2, plot(P(:,1),P(:,2),'x'); |
|
| 175 |
+% otherwise, plot3(P(:,1),P(:,2),P(:,3),'x'); rotate3d on |
|
| 176 |
+%end |
|
| 177 |
+%subplot(2,1,2), dydxplot(P,Mdist); |
|
| 178 |
+ |
|
| 179 |
+% to a project a new point x in the input space to the output space |
|
| 180 |
+% do the following: |
|
| 181 |
+ |
|
| 182 |
+% Diff = D - x(noc_x_1,:); Diff(find(isnan(Diff))) = 0; |
|
| 183 |
+% dx = sqrt((Diff.^2)*dim_x_1); |
|
| 184 |
+% p = project_point(P,x,dx); % this function can be found from below |
|
| 185 |
+% tlen = size(p,1); |
|
| 186 |
+% plot(P(:,1),P(:,2),'bx',p(tlen,1),p(tlen,2),'ro',p(:,1),p(:,2),'r-') |
|
| 187 |
+ |
|
| 188 |
+% similar trick can be made to the other direction |
|
| 189 |
+ |
|
| 190 |
+ |
|
| 191 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 192 |
+%% subfunctions |
|
| 193 |
+ |
|
| 194 |
+function vals = potency_curve(v0,vn,l) |
|
| 195 |
+ |
|
| 196 |
+ % curve that decreases from v0 to vn with a rate that is |
|
| 197 |
+ % somewhere between linear and 1/t |
|
| 198 |
+ vals = v0 * (vn/v0).^([0:(l-1)]/(l-1)); |
|
| 199 |
+ |
|
| 200 |
+ |
|
| 201 |
+function error = cca_error(P,Mdist,lambda) |
|
| 202 |
+ |
|
| 203 |
+ [noc odim] = size(P); |
|
| 204 |
+ noc_x_1 = ones(noc,1); |
|
| 205 |
+ odim_x_1 = ones(odim,1); |
|
| 206 |
+ |
|
| 207 |
+ error = 0; |
|
| 208 |
+ for i=1:noc, |
|
| 209 |
+ known = find(~isnan(Mdist(:,i))); |
|
| 210 |
+ if ~isempty(known), |
|
| 211 |
+ y = P(i,:); |
|
| 212 |
+ Dy = P(known,:) - y(noc_x_1(known),:); |
|
| 213 |
+ dy = sqrt((Dy.^2)*odim_x_1); |
|
| 214 |
+ fy = exp(-dy/lambda); |
|
| 215 |
+ error = error + sum(((Mdist(known,i) - dy).^2).*fy); |
|
| 216 |
+ end |
|
| 217 |
+ end |
|
| 218 |
+ error = error/2; |
|
| 219 |
+ |
|
| 220 |
+ |
|
| 221 |
+function [] = dydxplot(P,Mdist) |
|
| 222 |
+ |
|
| 223 |
+ [noc odim] = size(P); |
|
| 224 |
+ noc_x_1 = ones(noc,1); |
|
| 225 |
+ odim_x_1 = ones(odim,1); |
|
| 226 |
+ Pdist = zeros(noc,noc); |
|
| 227 |
+ |
|
| 228 |
+ for i=1:noc, |
|
| 229 |
+ y = P(i,:); |
|
| 230 |
+ Dy = P - y(noc_x_1,:); |
|
| 231 |
+ Pdist(:,i) = sqrt((Dy.^2)*odim_x_1); |
|
| 232 |
+ end |
|
| 233 |
+ |
|
| 234 |
+ Pdist = tril(Pdist,-1); |
|
| 235 |
+ inds = find(Pdist > 0); |
|
| 236 |
+ n = length(inds); |
|
| 237 |
+ plot(Pdist(inds),Mdist(inds),'.'); |
|
| 238 |
+ xlabel('dy'), ylabel('dx')
|
|
| 239 |
+ |
|
| 240 |
+ |
|
| 241 |
+function p = project_point(P,x,dx) |
|
| 242 |
+ |
|
| 243 |
+ [noc odim] = size(P); |
|
| 244 |
+ noc_x_1 = ones(noc,1); |
|
| 245 |
+ odim_x_1 = ones(odim,1); |
|
| 246 |
+ |
|
| 247 |
+ % initial projection |
|
| 248 |
+ [dummy,i] = min(dx); |
|
| 249 |
+ y = P(i,:)+rand(1,odim)*norm(P(i,:))/20; |
|
| 250 |
+ |
|
| 251 |
+ % lambda |
|
| 252 |
+ lambda = norm(std(P)); |
|
| 253 |
+ |
|
| 254 |
+ % termination |
|
| 255 |
+ eps = 1e-3; i_max = noc*10; |
|
| 256 |
+ |
|
| 257 |
+ i=1; p(i,:) = y; |
|
| 258 |
+ ready = 0; |
|
| 259 |
+ while ~ready, |
|
| 260 |
+ |
|
| 261 |
+ % mutual distances |
|
| 262 |
+ Dy = P - y(noc_x_1,:); % differences in output space |
|
| 263 |
+ dy = sqrt((Dy.^2)*odim_x_1); % distances in output space |
|
| 264 |
+ f = exp(-dy/lambda); |
|
| 265 |
+ |
|
| 266 |
+ fprintf(2,'iteration %d, error %g \r',i,sum(((dx - dy).^2).*f)); |
|
| 267 |
+ |
|
| 268 |
+ % all the other vectors push the projected one |
|
| 269 |
+ fy = f .* (dx ./ dy - 1) / sum(f); |
|
| 270 |
+ |
|
| 271 |
+ % update |
|
| 272 |
+ step = - sum(fy(:,odim_x_1).*Dy); |
|
| 273 |
+ y = y + step; |
|
| 274 |
+ |
|
| 275 |
+ i=i+1; |
|
| 276 |
+ p(i,:) = y; |
|
| 277 |
+ ready = (norm(step)/norm(y) < eps | i > i_max); |
|
| 278 |
+ |
|
| 279 |
+ end |
|
| 280 |
+ fprintf(2,'\n'); |
|
| 281 |
+ |
|
| 282 |
+ |
|
| 0 | 283 |
\ No newline at end of file |
| ... | ... |
@@ -0,0 +1,83 @@ |
| 1 |
+function [t,r] = db_index(D, cl, C, p, q) |
|
| 2 |
+ |
|
| 3 |
+% DB_INDEX Davies-Bouldin clustering evaluation index. |
|
| 4 |
+% |
|
| 5 |
+% [t,r] = db_index(D, cl, C, p, q) |
|
| 6 |
+% |
|
| 7 |
+% Input and output arguments ([]'s are optional): |
|
| 8 |
+% D (matrix) data (n x dim) |
|
| 9 |
+% (struct) map or data struct |
|
| 10 |
+% cl (vector) cluster numbers corresponding to data samples (n x 1) |
|
| 11 |
+% [C] (matrix) prototype vectors (c x dim) (default = cluster means) |
|
| 12 |
+% [p] (scalar) norm used in the computation (default == 2) |
|
| 13 |
+% [q] (scalar) moment used to calculate cluster dispersions (default = 2) |
|
| 14 |
+% |
|
| 15 |
+% t (scalar) Davies-Bouldin index for the clustering (=mean(r)) |
|
| 16 |
+% r (vector) maximum DB index for each cluster (size c x 1) |
|
| 17 |
+% |
|
| 18 |
+% See also KMEANS, KMEANS_CLUSTERS, SOM_GAPINDEX. |
|
| 19 |
+ |
|
| 20 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 21 |
+%% input arguments |
|
| 22 |
+ |
|
| 23 |
+if isstruct(D), |
|
| 24 |
+ switch D.type, |
|
| 25 |
+ case 'som_map', D = D.codebook; |
|
| 26 |
+ case 'som_data', D = D.data; |
|
| 27 |
+ end |
|
| 28 |
+end |
|
| 29 |
+ |
|
| 30 |
+% cluster centroids |
|
| 31 |
+[l dim] = size(D); |
|
| 32 |
+u = unique(cl); |
|
| 33 |
+c = length(u); |
|
| 34 |
+if nargin <3, |
|
| 35 |
+ C = zeros(c,dim); |
|
| 36 |
+ for i=1:c, |
|
| 37 |
+ me = nanstats(D(find(cl==u(i)),:)); |
|
| 38 |
+ C(i,:) = me'; |
|
| 39 |
+ end |
|
| 40 |
+end |
|
| 41 |
+ |
|
| 42 |
+u2i = zeros(max(u),1); u2i(u) = 1:c; |
|
| 43 |
+D = som_fillnans(D,C,u2i(cl)); % replace NaN's with cluster centroid values |
|
| 44 |
+ |
|
| 45 |
+if nargin <4, p = 2; end % euclidian distance between cluster centers |
|
| 46 |
+if nargin <5, q = 2; end % dispersion = standard deviation |
|
| 47 |
+ |
|
| 48 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 49 |
+%% action |
|
| 50 |
+ |
|
| 51 |
+% dispersion in each cluster |
|
| 52 |
+for i = 1:c |
|
| 53 |
+ ind = find(cl==u(i)); % points in this cluster |
|
| 54 |
+ l = length(ind); |
|
| 55 |
+ if l > 0 |
|
| 56 |
+ S(i) = (mean(sqrt(sum((D(ind,:) - ones(l,1) * C(i,:)).^2,2)).^q))^(1/q); |
|
| 57 |
+ else |
|
| 58 |
+ S(i) = NaN; |
|
| 59 |
+ end |
|
| 60 |
+end |
|
| 61 |
+ |
|
| 62 |
+% distances between clusters |
|
| 63 |
+%for i = 1:c |
|
| 64 |
+% for j = i+1:c |
|
| 65 |
+% M(i,j) = sum(abs(C(i,:) - C(j,:)).^p)^(1/p); |
|
| 66 |
+% end |
|
| 67 |
+%end |
|
| 68 |
+M = som_mdist(C,p); |
|
| 69 |
+ |
|
| 70 |
+% Davies-Bouldin index |
|
| 71 |
+R = NaN * zeros(c); |
|
| 72 |
+r = NaN * zeros(c,1); |
|
| 73 |
+for i = 1:c |
|
| 74 |
+ for j = i+1:c |
|
| 75 |
+ R(i,j) = (S(i) + S(j))/M(i,j); |
|
| 76 |
+ end |
|
| 77 |
+ r(i) = max(R(i,:)); |
|
| 78 |
+end |
|
| 79 |
+ |
|
| 80 |
+t = mean(r(isfinite(r))); |
|
| 81 |
+ |
|
| 82 |
+return; |
|
| 83 |
+ |
| ... | ... |
@@ -0,0 +1,53 @@ |
| 1 |
+function [hits,ninvalid] = hits(bmus, mmax, values) |
|
| 2 |
+ |
|
| 3 |
+%HITS Calculate number of occurances of each value. |
|
| 4 |
+% |
|
| 5 |
+% hits = hits(bmus,[mmax],[values]) |
|
| 6 |
+% |
|
| 7 |
+% h = hits(bmus); |
|
| 8 |
+% h = hits(bmus,length(sM.codebook)); |
|
| 9 |
+% |
|
| 10 |
+% Input and output arguments ([]'s are optional): |
|
| 11 |
+% bmus (vector) BMU indeces (or other similar) |
|
| 12 |
+% [mmax] (scalar) maximum index, default value max(bmus) |
|
| 13 |
+% (struct) map or topology struct from where the maximum |
|
| 14 |
+% index is acquired |
|
| 15 |
+% [values] (vector) values associated with the data (default = 1) |
|
| 16 |
+% |
|
| 17 |
+% hits (vector) the number of occurances of each index |
|
| 18 |
+% (or if values are given, their sum for each index) |
|
| 19 |
+% ninvalid (scalar) number of invalid indeces (NaN, Inf or |
|
| 20 |
+% <=0 or > mmax) |
|
| 21 |
+% |
|
| 22 |
+% See also SOM_HITS, SOM_BMUS. |
|
| 23 |
+ |
|
| 24 |
+% Copyright (c) 2002 by the SOM toolbox programming team. |
|
| 25 |
+% Contributed to SOM Toolbox by Juha Vesanto, April 24th, 2002 |
|
| 26 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 27 |
+ |
|
| 28 |
+% Version 2.0beta juuso 240402 |
|
| 29 |
+ |
|
| 30 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 31 |
+ |
|
| 32 |
+if nargin<2 | isempty(mmax), |
|
| 33 |
+ mmax = max(bmus); |
|
| 34 |
+elseif isstruct(mmax), |
|
| 35 |
+ switch mmax.type, |
|
| 36 |
+ case 'som_map', mmax = prod(mmax.topol.msize); |
|
| 37 |
+ case 'som_topol', mmax = prod(mmax.msize); |
|
| 38 |
+ otherwise, |
|
| 39 |
+ error('Illegal struct for 2nd argument.')
|
|
| 40 |
+ end |
|
| 41 |
+end |
|
| 42 |
+ |
|
| 43 |
+if nargin<3, values = 1; end |
|
| 44 |
+ |
|
| 45 |
+valid_bmus = find(isfinite(bmus) & bmus>0 & bmus<=mmax); |
|
| 46 |
+ninvalid = length(bmus)-length(valid_bmus); |
|
| 47 |
+ |
|
| 48 |
+bmus = bmus(valid_bmus); |
|
| 49 |
+if length(values)>length(bmus), values = values(valid_bmus); end |
|
| 50 |
+hits = full(sum(sparse(bmus,1:length(bmus),values,mmax,length(bmus)),2)); |
|
| 51 |
+ |
|
| 52 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 53 |
+ |
| ... | ... |
@@ -0,0 +1,120 @@ |
| 1 |
+function [centers,clusters,errors,ind] = kmeans_clusters(sD, n_max, c_max, verbose) |
|
| 2 |
+ |
|
| 3 |
+% KMEANS_CLUSTERS Clustering with k-means with different values for k. |
|
| 4 |
+% |
|
| 5 |
+% [c, p, err, ind] = kmeans_clusters(sD, [n_max], [c_max], [verbose]) |
|
| 6 |
+% |
|
| 7 |
+% [c, p, err, ind] = kmeans_clusters(sD); |
|
| 8 |
+% |
|
| 9 |
+% Input and output arguments ([]'s are optional): |
|
| 10 |
+% D (struct) map or data struct |
|
| 11 |
+% (matrix) size dlen x dim, the data |
|
| 12 |
+% [n_max] (scalar) maximum number of clusters, default is sqrt(dlen) |
|
| 13 |
+% [c_max] (scalar) maximum number of k-means runs, default is 5 |
|
| 14 |
+% [verbose] (scalar) verbose level, 0 by default |
|
| 15 |
+% |
|
| 16 |
+% c (cell array) c{i} contains cluster centroids for k=i
|
|
| 17 |
+% p (cell array) p{i} contains cluster indeces for k=i
|
|
| 18 |
+% err (vector) squared sum of errors for each value of k |
|
| 19 |
+% ind (vector) Davies-Bouldin index value for each clustering |
|
| 20 |
+% |
|
| 21 |
+% Makes a k-means to the given data set with different values of |
|
| 22 |
+% k. The k-means is run multiple times for each k, and the best of |
|
| 23 |
+% these is selected based on sum of squared errors. Finally, the |
|
| 24 |
+% Davies-Bouldin index is calculated for each clustering. |
|
| 25 |
+% |
|
| 26 |
+% For example to cluster a SOM: |
|
| 27 |
+% [c, p, err, ind] = kmeans_clusters(sM); % find clusterings |
|
| 28 |
+% [dummy,i] = min(ind); % select the one with smallest index |
|
| 29 |
+% som_show(sM,'color',{p{i},sprintf('%d clusters',i)}); % visualize
|
|
| 30 |
+% colormap(jet(i)), som_recolorbar % change colormap |
|
| 31 |
+% |
|
| 32 |
+% See also SOM_KMEANS. |
|
| 33 |
+ |
|
| 34 |
+% References: |
|
| 35 |
+% Jain, A.K., Dubes, R.C., "Algorithms for Clustering Data", |
|
| 36 |
+% Prentice Hall, 1988, pp. 96-101. |
|
| 37 |
+% |
|
| 38 |
+% Davies, D.L., Bouldin, D.W., "A Cluster Separation Measure", |
|
| 39 |
+% IEEE Transactions on Pattern Analysis and Machine Intelligence, |
|
| 40 |
+% vol. PAMI-1, no. 2, 1979, pp. 224-227. |
|
| 41 |
+% |
|
| 42 |
+% Vesanto, J., Alhoniemi, E., "Clustering of the Self-Organizing |
|
| 43 |
+% Map", IEEE Transactions on Neural Networks, 2000. |
|
| 44 |
+ |
|
| 45 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Esa Alhoniemi |
|
| 46 |
+% Copyright (c) by Esa Alhoniemi |
|
| 47 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 48 |
+ |
|
| 49 |
+% ecco 301299 juuso 020200 211201 |
|
| 50 |
+ |
|
| 51 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 52 |
+%% input arguments and initialization |
|
| 53 |
+ |
|
| 54 |
+if isstruct(sD), |
|
| 55 |
+ if isfield(sD,'data'), D = sD.data; |
|
| 56 |
+ else D = sD.codebook; |
|
| 57 |
+ end |
|
| 58 |
+else D = sD; |
|
| 59 |
+end |
|
| 60 |
+[dlen dim] = size(D); |
|
| 61 |
+ |
|
| 62 |
+if nargin < 2 | isempty(n_max) | isnan(n_max), n_max = ceil(sqrt(dlen)); end |
|
| 63 |
+if nargin < 3 | isempty(c_max) | isnan(c_max), c_max = 5; end |
|
| 64 |
+if nargin < 4 | isempty(verbose) | isnan(verbose), verbose = 0; end |
|
| 65 |
+ |
|
| 66 |
+centers = cell(n_max,1); |
|
| 67 |
+clusters = cell(n_max,1); |
|
| 68 |
+ind = zeros(1,n_max)+NaN; |
|
| 69 |
+errors = zeros(1,n_max)+NaN; |
|
| 70 |
+ |
|
| 71 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 72 |
+%% action |
|
| 73 |
+ |
|
| 74 |
+% the case k=1 is trivial, but Davies-Boulding index cannot be evaluated |
|
| 75 |
+m = zeros(1,dim); |
|
| 76 |
+for i=1:dim, m(i)=mean(D(isfinite(D(:,i)),i)); end |
|
| 77 |
+centers{1} = m;
|
|
| 78 |
+clusters{1} = ones(dlen,1);
|
|
| 79 |
+[dummy qerr] = som_bmus(m,D); |
|
| 80 |
+errors(1) = sum(qerr.^2); |
|
| 81 |
+ind(1) = NaN; |
|
| 82 |
+ |
|
| 83 |
+if verbose, fprintf(2,'Doing k-means for 2-%d clusters\n',n_max); end |
|
| 84 |
+ |
|
| 85 |
+for i = 2:n_max, % number of clusters |
|
| 86 |
+ |
|
| 87 |
+ % make k-means with k=i for c_max times and select the best based |
|
| 88 |
+ % on sum-of-squared errors (SSE) |
|
| 89 |
+ best = realmax; |
|
| 90 |
+ for j = 1:c_max % run number j for cluster i |
|
| 91 |
+ if verbose, |
|
| 92 |
+ fprintf('%d/%d clusters, k-means run %d/%d\r', i, n_max,j, c_max);
|
|
| 93 |
+ end |
|
| 94 |
+ [c, k, err] = som_kmeans('batch', D, i, 100, 0);
|
|
| 95 |
+ if err < best, k_best = k'; c_best = c; best = err; end |
|
| 96 |
+ % ' added in k_best = k'; by kr 1.10.02 |
|
| 97 |
+ end |
|
| 98 |
+ if verbose, fprintf(1, '\n'); end |
|
| 99 |
+ |
|
| 100 |
+ % store the results |
|
| 101 |
+ centers{i} = c_best;
|
|
| 102 |
+ clusters{i} = k_best;
|
|
| 103 |
+ errors(i) = best; |
|
| 104 |
+% ind(i) = db_index(D, c_best, k_best, 2); wrong version in somtbx ?? |
|
| 105 |
+ ind(i) = db_index(D, k_best, c_best, 2); % modified by kr 1.10.02 |
|
| 106 |
+ |
|
| 107 |
+ % if verbose mode, plot the index & SSE |
|
| 108 |
+ if verbose |
|
| 109 |
+ subplot(2,1,1), plot(ind), grid |
|
| 110 |
+ title('Davies-Bouldin''s index')
|
|
| 111 |
+ subplot(2,1,2), plot(errors), grid |
|
| 112 |
+ title('SSE')
|
|
| 113 |
+ drawnow |
|
| 114 |
+ end |
|
| 115 |
+end |
|
| 116 |
+ |
|
| 117 |
+return; |
|
| 118 |
+ |
|
| 119 |
+ |
|
| 120 |
+ |
| ... | ... |
@@ -0,0 +1,158 @@ |
| 1 |
+function [C,P]=knn(d, Cp, K) |
|
| 2 |
+ |
|
| 3 |
+%KNN K-Nearest Neighbor classifier using an arbitrary distance matrix |
|
| 4 |
+% |
|
| 5 |
+% [C,P]=knn(d, Cp, [K]) |
|
| 6 |
+% |
|
| 7 |
+% Input and output arguments ([]'s are optional): |
|
| 8 |
+% d (matrix) of size NxP: This is a precalculated dissimilarity (distance matrix). |
|
| 9 |
+% P is the number of prototype vectors and N is the number of data vectors |
|
| 10 |
+% That is, d(i,j) is the distance between data item i and prototype j. |
|
| 11 |
+% Cp (vector) of size Px1 that contains integer class labels. Cp(j) is the class of |
|
| 12 |
+% jth prototype. |
|
| 13 |
+% [K] (scalar) the maximum K in K-NN classifier, default is 1 |
|
| 14 |
+% C (matrix) of size NxK: integers indicating the class |
|
| 15 |
+% decision for data items according to the K-NN rule for each K. |
|
| 16 |
+% C(i,K) is the classification for data item i using the K-NN rule |
|
| 17 |
+% P (matrix) of size NxkxK: the relative amount of prototypes of |
|
| 18 |
+% each class among the K closest prototypes for each classifiee. |
|
| 19 |
+% That is, P(i,j,K) is the relative amount of prototypes of class j |
|
| 20 |
+% among K nearest prototypes for data item i. |
|
| 21 |
+% |
|
| 22 |
+% If there is a tie between representatives of two or more classes |
|
| 23 |
+% among the K closest neighbors to the classifiee, the class i selected randomly |
|
| 24 |
+% among these candidates. |
|
| 25 |
+% |
|
| 26 |
+% IMPORTANT If K>1 this function uses 'sort' which is considerably slower than |
|
| 27 |
+% 'max' which is used for K=1. If K>1 the knn always calculates |
|
| 28 |
+% results for all K-NN models from 1-NN up to K-NN. |
|
| 29 |
+% |
|
| 30 |
+% EXAMPLE 1 |
|
| 31 |
+% |
|
| 32 |
+% sP; % a SOM Toolbox data struct containing labeled prototype vectors |
|
| 33 |
+% [Cp,label]=som_label2num(sP); % get integer class labels for prototype vectors |
|
| 34 |
+% sD; % a SOM Toolbox data struct containing vectors to be classified |
|
| 35 |
+% d=som_eucdist2(sD,sP); % calculate euclidean distance matrix |
|
| 36 |
+% class=knn(d,Cp,10); % classify using 1,2,...,10-rules |
|
| 37 |
+% class(:,5); % includes results for 5NN |
|
| 38 |
+% label(class(:,5)) % original class labels for 5NN |
|
| 39 |
+% |
|
| 40 |
+% EXAMPLE 2 (leave-one-out-crossvalidate KNN for selection of proper K) |
|
| 41 |
+% |
|
| 42 |
+% P; % a data matrix of prototype vectors (rows) |
|
| 43 |
+% Cp; % column vector of integer class labels for vectors in P |
|
| 44 |
+% d=som_eucdist2(P,P); % calculate euclidean distance matrix PxP |
|
| 45 |
+% d(eye(size(d))==1)=NaN; % set self-dissimilarity to NaN: |
|
| 46 |
+% % this drops the prototype itself away from its neighborhood |
|
| 47 |
+% % leave-one-out-crossvalidation (LOOCV) |
|
| 48 |
+% class=knn(d,Cp,size(P,1)); % classify using all possible K |
|
| 49 |
+% % calculate and plot LOOC-validated errors for all K |
|
| 50 |
+% failratep = ... |
|
| 51 |
+% 100*sum((class~=repmat(Cp,1,size(P,1))))./size(P,1); plot(1:size(P,1),failratep) |
|
| 52 |
+ |
|
| 53 |
+% See also SOM_LABEL2NUM, SOM_EUCDIST2, PDIST. |
|
| 54 |
+% |
|
| 55 |
+% Contributed to SOM Toolbox 2.0, October 29th, 2000 by Johan Himberg |
|
| 56 |
+% Copyright (c) by Johan Himberg |
|
| 57 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 58 |
+ |
|
| 59 |
+% Version 2.0beta Johan 291000 |
|
| 60 |
+ |
|
| 61 |
+%% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 62 |
+ |
|
| 63 |
+% Check K |
|
| 64 |
+if nargin<3 | isempty(K), |
|
| 65 |
+ K=1; |
|
| 66 |
+end |
|
| 67 |
+ |
|
| 68 |
+if ~vis_valuetype(K,{'1x1'})
|
|
| 69 |
+ error('Value for K must be a scalar');
|
|
| 70 |
+end |
|
| 71 |
+ |
|
| 72 |
+% Check that dist is a matrix |
|
| 73 |
+if ~vis_valuetype(d,{'nxm'}),
|
|
| 74 |
+ error('Distance matrix not valid.')
|
|
| 75 |
+end |
|
| 76 |
+ |
|
| 77 |
+[N_data N_proto]=size(d); |
|
| 78 |
+ |
|
| 79 |
+% Check class label vector: must be numerical and of integers |
|
| 80 |
+if ~vis_valuetype(Cp,{[N_proto 1]});
|
|
| 81 |
+ error(['Class vector is invalid: has to be a N-of-data_rows x 1' ... |
|
| 82 |
+ ' vector of integers']); |
|
| 83 |
+elseif sum(fix(Cp)-Cp)~=0 |
|
| 84 |
+ error('Class labels in vector ''Cp'' must be integers.');
|
|
| 85 |
+end |
|
| 86 |
+ |
|
| 87 |
+if size(d,2) ~= length(Cp), |
|
| 88 |
+ error('Distance matrix and prototype class vector dimensions do not match.');
|
|
| 89 |
+end |
|
| 90 |
+ |
|
| 91 |
+% Check if the classes are given as labels (no class input arg.) |
|
| 92 |
+% if they are take them from prototype struct |
|
| 93 |
+ |
|
| 94 |
+% Find all class labels |
|
| 95 |
+ClassIndex=unique(Cp); |
|
| 96 |
+N_class=length(ClassIndex); % number of different classes |
|
| 97 |
+ |
|
| 98 |
+ |
|
| 99 |
+%%%% Classification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 100 |
+ |
|
| 101 |
+if K==1, % sort distances only if K>1 |
|
| 102 |
+ |
|
| 103 |
+ % 1NN |
|
| 104 |
+ % Select the closest prototype |
|
| 105 |
+ [tmp,proto_index]=min(d,[],2); |
|
| 106 |
+ C=Cp(proto_index); |
|
| 107 |
+ |
|
| 108 |
+else |
|
| 109 |
+ |
|
| 110 |
+ % Sort the prototypes for each classifiee according to distance |
|
| 111 |
+ [tmp, proto_index]=sort(d'); |
|
| 112 |
+ |
|
| 113 |
+ %% Select up to K closest prototypes |
|
| 114 |
+ proto_index=proto_index(1:K,:); |
|
| 115 |
+ knn_class=Cp(proto_index); |
|
| 116 |
+ for i=1:N_class, |
|
| 117 |
+ classcounter(:,:,i)=cumsum(knn_class==ClassIndex(i)); |
|
| 118 |
+ end |
|
| 119 |
+ |
|
| 120 |
+ %% Vote between classes of K neighbors |
|
| 121 |
+ [winner,vote_index]=max(classcounter,[],3); |
|
| 122 |
+ |
|
| 123 |
+ %%% Handle ties |
|
| 124 |
+ |
|
| 125 |
+ % Set index to classes that got as much votes as winner |
|
| 126 |
+ |
|
| 127 |
+ equal_to_winner=(repmat(winner,[1 1 N_class])==classcounter); |
|
| 128 |
+ |
|
| 129 |
+ % set index to ties |
|
| 130 |
+ [tie_indexi,tie_indexj]=find(sum(equal_to_winner,3)>1); % drop the winner from counter |
|
| 131 |
+ |
|
| 132 |
+ % Go through tie cases and reset vote_index randomly to one |
|
| 133 |
+ % of them |
|
| 134 |
+ |
|
| 135 |
+ for i=1:length(tie_indexi), |
|
| 136 |
+ tie_class_index=find(squeeze(equal_to_winner(tie_indexi(i),tie_indexj(i),:))); |
|
| 137 |
+ fortuna=randperm(length(tie_class_index)); |
|
| 138 |
+ vote_index(tie_indexi(i),tie_indexj(i))=tie_class_index(fortuna(1)); |
|
| 139 |
+ end |
|
| 140 |
+ |
|
| 141 |
+ C=ClassIndex(vote_index)'; |
|
| 142 |
+end |
|
| 143 |
+ |
|
| 144 |
+%% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 145 |
+ |
|
| 146 |
+% Relative amount of classes in K neighbors for each classifiee |
|
| 147 |
+ |
|
| 148 |
+if K==1, |
|
| 149 |
+ P=zeros(N_data,N_class); |
|
| 150 |
+ if nargout>1, |
|
| 151 |
+ for i=1:N_data, |
|
| 152 |
+ P(i,ClassIndex==C(i))=1; |
|
| 153 |
+ end |
|
| 154 |
+ end |
|
| 155 |
+else |
|
| 156 |
+ P=shiftdim(classcounter,1)./repmat(shiftdim(1:K,-1), [N_data N_class 1]); |
|
| 157 |
+end |
|
| 158 |
+ |
| ... | ... |
@@ -0,0 +1,251 @@ |
| 1 |
+function [Class,P]=knn_old(Data, Proto, proto_class, K) |
|
| 2 |
+ |
|
| 3 |
+%KNN_OLD A K-nearest neighbor classifier using Euclidean distance |
|
| 4 |
+% |
|
| 5 |
+% [Class,P]=knn_old(Data, Proto, proto_class, K) |
|
| 6 |
+% |
|
| 7 |
+% [sM_class,P]=knn_old(sM, sData, [], 3); |
|
| 8 |
+% [sD_class,P]=knn_old(sD, sM, class); |
|
| 9 |
+% [class,P]=knn_old(data, proto, class); |
|
| 10 |
+% [class,P]=knn_old(sData, sM, class,5); |
|
| 11 |
+% |
|
| 12 |
+% Input and output arguments ([]'s are optional): |
|
| 13 |
+% Data (matrix) size Nxd, vectors to be classified (=classifiees) |
|
| 14 |
+% (struct) map or data struct: map codebook vectors or |
|
| 15 |
+% data vectors are considered as classifiees. |
|
| 16 |
+% Proto (matrix) size Mxd, prototype vector matrix (=prototypes) |
|
| 17 |
+% (struct) map or data struct: map codebook vectors or |
|
| 18 |
+% data vectors are considered as prototypes. |
|
| 19 |
+% [proto_class] (vector) size Nx1, integers 1,2,...,k indicating the |
|
| 20 |
+% classes of corresponding protoptypes, default: see the |
|
| 21 |
+% explanation below. |
|
| 22 |
+% [K] (scalar) the K in KNN classifier, default is 1 |
|
| 23 |
+% |
|
| 24 |
+% Class (matrix) size Nx1, vector of 1,2, ..., k indicating the class |
|
| 25 |
+% desicion according to the KNN rule |
|
| 26 |
+% P (matrix) size Nxk, the relative amount of prototypes of |
|
| 27 |
+% each class among the K closest prototypes for |
|
| 28 |
+% each classifiee. |
|
| 29 |
+% |
|
| 30 |
+% If 'proto_class' is _not_ given, 'Proto' _must_ be a labeled SOM |
|
| 31 |
+% Toolbox struct. The label of the data vector or the first label of |
|
| 32 |
+% the map model vector is considered as class label for th prototype |
|
| 33 |
+% vector. In this case the output 'Class' is a copy of 'Data' (map or |
|
| 34 |
+% data struct) relabeled according to the classification. If input |
|
| 35 |
+% argument 'proto_class' _is_ given, the output argument 'Class' is |
|
| 36 |
+% _always_ a vector of integers 1,2,...,k indiacating the class. |
|
| 37 |
+% |
|
| 38 |
+% If there is a tie between representatives of two or more classes |
|
| 39 |
+% among the K closest neighbors to the classifiee, the class is |
|
| 40 |
+% selected randomly among these candidates. |
|
| 41 |
+% |
|
| 42 |
+% IMPORTANT |
|
| 43 |
+% |
|
| 44 |
+% ** Even if prototype vectors are given in a map struct the mask _is not |
|
| 45 |
+% taken into account_ when calculating Euclidean distance |
|
| 46 |
+% ** The function calculates the total distance matrix between all |
|
| 47 |
+% classifiees and prototype vectors. This results to an MxN matrix; |
|
| 48 |
+% if N is high it is recommended to divide the matrix 'Data' |
|
| 49 |
+% (the classifiees) into smaller sets in order to avoid memory |
|
| 50 |
+% overflow or swapping. Also, if K>1 this function uses 'sort' which is |
|
| 51 |
+% considerably slower than 'max' which is used for K==1. |
|
| 52 |
+% |
|
| 53 |
+% See also KNN, SOM_LABEL, SOM_AUTOLABEL |
|
| 54 |
+ |
|
| 55 |
+% Contributed to SOM Toolbox 2.0, February 11th, 2000 by Johan Himberg |
|
| 56 |
+% Copyright (c) by Johan Himberg |
|
| 57 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 58 |
+ |
|
| 59 |
+% Version 2.0beta Johan 040200 |
|
| 60 |
+ |
|
| 61 |
+%% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 62 |
+% This must exist later |
|
| 63 |
+classnames=''; |
|
| 64 |
+ |
|
| 65 |
+% Check K |
|
| 66 |
+if nargin<4 | isempty(K), |
|
| 67 |
+ K=1; |
|
| 68 |
+end |
|
| 69 |
+ |
|
| 70 |
+if ~vis_valuetype(K,{'1x1'})
|
|
| 71 |
+ error('Value for K must be a scalar.');
|
|
| 72 |
+end |
|
| 73 |
+ |
|
| 74 |
+% Take data from data or map struct |
|
| 75 |
+ |
|
| 76 |
+if isstruct(Data); |
|
| 77 |
+ if isfield(Data,'type') & ischar(Data.type), |
|
| 78 |
+ ; |
|
| 79 |
+ else |
|
| 80 |
+ error('Invalid map/data struct?');
|
|
| 81 |
+ end |
|
| 82 |
+ switch Data.type |
|
| 83 |
+ case 'som_map' |
|
| 84 |
+ data=Data.codebook; |
|
| 85 |
+ case 'som_data' |
|
| 86 |
+ data=Data.data; |
|
| 87 |
+ end |
|
| 88 |
+else |
|
| 89 |
+ % is already a matrix |
|
| 90 |
+ data=Data; |
|
| 91 |
+end |
|
| 92 |
+ |
|
| 93 |
+% Take prototype vectors from prototype struct |
|
| 94 |
+ |
|
| 95 |
+if isstruct(Proto), |
|
| 96 |
+ |
|
| 97 |
+ if isfield(Proto,'type') & ischar(Proto.type), |
|
| 98 |
+ ; |
|
| 99 |
+ else |
|
| 100 |
+ error('Invalid map/data struct?');
|
|
| 101 |
+ end |
|
| 102 |
+ switch Proto.type |
|
| 103 |
+ case 'som_map' |
|
| 104 |
+ proto=Proto.codebook; |
|
| 105 |
+ case 'som_data' |
|
| 106 |
+ proto=Proto.data; |
|
| 107 |
+ end |
|
| 108 |
+else |
|
| 109 |
+ % is already a matrix |
|
| 110 |
+ proto=Proto; |
|
| 111 |
+end |
|
| 112 |
+ |
|
| 113 |
+% Check that inputs are matrices |
|
| 114 |
+if ~vis_valuetype(proto,{'nxm'}) | ~vis_valuetype(data,{'nxm'}),
|
|
| 115 |
+ error('Prototype or data input not valid.')
|
|
| 116 |
+end |
|
| 117 |
+ |
|
| 118 |
+% Record data&proto sizes and check their dims |
|
| 119 |
+[N_data dim_data]=size(data); |
|
| 120 |
+[N_proto dim_proto]=size(proto); |
|
| 121 |
+if dim_proto ~= dim_data, |
|
| 122 |
+ error('Data and prototype vector dimension does not match.');
|
|
| 123 |
+end |
|
| 124 |
+ |
|
| 125 |
+% Check if the classes are given as labels (no class input arg.) |
|
| 126 |
+% if they are take them from prototype struct |
|
| 127 |
+ |
|
| 128 |
+if nargin<3 | isempty(proto_class) |
|
| 129 |
+ if ~isstruct(Proto) |
|
| 130 |
+ error(['If prototypes are not in labeled map or data struct' ... |
|
| 131 |
+ 'class must be given.']); |
|
| 132 |
+ % transform to interger (numerical) class labels |
|
| 133 |
+ else |
|
| 134 |
+ [proto_class,classnames]=class2num(Proto.labels); |
|
| 135 |
+ end |
|
| 136 |
+end |
|
| 137 |
+ |
|
| 138 |
+% Check class label vector: must be numerical and of integers |
|
| 139 |
+if ~vis_valuetype(proto_class,{[N_proto 1]});
|
|
| 140 |
+ error(['Class vector is invalid: has to be a N-of-data_rows x 1' ... |
|
| 141 |
+ ' vector of integers']); |
|
| 142 |
+elseif sum(fix(proto_class)-proto_class)~=0 |
|
| 143 |
+ error('Class labels in vector ''Class'' must be integers.');
|
|
| 144 |
+end |
|
| 145 |
+ |
|
| 146 |
+% Find all class labels |
|
| 147 |
+ClassIndex=unique(proto_class); |
|
| 148 |
+N_class=length(ClassIndex); % number of different classes |
|
| 149 |
+ |
|
| 150 |
+% Calculate euclidean distances between classifiees and prototypes |
|
| 151 |
+d=distance(proto,data); |
|
| 152 |
+ |
|
| 153 |
+%%%% Classification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 154 |
+ |
|
| 155 |
+if K==1, % sort distances only if K>1 |
|
| 156 |
+ |
|
| 157 |
+ % 1NN |
|
| 158 |
+ % Select the closest prototype |
|
| 159 |
+ [tmp,proto_index]=min(d); |
|
| 160 |
+ class=proto_class(proto_index); |
|
| 161 |
+ |
|
| 162 |
+else |
|
| 163 |
+ |
|
| 164 |
+ % Sort the prototypes for each classifiee according to distance |
|
| 165 |
+ [tmp,proto_index]=sort(d); |
|
| 166 |
+ |
|
| 167 |
+ %% Select K closest prototypes |
|
| 168 |
+ proto_index=proto_index(1:K,:); |
|
| 169 |
+ knn_class=proto_class(proto_index); |
|
| 170 |
+ for i=1:N_class, |
|
| 171 |
+ classcounter(i,:)=sum(knn_class==ClassIndex(i)); |
|
| 172 |
+ end |
|
| 173 |
+ |
|
| 174 |
+ %% Vote between classes of K neighbors |
|
| 175 |
+ [winner,vote_index]=max(classcounter); |
|
| 176 |
+ |
|
| 177 |
+ %% Handle ties |
|
| 178 |
+ |
|
| 179 |
+ % set index to clases that got as amuch votes as winner |
|
| 180 |
+ |
|
| 181 |
+ equal_to_winner=(repmat(winner,N_class,1)==classcounter); |
|
| 182 |
+ |
|
| 183 |
+ % set index to ties |
|
| 184 |
+ tie_index=find(sum(equal_to_winner)>1); % drop the winner from counter |
|
| 185 |
+ |
|
| 186 |
+ % Go through equal classes and reset vote_index randomly to one |
|
| 187 |
+ % of them |
|
| 188 |
+ |
|
| 189 |
+ for i=1:length(tie_index), |
|
| 190 |
+ tie_class_index=find(equal_to_winner(:,tie_index(i))); |
|
| 191 |
+ fortuna=randperm(length(tie_class_index)); |
|
| 192 |
+ vote_index(tie_index(i))=tie_class_index(fortuna(1)); |
|
| 193 |
+ end |
|
| 194 |
+ |
|
| 195 |
+ class=ClassIndex(vote_index); |
|
| 196 |
+end |
|
| 197 |
+ |
|
| 198 |
+%% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 199 |
+ |
|
| 200 |
+% Relative amount of classes in K neighbors for each classifiee |
|
| 201 |
+ |
|
| 202 |
+if K==1, |
|
| 203 |
+ P=zeros(N_data,N_class); |
|
| 204 |
+ if nargout>1, |
|
| 205 |
+ for i=1:N_data, |
|
| 206 |
+ P(i,ClassIndex==class(i))=1; |
|
| 207 |
+ end |
|
| 208 |
+ end |
|
| 209 |
+else |
|
| 210 |
+ P=classcounter'./K; |
|
| 211 |
+end |
|
| 212 |
+ |
|
| 213 |
+% xMake class names to struct if they exist |
|
| 214 |
+if ~isempty(classnames), |
|
| 215 |
+ Class=Data; |
|
| 216 |
+ for i=1:N_data, |
|
| 217 |
+ Class.labels{i,1}=classnames{class(i)};
|
|
| 218 |
+ end |
|
| 219 |
+else |
|
| 220 |
+ Class=class; |
|
| 221 |
+end |
|
| 222 |
+ |
|
| 223 |
+ |
|
| 224 |
+%%% Subfunctions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 225 |
+ |
|
| 226 |
+function [nos,names] = class2num(class) |
|
| 227 |
+ |
|
| 228 |
+% Change string labels in map/data struct to integer numbers |
|
| 229 |
+ |
|
| 230 |
+names = {};
|
|
| 231 |
+nos = zeros(length(class),1); |
|
| 232 |
+for i=1:length(class) |
|
| 233 |
+ if ~isempty(class{i}) & ~any(strcmp(class{i},names))
|
|
| 234 |
+ names=cat(1,names,class(i)); |
|
| 235 |
+ end |
|
| 236 |
+end |
|
| 237 |
+ |
|
| 238 |
+tmp_nos = (1:length(names))'; |
|
| 239 |
+for i=1:length(class) |
|
| 240 |
+ if ~isempty(class{i})
|
|
| 241 |
+ nos(i,1) = find(strcmp(class{i},names));
|
|
| 242 |
+ end |
|
| 243 |
+end |
|
| 244 |
+ |
|
| 245 |
+function d=distance(X,Y); |
|
| 246 |
+ |
|
| 247 |
+% Euclidean distance matrix between row vectors in X and Y |
|
| 248 |
+ |
|
| 249 |
+U=~isnan(Y); Y(~U)=0; |
|
| 250 |
+V=~isnan(X); X(~V)=0; |
|
| 251 |
+d=X.^2*U'+V*Y'.^2-2*X*Y'; |
| ... | ... |
@@ -0,0 +1,180 @@ |
| 1 |
+function codebook=lvq1(codebook, data, rlen, alpha); |
|
| 2 |
+ |
|
| 3 |
+%LVQ1 Trains a codebook with the LVQ1 -algorithm. |
|
| 4 |
+% |
|
| 5 |
+% sM = lvq1(sM, D, rlen, alpha) |
|
| 6 |
+% |
|
| 7 |
+% sM = lvq1(sM,sD,30*length(sM.codebook),0.08); |
|
| 8 |
+% |
|
| 9 |
+% Input and output arguments: |
|
| 10 |
+% sM (struct) map struct, the class information must be |
|
| 11 |
+% present on the first column of .labels field |
|
| 12 |
+% D (struct) data struct, the class information must |
|
| 13 |
+% be present on the first column of .labels field |
|
| 14 |
+% rlen (scalar) running length |
|
| 15 |
+% alpha (scalar) learning parameter |
|
| 16 |
+% |
|
| 17 |
+% sM (struct) map struct, the trained codebook |
|
| 18 |
+% |
|
| 19 |
+% NOTE: does not take mask into account. |
|
| 20 |
+% |
|
| 21 |
+% For more help, try 'type lvq1', or check out online documentation. |
|
| 22 |
+% See also LVQ3, SOM_SUPERVISED, SOM_SEQTRAIN. |
|
| 23 |
+ |
|
| 24 |
+%%%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 25 |
+% |
|
| 26 |
+% lvq1 |
|
| 27 |
+% |
|
| 28 |
+% PURPOSE |
|
| 29 |
+% |
|
| 30 |
+% Trains codebook with the LVQ1 -algorithm (described below). |
|
| 31 |
+% |
|
| 32 |
+% SYNTAX |
|
| 33 |
+% |
|
| 34 |
+% sM = lvq1(sM, D, rlen, alpha) |
|
| 35 |
+% |
|
| 36 |
+% DESCRIPTION |
|
| 37 |
+% |
|
| 38 |
+% Trains codebook with the LVQ1 -algorithm. Codebook contains a number |
|
| 39 |
+% of vectors (mi, i=1,2,...,n) and so does data (vectors xj, |
|
| 40 |
+% j=1,2,...,k). Both vector sets are classified: vectors may have a |
|
| 41 |
+% class (classes are set to the first column of data or map -structs' |
|
| 42 |
+% .labels -field). For each xj there is defined the nearest codebook |
|
| 43 |
+% -vector index c by searching the minimum of the euclidean distances |
|
| 44 |
+% between the current xj and codebook -vectors: |
|
| 45 |
+% |
|
| 46 |
+% c = min{ ||xj - mi|| }, i=[1,..,n], for fixed xj
|
|
| 47 |
+% i |
|
| 48 |
+% If xj and mc belong to the same class, mc is updated as follows: |
|
| 49 |
+% mc(t+1) = mc(t) + alpha * (xj(t) - mc(t)) |
|
| 50 |
+% If xj and mc belong to different classes, mc is updated as follows: |
|
| 51 |
+% mc(t+1) = mc(t) - alpha * (xj(t) - mc(t)) |
|
| 52 |
+% Otherwise updating is not performed. |
|
| 53 |
+% |
|
| 54 |
+% Argument 'rlen' tells how many times training sequence is performed. |
|
| 55 |
+% LVQ1 -algorithm may be stopped after a number of steps, that is |
|
| 56 |
+% 30-50 times the number of codebook vectors. |
|
| 57 |
+% |
|
| 58 |
+% Argument 'alpha' is the learning rate, recommended to be smaller |
|
| 59 |
+% than 0.1. |
|
| 60 |
+% |
|
| 61 |
+% NOTE: does not take mask into account. |
|
| 62 |
+% |
|
| 63 |
+% REFERENCES |
|
| 64 |
+% |
|
| 65 |
+% Kohonen, T., "Self-Organizing Map", 2nd ed., Springer-Verlag, |
|
| 66 |
+% Berlin, 1995, pp. 176-179. |
|
| 67 |
+% |
|
| 68 |
+% See also LVQ_PAK from http://www.cis.hut.fi/research/som_lvq_pak.shtml |
|
| 69 |
+% |
|
| 70 |
+% REQUIRED INPUT ARGUMENTS |
|
| 71 |
+% |
|
| 72 |
+% sM The data to be trained. |
|
| 73 |
+% (struct) A map struct. |
|
| 74 |
+% |
|
| 75 |
+% D The data to use in training. |
|
| 76 |
+% (struct) A data struct. |
|
| 77 |
+% |
|
| 78 |
+% rlen (integer) Running length of LVQ1 -algorithm. |
|
| 79 |
+% |
|
| 80 |
+% alpha (float) Learning rate used in training. |
|
| 81 |
+% |
|
| 82 |
+% OUTPUT ARGUMENTS |
|
| 83 |
+% |
|
| 84 |
+% codebook Trained data. |
|
| 85 |
+% (struct) A map struct. |
|
| 86 |
+% |
|
| 87 |
+% EXAMPLE |
|
| 88 |
+% |
|
| 89 |
+% lab = unique(sD.labels(:,1)); % different classes |
|
| 90 |
+% mu = length(lab)*5; % 5 prototypes for each |
|
| 91 |
+% sM = som_randinit(sD,'msize',[mu 1]); % initial prototypes |
|
| 92 |
+% sM.labels = [lab;lab;lab;lab;lab]; % their classes |
|
| 93 |
+% sM = lvq1(sM,sD,50*mu,0.05); % use LVQ1 to adjust |
|
| 94 |
+% % the prototypes |
|
| 95 |
+% sM = lvq3(sM,sD,50*mu,0.05,0.2,0.3); % then use LVQ3 |
|
| 96 |
+% |
|
| 97 |
+% SEE ALSO |
|
| 98 |
+% |
|
| 99 |
+% lvq3 Use LVQ3 algorithm for training. |
|
| 100 |
+% som_supervised Train SOM using supervised training. |
|
| 101 |
+% som_seqtrain Train SOM with sequential algorithm. |
|
| 102 |
+ |
|
| 103 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas |
|
| 104 |
+% Copyright (c) Juha Parhankangas |
|
| 105 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 106 |
+ |
|
| 107 |
+% Juha Parhankangas 310100 juuso 020200 |
|
| 108 |
+ |
|
| 109 |
+cod = codebook.codebook; |
|
| 110 |
+c_class = class2num(codebook.labels(:,1)); |
|
| 111 |
+ |
|
| 112 |
+dat = data.data; |
|
| 113 |
+d_class = class2num(data.labels(:,1)); |
|
| 114 |
+ |
|
| 115 |
+x=size(dat,1); |
|
| 116 |
+y=size(cod,2); |
|
| 117 |
+ |
|
| 118 |
+ONES=ones(size(cod,1),1); |
|
| 119 |
+ |
|
| 120 |
+for t=1:rlen |
|
| 121 |
+ |
|
| 122 |
+ fprintf(1,'\rTraining round: %d',t); |
|
| 123 |
+ tmp=NaN*ones(x,y); |
|
| 124 |
+ |
|
| 125 |
+ for j=1:x |
|
| 126 |
+ no_NaN=find(~isnan(dat(j,:))); |
|
| 127 |
+ di = sqrt(sum([cod(:,no_NaN) - ONES*dat(j,no_NaN)].^2,2)); |
|
| 128 |
+ |
|
| 129 |
+ [foo,ind] = min(di); |
|
| 130 |
+ |
|
| 131 |
+ if d_class(j) & d_class(j) == c_class(ind) % 0 is for unclassified vectors |
|
| 132 |
+ tmp(ind,:) = cod(ind,:) + alpha * (dat(j,:) - cod(ind,:)); |
|
| 133 |
+ elseif d_class(j) |
|
| 134 |
+ tmp(ind,:) = cod(ind,:) - alpha*(dat(j,:) - cod(ind,:)); |
|
| 135 |
+ end |
|
| 136 |
+ end |
|
| 137 |
+ |
|
| 138 |
+ inds = find(~isnan(sum(tmp,2))); |
|
| 139 |
+ cod(inds,:) = tmp(inds,:); |
|
| 140 |
+end |
|
| 141 |
+ |
|
| 142 |
+codebook.codebook = cod; |
|
| 143 |
+ |
|
| 144 |
+sTrain = som_set('som_train','algorithm','lvq1',...
|
|
| 145 |
+ 'data_name',data.name,... |
|
| 146 |
+ 'neigh','',... |
|
| 147 |
+ 'mask',ones(y,1),... |
|
| 148 |
+ 'radius_ini',NaN,... |
|
| 149 |
+ 'radius_fin',NaN,... |
|
| 150 |
+ 'alpha_ini',alpha,... |
|
| 151 |
+ 'alpha_type','constant',... |
|
| 152 |
+ 'trainlen',rlen,... |
|
| 153 |
+ 'time',datestr(now,0)); |
|
| 154 |
+codebook.trainhist(end+1) = sTrain; |
|
| 155 |
+ |
|
| 156 |
+return; |
|
| 157 |
+ |
|
| 158 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 159 |
+ |
|
| 160 |
+function nos = class2num(class) |
|
| 161 |
+ |
|
| 162 |
+names = {};
|
|
| 163 |
+nos = zeros(length(class),1); |
|
| 164 |
+ |
|
| 165 |
+for i=1:length(class) |
|
| 166 |
+ if ~isempty(class{i}) & ~any(strcmp(class{i},names))
|
|
| 167 |
+ names=cat(1,names,class(i)); |
|
| 168 |
+ end |
|
| 169 |
+end |
|
| 170 |
+ |
|
| 171 |
+tmp_nos = (1:length(names))'; |
|
| 172 |
+ |
|
| 173 |
+for i=1:length(class) |
|
| 174 |
+ if ~isempty(class{i})
|
|
| 175 |
+ nos(i,1) = find(strcmp(class{i},names));
|
|
| 176 |
+ end |
|
| 177 |
+end |
|
| 178 |
+ |
|
| 179 |
+ |
|
| 180 |
+ |
| ... | ... |
@@ -0,0 +1,215 @@ |
| 1 |
+function codebook = lvq3(codebook,data,rlen,alpha,win,epsilon) |
|
| 2 |
+ |
|
| 3 |
+%LVQ3 trains codebook with LVQ3 -algorithm |
|
| 4 |
+% |
|
| 5 |
+% sM = lvq3(sM,D,rlen,alpha,win,epsilon) |
|
| 6 |
+% |
|
| 7 |
+% sM = lvq3(sM,sD,50*length(sM.codebook),0.05,0.2,0.3); |
|
| 8 |
+% |
|
| 9 |
+% Input and output arguments: |
|
| 10 |
+% sM (struct) map struct, the class information must be |
|
| 11 |
+% present on the first column of .labels field |
|
| 12 |
+% D (struct) data struct, the class information must |
|
| 13 |
+% be present on the first column of .labels field |
|
| 14 |
+% rlen (scalar) running length |
|
| 15 |
+% alpha (scalar) learning parameter, e.g. 0.05 |
|
| 16 |
+% win (scalar) window width parameter, e.g. 0.25 |
|
| 17 |
+% epsilon (scalar) relative learning parameter, e.g. 0.3 |
|
| 18 |
+% |
|
| 19 |
+% sM (struct) map struct, the trained codebook |
|
| 20 |
+% |
|
| 21 |
+% NOTE: does not take mask into account. |
|
| 22 |
+% |
|
| 23 |
+% For more help, try 'type lvq3', or check out online documentation. |
|
| 24 |
+% See also LVQ1, SOM_SUPERVISED, SOM_SEQTRAIN. |
|
| 25 |
+ |
|
| 26 |
+%%%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 27 |
+% |
|
| 28 |
+% lvq3 |
|
| 29 |
+% |
|
| 30 |
+% PURPOSE |
|
| 31 |
+% |
|
| 32 |
+% Trains codebook with the LVQ3 -algorithm (described below). |
|
| 33 |
+% |
|
| 34 |
+% SYNTAX |
|
| 35 |
+% |
|
| 36 |
+% sM = lvq3(sM, data, rlen, alpha, win, epsilon) |
|
| 37 |
+% |
|
| 38 |
+% DESCRIPTION |
|
| 39 |
+% |
|
| 40 |
+% Trains codebook with the LVQ3 -algorithm. Codebook contains a number |
|
| 41 |
+% of vectors (mi, i=1,2,...,n) and so does data (vectors xj, j=1,2,...k). |
|
| 42 |
+% Both vector sets are classified: vectors may have a class (classes are |
|
| 43 |
+% set to data- or map -structure's 'labels' -field. For each xj the two |
|
| 44 |
+% closest codebookvectors mc1 and mc2 are searched (euclidean distances |
|
| 45 |
+% d1 and d2). xj must fall into the zone of window. That happens if: |
|
| 46 |
+% |
|
| 47 |
+% min(d1/d2, d2/d1) > s, where s = (1-win) / (1+win). |
|
| 48 |
+% |
|
| 49 |
+% If xj belongs to the same class of one of the mc1 and mc1, codebook |
|
| 50 |
+% is updated as follows (let mc1 belong to the same class as xj): |
|
| 51 |
+% mc1(t+1) = mc1(t) + alpha * (xj(t) - mc1(t)) |
|
| 52 |
+% mc2(t+1) = mc2(t) - alpha * (xj(t) - mc2(t)) |
|
| 53 |
+% If both mc1 and mc2 belong to the same class as xj, codebook is |
|
| 54 |
+% updated as follows: |
|
| 55 |
+% mc1(t+1) = mc1(t) + epsilon * alpha * (xj(t) - mc1(t)) |
|
| 56 |
+% mc2(t+1) = mc2(t) + epsilon * alpha * (xj(t) - mc2(t)) |
|
| 57 |
+% Otherwise updating is not performed. |
|
| 58 |
+% |
|
| 59 |
+% Argument 'rlen' tells how many times training -sequence is performed. |
|
| 60 |
+% |
|
| 61 |
+% Argument 'alpha' is recommended to be smaller than 0.1 and argument |
|
| 62 |
+% 'epsilon' should be between 0.1 and 0.5. |
|
| 63 |
+% |
|
| 64 |
+% NOTE: does not take mask into account. |
|
| 65 |
+% |
|
| 66 |
+% REFERENCES |
|
| 67 |
+% |
|
| 68 |
+% Kohonen, T., "Self-Organizing Map", 2nd ed., Springer-Verlag, |
|
| 69 |
+% Berlin, 1995, pp. 181-182. |
|
| 70 |
+% |
|
| 71 |
+% See also LVQ_PAK from http://www.cis.hut.fi/research/som_lvq_pak.shtml |
|
| 72 |
+% |
|
| 73 |
+% REQUIRED INPUT ARGUMENTS |
|
| 74 |
+% |
|
| 75 |
+% sM The data to be trained. |
|
| 76 |
+% (struct) A map struct. |
|
| 77 |
+% |
|
| 78 |
+% data The data to use in training. |
|
| 79 |
+% (struct) A data struct. |
|
| 80 |
+% |
|
| 81 |
+% rlen (integer) Running length of LVQ3 -algorithm. |
|
| 82 |
+% |
|
| 83 |
+% alpha (float) Learning rate used in training, e.g. 0.05 |
|
| 84 |
+% |
|
| 85 |
+% win (float) Window length, e.g. 0.25 |
|
| 86 |
+% |
|
| 87 |
+% epsilon (float) Relative learning parameter, e.g. 0.3 |
|
| 88 |
+% |
|
| 89 |
+% OUTPUT ARGUMENTS |
|
| 90 |
+% |
|
| 91 |
+% sM Trained data. |
|
| 92 |
+% (struct) A map struct. |
|
| 93 |
+% |
|
| 94 |
+% EXAMPLE |
|
| 95 |
+% |
|
| 96 |
+% lab = unique(sD.labels(:,1)); % different classes |
|
| 97 |
+% mu = length(lab)*5; % 5 prototypes for each |
|
| 98 |
+% sM = som_randinit(sD,'msize',[mu 1]); % initial prototypes |
|
| 99 |
+% sM.labels = [lab;lab;lab;lab;lab]; % their classes |
|
| 100 |
+% sM = lvq1(sM,sD,50*mu,0.05); % use LVQ1 to adjust |
|
| 101 |
+% % the prototypes |
|
| 102 |
+% sM = lvq3(sM,sD,50*mu,0.05,0.2,0.3); % then use LVQ3 |
|
| 103 |
+% |
|
| 104 |
+% SEE ALSO |
|
| 105 |
+% |
|
| 106 |
+% lvq1 Use LVQ1 algorithm for training. |
|
| 107 |
+% som_supervised Train SOM using supervised training. |
|
| 108 |
+% som_seqtrain Train SOM with sequential algorithm. |
|
| 109 |
+ |
|
| 110 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas |
|
| 111 |
+% Copyright (c) by Juha Parhankangas |
|
| 112 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 113 |
+ |
|
| 114 |
+% Juha Parhankangas 310100 juuso 020200 |
|
| 115 |
+ |
|
| 116 |
+NOTFOUND = 1; |
|
| 117 |
+ |
|
| 118 |
+cod = codebook.codebook; |
|
| 119 |
+dat = data.data; |
|
| 120 |
+ |
|
| 121 |
+c_class = codebook.labels(:,1); |
|
| 122 |
+d_class = data.labels(:,1); |
|
| 123 |
+ |
|
| 124 |
+s = (1-win)/(1+win); |
|
| 125 |
+ |
|
| 126 |
+x = size(dat,1); |
|
| 127 |
+y = size(cod,2); |
|
| 128 |
+ |
|
| 129 |
+c_class=class2num(c_class); |
|
| 130 |
+d_class=class2num(d_class); |
|
| 131 |
+ |
|
| 132 |
+ONES=ones(size(cod,1),1); |
|
| 133 |
+ |
|
| 134 |
+for t=1:rlen |
|
| 135 |
+ fprintf('\rTraining round: %d/%d',t,rlen);
|
|
| 136 |
+ tmp = NaN*ones(x,y); |
|
| 137 |
+ |
|
| 138 |
+ for j=1:x |
|
| 139 |
+ flag = 0; |
|
| 140 |
+ mj = 0; |
|
| 141 |
+ mi = 0; |
|
| 142 |
+ no_NaN=find(~isnan(dat(j,:))); |
|
| 143 |
+ di=sqrt(sum([cod(:,no_NaN) - ONES*dat(j,no_NaN)].^2,2)); |
|
| 144 |
+ [foo, ind1] = min(di); |
|
| 145 |
+ di(ind1)=Inf; |
|
| 146 |
+ [foo,ind2] = min(di); |
|
| 147 |
+ |
|
| 148 |
+ %ind2=ind2+1; |
|
| 149 |
+ |
|
| 150 |
+ if d_class(j) & d_class(j)==c_class(ind1) |
|
| 151 |
+ mj = ind1; |
|
| 152 |
+ mi = ind2; |
|
| 153 |
+ if d_class(j)==c_class(ind2) |
|
| 154 |
+ flag = 1; |
|
| 155 |
+ end |
|
| 156 |
+ elseif d_class(j) & d_class(j)==c_class(ind2) |
|
| 157 |
+ mj = ind2; |
|
| 158 |
+ mi = ind1; |
|
| 159 |
+ if d_class(j)==c_class(ind1) |
|
| 160 |
+ flag = 1; |
|
| 161 |
+ end |
|
| 162 |
+ end |
|
| 163 |
+ |
|
| 164 |
+ if mj & mi |
|
| 165 |
+ if flag |
|
| 166 |
+ tmp([mj mi],:) = cod([mj mi],:) + epsilon*alpha*... |
|
| 167 |
+ (dat([j j],:) - cod([mj mi],:)); |
|
| 168 |
+ else |
|
| 169 |
+ tmp(mj,:) = cod(mj,:) + alpha * (dat(j,:)-cod(mj,:)); |
|
| 170 |
+ tmp(mi,:) = cod(mi,:) - alpha * (dat(j,:)-cod(mj,:)); |
|
| 171 |
+ end |
|
| 172 |
+ end |
|
| 173 |
+ end |
|
| 174 |
+ inds = find(~isnan(sum(tmp,2))); |
|
| 175 |
+ cod(inds,:) = tmp(inds,:); |
|
| 176 |
+end |
|
| 177 |
+fprintf(1,'\n'); |
|
| 178 |
+ |
|
| 179 |
+sTrain = som_set('som_train','algorithm','lvq3',...
|
|
| 180 |
+ 'data_name',data.name,... |
|
| 181 |
+ 'neigh','',... |
|
| 182 |
+ 'mask',ones(y,1),... |
|
| 183 |
+ 'radius_ini',NaN,... |
|
| 184 |
+ 'radius_fin',NaN,... |
|
| 185 |
+ 'alpha_ini',alpha,... |
|
| 186 |
+ 'alpha_type','constant',... |
|
| 187 |
+ 'trainlen',rlen,... |
|
| 188 |
+ 'time',datestr(now,0)); |
|
| 189 |
+codebook.trainhist(end+1) = sTrain; |
|
| 190 |
+ |
|
| 191 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 192 |
+ |
|
| 193 |
+function nos = class2num(class) |
|
| 194 |
+ |
|
| 195 |
+names = {};
|
|
| 196 |
+nos = zeros(length(class),1); |
|
| 197 |
+ |
|
| 198 |
+for i=1:length(class) |
|
| 199 |
+ if ~isempty(class{i}) & ~any(strcmp(class{i},names))
|
|
| 200 |
+ names=cat(1,names,class(i)); |
|
| 201 |
+ end |
|
| 202 |
+end |
|
| 203 |
+ |
|
| 204 |
+tmp_nos = (1:length(names))'; |
|
| 205 |
+ |
|
| 206 |
+for i=1:length(class) |
|
| 207 |
+ if ~isempty(class{i})
|
|
| 208 |
+ nos(i,1) = find(strcmp(class{i},names));
|
|
| 209 |
+ end |
|
| 210 |
+end |
|
| 211 |
+ |
|
| 212 |
+ |
|
| 213 |
+ |
|
| 214 |
+ |
|
| 215 |
+ |
| ... | ... |
@@ -0,0 +1,65 @@ |
| 1 |
+function [me, st, md, no] = nanstats(D) |
|
| 2 |
+ |
|
| 3 |
+%NANSTATS Statistical operations that ignore NaNs and Infs. |
|
| 4 |
+% |
|
| 5 |
+% [mean, std, median, nans] = nanstats(D) |
|
| 6 |
+% |
|
| 7 |
+% Input and output arguments: |
|
| 8 |
+% D (struct) data or map struct |
|
| 9 |
+% (matrix) size dlen x dim |
|
| 10 |
+% |
|
| 11 |
+% me (double) columnwise mean |
|
| 12 |
+% st (double) columnwise standard deviation |
|
| 13 |
+% md (double) columnwise median |
|
| 14 |
+% no (vector) columnwise number of samples (finite, not-NaN) |
|
| 15 |
+ |
|
| 16 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Vesanto |
|
| 17 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 18 |
+ |
|
| 19 |
+% Version 2.0beta juuso 300798 200900 |
|
| 20 |
+ |
|
| 21 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 22 |
+%% check arguments |
|
| 23 |
+ |
|
| 24 |
+(nargchk(1, 1, nargin)); % check no. of input args is correct |
|
| 25 |
+ |
|
| 26 |
+if isstruct(D), |
|
| 27 |
+ if strcmp(D.type,'som_map'), D = D.codebook; |
|
| 28 |
+ else D = D.data; |
|
| 29 |
+ end |
|
| 30 |
+end |
|
| 31 |
+[dlen dim] = size(D); |
|
| 32 |
+me = zeros(dim,1)+NaN; |
|
| 33 |
+md = me; |
|
| 34 |
+st = me; |
|
| 35 |
+no = me; |
|
| 36 |
+ |
|
| 37 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 38 |
+%% computation |
|
| 39 |
+ |
|
| 40 |
+for i = 1:dim, |
|
| 41 |
+ ind = find(isfinite(D(:, i))); % indices of non-NaN/Inf elements |
|
| 42 |
+ n = length(ind); % no of non-NaN/Inf elements |
|
| 43 |
+ |
|
| 44 |
+ me(i) = sum(D(ind, i)); % compute average |
|
| 45 |
+ if n == 0, me(i) = NaN; else me(i) = me(i) / n; end |
|
| 46 |
+ |
|
| 47 |
+ if nargout>1, |
|
| 48 |
+ md(i) = median(D(ind, i)); % compute median |
|
| 49 |
+ |
|
| 50 |
+ if nargout>2, |
|
| 51 |
+ st(i) = sum((me(i) - D(ind, i)).^2); % compute standard deviation |
|
| 52 |
+ if n == 0, st(i) = NaN; |
|
| 53 |
+ elseif n == 1, st(i) = 0; |
|
| 54 |
+ else st(i) = sqrt(st(i) / (n - 1)); |
|
| 55 |
+ end |
|
| 56 |
+ |
|
| 57 |
+ if nargout>3, |
|
| 58 |
+ no(i) = n; % number of samples (finite, not-NaN) |
|
| 59 |
+ end |
|
| 60 |
+ end |
|
| 61 |
+ end |
|
| 62 |
+end |
|
| 63 |
+ |
|
| 64 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 65 |
+ |
| ... | ... |
@@ -0,0 +1,89 @@ |
| 1 |
+function [Neurons] = neural_gas(D,n,epochs,alpha0,lambda0) |
|
| 2 |
+ |
|
| 3 |
+%NEURAL_GAS Quantizes the data space using the neural gas algorithm. |
|
| 4 |
+% |
|
| 5 |
+% Neurons = neural_gas(D, n, epochs, [alpha0], [lambda0]) |
|
| 6 |
+% |
|
| 7 |
+% C = neural_gas(D,50,10); |
|
| 8 |
+% sM = som_map_struct(sD); |
|
| 9 |
+% sM.codebook = neural_gas(sD,size(sM.codebook,1),10); |
|
| 10 |
+% |
|
| 11 |
+% Input and output arguments ([]'s are optional): |
|
| 12 |
+% D (matrix) the data matrix, size dlen x dim |
|
| 13 |
+% (struct) a data struct |
|
| 14 |
+% n (scalar) the number of neurons |
|
| 15 |
+% epochs (scalar) the number of training epochs (the number of |
|
| 16 |
+% training steps is dlen*epochs) |
|
| 17 |
+% [alpha0] (scalar) initial step size, 0.5 by default |
|
| 18 |
+% [lambda0] (scalar) initial decay constant, n/2 by default |
|
| 19 |
+% |
|
| 20 |
+% Neurons (matrix) the neuron matrix, size n x dim |
|
| 21 |
+% |
|
| 22 |
+% See also SOM_MAKE, KMEANS. |
|
| 23 |
+ |
|
| 24 |
+% References: |
|
| 25 |
+% T.M.Martinetz, S.G.Berkovich, and K.J.Schulten. "Neural-gas" network |
|
| 26 |
+% for vector quantization and its application to time-series prediction. |
|
| 27 |
+% IEEE Transactions on Neural Networks, 4(4):558-569, 1993. |
|
| 28 |
+ |
|
| 29 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Vesanto |
|
| 30 |
+% Copyright (c) by Juha Vesanto |
|
| 31 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 32 |
+ |
|
| 33 |
+% juuso 101297 020200 |
|
| 34 |
+ |
|
| 35 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 36 |
+%% Check arguments and initialize |
|
| 37 |
+ |
|
| 38 |
+error(nargchk(3, 5, nargin)); % check the number of input arguments |
|
| 39 |
+ |
|
| 40 |
+if isstruct(D), D = D.data; end |
|
| 41 |
+[dlen,dim] = size(D); |
|
| 42 |
+Neurons = (rand(n,dim)-0.5)*10e-5; % small initial values |
|
| 43 |
+train_len = epochs*dlen; |
|
| 44 |
+ |
|
| 45 |
+if nargin<4 | isempty(alpha0) | isnan(alpha0), alpha0 = 0.5; end |
|
| 46 |
+if nargin<5 | isempty(lambda0) | isnan(lambda0), lambda0 = n/2; end |
|
| 47 |
+ |
|
| 48 |
+% random sample order |
|
| 49 |
+rand('state',sum(100*clock));
|
|
| 50 |
+sample_inds = ceil(dlen*rand(train_len,1)); |
|
| 51 |
+ |
|
| 52 |
+% lambda |
|
| 53 |
+lambda = lambda0 * (0.01/lambda0).^([0:(train_len-1)]/train_len); |
|
| 54 |
+ |
|
| 55 |
+% alpha |
|
| 56 |
+alpha = alpha0 * (0.005/alpha0).^([0:(train_len-1)]/train_len); |
|
| 57 |
+ |
|
| 58 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 59 |
+%% Action |
|
| 60 |
+ |
|
| 61 |
+for i=1:train_len, |
|
| 62 |
+ |
|
| 63 |
+ % sample vector |
|
| 64 |
+ x = D(sample_inds(i),:); % sample vector |
|
| 65 |
+ known = ~isnan(x); % its known components |
|
| 66 |
+ X = x(ones(n,1),known); % we'll need this |
|
| 67 |
+ |
|
| 68 |
+ % neighborhood ranking |
|
| 69 |
+ Dx = Neurons(:,known) - X; % difference between vector and all map units |
|
| 70 |
+ [qerrs, inds] = sort((Dx.^2)*known'); % 1-BMU, 2-BMU, etc. |
|
| 71 |
+ ranking(inds) = [0:(n-1)]; |
|
| 72 |
+ h = exp(-ranking/lambda(i)); |
|
| 73 |
+ H = h(ones(length(known),1),:)'; |
|
| 74 |
+ |
|
| 75 |
+ % update |
|
| 76 |
+ Neurons = Neurons + alpha(i)*H.*(x(ones(n,1),known) - Neurons(:,known)); |
|
| 77 |
+ |
|
| 78 |
+ % track |
|
| 79 |
+ fprintf(1,'%d / %d \r',i,train_len); |
|
| 80 |
+ if 0 & mod(i,50) == 0, |
|
| 81 |
+ hold off, plot3(D(:,1),D(:,2),D(:,3),'bo') |
|
| 82 |
+ hold on, plot3(Neurons(:,1),Neurons(:,2),Neurons(:,3),'r+') |
|
| 83 |
+ drawnow |
|
| 84 |
+ end |
|
| 85 |
+end |
|
| 86 |
+ |
|
| 87 |
+fprintf(1,'\n'); |
|
| 88 |
+ |
|
| 89 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 0 | 90 |
\ No newline at end of file |
| ... | ... |
@@ -0,0 +1,80 @@ |
| 1 |
+function [P,V,me,l] = pcaproj(D,arg1,arg2) |
|
| 2 |
+ |
|
| 3 |
+%PCAPROJ Projects data vectors using Principal Component Analysis. |
|
| 4 |
+% |
|
| 5 |
+% [P,V,me,l] = pcaproj(D, odim) |
|
| 6 |
+% P = pcaproj(D, V, me) |
|
| 7 |
+% |
|
| 8 |
+% Input and output arguments ([]'s are optional) |
|
| 9 |
+% D (matrix) size dlen x dim, the data matrix |
|
| 10 |
+% (struct) data or map struct |
|
| 11 |
+% odim (scalar) how many principal vectors are used |
|
| 12 |
+% |
|
| 13 |
+% P (matrix) size dlen x odim, the projections |
|
| 14 |
+% V (matrix) size dim x odim, principal eigenvectors (unit length) |
|
| 15 |
+% me (vector) size 1 x dim, center point of D |
|
| 16 |
+% l (vector) size 1 x odim, the corresponding eigenvalues, |
|
| 17 |
+% relative to total sum of eigenvalues |
|
| 18 |
+% |
|
| 19 |
+% See also SAMMON, CCA. |
|
| 20 |
+ |
|
| 21 |
+% Contributed to SOM Toolbox 2.0, February 2nd, 2000 by Juha Vesanto |
|
| 22 |
+% Copyright (c) by Juha Vesanto |
|
| 23 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 24 |
+ |
|
| 25 |
+% juuso 191297 070200 |
|
| 26 |
+ |
|
| 27 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 28 |
+ |
|
| 29 |
+error(nargchk(2, 3, nargin)); % check the number of input arguments |
|
| 30 |
+ |
|
| 31 |
+% the data |
|
| 32 |
+if isstruct(D), |
|
| 33 |
+ if strcmp(D.type,'som_map'), D=D.codebook; else D=D.data; end |
|
| 34 |
+end |
|
| 35 |
+[dlen dim] = size(D); |
|
| 36 |
+ |
|
| 37 |
+if nargin==2, |
|
| 38 |
+ |
|
| 39 |
+ odim = arg1; |
|
| 40 |
+ |
|
| 41 |
+ % autocorrelation matrix |
|
| 42 |
+ A = zeros(dim); |
|
| 43 |
+ me = zeros(1,dim); |
|
| 44 |
+ for i=1:dim, |
|
| 45 |
+ me(i) = mean(D(isfinite(D(:,i)),i)); |
|
| 46 |
+ D(:,i) = D(:,i) - me(i); |
|
| 47 |
+ end |
|
| 48 |
+ for i=1:dim, |
|
| 49 |
+ for j=i:dim, |
|
| 50 |
+ c = D(:,i).*D(:,j); c = c(isfinite(c)); |
|
| 51 |
+ A(i,j) = sum(c)/length(c); A(j,i) = A(i,j); |
|
| 52 |
+ end |
|
| 53 |
+ end |
|
| 54 |
+ |
|
| 55 |
+ % eigenvectors, sort them according to eigenvalues, and normalize |
|
| 56 |
+ [V,S] = eig(A); |
|
| 57 |
+ eigval = diag(S); |
|
| 58 |
+ [y,ind] = sort(abs(eigval)); |
|
| 59 |
+ eigval = eigval(flipud(ind)); |
|
| 60 |
+ V = V(:,flipud(ind)); |
|
| 61 |
+ for i=1:odim, V(:,i) = (V(:,i) / norm(V(:,i))); end |
|
| 62 |
+ |
|
| 63 |
+ % take only odim first eigenvectors |
|
| 64 |
+ V = V(:,1:odim); |
|
| 65 |
+ l = abs(eigval)/sum(abs(eigval)); |
|
| 66 |
+ l = l(1:odim); |
|
| 67 |
+ |
|
| 68 |
+else % nargin==3, |
|
| 69 |
+ |
|
| 70 |
+ V = arg1; |
|
| 71 |
+ me = arg2; |
|
| 72 |
+ odim = size(V,2); |
|
| 73 |
+ D = D-me(ones(dlen,1),:); |
|
| 74 |
+ |
|
| 75 |
+end |
|
| 76 |
+ |
|
| 77 |
+% project the data using odim first eigenvectors |
|
| 78 |
+P = D*V; |
|
| 79 |
+ |
|
| 80 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... |
@@ -0,0 +1,6642 @@ |
| 1 |
+function preprocess(sData,arg2) |
|
| 2 |
+ |
|
| 3 |
+%PREPROCESS A GUI for data preprocessing. |
|
| 4 |
+% |
|
| 5 |
+% preprocess(sData) |
|
| 6 |
+% |
|
| 7 |
+% preprocess(sData) |
|
| 8 |
+% |
|
| 9 |
+% Launches a preprocessing GUI. The optional input argument can be |
|
| 10 |
+% either a data struct or a struct array of such. However, primarily |
|
| 11 |
+% the processed data sets are loaded to the application using the |
|
| 12 |
+% tools in the GUI. Also, the only way to get the preprocessed data |
|
| 13 |
+% sets back into the workspace is to use the tools in the GUI (press |
|
| 14 |
+% the button DATA SET MANAGEMENT). |
|
| 15 |
+% |
|
| 16 |
+% For a more throughout description, see online documentation. |
|
| 17 |
+% See also SOM_GUI. |
|
| 18 |
+ |
|
| 19 |
+%%%%%%%%%%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 20 |
+% |
|
| 21 |
+% IN FILES: preprocess.html,preproc.jpg,sDman.jpg,clip.jpg,delay.jpg,window.jpg,selVect.jpg |
|
| 22 |
+ |
|
| 23 |
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Parhankangas |
|
| 24 |
+% Copyright (c) by Juha Parhankangas and the SOM Toolbox team |
|
| 25 |
+ |
|
| 26 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 27 |
+ |
|
| 28 |
+% Juha Parhankangas 050100 |
|
| 29 |
+ |
|
| 30 |
+global no_of_sc % every Nth component in 'relative values' is drawn stronger. |
|
| 31 |
+no_of_sc=5; |
|
| 32 |
+ |
|
| 33 |
+if nargin < 1 | nargin > 2 |
|
| 34 |
+ error('Invalid number of input arguments');
|
|
| 35 |
+ return; |
|
| 36 |
+end |
|
| 37 |
+ |
|
| 38 |
+if nargin == 1, arg2=[]; end |
|
| 39 |
+ |
|
| 40 |
+if ~isstr(sData) %%% Preprocess is started... |
|
| 41 |
+data.LOG{1}='% Starting the ''Preprocess'' -window...';
|
|
| 42 |
+data.LOG{2}=cat(2,'preprocess(',...
|
|
| 43 |
+ sprintf('%s);',inputname(1)));
|
|
| 44 |
+ |
|
| 45 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 46 |
+if ~isempty(pre_h) |
|
| 47 |
+ figure(pre_h); |
|
| 48 |
+ msgbox('''Preprocess''-figure already exists.');
|
|
| 49 |
+ return; |
|
| 50 |
+end |
|
| 51 |
+ |
|
| 52 |
+h0 = figure('Color',[0.8 0.8 0.8], ...
|
|
| 53 |
+ 'PaperPosition',[18 180 576 432], ... |
|
| 54 |
+ 'PaperUnits','points', ... |
|
| 55 |
+ 'Position',[595 216 600 775], ... |
|
| 56 |
+ 'Tag','Preprocess'); |
|
| 57 |
+ |
|
| 58 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 59 |
+ 'Units','normalized', ... |
|
| 60 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 61 |
+ 'FontWeight','demi', ... |
|
| 62 |
+ 'HorizontalAlignment','left', ... |
|
| 63 |
+ 'ListboxTop',0, ... |
|
| 64 |
+ 'Position',[0.015 0.06064516129032258 0.9550000000000001 0.1458064516129032], ... |
|
| 65 |
+ 'Style','text', ... |
|
| 66 |
+ 'Tag','StaticText1'); |
|
| 67 |
+ |
|
| 68 |
+data.results_h = h1; |
|
| 69 |
+ |
|
| 70 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 71 |
+ 'Units','normalized', ... |
|
| 72 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 73 |
+ 'Callback','preprocess close', ... |
|
| 74 |
+ 'FontWeight','demi', ... |
|
| 75 |
+ 'ListboxTop',0, ... |
|
| 76 |
+ 'Position',[0.8067 0.0142 0.1667 0.0348],... |
|
| 77 |
+ 'String','CLOSE', ... |
|
| 78 |
+ 'Tag','Pushbutton1'); |
|
| 79 |
+ |
|
| 80 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 81 |
+ 'Units','normalized', ... |
|
| 82 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 83 |
+ 'FontWeight','demi', ... |
|
| 84 |
+ 'HorizontalAlignment','left', ... |
|
| 85 |
+ 'ListboxTop',0, ... |
|
| 86 |
+ 'Position',[0.01833333333333333 0.2141935483870968 0.07000000000000001 0.01806451612903226], ... |
|
| 87 |
+ 'String','LOG', ... |
|
| 88 |
+ 'Style','text', ... |
|
| 89 |
+ 'Tag','StaticText2'); |
|
| 90 |
+ |
|
| 91 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 92 |
+ 'Units','normalized', ... |
|
| 93 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 94 |
+ 'Callback','preprocess sel_comp',... |
|
| 95 |
+ 'FontWeight','demi', ... |
|
| 96 |
+ 'ListboxTop',0, ... |
|
| 97 |
+ 'Position',[0.7983333333333333 0.2090322580645161 0.1666666666666667 0.03483870967741935], ... |
|
| 98 |
+ 'String',' ', ... |
|
| 99 |
+ 'Style','popupmenu', ... |
|
| 100 |
+ 'Tag','sel_comp_h', ... |
|
| 101 |
+ 'Value',1); |
|
| 102 |
+ |
|
| 103 |
+data.sel_comp_h=h1; |
|
| 104 |
+ |
|
| 105 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 106 |
+ 'Units','normalized', ... |
|
| 107 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 108 |
+ 'ListboxTop',0, ... |
|
| 109 |
+ 'Position',[0.0183 0.2568 0.2133 0.1290], ... |
|
| 110 |
+ 'Style','text', ... |
|
| 111 |
+ 'Tag','StaticText3'); |
|
| 112 |
+ |
|
| 113 |
+data.sel_cdata_h=h1; |
|
| 114 |
+ |
|
| 115 |
+h1 = axes('Parent',h0, ...
|
|
| 116 |
+ 'CameraUpVector',[0 1 0], ... |
|
| 117 |
+ 'CameraUpVectorMode','manual', ... |
|
| 118 |
+ 'Color',[1 1 1], ... |
|
| 119 |
+ 'Position',[0.2583 0.2568 0.2133 0.1290], ... |
|
| 120 |
+ 'Tag','Axes1', ... |
|
| 121 |
+ 'XColor',[0 0 0], ... |
|
| 122 |
+ 'XTickLabel',['0 ';'0.5';'1 '], ... |
|
| 123 |
+ 'XTickLabelMode','manual', ... |
|
| 124 |
+ 'XTickMode','manual', ... |
|
| 125 |
+ 'YColor',[0 0 0], ... |
|
| 126 |
+ 'YTickMode','manual', ... |
|
| 127 |
+ 'ZColor',[0 0 0]); |
|
| 128 |
+ |
|
| 129 |
+data.sel_chist_h=h1; |
|
| 130 |
+ |
|
| 131 |
+h2 = text('Parent',h1, ...
|
|
| 132 |
+ 'Color',[0 0 0], ... |
|
| 133 |
+ 'HandleVisibility','off', ... |
|
| 134 |
+ 'HorizontalAlignment','center', ... |
|
| 135 |
+ 'Position',[0.4960629921259843 -0.08080808080808044 9.160254037844386], ... |
|
| 136 |
+ 'Tag','Axes1Text4', ... |
|
| 137 |
+ 'VerticalAlignment','cap'); |
|
| 138 |
+set(get(h2,'Parent'),'XLabel',h2); |
|
| 139 |
+h2 = text('Parent',h1, ...
|
|
| 140 |
+ 'Color',[0 0 0], ... |
|
| 141 |
+ 'HandleVisibility','off', ... |
|
| 142 |
+ 'HorizontalAlignment','center', ... |
|
| 143 |
+ 'Position',[-0.0551181102362206 0.4848484848484853 9.160254037844386], ... |
|
| 144 |
+ 'Rotation',90, ... |
|
| 145 |
+ 'Tag','Axes1Text3', ... |
|
| 146 |
+ 'VerticalAlignment','baseline'); |
|
| 147 |
+set(get(h2,'Parent'),'YLabel',h2); |
|
| 148 |
+h2 = text('Parent',h1, ...
|
|
| 149 |
+ 'Color',[0 0 0], ... |
|
| 150 |
+ 'HandleVisibility','off', ... |
|
| 151 |
+ 'HorizontalAlignment','right', ... |
|
| 152 |
+ 'Position',[-1.2283 5.7980 9.1603], ... |
|
| 153 |
+ 'Tag','Axes1Text2', ... |
|
| 154 |
+ 'Visible','off'); |
|
| 155 |
+set(get(h2,'Parent'),'ZLabel',h2); |
|
| 156 |
+h2 = text('Parent',h1, ...
|
|
| 157 |
+ 'Color',[0 0 0], ... |
|
| 158 |
+ 'HandleVisibility','off', ... |
|
| 159 |
+ 'HorizontalAlignment','center', ... |
|
| 160 |
+ 'Position',[0.4960629921259843 1.070707070707071 9.160254037844386], ... |
|
| 161 |
+ 'Tag','Axes1Text1', ... |
|
| 162 |
+ 'VerticalAlignment','bottom'); |
|
| 163 |
+set(get(h2,'Parent'),'Title',h2); |
|
| 164 |
+ |
|
| 165 |
+h1 = axes('Parent',h0, ...
|
|
| 166 |
+ 'CameraUpVector',[0 1 0], ... |
|
| 167 |
+ 'CameraUpVectorMode','manual', ... |
|
| 168 |
+ 'Color',[0.7529 0.7529 0.7529], ... |
|
| 169 |
+ 'Position',[0.4950000000000001 0.2567741935483871 0.4766666666666667 0.1290322580645161], ... |
|
| 170 |
+ 'Tag','Axes2', ... |
|
| 171 |
+ 'XColor',[0 0 0], ... |
|
| 172 |
+ 'XTickMode','manual', ... |
|
| 173 |
+ 'YColor',[0 0 0], ... |
|
| 174 |
+ 'YTick',[0 0.5 1], ... |
|
| 175 |
+ 'YTickMode','manual', ... |
|
| 176 |
+ 'ZColor',[0 0 0]); |
|
| 177 |
+ |
|
| 178 |
+data.vector_h=h1; |
|
| 179 |
+ |
|
| 180 |
+h2 = text('Parent',h1, ...
|
|
| 181 |
+ 'Color',[0 0 0], ... |
|
| 182 |
+ 'HandleVisibility','off', ... |
|
| 183 |
+ 'HorizontalAlignment','center', ... |
|
| 184 |
+ 'Position',[0.4982456140350879 -0.08080808080808044 9.160254037844386], ... |
|
| 185 |
+ 'Tag','Axes2Text4', ... |
|
| 186 |
+ 'VerticalAlignment','cap'); |
|
| 187 |
+set(get(h2,'Parent'),'XLabel',h2); |
|
| 188 |
+h2 = text('Parent',h1, ...
|
|
| 189 |
+ 'Color',[0 0 0], ... |
|
| 190 |
+ 'HandleVisibility','off', ... |
|
| 191 |
+ 'HorizontalAlignment','center', ... |
|
| 192 |
+ 'Position',[-0.1018 0.4848 9.1603], ... |
|
| 193 |
+ 'Rotation',90, ... |
|
| 194 |
+ 'Tag','Axes2Text3', ... |
|
| 195 |
+ 'VerticalAlignment','baseline'); |
|
| 196 |
+set(get(h2,'Parent'),'YLabel',h2); |
|
| 197 |
+h2 = text('Parent',h1, ...
|
|
| 198 |
+ 'Color',[0 0 0], ... |
|
| 199 |
+ 'HandleVisibility','off', ... |
|
| 200 |
+ 'HorizontalAlignment','right', ... |
|
| 201 |
+ 'Position',[-1.045614035087719 5.797979797979799 9.160254037844386], ... |
|
| 202 |
+ 'Tag','Axes2Text2', ... |
|
| 203 |
+ 'Visible','off'); |
|
| 204 |
+set(get(h2,'Parent'),'ZLabel',h2); |
|
| 205 |
+h2 = text('Parent',h1, ...
|
|
| 206 |
+ 'Color',[0 0 0], ... |
|
| 207 |
+ 'HandleVisibility','off', ... |
|
| 208 |
+ 'HorizontalAlignment','center', ... |
|
| 209 |
+ 'Position',[0.4982456140350879 1.070707070707071 9.160254037844386], ... |
|
| 210 |
+ 'Tag','Axes2Text1', ... |
|
| 211 |
+ 'VerticalAlignment','bottom'); |
|
| 212 |
+set(get(h2,'Parent'),'Title',h2); |
|
| 213 |
+ |
|
| 214 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 215 |
+ 'Units','normalized', ... |
|
| 216 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 217 |
+ 'FontWeight','demi', ... |
|
| 218 |
+ 'HorizontalAlignment','left', ... |
|
| 219 |
+ 'ListboxTop',0, ... |
|
| 220 |
+ 'Position',[0.01833333333333333 0.3922580645161291 0.17 0.01806451612903226], ... |
|
| 221 |
+ 'String','STATISTICS', ... |
|
| 222 |
+ 'Style','text', ... |
|
| 223 |
+ 'Tag','StaticText4'); |
|
| 224 |
+ |
|
| 225 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 226 |
+ 'Units','normalized', ... |
|
| 227 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 228 |
+ 'FontWeight','demi', ... |
|
| 229 |
+ 'HorizontalAlignment','left', ... |
|
| 230 |
+ 'ListboxTop',0, ... |
|
| 231 |
+ 'Position',[0.2583333333333334 0.3922580645161291 0.1633333333333333 0.01806451612903226], ... |
|
| 232 |
+ 'String','HISTOGRAM', ... |
|
| 233 |
+ 'Style','text', ... |
|
| 234 |
+ 'Tag','StaticText5'); |
|
| 235 |
+ |
|
| 236 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 237 |
+ 'Units','normalized', ... |
|
| 238 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 239 |
+ 'FontWeight','demi',... |
|
| 240 |
+ 'FontSize',6,... |
|
| 241 |
+ 'HorizontalAlignment','left',... |
|
| 242 |
+ 'String',{'LEFT: NEW SELECTION';'RIGHT: ADD TO SELECTION'}, ...
|
|
| 243 |
+ 'ListboxTop',0, ... |
|
| 244 |
+ 'Position',[0.5016666666666667 0.38 0.235 0.03741935483870968], ... |
|
| 245 |
+ 'Style','text', ... |
|
| 246 |
+ 'Tag','StaticText6', ... |
|
| 247 |
+ 'UserData','[ ]'); |
|
| 248 |
+ |
|
| 249 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 250 |
+ 'Units','normalized', ... |
|
| 251 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 252 |
+ 'Callback','preprocess selall', ... |
|
| 253 |
+ 'FontWeight','demi', ... |
|
| 254 |
+ 'ListboxTop',0, ... |
|
| 255 |
+ 'Position',[0.8066666666666668 0.3922580645161291 0.1666666666666667 0.03483870967741935], ... |
|
| 256 |
+ 'String','SELECT ALL', ... |
|
| 257 |
+ 'Tag','Pushbutton2', ... |
|
| 258 |
+ 'UserData','[ ]'); |
|
| 259 |
+ |
|
| 260 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 261 |
+ 'Units','normalized', ... |
|
| 262 |
+ 'BackgroundColor',[0.7529 0.7529 0.7529], ... |
|
| 263 |
+ 'Position',[0.01833333333333333 0.4503225806451613 0.23 0.3225806451612903], ... |
|
| 264 |
+ 'String',' ', ... |
|
| 265 |
+ 'Style','listbox', ... |
|
| 266 |
+ 'Tag','Listbox1', ... |
|
| 267 |
+ 'Value',1); |
|
| 268 |
+ |
|
| 269 |
+data.comp_names_h=h1; |
|
| 270 |
+ |
|
| 271 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 272 |
+ 'Units','normalized', ... |
|
| 273 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 274 |
+ 'Position',[0.4950000000000001 0.4503225806451613 0.2333333333333333 0.3225806451612903], ... |
|
| 275 |
+ 'String',' ', ... |
|
| 276 |
+ 'Style','listbox', ... |
|
| 277 |
+ 'Tag','Listbox2', ... |
|
| 278 |
+ 'Value',1); |
|
| 279 |
+ |
|
| 280 |
+data.vect_mean_h = h1; |
|
| 281 |
+ |
|
| 282 |
+h1 = axes('Parent',h0, ...
|
|
| 283 |
+ 'CameraUpVector',[0 1 0], ... |
|
| 284 |
+ 'CameraUpVectorMode','manual', ... |
|
| 285 |
+ 'Color',[1 1 1], ... |
|
| 286 |
+ 'Position',[0.7383333333333334 0.4503225806451613 0.2333333333333333 0.3225806451612903], ... |
|
| 287 |
+ 'Tag','Axes3', ... |
|
| 288 |
+ 'XColor',[0 0 0], ... |
|
| 289 |
+ 'XTickMode','manual', ... |
|
| 290 |
+ 'YColor',[0 0 0], ... |
|
| 291 |
+ 'YTickMode','manual', ... |
|
| 292 |
+ 'ZColor',[0 0 0]); |
|
| 293 |
+ |
|
| 294 |
+data.sel_cplot_h = h1; |
|
| 295 |
+ |
|
| 296 |
+h2 = text('Parent',h1, ...
|
|
| 297 |
+ 'Color',[0 0 0], ... |
|
| 298 |
+ 'HandleVisibility','off', ... |
|
| 299 |
+ 'HorizontalAlignment','center', ... |
|
| 300 |
+ 'Position',[0.4964028776978418 -0.03212851405622486 9.160254037844386], ... |
|
| 301 |
+ 'Tag','Axes3Text4', ... |
|
| 302 |
+ 'VerticalAlignment','cap'); |
|
| 303 |
+set(get(h2,'Parent'),'XLabel',h2); |
|
| 304 |
+h2 = text('Parent',h1, ...
|
|
| 305 |
+ 'Color',[0 0 0], ... |
|
| 306 |
+ 'HandleVisibility','off', ... |
|
| 307 |
+ 'HorizontalAlignment','center', ... |
|
| 308 |
+ 'Position',[-0.05035971223021596 0.493975903614458 9.160254037844386], ... |
|
| 309 |
+ 'Rotation',90, ... |
|
| 310 |
+ 'Tag','Axes3Text3', ... |
|
| 311 |
+ 'VerticalAlignment','baseline'); |
|
| 312 |
+set(get(h2,'Parent'),'YLabel',h2); |
|
| 313 |
+h2 = text('Parent',h1, ...
|
|
| 314 |
+ 'Color',[0 0 0], ... |
|
| 315 |
+ 'HandleVisibility','off', ... |
|
| 316 |
+ 'HorizontalAlignment','right', ... |
|
| 317 |
+ 'Position',[-3.1942 1.7028 9.1603], ... |
|
| 318 |
+ 'Tag','Axes3Text2', ... |
|
| 319 |
+ 'Visible','off'); |
|
| 320 |
+set(get(h2,'Parent'),'ZLabel',h2); |
|
| 321 |
+h2 = text('Parent',h1, ...
|
|
| 322 |
+ 'Color',[0 0 0], ... |
|
| 323 |
+ 'HandleVisibility','off', ... |
|
| 324 |
+ 'HorizontalAlignment','center', ... |
|
| 325 |
+ 'Position',[0.4964028776978418 1.028112449799197 9.160254037844386], ... |
|
| 326 |
+ 'Tag','Axes3Text1', ... |
|
| 327 |
+ 'VerticalAlignment','bottom'); |
|
| 328 |
+set(get(h2,'Parent'),'Title',h2); |
|
| 329 |
+ |
|
| 330 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 331 |
+ 'Units','normalized', ... |
|
| 332 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 333 |
+ 'Callback','preprocess plxy', ... |
|
| 334 |
+ 'FontWeight','demi', ... |
|
| 335 |
+ 'ListboxTop',0, ... |
|
| 336 |
+ 'Position',[0.265 0.4683870967741936 0.125 0.03483870967741935], ... |
|
| 337 |
+ 'String','XY-PLOT', ... |
|
| 338 |
+ 'Tag','Pushbutton3'); |
|
| 339 |
+ |
|
| 340 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 341 |
+ 'Units','normalized', ... |
|
| 342 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 343 |
+ 'Callback','preprocess hist', ... |
|
| 344 |
+ 'FontWeight','demi', ... |
|
| 345 |
+ 'ListboxTop',0, ... |
|
| 346 |
+ 'Position',[0.265 0.5303225806451613 0.125 0.03483870967741935], ... |
|
| 347 |
+ 'String','HISTOGRAM', ... |
|
| 348 |
+ 'Tag','Pushbutton4'); |
|
| 349 |
+ |
|
| 350 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 351 |
+ 'Units','normalized', ... |
|
| 352 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 353 |
+ 'Callback','preprocess bplo', ... |
|
| 354 |
+ 'FontWeight','demi', ... |
|
| 355 |
+ 'ListboxTop',0, ... |
|
| 356 |
+ 'Position',[0.265 0.5922580645161291 0.125 0.03483870967741935], ... |
|
| 357 |
+ 'String','BOX PLOT', ... |
|
| 358 |
+ 'Tag','Pushbutton5'); |
|
| 359 |
+ |
|
| 360 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 361 |
+ 'Units','normalized', ... |
|
| 362 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 363 |
+ 'Callback','preprocess plot', ... |
|
| 364 |
+ 'FontWeight','demi', ... |
|
| 365 |
+ 'ListboxTop',0, ... |
|
| 366 |
+ 'Position',[0.265 0.654195483870968 0.125 0.03483870967741935], ... |
|
| 367 |
+ 'String','PLOT', ... |
|
| 368 |
+ 'Tag','Pushbutton6'); |
|
| 369 |
+ |
|
| 370 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 371 |
+ 'Units','normalized', ... |
|
| 372 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 373 |
+ 'ListboxTop',0, ... |
|
| 374 |
+ 'Position',[0.4088888888888889 0.5333333333333333 0.06 0.03268817204301075], ... |
|
| 375 |
+ 'String','30', ... |
|
| 376 |
+ 'Style','edit', ... |
|
| 377 |
+ 'Tag','EditText1'); |
|
| 378 |
+ |
|
| 379 |
+data.no_of_bins_h = h1; |
|
| 380 |
+ |
|
| 381 |
+ |
|
| 382 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 383 |
+ 'Units','normalized', ... |
|
| 384 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 385 |
+ 'FontWeight','demi', ... |
|
| 386 |
+ 'HorizontalAlignment','left', ... |
|
| 387 |
+ 'ListboxTop',0, ... |
|
| 388 |
+ 'Position',[0.01833333333333333 0.775483870967742 0.2016666666666667 0.01806451612903226], ... |
|
| 389 |
+ 'String','COMPONENT LIST', ... |
|
| 390 |
+ 'Style','text', ... |
|
| 391 |
+ 'Tag','StaticText7'); |
|
| 392 |
+ |
|
| 393 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 394 |
+ 'Units','normalized', ... |
|
| 395 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 396 |
+ 'FontWeight','demi', ... |
|
| 397 |
+ 'HorizontalAlignment','left', ... |
|
| 398 |
+ 'ListboxTop',0, ... |
|
| 399 |
+ 'Position',[0.4950000000000001 0.775483870967742 0.1966666666666667 0.01806451612903226], ... |
|
| 400 |
+ 'String','AVERAGE', ... |
|
| 401 |
+ 'Style','text', ... |
|
| 402 |
+ 'Tag','StaticText8'); |
|
| 403 |
+ |
|
| 404 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 405 |
+ 'Units','normalized', ... |
|
| 406 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 407 |
+ 'FontWeight','demi', ... |
|
| 408 |
+ 'HorizontalAlignment','left', ... |
|
| 409 |
+ 'ListboxTop',0, ... |
|
| 410 |
+ 'Position',[0.7383333333333334 0.775483870967742 0.225 0.01806451612903226], ... |
|
| 411 |
+ 'String','RELATIVE VALUES', ... |
|
| 412 |
+ 'Style','text', ... |
|
| 413 |
+ 'Tag','StaticText9'); |
|
| 414 |
+ |
|
| 415 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 416 |
+ 'Units','normalized', ... |
|
| 417 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 418 |
+ 'FontSize',10, ... |
|
| 419 |
+ 'FontWeight','demi', ... |
|
| 420 |
+ 'HorizontalAlignment','left', ... |
|
| 421 |
+ 'ListboxTop',0, ... |
|
| 422 |
+ 'Position',[0.01833333333333333 0.8154838709677419 0.2033333333333333 0.0232258064516129], ... |
|
| 423 |
+ 'String','COMPONENTS', ... |
|
| 424 |
+ 'Style','text', ... |
|
| 425 |
+ 'Tag','StaticText10'); |
|
| 426 |
+ |
|
| 427 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 428 |
+ 'Units','normalized', ... |
|
| 429 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 430 |
+ 'FontSize',10, ... |
|
| 431 |
+ 'FontWeight','demi', ... |
|
| 432 |
+ 'HorizontalAlignment','left', ... |
|
| 433 |
+ 'ListboxTop',0, ... |
|
| 434 |
+ 'Position',[0.4950000000000001 0.8154838709677419 0.2 0.0232258064516129], ... |
|
| 435 |
+ 'String','VECTORS', ... |
|
| 436 |
+ 'Style','text', ... |
|
| 437 |
+ 'Tag','StaticText11'); |
|
| 438 |
+ |
|
| 439 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 440 |
+ 'Units','normalized', ... |
|
| 441 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 442 |
+ 'Callback','preprocess sD_management', ... |
|
| 443 |
+ 'FontSize',5, ... |
|
| 444 |
+ 'FontWeight','demi', ... |
|
| 445 |
+ 'ListboxTop',0, ... |
|
| 446 |
+ 'Position',[0.01833333333333333 0.8503225806451613 0.1666666666666667 0.03483870967741935], ... |
|
| 447 |
+ 'String','DATA SET MANAGEMENT', ... |
|
| 448 |
+ 'Tag','Pushbutton7'); |
|
| 449 |
+ |
|
| 450 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 451 |
+ 'Units','normalized', ... |
|
| 452 |
+ 'Callback','preprocess sel_sD', ... |
|
| 453 |
+ 'ListboxTop',0, ... |
|
| 454 |
+ 'Position',[0.01833333333333333 0.8890322580645161 0.1666666666666667 0.03483870967741935], ... |
|
| 455 |
+ 'String',' ', ... |
|
| 456 |
+ 'Style','popupmenu', ... |
|
| 457 |
+ 'Tag','PopupMenu2', ... |
|
| 458 |
+ 'Value',1); |
|
| 459 |
+ |
|
| 460 |
+data.sD_set_h = h1; |
|
| 461 |
+ |
|
| 462 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 463 |
+ 'Units','normalized', ... |
|
| 464 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 465 |
+ 'ListboxTop',0, ... |
|
| 466 |
+ 'Position',[0.2516666666666667 0.8503225806451613 0.7216666666666667 0.07354838709677419], ... |
|
| 467 |
+ 'Style','text', ... |
|
| 468 |
+ 'Tag','StaticText12'); |
|
| 469 |
+ |
|
| 470 |
+data.sD_name_h = h1; |
|
| 471 |
+ |
|
| 472 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 473 |
+ 'Units','normalized', ... |
|
| 474 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 475 |
+ 'FontSize',10, ... |
|
| 476 |
+ 'FontWeight','demi', ... |
|
| 477 |
+ 'HorizontalAlignment','left', ... |
|
| 478 |
+ 'ListboxTop',0, ... |
|
| 479 |
+ 'Position',[0.01833333333333333 0.9341935483870968 0.1616666666666667 0.02064516129032258], ... |
|
| 480 |
+ 'String','DATA SETS', ... |
|
| 481 |
+ 'Style','text', ... |
|
| 482 |
+ 'Tag','StaticText13'); |
|
| 483 |
+ |
|
| 484 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 485 |
+ 'Units','normalized', ... |
|
| 486 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 487 |
+ 'FontSize',10, ... |
|
| 488 |
+ 'FontWeight','demi', ... |
|
| 489 |
+ 'HorizontalAlignment','left', ... |
|
| 490 |
+ 'ListboxTop',0, ... |
|
| 491 |
+ 'Position',[0.2516666666666667 0.9341935483870968 0.2833333333333333 0.02064516129032258], ... |
|
| 492 |
+ 'String','SELECTED DATA SET', ... |
|
| 493 |
+ 'Style','text', ... |
|
| 494 |
+ 'Tag','StaticText14'); |
|
| 495 |
+ |
|
| 496 |
+if ~isstruct(sData), |
|
| 497 |
+ sData=som_data_struct(sData); |
|
| 498 |
+end |
|
| 499 |
+ |
|
| 500 |
+ui_h=uimenu('Label','&Normalization');
|
|
| 501 |
+uimenu(ui_h,'Label','Scale [0,1]','Callback','preprocess zscale'); |
|
| 502 |
+uimenu(ui_h,'Label','Scale var=1','Callback','preprocess vscale'); |
|
| 503 |
+uimenu(ui_h,'Label','HistD','Callback','preprocess histeq'); |
|
| 504 |
+uimenu(ui_h,'Label','HistC','Callback','preprocess histeq2'); |
|
| 505 |
+uimenu(ui_h,'Label','Log','Callback','preprocess log'); |
|
| 506 |
+uimenu(ui_h,'Label','Eval (1-comp)','Callback','preprocess eval1'); |
|
| 507 |
+ |
|
| 508 |
+ui_h=uimenu('Label','&Components');
|
|
| 509 |
+uimenu(ui_h,'Label','Move component','Callback','preprocess move'); |
|
| 510 |
+uimenu(ui_h,'Label','Copy component','Callback','preprocess copy'); |
|
| 511 |
+uimenu(ui_h,'Label','Add: N binary types','Callback','preprocess oneo'); |
|
| 512 |
+uimenu(ui_h,'Label','Add: zeros','Callback','preprocess zero'); |
|
| 513 |
+uimenu(ui_h,'Label','Remove component','Callback','preprocess remove'); |
|
| 514 |
+uimenu(ui_h,'Label','Remove selected vectors',... |
|
| 515 |
+ 'Callback','preprocess remove_vects'); |
|
| 516 |
+uimenu(ui_h,'Label','Select all components',... |
|
| 517 |
+ 'Callback','preprocess sel_all_comps'); |
|
| 518 |
+ |
|
| 519 |
+ui_h=uimenu('Label','&Misc');
|
|
| 520 |
+ui_h1=uimenu(ui_h,'Label','Calculate'); |
|
| 521 |
+ui_h2=uimenu(ui_h,'Label','Process'); |
|
| 522 |
+ |
|
| 523 |
+uimenu(ui_h,'Label','Get LOG-file','Callback','preprocess LOG'); |
|
| 524 |
+uimenu(ui_h,'Label','Indices of the selected vectors',... |
|
| 525 |
+ 'Callback','preprocess get_inds'); |
|
| 526 |
+uimenu(ui_h,'Label','Undo','Callback','preprocess undo'); |
|
| 527 |
+uimenu(ui_h1,'Label','Number of values','Callback','preprocess noof'); |
|
| 528 |
+uimenu(ui_h1,'Label','Number of selected vectors',... |
|
| 529 |
+ 'Callback','preprocess no_of_sel'); |
|
| 530 |
+uimenu(ui_h1,'Label','Correlation','Callback','preprocess corr'); |
|
| 531 |
+uimenu(ui_h2,'Label','Unit length','Callback','preprocess unit'); |
|
| 532 |
+uimenu(ui_h2,'Label','Eval','Callback','preprocess eval2'); |
|
| 533 |
+uimenu(ui_h2,'Label','Clipping','Callback','preprocess clipping'); |
|
| 534 |
+uimenu(ui_h2,'Label','Delay','Callback','preprocess delay'); |
|
| 535 |
+uimenu(ui_h2,'Label','Windowed','Callback','preprocess window'); |
|
| 536 |
+uimenu(ui_h2,'Label','Select vectors','Callback','preprocess select'); |
|
| 537 |
+ |
|
| 538 |
+len=getfield(size(sData(1).data),{1});
|
|
| 539 |
+data.selected_vects=find(ones(1,len)); |
|
| 540 |
+data.sD_set=sData; |
|
| 541 |
+set(data.vector_h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');
|
|
| 542 |
+set(gcf,'UserData',data); |
|
| 543 |
+if ~set_sD_stats; |
|
| 544 |
+ return; |
|
| 545 |
+end |
|
| 546 |
+sel_sD; |
|
| 547 |
+return; %%% Preprocess-window is ready. |
|
| 548 |
+ |
|
| 549 |
+else |
|
| 550 |
+ arg=sData; |
|
| 551 |
+ if strcmp(arg,'rename') |
|
| 552 |
+ rename(arg2); |
|
| 553 |
+ elseif strcmp(arg,'sel_sD') |
|
| 554 |
+ if isempty(arg2) |
|
| 555 |
+ sel_sD; |
|
| 556 |
+ else |
|
| 557 |
+ sel_sD(arg2); |
|
| 558 |
+ end |
|
| 559 |
+ elseif strcmp(arg,'zscale') |
|
| 560 |
+ if isempty(arg2) |
|
| 561 |
+ zero2one_scale; |
|
| 562 |
+ else |
|
| 563 |
+ zero2one_scale(arg2); |
|
| 564 |
+ end |
|
| 565 |
+ elseif strcmp(arg,'vscale'); |
|
| 566 |
+ if isempty(arg2) |
|
| 567 |
+ var_scale; |
|
| 568 |
+ else |
|
| 569 |
+ var_scale(arg2); |
|
| 570 |
+ end |
|
| 571 |
+ elseif strcmp(arg,'histeq2') |
|
| 572 |
+ if isempty(arg2) |
|
| 573 |
+ hist_eq2; |
|
| 574 |
+ else |
|
| 575 |
+ hist_eq2(arg2); |
|
| 576 |
+ end |
|
| 577 |
+ elseif strcmp(arg,'log') |
|
| 578 |
+ if isempty(arg2) |
|
| 579 |
+ logarithm; |
|
| 580 |
+ else |
|
| 581 |
+ logarithm(arg2); |
|
| 582 |
+ end |
|
| 583 |
+ elseif strcmp(arg,'eval1') |
|
| 584 |
+ if isempty(arg2) |
|
| 585 |
+ eval1; |
|
| 586 |
+ else |
|
| 587 |
+ eval1(arg2); |
|
| 588 |
+ end |
|
| 589 |
+ elseif strcmp(arg,'eval2') |
|
| 590 |
+ if isempty(arg2) |
|
| 591 |
+ eval2; |
|
| 592 |
+ else |
|
| 593 |
+ eval2(arg2); |
|
| 594 |
+ end |
|
| 595 |
+ elseif strcmp(arg,'histeq'); |
|
| 596 |
+ if isempty(arg2) |
|
| 597 |
+ hist_eq; |
|
| 598 |
+ else |
|
| 599 |
+ hist_eq(arg2); |
|
| 600 |
+ end |
|
| 601 |
+ elseif strcmp(arg,'selall') |
|
| 602 |
+ if isempty(arg2) |
|
| 603 |
+ select_all; |
|
| 604 |
+ else |
|
| 605 |
+ select_all(arg2); |
|
| 606 |
+ end |
|
| 607 |
+ elseif strcmp(arg,'sel_button'); |
|
| 608 |
+ if isempty(arg2) |
|
| 609 |
+ sel_button; |
|
| 610 |
+ else |
|
| 611 |
+ sel_button(arg2); |
|
| 612 |
+ end |
|
| 613 |
+ elseif strcmp(arg,'clear_button') |
|
| 614 |
+ if isempty(arg2) |
|
| 615 |
+ clear_button; |
|
| 616 |
+ else |
|
| 617 |
+ clear_button(arg2) |
|
| 618 |
+ end |
|
| 619 |
+ elseif(strcmp(arg,'move')) |
|
| 620 |
+ if isempty(arg2) |
|
| 621 |
+ move_component; |
|
| 622 |
+ else |
|
| 623 |
+ move_component(arg2); |
|
| 624 |
+ end |
|
| 625 |
+ elseif(strcmp(arg,'copy')) |
|
| 626 |
+ if isempty(arg2) |
|
| 627 |
+ copy_component; |
|
| 628 |
+ else |
|
| 629 |
+ copy_component(arg2); |
|
| 630 |
+ end |
|
| 631 |
+ elseif strcmp(arg,'oneo') |
|
| 632 |
+ if isempty(arg2) |
|
| 633 |
+ one_of_n; |
|
| 634 |
+ else |
|
| 635 |
+ one_of_n(arg2); |
|
| 636 |
+ end |
|
| 637 |
+ elseif strcmp(arg,'zero') |
|
| 638 |
+ if isempty(arg2) |
|
| 639 |
+ add_zeros; |
|
| 640 |
+ else |
|
| 641 |
+ add_zeros(arg2); |
|
| 642 |
+ end |
|
| 643 |
+ elseif strcmp(arg,'remove') |
|
| 644 |
+ if isempty(arg2) |
|
| 645 |
+ remove_component; |
|
| 646 |
+ else |
|
| 647 |
+ remove_component(arg2); |
|
| 648 |
+ end |
|
| 649 |
+ elseif strcmp(arg,'remove_vects') |
|
| 650 |
+ if isempty(arg2) |
|
| 651 |
+ remove_vects; |
|
| 652 |
+ else |
|
| 653 |
+ remove_vects(arg2); |
|
| 654 |
+ end |
|
| 655 |
+ elseif strcmp(arg,'noof') |
|
| 656 |
+ if isempty(arg2) |
|
| 657 |
+ no_of_values; |
|
| 658 |
+ else |
|
| 659 |
+ no_of_values(arg2); |
|
| 660 |
+ end |
|
| 661 |
+ elseif strcmp(arg,'corr'); |
|
| 662 |
+ if isempty(arg2) |
|
| 663 |
+ correlation; |
|
| 664 |
+ else |
|
| 665 |
+ correlation(arg2); |
|
| 666 |
+ end |
|
| 667 |
+ elseif strcmp(arg,'unit') |
|
| 668 |
+ if isempty(arg2) |
|
| 669 |
+ unit_length; |
|
| 670 |
+ else |
|
| 671 |
+ unit_length(arg2); |
|
| 672 |
+ end |
|
| 673 |
+ elseif strcmp(arg,'clip_data') |
|
| 674 |
+ clip_data(arg2); |
|
| 675 |
+ elseif strcmp(arg,'copy_delete') |
|
| 676 |
+ copy_delete(arg2); |
|
| 677 |
+ elseif strcmp(arg,'and_or_cb') |
|
| 678 |
+ and_or_cb(arg2); |
|
| 679 |
+ elseif strcmp(arg,'all_sel_cb') |
|
| 680 |
+ all_sel_cb(arg2); |
|
| 681 |
+ elseif strcmp(arg,'clip_exp_cb') |
|
| 682 |
+ clip_exp_cb(arg2); |
|
| 683 |
+ elseif strcmp(arg,'window_cb') |
|
| 684 |
+ window_cb(arg2); |
|
| 685 |
+ elseif strcmp(arg,'set_state_vals') |
|
| 686 |
+ set_state_vals(arg2); |
|
| 687 |
+ elseif strcmp(arg,'vector_bdf') |
|
| 688 |
+ vector_bdf(arg2); |
|
| 689 |
+ elseif strcmp(arg,'sD_management'); |
|
| 690 |
+ if isempty(arg2) |
|
| 691 |
+ sD_management; |
|
| 692 |
+ else |
|
| 693 |
+ sD_management(arg2); |
|
| 694 |
+ end |
|
| 695 |
+ elseif strcmp(arg,'clipping') |
|
| 696 |
+ if isempty(arg2) |
|
| 697 |
+ clipping; |
|
| 698 |
+ else |
|
| 699 |
+ clipping(arg2); |
|
| 700 |
+ end |
|
| 701 |
+ elseif strcmp(arg,'delay') |
|
| 702 |
+ if isempty(arg2) |
|
| 703 |
+ delay; |
|
| 704 |
+ else |
|
| 705 |
+ delay(arg2); |
|
| 706 |
+ end |
|
| 707 |
+ elseif strcmp(arg,'window'); |
|
| 708 |
+ if isempty(arg2) |
|
| 709 |
+ window; |
|
| 710 |
+ else |
|
| 711 |
+ window(arg2); |
|
| 712 |
+ end |
|
| 713 |
+ elseif strcmp(arg,'select'); |
|
| 714 |
+ if isempty(arg2) |
|
| 715 |
+ select; |
|
| 716 |
+ else |
|
| 717 |
+ select(arg2); |
|
| 718 |
+ end |
|
| 719 |
+ elseif strcmp(arg,'import') |
|
| 720 |
+ if isempty(arg2) |
|
| 721 |
+ import; |
|
| 722 |
+ else |
|
| 723 |
+ import(arg2); |
|
| 724 |
+ end |
|
| 725 |
+ elseif strcmp(arg,'export') |
|
| 726 |
+ if isempty(arg2) |
|
| 727 |
+ export; |
|
| 728 |
+ else |
|
| 729 |
+ export(arg2); |
|
| 730 |
+ end |
|
| 731 |
+ elseif strcmp(arg,'undo'); |
|
| 732 |
+ if isempty(arg2) |
|
| 733 |
+ undo; |
|
| 734 |
+ else |
|
| 735 |
+ undo(arg2); |
|
| 736 |
+ end |
|
| 737 |
+ elseif strcmp(arg,'delay_data') |
|
| 738 |
+ if isempty(arg2) |
|
| 739 |
+ delay_data; |
|
| 740 |
+ else |
|
| 741 |
+ delay_data(arg2); |
|
| 742 |
+ end |
|
| 743 |
+ elseif strcmp(arg,'eval_windowed') |
|
| 744 |
+ if isempty(arg2) |
|
| 745 |
+ eval_windowed; |
|
| 746 |
+ else |
|
| 747 |
+ eval_windowed(arg2); |
|
| 748 |
+ end |
|
| 749 |
+ elseif strcmp(arg,'get_inds') |
|
| 750 |
+ if isempty(arg2) |
|
| 751 |
+ get_selected_inds; |
|
| 752 |
+ else |
|
| 753 |
+ get_selected_inds(arg2); |
|
| 754 |
+ end |
|
| 755 |
+ elseif strcmp(arg,'no_of_sel') |
|
| 756 |
+ if isempty(arg2) |
|
| 757 |
+ no_of_selected; |
|
| 758 |
+ else |
|
| 759 |
+ no_of_selected(arg2); |
|
| 760 |
+ end |
|
| 761 |
+ elseif strcmp(arg,'sel_comp'); |
|
| 762 |
+ if isempty(arg2) |
|
| 763 |
+ sel_comp; |
|
| 764 |
+ else |
|
| 765 |
+ sel_comp(arg2); |
|
| 766 |
+ end |
|
| 767 |
+ elseif strcmp(arg,'sel_all_comps') |
|
| 768 |
+ if isempty(arg2) |
|
| 769 |
+ select_all_comps; |
|
| 770 |
+ else |
|
| 771 |
+ select_all_comps(arg2); |
|
| 772 |
+ end |
|
| 773 |
+ elseif strcmp(arg,'refresh') |
|
| 774 |
+ set_var_names; |
|
| 775 |
+ elseif any(strcmp(arg,{'close_c','close_d','close_s','close_w','close_sD'}))
|
|
| 776 |
+ if isempty(arg2) |
|
| 777 |
+ close_func(arg) |
|
| 778 |
+ else |
|
| 779 |
+ close_func(arg,arg2); |
|
| 780 |
+ end |
|
| 781 |
+ end |
|
| 782 |
+ |
|
| 783 |
+ |
|
| 784 |
+ switch arg |
|
| 785 |
+ case 'sD_stats' |
|
| 786 |
+ sD_stats; |
|
| 787 |
+ case 'LOG' |
|
| 788 |
+ log_file; |
|
| 789 |
+ otherwise |
|
| 790 |
+ pro_tools(arg); |
|
| 791 |
+ end |
|
| 792 |
+end |
|
| 793 |
+ |
|
| 794 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 795 |
+ |
|
| 796 |
+function set_compnames(sData,h) |
|
| 797 |
+ |
|
| 798 |
+%SET_COMPNAMES |
|
| 799 |
+% |
|
| 800 |
+% set_compnames(sData,h) |
|
| 801 |
+% |
|
| 802 |
+% ARGUMENTS |
|
| 803 |
+% |
|
| 804 |
+% sData (struct) som_data_struct |
|
| 805 |
+% h (scalar) handle to a list box object |
|
| 806 |
+% |
|
| 807 |
+% |
|
| 808 |
+% This function sets the component names of sData to the list box |
|
| 809 |
+% indicated by 'h'. |
|
| 810 |
+% |
|
| 811 |
+ |
|
| 812 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 813 |
+ |
|
| 814 |
+if isempty(pre_h) |
|
| 815 |
+ error('Figure ''Preprocess'' does not exist. Closing program...');
|
|
| 816 |
+ close_preprocess; |
|
| 817 |
+end |
|
| 818 |
+ |
|
| 819 |
+udata=get(pre_h,'UserData'); |
|
| 820 |
+ |
|
| 821 |
+set(h,'Value',[]); |
|
| 822 |
+for i=1:length(sData.comp_names) |
|
| 823 |
+ tmp=sprintf('#%d: ',i);
|
|
| 824 |
+ names{i,1}=cat(2,tmp, sData.comp_names{i});
|
|
| 825 |
+end |
|
| 826 |
+ |
|
| 827 |
+ |
|
| 828 |
+set(h,'String',names,'Max',2); |
|
| 829 |
+set(udata.sel_comp_h,'String',names); |
|
| 830 |
+ |
|
| 831 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 832 |
+ |
|
| 833 |
+function draw_vectors(vectors,h) |
|
| 834 |
+ |
|
| 835 |
+%DRAW_VECTORS |
|
| 836 |
+% |
|
| 837 |
+% draw_vectors(vectors,h) |
|
| 838 |
+% |
|
| 839 |
+% ARGUMENTS |
|
| 840 |
+% |
|
| 841 |
+% vectors (vector) vector of 0's and 1's |
|
| 842 |
+% h (scalar) handle to an axis object |
|
| 843 |
+% |
|
| 844 |
+% |
|
| 845 |
+% This function draws an horizontal bar of 'vectors' in the axis |
|
| 846 |
+% indicated by 'h'. |
|
| 847 |
+% |
|
| 848 |
+% |
|
| 849 |
+ |
|
| 850 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 851 |
+subplot(h); |
|
| 852 |
+hold off; |
|
| 853 |
+cla; |
|
| 854 |
+ |
|
| 855 |
+set(h,'YLim',[0 1]); |
|
| 856 |
+set(h,'YTick',[]); |
|
| 857 |
+set(h,'XLim',[0 length(vectors)+1]); |
|
| 858 |
+hold on; |
|
| 859 |
+ |
|
| 860 |
+comp_no=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value'); |
|
| 861 |
+comp=getfield(get(pre_h,'UserData'),'sData'); |
|
| 862 |
+comp=comp.data(:,comp_no); |
|
| 863 |
+Max = max(comp); |
|
| 864 |
+Min = min(comp); |
|
| 865 |
+lims=get(gca,'YLim'); |
|
| 866 |
+lims(1)=Min; |
|
| 867 |
+h=abs(0.1*Max); |
|
| 868 |
+lims(2)=Max; |
|
| 869 |
+if Max - Min <= eps |
|
| 870 |
+ tmp=Max; |
|
| 871 |
+ lims(1)=tmp-1; |
|
| 872 |
+ lims(2)=tmp+1; |
|
| 873 |
+end |
|
| 874 |
+lims(2)=lims(2)+h; |
|
| 875 |
+if ~all(isnan(lims)) |
|
| 876 |
+ set(gca,'YLim',lims); |
|
| 877 |
+end |
|
| 878 |
+h=(lims(2)-lims(1))/4; |
|
| 879 |
+set(gca,'YTickMode','auto'); |
|
| 880 |
+t=1:length(vectors); |
|
| 881 |
+h=plot(t,comp); |
|
| 882 |
+set(h,'ButtonDownFcn','preprocess(''vector_bdf'',''down'')');
|
|
| 883 |
+indices =find(vectors); |
|
| 884 |
+vectors(indices)=0.1*(getfield(get(gca,'YLim'),... |
|
| 885 |
+ {2})-getfield(get(gca,'YLim'),{1}));
|
|
| 886 |
+plot(indices,vectors(indices)+getfield(get(gca,'YLim'),{1}),...
|
|
| 887 |
+ 'ored','MarkerSize',4); |
|
| 888 |
+ |
|
| 889 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 890 |
+ |
|
| 891 |
+function vect_means(sData,handle,indices) |
|
| 892 |
+ |
|
| 893 |
+%VECT_MEANS |
|
| 894 |
+% |
|
| 895 |
+% vect_means(sData,handle,indices) |
|
| 896 |
+% |
|
| 897 |
+% ARGUMENTS |
|
| 898 |
+% |
|
| 899 |
+% sData (struct) som_data_struct |
|
| 900 |
+% handle (scalar) handle to the static text box object |
|
| 901 |
+% indices (vector) indices of selected vectors |
|
| 902 |
+% |
|
| 903 |
+% |
|
| 904 |
+% This function calculates means of selected vectors' components |
|
| 905 |
+% and writes them in the static text box indicated by 'handle'. |
|
| 906 |
+% |
|
| 907 |
+% |
|
| 908 |
+ |
|
| 909 |
+sData= sData.data(indices,:); |
|
| 910 |
+ |
|
| 911 |
+for i=1:length(sData(1,:)) |
|
| 912 |
+ names{i}=sprintf('#%d: ',i);
|
|
| 913 |
+end |
|
| 914 |
+ |
|
| 915 |
+ |
|
| 916 |
+for i=1:length(sData(1,:)) |
|
| 917 |
+ tmp=sData(:,i); |
|
| 918 |
+ tmp=cat(2,names{i},sprintf('%-10.3g',mean(tmp(find(~isnan(tmp))))));
|
|
| 919 |
+ string{i}=tmp;
|
|
| 920 |
+end |
|
| 921 |
+ |
|
| 922 |
+set(handle,'String',string); |
|
| 923 |
+set(handle,'HorizontalAlignment','left'); |
|
| 924 |
+ |
|
| 925 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 926 |
+ |
|
| 927 |
+function vector_bdf(arg) |
|
| 928 |
+ |
|
| 929 |
+%VECTOR_BDF A button down function. |
|
| 930 |
+% |
|
| 931 |
+% vector_bdf(arg) |
|
| 932 |
+% |
|
| 933 |
+% ARGUMENTS |
|
| 934 |
+% |
|
| 935 |
+% arg (string) 'down' or 'up', tells the mouse button's state. |
|
| 936 |
+% |
|
| 937 |
+% |
|
| 938 |
+% This function selects vectors in the vector-window and plots maxima, |
|
| 939 |
+% minima and means of the selected vectors. It also writes means of the |
|
| 940 |
+% selected vectors' components in a static text box and takes care of |
|
| 941 |
+% changes of the chosen component's data. |
|
| 942 |
+% |
|
| 943 |
+% See also VECTOR_MEANS, SEL_COMP |
|
| 944 |
+% |
|
| 945 |
+% |
|
| 946 |
+ |
|
| 947 |
+ |
|
| 948 |
+arg2=arg(6:length(arg)); |
|
| 949 |
+if ~isempty(arg2) |
|
| 950 |
+ LOG=1; |
|
| 951 |
+else |
|
| 952 |
+ LOG=0; |
|
| 953 |
+end |
|
| 954 |
+arg=arg(1:4); |
|
| 955 |
+ |
|
| 956 |
+%%% arg's first "word" is 4 letters long and it can be: |
|
| 957 |
+%%% |
|
| 958 |
+%%% 'key ' |
|
| 959 |
+%%% 'down' |
|
| 960 |
+%%% 'drag' |
|
| 961 |
+%%% 'up ' |
|
| 962 |
+ |
|
| 963 |
+if strcmp(arg,'key ') %string is 'key' + 1 space!!! |
|
| 964 |
+ if ~LOG |
|
| 965 |
+ key=get(gcf,'CurrentCharacter'); |
|
| 966 |
+ else |
|
| 967 |
+ key=arg2 |
|
| 968 |
+ end |
|
| 969 |
+ if ~strcmp(key,'<') & ~strcmp(key,'>') |
|
| 970 |
+ return; |
|
| 971 |
+ end |
|
| 972 |
+ data=get(gcf,'UserData'); |
|
| 973 |
+ sel=data.selected_vects; |
|
| 974 |
+ if length(sel) == 1 |
|
| 975 |
+ if strcmp(key,'<') & sel ~= 1 |
|
| 976 |
+ data.selected_vects=sel-1; |
|
| 977 |
+ set(gcf,'UserData',data); |
|
| 978 |
+ elseif strcmp(key,'>') & sel ~= length(data.sData.data(:,1)) |
|
| 979 |
+ data.selected_vects = sel + 1; |
|
| 980 |
+ set(gcf,'UserData',data); |
|
| 981 |
+ end |
|
| 982 |
+ else |
|
| 983 |
+ if strcmp(key,'<') & sel(1) ~= 1 |
|
| 984 |
+ data.selected_vects=cat(2,sel(1)-1,sel); |
|
| 985 |
+ set(gcf,'UserData',data); |
|
| 986 |
+ elseif strcmp(key,'>') & sel(length(sel)) ~= length(sel) |
|
| 987 |
+ data.selected_vects=cat(2,sel,sel(length(sel))+1); |
|
| 988 |
+ set(gcf,'UserData',data); |
|
| 989 |
+ end |
|
| 990 |
+ end |
|
| 991 |
+ cplot_mimema; |
|
| 992 |
+ pro_tools('plot_hist');
|
|
| 993 |
+ pro_tools('c_stat');
|
|
| 994 |
+ vects=zeros(1,length(data.sData.data(:,1))); |
|
| 995 |
+ vects(data.selected_vects)=1; |
|
| 996 |
+ draw_vectors(vects,data.vector_h); |
|
| 997 |
+ |
|
| 998 |
+ if ~LOG |
|
| 999 |
+ data=get(gcf,'UserData'); |
|
| 1000 |
+ data.LOG{length(data.LOG)+1}=...
|
|
| 1001 |
+ sprintf('preprocess(''vector_bdf'',''key %s'');',key);
|
|
| 1002 |
+ %string is 'key'+2spaces+%s |
|
| 1003 |
+ set(gcf,'UserData',data); |
|
| 1004 |
+ end |
|
| 1005 |
+ return; |
|
| 1006 |
+end |
|
| 1007 |
+ |
|
| 1008 |
+switch arg |
|
| 1009 |
+ case 'down' |
|
| 1010 |
+ set(gcf,'WindowButtonUpFcn','preprocess(''vector_bdf'',''up '')');
|
|
| 1011 |
+ set(gcf,'WindowButtonMotionFcn','preprocess(''vector_bdf'',''drag'')');
|
|
| 1012 |
+ switch get(gcf,'SelectionType') |
|
| 1013 |
+ case 'normal' |
|
| 1014 |
+ data.lims1=round(getfield(get(gca,'CurrentPoint'),{1,1}));
|
|
| 1015 |
+ data.lims2=[]; |
|
| 1016 |
+ case 'alt' |
|
| 1017 |
+ tmp=round(getfield(get(gca,'CurrentPoint'),{1,1}));
|
|
| 1018 |
+ if isempty(get(gca,'UserData')) |
|
| 1019 |
+ data.lims1=tmp; |
|
| 1020 |
+ data.lims2=[]; |
|
| 1021 |
+ else |
|
| 1022 |
+ data.lims1=cat(2,getfield(get(gca,'UserData'),'lims1'),tmp); |
|
| 1023 |
+ data.lims2=getfield(get(gca,'UserData'),'lims2'); |
|
| 1024 |
+ end |
|
| 1025 |
+ end |
|
| 1026 |
+ coords=get(gca,'CurrentPoint'); |
|
| 1027 |
+ h=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor'); |
|
| 1028 |
+ set(h,'Color','red'); |
|
| 1029 |
+ h2=line([coords(1),coords(1)],get(gca,'YLim'),'EraseMode','xor'); |
|
| 1030 |
+ set(h2,'Color','red'); |
|
| 1031 |
+ data.h=h; |
|
| 1032 |
+ data.h2=h2; |
|
| 1033 |
+ set(gca,'UserData',data); |
|
| 1034 |
+ |
|
| 1035 |
+ case 'drag' |
|
| 1036 |
+ coords=get(gca,'CurrentPoint'); |
|
| 1037 |
+ lim=get(gca,'XLim'); |
|
| 1038 |
+ h2=getfield(get(gca,'UserData'),'h2'); |
|
| 1039 |
+ if lim(1) >= coords(1) |
|
| 1040 |
+ set(h2,'XData',[lim(1) lim(1)]); |
|
| 1041 |
+ elseif lim(2) <= coords(2) |
|
| 1042 |
+ set(h2,'XData',[lim(2) lim(2)]); |
|
| 1043 |
+ else |
|
| 1044 |
+ set(h2,'XData',[coords(1) coords(1)]); |
|
| 1045 |
+ end |
|
| 1046 |
+ case 'up ' % string is 'up' + 2 spaces!!! |
|
| 1047 |
+ set(gcf,'WindowButtonUpFcn',''); |
|
| 1048 |
+ set(gcf,'WindowButtonMotionFcn',''); |
|
| 1049 |
+ if ~LOG |
|
| 1050 |
+ data=get(gca,'UserData'); |
|
| 1051 |
+ delete(data.h); |
|
| 1052 |
+ delete(data.h2); |
|
| 1053 |
+ tmp=round(getfield(get(gca,'CurrentPoint'),{1,1}));
|
|
| 1054 |
+ data.lims2=cat(2,data.lims2,tmp); |
|
| 1055 |
+ tmp_data=sort(cat(1,data.lims1,data.lims2)); |
|
| 1056 |
+ high=getfield(get(gca,'XLim'),{2})-1;
|
|
| 1057 |
+ vectors=zeros(1,high); |
|
| 1058 |
+ tmp_data(find(tmp_data<1))=1; |
|
| 1059 |
+ tmp_data(find(tmp_data>high))=high; |
|
| 1060 |
+ |
|
| 1061 |
+ for i=1:getfield(size(tmp_data),{2})
|
|
| 1062 |
+ vectors(tmp_data(1,i):tmp_data(2,i))=1; |
|
| 1063 |
+ end |
|
| 1064 |
+ selected_vects=find(vectors); |
|
| 1065 |
+ else |
|
| 1066 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1067 |
+ len=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')); |
|
| 1068 |
+ vectors=zeros(1,len(1)); |
|
| 1069 |
+ i=1; |
|
| 1070 |
+ while i <= length(arg2) & (isspace(arg2(i)) | ~isletter(arg2(i))) |
|
| 1071 |
+ i=i+1; |
|
| 1072 |
+ end |
|
| 1073 |
+ arg3=arg2(i:length(arg2)); |
|
| 1074 |
+ selected_vects=str2num(arg2(1:i-1)); |
|
| 1075 |
+ if ~isempty(arg3) & ~all(isspace(arg3)) |
|
| 1076 |
+ selected_vects=unique(cat(2,selected_vects,... |
|
| 1077 |
+ getfield(get(pre_h,'UserData'),'selected_vects'))); |
|
| 1078 |
+ end |
|
| 1079 |
+ vectors(selected_vects)=1; |
|
| 1080 |
+ set(pre_h,'CurrentAxes',getfield(get(pre_h,'UserData'),'vector_h')); |
|
| 1081 |
+ set(0,'CurrentFigure',pre_h); |
|
| 1082 |
+ end |
|
| 1083 |
+ draw_vectors(vectors,gca); |
|
| 1084 |
+ sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 1085 |
+ h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 1086 |
+ vect_means(sData,h,selected_vects); |
|
| 1087 |
+ if ~LOG |
|
| 1088 |
+ set(gca,'UserData',data); |
|
| 1089 |
+ end |
|
| 1090 |
+ data=get(gcf,'UserData'); |
|
| 1091 |
+ data.undo.sData=data.sData; |
|
| 1092 |
+ data.undo.selected=data.selected_vects; |
|
| 1093 |
+ data.selected_vects=selected_vects; |
|
| 1094 |
+ if ~LOG |
|
| 1095 |
+ data.LOG{length(data.LOG)+1}='% Vector selection by using the mouse...';
|
|
| 1096 |
+ tmp=sprintf('preprocess(''vector_bdf'',''up %s'');',...
|
|
| 1097 |
+ num2str(data.selected_vects)); |
|
| 1098 |
+ if length(tmp) > 500 |
|
| 1099 |
+ tmp=textwrap({tmp},500);
|
|
| 1100 |
+ data.LOG{length(data.LOG)+1}=cat(2,tmp{1},''');');
|
|
| 1101 |
+ for i=2:length(tmp)-1 |
|
| 1102 |
+ data.LOG{length(data.LOG)+1}=...
|
|
| 1103 |
+ cat(2,sprintf('preprocess(''vector_bdf'',''up %s',...
|
|
| 1104 |
+ tmp{i}),'add'');');
|
|
| 1105 |
+ end |
|
| 1106 |
+ data.LOG{length(data.LOG)+1}=...
|
|
| 1107 |
+ cat(2,sprintf('preprocess(''vector_bdf'',''up %s',...
|
|
| 1108 |
+ tmp{length(tmp)}(1:length(tmp{length(tmp)})-3)),' add'');');
|
|
| 1109 |
+ else |
|
| 1110 |
+ data.LOG{length(data.LOG)+1}=tmp;
|
|
| 1111 |
+ end |
|
| 1112 |
+ end |
|
| 1113 |
+ set(gcf,'UserData',data); |
|
| 1114 |
+ cplot_mimema; |
|
| 1115 |
+ sel_comp; |
|
| 1116 |
+end |
|
| 1117 |
+ |
|
| 1118 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1119 |
+ |
|
| 1120 |
+function sel_button(varargin) |
|
| 1121 |
+ |
|
| 1122 |
+%SEL_BUTTON A Callback function. It performs the operations needed |
|
| 1123 |
+% when vector components are selected. |
|
| 1124 |
+% |
|
| 1125 |
+% See also SEL_COMP |
|
| 1126 |
+% |
|
| 1127 |
+ |
|
| 1128 |
+if nargin == 1 |
|
| 1129 |
+ LOG=1; |
|
| 1130 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1131 |
+ string=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 1132 |
+ string=getfield(get(string,'String'),{str2num(varargin{1})});
|
|
| 1133 |
+ set(0,'CurrentFigure',pre_h); |
|
| 1134 |
+else |
|
| 1135 |
+ LOG=0; |
|
| 1136 |
+ val=get(getfield(get(gcf,'UserData'),'comp_names_h'),'Value'); |
|
| 1137 |
+end |
|
| 1138 |
+ |
|
| 1139 |
+sel_button_h=getfield(get(gcf,'UserData'),'sel_button_h'); |
|
| 1140 |
+sel_comps_h=getfield(get(gcf,'UserData'),'sel_comps_h'); |
|
| 1141 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 1142 |
+if ~LOG |
|
| 1143 |
+ string=getfield(get(comp_names_h,'String'),{get(comp_names_h,'Value')});
|
|
| 1144 |
+end |
|
| 1145 |
+tmp_string=get(sel_comps_h,'String'); |
|
| 1146 |
+ |
|
| 1147 |
+if iscell(tmp_string) |
|
| 1148 |
+ |
|
| 1149 |
+ for i=1:length(string) |
|
| 1150 |
+ if ~any(strcmp(string{i},tmp_string))
|
|
| 1151 |
+ tmp_string=cat(1,tmp_string,string(i)); |
|
| 1152 |
+ end |
|
| 1153 |
+ end |
|
| 1154 |
+ string=tmp_string; |
|
| 1155 |
+end |
|
| 1156 |
+ |
|
| 1157 |
+set(sel_comps_h,'String',string); |
|
| 1158 |
+set(comp_names_h,'Value',[]); |
|
| 1159 |
+sel_comp; |
|
| 1160 |
+if ~LOG |
|
| 1161 |
+ data=get(gcf,'UserData'); |
|
| 1162 |
+ data.LOG{length(data.LOG)+1}='% Select components';
|
|
| 1163 |
+ data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_button'',''%s'');',...
|
|
| 1164 |
+ num2str(val)); |
|
| 1165 |
+ set(gcf,'UserData',data); |
|
| 1166 |
+end |
|
| 1167 |
+ |
|
| 1168 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1169 |
+ |
|
| 1170 |
+function clear_button(varargin) |
|
| 1171 |
+ |
|
| 1172 |
+%CLEAR_BUTTON Function callback evaluated when a 'Clear'-button is |
|
| 1173 |
+% pressed. It removes texts from the 'selected components' |
|
| 1174 |
+% -window and the 'selected component data' -window and |
|
| 1175 |
+% clears the 'histogram' -axis. |
|
| 1176 |
+% |
|
| 1177 |
+% |
|
| 1178 |
+ |
|
| 1179 |
+if nargin==1 |
|
| 1180 |
+ LOG=1; |
|
| 1181 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1182 |
+ set(0,'CurrentFigure',pre_h); |
|
| 1183 |
+else |
|
| 1184 |
+ LOG=0; |
|
| 1185 |
+end |
|
| 1186 |
+ |
|
| 1187 |
+sel_comp_h=getfield(get(gcf,'UserData'),'sel_comp_h'); |
|
| 1188 |
+sel_cdata_h=getfield(get(gcf,'UserData'),'sel_cdata_h'); |
|
| 1189 |
+sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h'); |
|
| 1190 |
+sel_chist_h=getfield(get(gcf,'UserData'),'sel_chist_h'); |
|
| 1191 |
+vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 1192 |
+ |
|
| 1193 |
+set(sel_comp_h,'Value',1); |
|
| 1194 |
+set(sel_cdata_h,'String',' '); |
|
| 1195 |
+subplot(sel_chist_h); |
|
| 1196 |
+hold off; |
|
| 1197 |
+cla; |
|
| 1198 |
+ |
|
| 1199 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 1200 |
+dims=size(getfield(getfield(get(gcf,'UserData'),'sData'),'data')); |
|
| 1201 |
+vectors=zeros(1,dims(1)); |
|
| 1202 |
+vectors(selected)=1; |
|
| 1203 |
+subplot(vector_h); |
|
| 1204 |
+draw_vectors(vectors,vector_h); |
|
| 1205 |
+if ~LOG |
|
| 1206 |
+ data=get(gcf,'UserData'); |
|
| 1207 |
+ data.LOG{length(data.LOG)+1}='% Remove components from the selected list.';
|
|
| 1208 |
+ data.LOG{length(data.LOG)+1}='preprocess(''clear_button'',''foo'');';
|
|
| 1209 |
+ set(gcf,'UserData',data); |
|
| 1210 |
+end |
|
| 1211 |
+ |
|
| 1212 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1213 |
+ |
|
| 1214 |
+function sel_comp(varargin) |
|
| 1215 |
+ |
|
| 1216 |
+%SEL_COMP performs the operations needed when vector components are |
|
| 1217 |
+% chosen. It writes maxima, minima, mean and standard deviation |
|
| 1218 |
+% of the chosen component to a text box window and draws a |
|
| 1219 |
+% histogram of the chosen component of selected vectors' |
|
| 1220 |
+% |
|
| 1221 |
+% |
|
| 1222 |
+ |
|
| 1223 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1224 |
+set(0,'CurrentFigure',pre_h); |
|
| 1225 |
+sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h'); |
|
| 1226 |
+ |
|
| 1227 |
+if nargin == 1 |
|
| 1228 |
+ set(sel_comp_h,'Value',str2num(varargin{1}));
|
|
| 1229 |
+elseif ~isempty(gcbo) |
|
| 1230 |
+ no=get(sel_comp_h,'Value'); |
|
| 1231 |
+ data=get(gcf,'UserData'); |
|
| 1232 |
+ data.LOG{length(data.LOG)+1}='% Select one component';
|
|
| 1233 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''sel_comp'',''',...
|
|
| 1234 |
+ num2str(no),''');'); |
|
| 1235 |
+ set(gcf,'UserData',data); |
|
| 1236 |
+end |
|
| 1237 |
+ |
|
| 1238 |
+pro_tools('c_stat');
|
|
| 1239 |
+pro_tools('plot_hist');
|
|
| 1240 |
+data=get(gcf,'UserData'); |
|
| 1241 |
+sData=data.sData; |
|
| 1242 |
+vector_h=data.vector_h; |
|
| 1243 |
+len=length(sData.data(:,1)); |
|
| 1244 |
+vects=zeros(1,len); |
|
| 1245 |
+vects(data.selected_vects)=1; |
|
| 1246 |
+draw_vectors(vects,vector_h); |
|
| 1247 |
+ |
|
| 1248 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1249 |
+ |
|
| 1250 |
+function cplot_mimema |
|
| 1251 |
+ |
|
| 1252 |
+global no_of_sc |
|
| 1253 |
+ |
|
| 1254 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 1255 |
+sel_cplot_h=getfield(get(gcf,'UserData'),'sel_cplot_h'); |
|
| 1256 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 1257 |
+ |
|
| 1258 |
+set(sel_cplot_h,'YLim',[0 length(sData.data(1,:))+1]); |
|
| 1259 |
+ |
|
| 1260 |
+subplot(sel_cplot_h); |
|
| 1261 |
+hold off; |
|
| 1262 |
+cla; |
|
| 1263 |
+hold on; |
|
| 1264 |
+ |
|
| 1265 |
+for i=1:length(sData.data(1,:)) |
|
| 1266 |
+ Max=max(sData.data(:,i)); |
|
| 1267 |
+ Min=min(sData.data(:,i)); |
|
| 1268 |
+ tmp=sData.data(selected,i); |
|
| 1269 |
+ |
|
| 1270 |
+ selMax=max(tmp); |
|
| 1271 |
+ selMin=min(tmp); |
|
| 1272 |
+ Mean=abs(mean(tmp(find(~isnan(tmp))))); |
|
| 1273 |
+ Median=abs(median(tmp(find(~isnan(tmp))))); |
|
| 1274 |
+ |
|
| 1275 |
+ if Max ~= Min & ~all(isnan(sData.data(:,i))) |
|
| 1276 |
+ |
|
| 1277 |
+ if rem(i,no_of_sc) % no_of_sc is defined in the beginning of this file... |
|
| 1278 |
+ |
|
| 1279 |
+ line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],... |
|
| 1280 |
+ [i i],'Color','black'); |
|
| 1281 |
+ plot(abs(Mean-Min)/(Max-Min),i,'oblack'); |
|
| 1282 |
+ plot(abs(Median-Min)/(Max-Min),i,'xblack'); |
|
| 1283 |
+ else |
|
| 1284 |
+ line([abs(selMin-Min)/(Max-Min) (selMax-Min)/(Max-Min)],... |
|
| 1285 |
+ [i i],'Color','black','LineWidth',2); |
|
| 1286 |
+ plot(abs(Mean-Min)/(Max-Min),i,'oblack','LineWidth',2); |
|
| 1287 |
+ plot(abs(Median-Min)/(Max-Min),i,'xblack','LineWidth',2); |
|
| 1288 |
+ end |
|
| 1289 |
+ else |
|
| 1290 |
+ |
|
| 1291 |
+ if rem(i,no_of_sc) % N is defined in the beginning of this file. |
|
| 1292 |
+ |
|
| 1293 |
+ plot(mean(get(gca,'XLim')),i,'oblack'); |
|
| 1294 |
+ plot(mean(get(gca,'XLim')),i,'xblack'); |
|
| 1295 |
+ else |
|
| 1296 |
+ plot(mean(get(gca,'XLim')),i,'oblack','LineWidth',2); |
|
| 1297 |
+ plot(mean(get(gca,'XLim')),i,'xblack','LineWidth',2); |
|
| 1298 |
+ end |
|
| 1299 |
+ end |
|
| 1300 |
+end |
|
| 1301 |
+ |
|
| 1302 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1303 |
+ |
|
| 1304 |
+ |
|
| 1305 |
+function bool=set_sD_stats |
|
| 1306 |
+ |
|
| 1307 |
+%SET_SD_STATS Writes the data set names to popup menu. |
|
| 1308 |
+% |
|
| 1309 |
+% |
|
| 1310 |
+ |
|
| 1311 |
+bool=1; |
|
| 1312 |
+data=get(gcf,'UserData'); |
|
| 1313 |
+ |
|
| 1314 |
+for i=1:length(data.sD_set) |
|
| 1315 |
+ % if ~isvalid_var_name({data.sD_set(i).name})
|
|
| 1316 |
+ % close_preprocess; |
|
| 1317 |
+ % bool=0; |
|
| 1318 |
+ % return; |
|
| 1319 |
+ % end |
|
| 1320 |
+ string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name);
|
|
| 1321 |
+end |
|
| 1322 |
+ |
|
| 1323 |
+set(data.sD_set_h,'String',string); |
|
| 1324 |
+data.sData=data.sD_set(get(data.sD_set_h,'Value')); |
|
| 1325 |
+data.sData.MODIFIED=0; |
|
| 1326 |
+data.sData.INDEX=1; |
|
| 1327 |
+set(gcf,'UserData',data); |
|
| 1328 |
+write_sD_stats; |
|
| 1329 |
+ |
|
| 1330 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1331 |
+ |
|
| 1332 |
+function write_sD_stats |
|
| 1333 |
+ |
|
| 1334 |
+%WRITE_SD_STATS writes data's name, length and dimension to text box. |
|
| 1335 |
+% |
|
| 1336 |
+% |
|
| 1337 |
+ |
|
| 1338 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1339 |
+ |
|
| 1340 |
+ |
|
| 1341 |
+sD_name_h=getfield(get(pre_h,'UserData'),'sD_name_h'); |
|
| 1342 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 1343 |
+dims=size(sData.data); |
|
| 1344 |
+string{1}=cat(2,'Name: ',sData.name);
|
|
| 1345 |
+string{2}=cat(2,'Length: ',sprintf('%d',dims(1)));
|
|
| 1346 |
+string{3}=cat(2,'Dim: ',sprintf('%d',dims(2)));
|
|
| 1347 |
+ |
|
| 1348 |
+set(sD_name_h,'String',string); |
|
| 1349 |
+set(sD_name_h,'HorizontalAlignment','left'); |
|
| 1350 |
+ |
|
| 1351 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1352 |
+ |
|
| 1353 |
+ |
|
| 1354 |
+ |
|
| 1355 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1356 |
+ |
|
| 1357 |
+function sel_sD(varargin) |
|
| 1358 |
+ |
|
| 1359 |
+%SEL_SD sets new data to UserData's 'sData'. |
|
| 1360 |
+% |
|
| 1361 |
+% |
|
| 1362 |
+ |
|
| 1363 |
+if nargin==1 |
|
| 1364 |
+ LOG=1; |
|
| 1365 |
+ index=str2num(varargin{1});
|
|
| 1366 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1367 |
+ set(0,'CurrentFigure',pre_h); |
|
| 1368 |
+else |
|
| 1369 |
+ LOG=0; |
|
| 1370 |
+end |
|
| 1371 |
+ |
|
| 1372 |
+sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h'); |
|
| 1373 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 1374 |
+vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 1375 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 1376 |
+ |
|
| 1377 |
+if ~LOG |
|
| 1378 |
+ index=get(sD_set_h,'Value'); |
|
| 1379 |
+end |
|
| 1380 |
+data=get(gcf,'UserData'); |
|
| 1381 |
+data.undo = []; |
|
| 1382 |
+INDEX=data.sData.INDEX; |
|
| 1383 |
+data.sData=rmfield(data.sData,'MODIFIED'); |
|
| 1384 |
+data.sData=rmfield(data.sData,'INDEX'); |
|
| 1385 |
+ |
|
| 1386 |
+tmp=data.sD_set(index); |
|
| 1387 |
+tmp.MODIFIED=0; |
|
| 1388 |
+tmp.INDEX=index; |
|
| 1389 |
+data.sD_set(INDEX)=data.sData; |
|
| 1390 |
+data.sData=tmp; |
|
| 1391 |
+ |
|
| 1392 |
+len=getfield(size(tmp.data),{1});
|
|
| 1393 |
+ |
|
| 1394 |
+data.selected_vects=find(ones(1,len)); |
|
| 1395 |
+if ~LOG |
|
| 1396 |
+ data.LOG{length(data.LOG)+1}='% Select a new data set.';
|
|
| 1397 |
+ data.LOG{length(data.LOG)+1}=sprintf('preprocess(''sel_sD'',''%s'');',...
|
|
| 1398 |
+ num2str(index)); |
|
| 1399 |
+end |
|
| 1400 |
+set(gcf,'UserData',data); |
|
| 1401 |
+write_sD_stats; |
|
| 1402 |
+set_compnames(tmp,comp_names_h); |
|
| 1403 |
+draw_vectors(ones(1,len),vector_h); |
|
| 1404 |
+vect_means(tmp,vect_mean_h,data.selected_vects); |
|
| 1405 |
+clear_button; |
|
| 1406 |
+sel_comp; |
|
| 1407 |
+cplot_mimema; |
|
| 1408 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1409 |
+ |
|
| 1410 |
+function indices=get_indices |
|
| 1411 |
+ |
|
| 1412 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1413 |
+ |
|
| 1414 |
+comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 1415 |
+indices = get(comp_names_h,'Value'); |
|
| 1416 |
+ |
|
| 1417 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1418 |
+ |
|
| 1419 |
+ |
|
| 1420 |
+ |
|
| 1421 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1422 |
+ |
|
| 1423 |
+function sD_management(varargin) |
|
| 1424 |
+ |
|
| 1425 |
+if nargin ~= 1 |
|
| 1426 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1427 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 1428 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 1429 |
+ '% Starting the ''Data Set Management'' -window...'; |
|
| 1430 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 1431 |
+ 'preprocess(''sD_management'',''foo'');';
|
|
| 1432 |
+ set(pre_h,'UserData',preh_udata); |
|
| 1433 |
+end |
|
| 1434 |
+ |
|
| 1435 |
+man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 1436 |
+if ~isempty(man_h) |
|
| 1437 |
+ figure(man_h); |
|
| 1438 |
+ return; |
|
| 1439 |
+end |
|
| 1440 |
+ |
|
| 1441 |
+h0 = figure('BackingStore','off', ...
|
|
| 1442 |
+ 'Color',[0.8 0.8 0.8], ... |
|
| 1443 |
+ 'Name','Data Set Management', ... |
|
| 1444 |
+ 'PaperPosition',[18 180 576 432], ... |
|
| 1445 |
+ 'PaperUnits','points', ... |
|
| 1446 |
+ 'Position',[753 523 324 470], ... |
|
| 1447 |
+ 'RendererMode','manual', ... |
|
| 1448 |
+ 'Tag','Management'); |
|
| 1449 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1450 |
+ 'Units','normalized', ... |
|
| 1451 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 1452 |
+ 'FontWeight','demi', ... |
|
| 1453 |
+ 'HorizontalAlignment','left', ... |
|
| 1454 |
+ 'ListboxTop',0, ... |
|
| 1455 |
+ 'Max',2, ... |
|
| 1456 |
+ 'Position',[0.02777777777777778 0.0723404255319149 0.7716049382716049 0.1914893617021277], ... |
|
| 1457 |
+ 'String',' ', ... |
|
| 1458 |
+ 'Style','edit', ... |
|
| 1459 |
+ 'Tag','EditText1'); |
|
| 1460 |
+ |
|
| 1461 |
+data.new_c_name_h = h1; |
|
| 1462 |
+ |
|
| 1463 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1464 |
+ 'Callback','preprocess rename comp',... |
|
| 1465 |
+ 'Units','normalized', ... |
|
| 1466 |
+ 'FontSize',6, ... |
|
| 1467 |
+ 'FontWeight','demi', ... |
|
| 1468 |
+ 'ListboxTop',0, ... |
|
| 1469 |
+ 'Position',[0.8240740740740741 0.2106382978723404 0.154320987654321 0.05319148936170213], ... |
|
| 1470 |
+ 'String','RENAME', ... |
|
| 1471 |
+ 'Tag','Pushbutton1'); |
|
| 1472 |
+ |
|
| 1473 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1474 |
+ 'Callback','preprocess close_sD',... |
|
| 1475 |
+ 'Units','normalized', ... |
|
| 1476 |
+ 'FontWeight','demi', ... |
|
| 1477 |
+ 'ListboxTop',0, ... |
|
| 1478 |
+ 'Position',[0.8240740740740741 0.01914893617021277 0.154320987654321 0.05319148936170213], ... |
|
| 1479 |
+ 'String','CLOSE', ... |
|
| 1480 |
+ 'Tag','Pushbutton2'); |
|
| 1481 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1482 |
+ 'Units','normalized', ... |
|
| 1483 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 1484 |
+ 'FontWeight','demi', ... |
|
| 1485 |
+ 'HorizontalAlignment','left', ... |
|
| 1486 |
+ 'ListboxTop',0, ... |
|
| 1487 |
+ 'Position',[0.02777777777777778 0.2680851063829787 0.345679012345679 0.02978723404255319], ... |
|
| 1488 |
+ 'String','COMPONENTS:', ... |
|
| 1489 |
+ 'Style','text', ... |
|
| 1490 |
+ 'Tag','StaticText1'); |
|
| 1491 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1492 |
+ 'Units','normalized', ... |
|
| 1493 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 1494 |
+ 'HorizontalAlignment','left', ... |
|
| 1495 |
+ 'Position',[0.02777777777777778 0.3170212765957447 0.3549382716049382 0.5319148936170213], ... |
|
| 1496 |
+ 'String',' ', ... |
|
| 1497 |
+ 'Style','listbox', ... |
|
| 1498 |
+ 'Tag','Listbox1', ... |
|
| 1499 |
+ 'Value',1); |
|
| 1500 |
+ |
|
| 1501 |
+data.sets_h=h1; |
|
| 1502 |
+ |
|
| 1503 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1504 |
+ 'Units','normalized', ... |
|
| 1505 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 1506 |
+ 'HorizontalAlignment','left', ... |
|
| 1507 |
+ 'Position',[0.6234567901234568 0.3170212765957447 0.3549382716049382 0.5319148936170213], ... |
|
| 1508 |
+ 'String',' ', ... |
|
| 1509 |
+ 'Style','listbox', ... |
|
| 1510 |
+ 'Tag','Listbox2', ... |
|
| 1511 |
+ 'Value',1); |
|
| 1512 |
+ |
|
| 1513 |
+ |
|
| 1514 |
+data.variables_h = h1; |
|
| 1515 |
+ |
|
| 1516 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1517 |
+ 'Callback','preprocess export',... |
|
| 1518 |
+ 'Units','normalized', ... |
|
| 1519 |
+ 'FontWeight','demi', ... |
|
| 1520 |
+ 'ListboxTop',0, ... |
|
| 1521 |
+ 'Position',[0.4259259259259259 0.551063829787234 0.154320987654321 0.0425531914893617], ... |
|
| 1522 |
+ 'String','->', ... |
|
| 1523 |
+ 'Tag','Pushbutton4'); |
|
| 1524 |
+ |
|
| 1525 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1526 |
+ 'Callback','preprocess import',... |
|
| 1527 |
+ 'Units','normalized', ... |
|
| 1528 |
+ 'FontWeight','demi', ... |
|
| 1529 |
+ 'ListboxTop',0, ... |
|
| 1530 |
+ 'Position',[0.4259259259259259 0.625531914893617 0.154320987654321 0.0425531914893617], ... |
|
| 1531 |
+ 'String','<-', ... |
|
| 1532 |
+ 'Tag','Pushbutton3'); |
|
| 1533 |
+ |
|
| 1534 |
+ |
|
| 1535 |
+ |
|
| 1536 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1537 |
+ 'Units','normalized', ... |
|
| 1538 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 1539 |
+ 'FontWeight','demi', ... |
|
| 1540 |
+ 'HorizontalAlignment','left', ... |
|
| 1541 |
+ 'ListboxTop',0, ... |
|
| 1542 |
+ 'Position',[0.02777777777777778 0.8531914893617022 0.2993827160493827 0.02978723404255319], ... |
|
| 1543 |
+ 'String','DATA SETS', ... |
|
| 1544 |
+ 'Style','text', ... |
|
| 1545 |
+ 'Tag','StaticText2'); |
|
| 1546 |
+ |
|
| 1547 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1548 |
+ 'Units','normalized', ... |
|
| 1549 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 1550 |
+ 'FontWeight','demi', ... |
|
| 1551 |
+ 'HorizontalAlignment','left', ... |
|
| 1552 |
+ 'ListboxTop',0, ... |
|
| 1553 |
+ 'Position',[0.6234567901234568 0.8531914893617022 0.2561728395061728 0.02978723404255319], ... |
|
| 1554 |
+ 'String','WORKSPACE', ... |
|
| 1555 |
+ 'Style','text', ... |
|
| 1556 |
+ 'Tag','StaticText3'); |
|
| 1557 |
+ |
|
| 1558 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1559 |
+ 'Callback','preprocess rename set',... |
|
| 1560 |
+ 'Units','normalized', ... |
|
| 1561 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 1562 |
+ 'HorizontalAlignment','left', ... |
|
| 1563 |
+ 'ListboxTop',0, ... |
|
| 1564 |
+ 'Position',[0.1820987654320987 0.9127659574468086 0.7808641975308641 0.0425531914893617], ... |
|
| 1565 |
+ 'Style','edit', ... |
|
| 1566 |
+ 'Tag','EditText2'); |
|
| 1567 |
+ |
|
| 1568 |
+data.new_name_h = h1; |
|
| 1569 |
+ |
|
| 1570 |
+ |
|
| 1571 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 1572 |
+ 'Units','normalized', ... |
|
| 1573 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 1574 |
+ 'FontWeight','demi', ... |
|
| 1575 |
+ 'HorizontalAlignment','left', ... |
|
| 1576 |
+ 'ListboxTop',0, ... |
|
| 1577 |
+ 'Position',[0.02777777777777778 0.9127659574468086 0.1388888888888889 0.02978723404255319], ... |
|
| 1578 |
+ 'String','NAME:', ... |
|
| 1579 |
+ 'Style','text', ... |
|
| 1580 |
+ 'Tag','StaticText4'); |
|
| 1581 |
+ |
|
| 1582 |
+ |
|
| 1583 |
+ui_h=uimenu('Label','&Tools');
|
|
| 1584 |
+uimenu(ui_h,'Label','Copy','Callback','preprocess copy_delete copy'); |
|
| 1585 |
+uimenu(ui_h,'Label','Delete','Callback','preprocess copy_delete delete'); |
|
| 1586 |
+uimenu(ui_h,'Label','Refresh','Callback','preprocess refresh'); |
|
| 1587 |
+ |
|
| 1588 |
+set(gcf,'UserData',data); |
|
| 1589 |
+set_var_names; |
|
| 1590 |
+sD_names; |
|
| 1591 |
+sD_stats; |
|
| 1592 |
+ |
|
| 1593 |
+ |
|
| 1594 |
+ |
|
| 1595 |
+%%% Subfunction: set_var_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1596 |
+ |
|
| 1597 |
+function set_var_names |
|
| 1598 |
+ |
|
| 1599 |
+ |
|
| 1600 |
+variables_h=getfield(get(gcf,'UserData'),'variables_h'); |
|
| 1601 |
+value=get(variables_h,'Value'); |
|
| 1602 |
+len=evalin('base','length(who)');
|
|
| 1603 |
+ |
|
| 1604 |
+names=cell(len,1); |
|
| 1605 |
+ |
|
| 1606 |
+for i=1:len |
|
| 1607 |
+ string=cat(2,'getfield(who,{',num2str(i),'})');
|
|
| 1608 |
+ names(i)=evalin('base',string);
|
|
| 1609 |
+end |
|
| 1610 |
+ |
|
| 1611 |
+set(variables_h,'String',names); |
|
| 1612 |
+if(value > length(names)) |
|
| 1613 |
+ set(variables_h,'Value',1); |
|
| 1614 |
+end |
|
| 1615 |
+ |
|
| 1616 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1617 |
+ |
|
| 1618 |
+%%% Subfunction: sD_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1619 |
+ |
|
| 1620 |
+function sD_names |
|
| 1621 |
+ |
|
| 1622 |
+sets_h=getfield(get(gcf,'UserData'),'sets_h'); |
|
| 1623 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1624 |
+ |
|
| 1625 |
+sD_set = getfield(get(pre_h,'UserData'),'sD_set'); |
|
| 1626 |
+ |
|
| 1627 |
+for i=1:length(sD_set) |
|
| 1628 |
+ names{i,1}=cat(2,sprintf('#%d: ',i),sD_set(i).name);
|
|
| 1629 |
+end |
|
| 1630 |
+ |
|
| 1631 |
+set(sets_h,'String',names); |
|
| 1632 |
+ |
|
| 1633 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1634 |
+ |
|
| 1635 |
+%%% Subfunction: sD_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1636 |
+ |
|
| 1637 |
+function sD_stats |
|
| 1638 |
+ |
|
| 1639 |
+man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 1640 |
+c_names_h=getfield(get(man_h,'UserData'),'new_c_name_h'); |
|
| 1641 |
+sD_name_h=getfield(get(man_h,'UserData'),'new_name_h'); |
|
| 1642 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1643 |
+INDEX=getfield(getfield(get(pre_h,'UserData'),'sData'),'INDEX'); |
|
| 1644 |
+MODIFIED=getfield(getfield(get(pre_h,'UserData'),'sData'),'MODIFIED'); |
|
| 1645 |
+value=get(getfield(get(man_h,'UserData'),'sets_h'),'Value'); |
|
| 1646 |
+ |
|
| 1647 |
+if value==INDEX |
|
| 1648 |
+ data=get(pre_h,'UserData'); |
|
| 1649 |
+ sData=rmfield(data.sData,[{'INDEX'};{'MODIFIED'}]);
|
|
| 1650 |
+ data.sD_set(INDEX)=sData; |
|
| 1651 |
+ data.sData.MODIFIED=0; |
|
| 1652 |
+ set(pre_h,'UserData',data); |
|
| 1653 |
+end |
|
| 1654 |
+ |
|
| 1655 |
+sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{value});
|
|
| 1656 |
+string1=[{sData.name}];
|
|
| 1657 |
+ |
|
| 1658 |
+ |
|
| 1659 |
+set(sD_name_h,'String',string1); |
|
| 1660 |
+set(c_names_h,'String',sData.comp_names); |
|
| 1661 |
+ |
|
| 1662 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1663 |
+ |
|
| 1664 |
+%%% Subfunction: import %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1665 |
+ |
|
| 1666 |
+function import(varargin) |
|
| 1667 |
+ |
|
| 1668 |
+if nargin==1 |
|
| 1669 |
+ LOG=1; |
|
| 1670 |
+ man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 1671 |
+ set(0,'CurrentFigure',man_h); |
|
| 1672 |
+ name=varargin; |
|
| 1673 |
+else |
|
| 1674 |
+ LOG=0; |
|
| 1675 |
+end |
|
| 1676 |
+ |
|
| 1677 |
+variables_h=getfield(get(gcf,'UserData'),'variables_h'); |
|
| 1678 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1679 |
+if ~LOG |
|
| 1680 |
+ name=getfield(get(variables_h,'String'),{get(variables_h,'Value')});
|
|
| 1681 |
+end |
|
| 1682 |
+errstr='Data to be imported must be real matrix or ''som_data_struct''.'; |
|
| 1683 |
+new_sD=evalin('base',name{1});
|
|
| 1684 |
+ |
|
| 1685 |
+if isempty(pre_h) |
|
| 1686 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program...');
|
|
| 1687 |
+ close_preprocess; |
|
| 1688 |
+ return; |
|
| 1689 |
+end |
|
| 1690 |
+ |
|
| 1691 |
+if isstr(new_sD) | (~isstruct(new_sD) & ~isreal(new_sD)) |
|
| 1692 |
+ errordlg(errstr); |
|
| 1693 |
+ return; |
|
| 1694 |
+elseif isstruct(new_sD) & length(new_sD) > 1 |
|
| 1695 |
+ errordlg(errstr) |
|
| 1696 |
+ return; |
|
| 1697 |
+elseif ~isstruct(new_sD) |
|
| 1698 |
+ new_sD=som_data_struct(new_sD); |
|
| 1699 |
+ new_sD.name=name{1};
|
|
| 1700 |
+end |
|
| 1701 |
+ |
|
| 1702 |
+new_sD_names=fieldnames(new_sD); |
|
| 1703 |
+right_names=fieldnames(som_data_struct(1)); |
|
| 1704 |
+for i=1:length(new_sD_names) |
|
| 1705 |
+ if ~any(strcmp(new_sD_names(i),right_names)); |
|
| 1706 |
+ errordlg(errstr); |
|
| 1707 |
+ return; |
|
| 1708 |
+ end |
|
| 1709 |
+end |
|
| 1710 |
+ |
|
| 1711 |
+data=get(pre_h,'UserData'); |
|
| 1712 |
+data.sD_set(length(data.sD_set) + 1)=new_sD; |
|
| 1713 |
+if ~LOG |
|
| 1714 |
+ data.LOG{length(data.LOG)+1}='% Import a data set from the workspace.';
|
|
| 1715 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''import'',''',...
|
|
| 1716 |
+ name{1},''');');
|
|
| 1717 |
+end |
|
| 1718 |
+set(pre_h,'UserData',data); |
|
| 1719 |
+sD_names; |
|
| 1720 |
+sD_stats; |
|
| 1721 |
+old =gcf; |
|
| 1722 |
+set(0,'CurrentFigure',pre_h); |
|
| 1723 |
+set_sD_stats; |
|
| 1724 |
+set(0,'CurrentFigure',old); |
|
| 1725 |
+ |
|
| 1726 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1727 |
+ |
|
| 1728 |
+%%% Subfunction: export %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1729 |
+ |
|
| 1730 |
+function export(varargin) |
|
| 1731 |
+ |
|
| 1732 |
+if nargin == 1 |
|
| 1733 |
+ LOG=1; |
|
| 1734 |
+ man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 1735 |
+ set(0,'CurrentFigure',man_h); |
|
| 1736 |
+ index=str2num(varargin{1});
|
|
| 1737 |
+else |
|
| 1738 |
+ LOG=0; |
|
| 1739 |
+end |
|
| 1740 |
+ |
|
| 1741 |
+sets_h=getfield(get(gcf,'UserData'),'sets_h'); |
|
| 1742 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1743 |
+ |
|
| 1744 |
+if ~LOG |
|
| 1745 |
+ index=get(sets_h,'Value'); |
|
| 1746 |
+end |
|
| 1747 |
+ |
|
| 1748 |
+if isempty(pre_h) |
|
| 1749 |
+ errordlg('''Preprocess''-figure does not exist. Terminating program...');
|
|
| 1750 |
+ close(findobj(get(0,'Children'),'Tag','Management')); |
|
| 1751 |
+ close(findobj(get(0,'Children'),'Tag','PlotWin')); |
|
| 1752 |
+ return; |
|
| 1753 |
+end |
|
| 1754 |
+ |
|
| 1755 |
+sData=getfield(getfield(get(pre_h,'UserData'),'sD_set'),{index});
|
|
| 1756 |
+ |
|
| 1757 |
+if ~isvalid_var_name({sData.name})
|
|
| 1758 |
+ return; |
|
| 1759 |
+end |
|
| 1760 |
+ |
|
| 1761 |
+assignin('base',sData.name,sData);
|
|
| 1762 |
+disp(sprintf('Data set ''%s'' is set to the workspace.',sData.name));
|
|
| 1763 |
+if ~LOG |
|
| 1764 |
+ data=get(pre_h,'UserData'); |
|
| 1765 |
+ data.LOG{length(data.LOG)+1}='% Export a data set to the workspace.';
|
|
| 1766 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''export'',''',...
|
|
| 1767 |
+ num2str(index),''');'); |
|
| 1768 |
+ set(pre_h,'UserData',data); |
|
| 1769 |
+end |
|
| 1770 |
+set_var_names; |
|
| 1771 |
+ |
|
| 1772 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1773 |
+ |
|
| 1774 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1775 |
+%%% Subfunction: rename %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1776 |
+ |
|
| 1777 |
+function rename(arg) |
|
| 1778 |
+ |
|
| 1779 |
+i=1; |
|
| 1780 |
+while i <= length(arg) & arg(i) ~= ' ' |
|
| 1781 |
+ i=i+1; |
|
| 1782 |
+end |
|
| 1783 |
+ |
|
| 1784 |
+arg2=arg(i+1:length(arg)); |
|
| 1785 |
+arg=arg(1:i-1); |
|
| 1786 |
+if ~isempty(arg2) |
|
| 1787 |
+ LOG=1; |
|
| 1788 |
+ i=1; |
|
| 1789 |
+ if arg2(1) ~= '{'
|
|
| 1790 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 1791 |
+ i=i+1; |
|
| 1792 |
+ end |
|
| 1793 |
+ index=str2num(arg2(i+1:length(arg2))); |
|
| 1794 |
+ arg2=arg2(1:i-1); |
|
| 1795 |
+ else |
|
| 1796 |
+ while i <= length(arg2) & arg2(i) ~= '}' |
|
| 1797 |
+ i=i+1; |
|
| 1798 |
+ end |
|
| 1799 |
+ index=str2num(arg2(i+1:length(arg2))); |
|
| 1800 |
+ arg2=arg2(1:i); |
|
| 1801 |
+ end |
|
| 1802 |
+else |
|
| 1803 |
+ LOG=0; |
|
| 1804 |
+end |
|
| 1805 |
+ |
|
| 1806 |
+new_name_h=getfield(get(gcf,'UserData'),'new_name_h'); |
|
| 1807 |
+new_c_name_h=getfield(get(gcf,'UserData'),'new_c_name_h'); |
|
| 1808 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1809 |
+ |
|
| 1810 |
+if isempty(pre_h) |
|
| 1811 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program...');
|
|
| 1812 |
+ close_preprocess; |
|
| 1813 |
+ return; |
|
| 1814 |
+end |
|
| 1815 |
+ |
|
| 1816 |
+switch arg |
|
| 1817 |
+ case 'set' |
|
| 1818 |
+ if LOG |
|
| 1819 |
+ name={arg2};
|
|
| 1820 |
+ else |
|
| 1821 |
+ name=get(new_name_h,'String'); |
|
| 1822 |
+ end |
|
| 1823 |
+ if ~isempty(name{1}) & ~any(isspace(name{1}))
|
|
| 1824 |
+ if ~isvalid_var_name(name) |
|
| 1825 |
+ sD_stats; |
|
| 1826 |
+ return; |
|
| 1827 |
+ end |
|
| 1828 |
+ if ~LOG |
|
| 1829 |
+ index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value'); |
|
| 1830 |
+ end |
|
| 1831 |
+ data=get(pre_h,'UserData'); |
|
| 1832 |
+ tmp_set.name=name{1};
|
|
| 1833 |
+ data.sD_set(index).name=name{1};
|
|
| 1834 |
+ if data.sData.INDEX == index |
|
| 1835 |
+ data.sData.name=name{1};
|
|
| 1836 |
+ end |
|
| 1837 |
+ if ~LOG |
|
| 1838 |
+ data.LOG{length(data.LOG)+1}='% Rename a data set.';
|
|
| 1839 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''rename'',''set ',...
|
|
| 1840 |
+ name{1},' ',...
|
|
| 1841 |
+ num2str(index),... |
|
| 1842 |
+ ''');'); |
|
| 1843 |
+ end |
|
| 1844 |
+ |
|
| 1845 |
+ set(pre_h,'UserData',data); |
|
| 1846 |
+ sD_names; |
|
| 1847 |
+ string=get(data.sD_set_h,'String'); |
|
| 1848 |
+ string{index}=cat(2,sprintf('#%d: ',index),name{1});
|
|
| 1849 |
+ set(data.sD_set_h,'String',string); |
|
| 1850 |
+ string=get(data.sD_name_h,'String'); |
|
| 1851 |
+ string{1}=cat(2,'Name: ',name{1});
|
|
| 1852 |
+ if index==data.sData.INDEX |
|
| 1853 |
+ set(data.sD_name_h,'String',string); |
|
| 1854 |
+ end |
|
| 1855 |
+ else |
|
| 1856 |
+ sD_stats; |
|
| 1857 |
+ end |
|
| 1858 |
+ case 'comp' |
|
| 1859 |
+ if ~LOG |
|
| 1860 |
+ names=get(new_c_name_h,'String'); |
|
| 1861 |
+ index=get(getfield(get(gcf,'UserData'),'sets_h'),'Value'); |
|
| 1862 |
+ else |
|
| 1863 |
+ names=eval(arg2); |
|
| 1864 |
+ end |
|
| 1865 |
+ if check_cell_names(names) |
|
| 1866 |
+ data=get(pre_h,'UserData'); |
|
| 1867 |
+ sData=data.sD_set(index); |
|
| 1868 |
+ if length(sData.comp_names)==length(names) |
|
| 1869 |
+ data.sD_set(index).comp_names=names; |
|
| 1870 |
+ if index == data.sData.INDEX |
|
| 1871 |
+ for i=1:length(names) |
|
| 1872 |
+ names{i}=cat(2,sprintf('#%d: ',i),names{i});
|
|
| 1873 |
+ end |
|
| 1874 |
+ set(data.comp_names_h,'String',names); |
|
| 1875 |
+ set(data.sel_comp_h,'String',names); |
|
| 1876 |
+ end |
|
| 1877 |
+ if ~LOG |
|
| 1878 |
+ data.LOG{length(data.LOG)+1}='% Rename components.';
|
|
| 1879 |
+ str='preprocess(''rename'',''comp {';
|
|
| 1880 |
+ for i=1:length(names)-1 |
|
| 1881 |
+ str=cat(2,str,'''''',names{i},''''',');
|
|
| 1882 |
+ end |
|
| 1883 |
+ str=cat(2,str,'''''',names{length(names)},'''''} ',...
|
|
| 1884 |
+ num2str(index),''');'); |
|
| 1885 |
+ data.LOG{length(data.LOG)+1}=str;
|
|
| 1886 |
+ else |
|
| 1887 |
+ set(new_c_name_h,'String',names); |
|
| 1888 |
+ end |
|
| 1889 |
+ set(pre_h,'UserData',data); |
|
| 1890 |
+ else |
|
| 1891 |
+ errordlg('There are less components in data.');
|
|
| 1892 |
+ sD_stats; |
|
| 1893 |
+ return; |
|
| 1894 |
+ end |
|
| 1895 |
+ else |
|
| 1896 |
+ sD_stats; |
|
| 1897 |
+ end |
|
| 1898 |
+end |
|
| 1899 |
+ |
|
| 1900 |
+%%% Subfunction: check_cell_names %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1901 |
+ |
|
| 1902 |
+function bool=check_cell_names(names) |
|
| 1903 |
+ |
|
| 1904 |
+bool = 1; |
|
| 1905 |
+ |
|
| 1906 |
+if isempty(names) |
|
| 1907 |
+ bool= 0; |
|
| 1908 |
+ return; |
|
| 1909 |
+end |
|
| 1910 |
+for i=1:length(names) |
|
| 1911 |
+ if isempty(names{i}) | isspace(names{i})
|
|
| 1912 |
+ bool = 0; |
|
| 1913 |
+ return; |
|
| 1914 |
+ end |
|
| 1915 |
+end |
|
| 1916 |
+ |
|
| 1917 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1918 |
+ |
|
| 1919 |
+%%% Subfunction: isvalid_var_name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1920 |
+ |
|
| 1921 |
+function bool=isvalid_var_name(name) |
|
| 1922 |
+ |
|
| 1923 |
+bool=1; |
|
| 1924 |
+ |
|
| 1925 |
+tmp=name{1};
|
|
| 1926 |
+if ~((tmp(1)>='a' & tmp(1)<='z') | (tmp(1)>='A' & tmp(1)<='Z')) |
|
| 1927 |
+ errordlg('Invalid name.');
|
|
| 1928 |
+ bool=0; |
|
| 1929 |
+ return; |
|
| 1930 |
+end |
|
| 1931 |
+for j=1:length(tmp) |
|
| 1932 |
+ if ~((tmp(j)>='a' & tmp(j)<='z') | ... |
|
| 1933 |
+ (tmp(j)>='A' & tmp(j)<='Z') | ... |
|
| 1934 |
+ (j>1 & tmp(j) == '_') | ... |
|
| 1935 |
+ (tmp(j)>='0' & tmp(j) <= '9')) | tmp(j) == '.' |
|
| 1936 |
+ errordlg('Invalid name.');
|
|
| 1937 |
+ bool=0; |
|
| 1938 |
+ return; |
|
| 1939 |
+ end |
|
| 1940 |
+ if j == length(tmp) & tmp(j) == '_' |
|
| 1941 |
+ errordlg('Invalid name.');
|
|
| 1942 |
+ bool=0; |
|
| 1943 |
+ return; |
|
| 1944 |
+ end |
|
| 1945 |
+end |
|
| 1946 |
+ |
|
| 1947 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1948 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1949 |
+ |
|
| 1950 |
+%%% Subfunction: copy_delete %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 1951 |
+ |
|
| 1952 |
+function copy_delete(arg) |
|
| 1953 |
+ |
|
| 1954 |
+i=1; |
|
| 1955 |
+while i <= length(arg) & arg(i) ~= ' ' |
|
| 1956 |
+ i=i+1; |
|
| 1957 |
+end |
|
| 1958 |
+ |
|
| 1959 |
+arg2=arg(i+1:length(arg)); |
|
| 1960 |
+arg=arg(1:i-1); |
|
| 1961 |
+ |
|
| 1962 |
+if ~isempty(arg2) |
|
| 1963 |
+ index=str2num(arg2); |
|
| 1964 |
+ LOG=1; |
|
| 1965 |
+else |
|
| 1966 |
+ LOG=0; |
|
| 1967 |
+end |
|
| 1968 |
+ |
|
| 1969 |
+sets_h=getfield(get(gcf,'UserData'),'sets_h'); |
|
| 1970 |
+if ~LOG |
|
| 1971 |
+ index=get(sets_h,'Value'); |
|
| 1972 |
+end |
|
| 1973 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 1974 |
+ |
|
| 1975 |
+if isempty(pre_h) |
|
| 1976 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program.');
|
|
| 1977 |
+ close_preprocess; |
|
| 1978 |
+ return; |
|
| 1979 |
+end |
|
| 1980 |
+ |
|
| 1981 |
+switch arg |
|
| 1982 |
+ case 'copy' |
|
| 1983 |
+ data=get(pre_h,'UserData'); |
|
| 1984 |
+ data.sD_set(length(data.sD_set)+1)=data.sD_set(index); |
|
| 1985 |
+ if ~LOG |
|
| 1986 |
+ data.LOG{length(data.LOG)+1}='% Copy a data set.';
|
|
| 1987 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',...
|
|
| 1988 |
+ 'copy ',num2str(index),''');'); |
|
| 1989 |
+ end |
|
| 1990 |
+ set(pre_h,'UserData',data); |
|
| 1991 |
+ sD_names; |
|
| 1992 |
+ old=gcf; |
|
| 1993 |
+ set(0,'CurrentFigure',pre_h); |
|
| 1994 |
+ set_sD_stats; |
|
| 1995 |
+ set(0,'CurrentFigure',old); |
|
| 1996 |
+ case 'delete' |
|
| 1997 |
+ if length(get(sets_h,'String')) == 1 |
|
| 1998 |
+ msgbox('No data left. Closing program...')
|
|
| 1999 |
+ close_preprocess; |
|
| 2000 |
+ return; |
|
| 2001 |
+ end |
|
| 2002 |
+ data=get(pre_h,'UserData'); |
|
| 2003 |
+ if ~isempty(data.undo) & any(strcmp('index',fieldnames(data.undo)))
|
|
| 2004 |
+ if data.undo.index > index |
|
| 2005 |
+ data.undo.index = data.undo.index-1; |
|
| 2006 |
+ elseif data.undo.index==index; |
|
| 2007 |
+ data.undo=[]; |
|
| 2008 |
+ end |
|
| 2009 |
+ end |
|
| 2010 |
+ set1=data.sD_set(1:index-1); |
|
| 2011 |
+ set2=data.sD_set(index+1:length(data.sD_set)); |
|
| 2012 |
+ |
|
| 2013 |
+ if ~isempty(set1) |
|
| 2014 |
+ data.sD_set=[set1 set2]; |
|
| 2015 |
+ else |
|
| 2016 |
+ data.sD_set=set2; |
|
| 2017 |
+ end |
|
| 2018 |
+ if ~LOG |
|
| 2019 |
+ data.LOG{length(data.LOG)+1}='% Delete a data set.';
|
|
| 2020 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''copy_delete'',''',...
|
|
| 2021 |
+ 'delete ',num2str(index),''');'); |
|
| 2022 |
+ end |
|
| 2023 |
+ set(pre_h,'UserData',data); |
|
| 2024 |
+ |
|
| 2025 |
+ set(sets_h,'Value',1); |
|
| 2026 |
+ sD_names; |
|
| 2027 |
+ sD_stats; |
|
| 2028 |
+ old = gcf; |
|
| 2029 |
+ set(0,'CurrentFigure',pre_h); |
|
| 2030 |
+ |
|
| 2031 |
+ for i=1:length(data.sD_set) |
|
| 2032 |
+ string{i}=cat(2,sprintf('#%d: ',i),data.sD_set(i).name);
|
|
| 2033 |
+ end |
|
| 2034 |
+ |
|
| 2035 |
+ set(data.sD_set_h,'String',string); |
|
| 2036 |
+ data.sData=data.sD_set(get(data.sD_set_h,'Value')); |
|
| 2037 |
+ data.sData.MODIFIED=0; |
|
| 2038 |
+ data.sData.INDEX=1; |
|
| 2039 |
+ set(gcf,'UserData',data); |
|
| 2040 |
+ write_sD_stats; |
|
| 2041 |
+ |
|
| 2042 |
+ sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 2043 |
+ if sData.INDEX > index |
|
| 2044 |
+ value=get(getfield(get(gcf,'UserData'),'sD_set_h'),'Value'); |
|
| 2045 |
+ set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',value-1); |
|
| 2046 |
+ sData.INDEX = sData.INDEX -1; |
|
| 2047 |
+ elseif sData.INDEX == index |
|
| 2048 |
+ set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',1); |
|
| 2049 |
+ end |
|
| 2050 |
+ |
|
| 2051 |
+ sel_sD; |
|
| 2052 |
+ set(0,'CurrentFigure',old); |
|
| 2053 |
+end |
|
| 2054 |
+ |
|
| 2055 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2056 |
+ |
|
| 2057 |
+function clipping(varargin) |
|
| 2058 |
+ |
|
| 2059 |
+if nargin ~= 1 |
|
| 2060 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 2061 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 2062 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 2063 |
+ '% Starting the ''Clipping'' -window...'; |
|
| 2064 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''clipping'',''foo'');';
|
|
| 2065 |
+ set(pre_h,'UserData',preh_udata); |
|
| 2066 |
+end |
|
| 2067 |
+ |
|
| 2068 |
+clip_h=findobj(get(0,'Children'),'Tag','Clipping'); |
|
| 2069 |
+ |
|
| 2070 |
+if ~isempty(clip_h) |
|
| 2071 |
+ figure(clip_h); |
|
| 2072 |
+ return; |
|
| 2073 |
+end |
|
| 2074 |
+ |
|
| 2075 |
+h0 = figure('Color',[0.8 0.8 0.8], ...
|
|
| 2076 |
+ 'PaperPosition',[18 180 575 432], ... |
|
| 2077 |
+ 'PaperUnits','points', ... |
|
| 2078 |
+ 'Position',[718 389 300 249], ... |
|
| 2079 |
+ 'Tag','Clipping'); |
|
| 2080 |
+ |
|
| 2081 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2082 |
+ 'Units','normalized', ... |
|
| 2083 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2084 |
+ 'ListboxTop',0, ... |
|
| 2085 |
+ 'Position',[0.03 0.03614457831325301 0.4666666666666667 0.9236947791164658], ... |
|
| 2086 |
+ 'Style','frame', ... |
|
| 2087 |
+ 'Tag','Frame1'); |
|
| 2088 |
+ |
|
| 2089 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2090 |
+ 'Units','normalized', ... |
|
| 2091 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2092 |
+ 'ListboxTop',0, ... |
|
| 2093 |
+ 'Position',[0.05333333333333334 0.5983935742971887 0.42 0.3333333333333333], ... |
|
| 2094 |
+ 'Style','frame', ... |
|
| 2095 |
+ 'Tag','Frame2'); |
|
| 2096 |
+ |
|
| 2097 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2098 |
+ 'Units','normalized', ... |
|
| 2099 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2100 |
+ 'ListboxTop',0, ... |
|
| 2101 |
+ 'Style','frame', ... |
|
| 2102 |
+ 'Position',[0.05333333333333334 0.33 0.42 0.24], ... |
|
| 2103 |
+ 'Tag','Frame3'); |
|
| 2104 |
+ |
|
| 2105 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2106 |
+ 'Units','normalized', ... |
|
| 2107 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2108 |
+ 'ListboxTop',0, ... |
|
| 2109 |
+ 'Style','frame', ... |
|
| 2110 |
+ 'Position',[0.05333333333333334 0.06 0.42 0.24],... |
|
| 2111 |
+ 'Tag','Frame4'); |
|
| 2112 |
+ |
|
| 2113 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2114 |
+ 'Units','normalized', ... |
|
| 2115 |
+ 'ListboxTop',0, ... |
|
| 2116 |
+ 'Position',[0.5133333333333334 0.6385542168674698 0.4666666666666667 0.321285140562249], ... |
|
| 2117 |
+ 'Style','frame', ... |
|
| 2118 |
+ 'Tag','Frame5'); |
|
| 2119 |
+ |
|
| 2120 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2121 |
+ 'Units','normalized', ... |
|
| 2122 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2123 |
+ 'ListboxTop',0, ... |
|
| 2124 |
+ 'Position',[0.5366666666666667 0.6666666666666666 0.42 0.2650602409638554], ... |
|
| 2125 |
+ 'Style','frame', ... |
|
| 2126 |
+ 'Tag','Frame6'); |
|
| 2127 |
+ |
|
| 2128 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2129 |
+ 'Units','normalized', ... |
|
| 2130 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2131 |
+ 'ListboxTop',0, ... |
|
| 2132 |
+ 'Position',[0.31 0.823293172690763 0.15 0.09638554216867469], ... |
|
| 2133 |
+ 'Style','edit', ... |
|
| 2134 |
+ 'Tag','EditText1'); |
|
| 2135 |
+ |
|
| 2136 |
+data.big_val_h = h1; |
|
| 2137 |
+ |
|
| 2138 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2139 |
+ 'Units','normalized', ... |
|
| 2140 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2141 |
+ 'ListboxTop',0, ... |
|
| 2142 |
+ 'Position',[0.31 0.7148594377510039 0.15 0.09638554216867469], ... |
|
| 2143 |
+ 'Style','edit', ... |
|
| 2144 |
+ 'Tag','EditText2'); |
|
| 2145 |
+ |
|
| 2146 |
+data.small_val_h = h1; |
|
| 2147 |
+ |
|
| 2148 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2149 |
+ 'Units','normalized', ... |
|
| 2150 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2151 |
+ 'ListboxTop',0, ... |
|
| 2152 |
+ 'Position',[0.31 0.606425702811245 0.15 0.09638554216867469], ... |
|
| 2153 |
+ 'Style','edit', ... |
|
| 2154 |
+ 'Tag','EditText3'); |
|
| 2155 |
+ |
|
| 2156 |
+data.equal_val_h=h1; |
|
| 2157 |
+ |
|
| 2158 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2159 |
+ 'Units','normalized', ... |
|
| 2160 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2161 |
+ 'FontSize',6, ... |
|
| 2162 |
+ 'FontWeight','demi', ... |
|
| 2163 |
+ 'HorizontalAlignment','left', ... |
|
| 2164 |
+ 'ListboxTop',0, ... |
|
| 2165 |
+ 'Position',[0.06000000000000001 0.8473895582329316 0.22 0.05622489959839357], ... |
|
| 2166 |
+ 'String','Bigger than', ... |
|
| 2167 |
+ 'Style','text', ... |
|
| 2168 |
+ 'Tag','StaticText1'); |
|
| 2169 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2170 |
+ 'Units','normalized', ... |
|
| 2171 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2172 |
+ 'FontSize',6, ... |
|
| 2173 |
+ 'FontWeight','demi', ... |
|
| 2174 |
+ 'HorizontalAlignment','left', ... |
|
| 2175 |
+ 'ListboxTop',0, ... |
|
| 2176 |
+ 'Position',[0.06000000000000001 0.7389558232931727 0.24 0.04819277108433735], ... |
|
| 2177 |
+ 'String','Smaller than', ... |
|
| 2178 |
+ 'Style','text', ... |
|
| 2179 |
+ 'Tag','StaticText2'); |
|
| 2180 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2181 |
+ 'Units','normalized', ... |
|
| 2182 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2183 |
+ 'FontSize',6, ... |
|
| 2184 |
+ 'FontWeight','demi', ... |
|
| 2185 |
+ 'HorizontalAlignment','left', ... |
|
| 2186 |
+ 'ListboxTop',0, ... |
|
| 2187 |
+ 'Position',[0.06000000000000001 0.610441767068273 0.22 0.07228915662650602], ... |
|
| 2188 |
+ 'String','Equal to', ... |
|
| 2189 |
+ 'Style','text', ... |
|
| 2190 |
+ 'Tag','StaticText3'); |
|
| 2191 |
+ |
|
| 2192 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2193 |
+ 'Units','normalized', ... |
|
| 2194 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2195 |
+ 'ListboxTop',0, ... |
|
| 2196 |
+ 'Position',[0.07000000000000001 0.465863453815261 0.06333333333333334 0.07228915662650602], ... |
|
| 2197 |
+ 'Style','radiobutton', ... |
|
| 2198 |
+ 'Value',1,... |
|
| 2199 |
+ 'Tag','Radiobutton1'); |
|
| 2200 |
+ |
|
| 2201 |
+data.and_button_h=h1; |
|
| 2202 |
+ |
|
| 2203 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2204 |
+ 'Units','normalized', ... |
|
| 2205 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2206 |
+ 'ListboxTop',0, ... |
|
| 2207 |
+ 'Position',[0.07000000000000001 0.3734939759036144 0.06333333333333334 0.07228915662650602], ... |
|
| 2208 |
+ 'Style','radiobutton', ... |
|
| 2209 |
+ 'Tag','Radiobutton2'); |
|
| 2210 |
+ |
|
| 2211 |
+data.or_button_h=h1; |
|
| 2212 |
+ |
|
| 2213 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2214 |
+ 'Units','normalized', ... |
|
| 2215 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2216 |
+ 'FontSize',6, ... |
|
| 2217 |
+ 'FontWeight','demi', ... |
|
| 2218 |
+ 'HorizontalAlignment','left', ... |
|
| 2219 |
+ 'Position',[0.1466666666666667 0.45 0.2333333333333333 0.07228915662650602], ... |
|
| 2220 |
+ 'String','AND', ... |
|
| 2221 |
+ 'Style','text', ... |
|
| 2222 |
+ 'Tag','StaticText4'); |
|
| 2223 |
+ |
|
| 2224 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2225 |
+ 'Units','normalized', ... |
|
| 2226 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2227 |
+ 'FontSize',6, ... |
|
| 2228 |
+ 'FontWeight','demi', ... |
|
| 2229 |
+ 'HorizontalAlignment','left', ... |
|
| 2230 |
+ 'ListboxTop',0, ... |
|
| 2231 |
+ 'String','OR', ... |
|
| 2232 |
+ 'Position',[0.1466666666666667 0.35 0.2333333333333333 0.07228915662650602], ... |
|
| 2233 |
+ 'Style','text', ... |
|
| 2234 |
+ 'Tag','StaticText5'); |
|
| 2235 |
+ |
|
| 2236 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2237 |
+ 'Units','normalized', ... |
|
| 2238 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2239 |
+ 'ListboxTop',0, ... |
|
| 2240 |
+ 'Position',[0.07000000000000001 0.1967871485943775 0.06333333333333334 0.07228915662650602], ... |
|
| 2241 |
+ 'Style','radiobutton', ... |
|
| 2242 |
+ 'Value',1,... |
|
| 2243 |
+ 'Tag','Radiobutton3'); |
|
| 2244 |
+ |
|
| 2245 |
+data.all_button_h=h1; |
|
| 2246 |
+ |
|
| 2247 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2248 |
+ 'Units','normalized', ... |
|
| 2249 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2250 |
+ 'ListboxTop',0, ... |
|
| 2251 |
+ 'Position',[0.07000000000000001 0.09236947791164658 0.06333333333333334 0.07228915662650602], ... |
|
| 2252 |
+ 'Style','radiobutton', ... |
|
| 2253 |
+ 'Tag','Radiobutton4'); |
|
| 2254 |
+ |
|
| 2255 |
+data.sel_vects_button_h=h1; |
|
| 2256 |
+ |
|
| 2257 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2258 |
+ 'Units','normalized', ... |
|
| 2259 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2260 |
+ 'FontSize',6, ... |
|
| 2261 |
+ 'FontWeight','demi', ... |
|
| 2262 |
+ 'HorizontalAlignment','left', ... |
|
| 2263 |
+ 'ListboxTop',0, ... |
|
| 2264 |
+ 'Position',[0.1466666666666667 0.1927710843373494 0.2333333333333333 0.07228915662650602], ... |
|
| 2265 |
+ 'String','All vectors', ... |
|
| 2266 |
+ 'Style','text', ... |
|
| 2267 |
+ 'Tag','StaticText6'); |
|
| 2268 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2269 |
+ 'Units','normalized', ... |
|
| 2270 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2271 |
+ 'FontSize',6, ... |
|
| 2272 |
+ 'FontWeight','demi', ... |
|
| 2273 |
+ 'HorizontalAlignment','left', ... |
|
| 2274 |
+ 'ListboxTop',0, ... |
|
| 2275 |
+ 'Position',[0.1466666666666667 0.09638554216867469 0.3133333333333334 0.05622489959839357], ... |
|
| 2276 |
+ 'String','Among selected', ... |
|
| 2277 |
+ 'Style','text', ... |
|
| 2278 |
+ 'Tag','StaticText7'); |
|
| 2279 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2280 |
+ 'Units','normalized', ... |
|
| 2281 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2282 |
+ 'ListboxTop',0, ... |
|
| 2283 |
+ 'Position',[0.7866666666666667 0.823293172690763 0.1366666666666667 0.09236947791164658], ... |
|
| 2284 |
+ 'Style','edit', ... |
|
| 2285 |
+ 'Tag','EditText4'); |
|
| 2286 |
+ |
|
| 2287 |
+data.replace_val_h=h1; |
|
| 2288 |
+ |
|
| 2289 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2290 |
+ 'Units','normalized', ... |
|
| 2291 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2292 |
+ 'FontSize',6, ... |
|
| 2293 |
+ 'FontWeight','demi', ... |
|
| 2294 |
+ 'HorizontalAlignment','left', ... |
|
| 2295 |
+ 'ListboxTop',0, ... |
|
| 2296 |
+ 'Position',[0.5633333333333334 0.8273092369477911 0.2066666666666667 0.07630522088353413], ... |
|
| 2297 |
+ 'String','Replace', ... |
|
| 2298 |
+ 'Style','text', ... |
|
| 2299 |
+ 'Tag','StaticText8'); |
|
| 2300 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2301 |
+ 'Units','normalized', ... |
|
| 2302 |
+ 'FontWeight','demi', ... |
|
| 2303 |
+ 'ListboxTop',0, ... |
|
| 2304 |
+ 'Position',[0.5700000000000001 0.6827309236947791 0.3566666666666667 0.08032128514056225], ... |
|
| 2305 |
+ 'String','Replace', ... |
|
| 2306 |
+ 'Tag','Pushbutton1'); |
|
| 2307 |
+ |
|
| 2308 |
+data.OK_button_h=h1; |
|
| 2309 |
+ |
|
| 2310 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2311 |
+ 'Units','normalized', ... |
|
| 2312 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2313 |
+ 'Callback','preprocess close_c',... |
|
| 2314 |
+ 'FontWeight','demi', ... |
|
| 2315 |
+ 'ListboxTop',0, ... |
|
| 2316 |
+ 'Position',[0.6633333333333333 0.07228915662650602 0.2833333333333333 0.09638554216867469], ... |
|
| 2317 |
+ 'String','Close', ... |
|
| 2318 |
+ 'Tag','Pushbutton2'); |
|
| 2319 |
+ |
|
| 2320 |
+ |
|
| 2321 |
+data.state.and=1; |
|
| 2322 |
+data.state.all=1; |
|
| 2323 |
+data.state.big=[]; |
|
| 2324 |
+data.state.small=[]; |
|
| 2325 |
+data.state.equal=[]; |
|
| 2326 |
+data.state.replace=[]; |
|
| 2327 |
+ |
|
| 2328 |
+set(data.or_button_h,'Callback','preprocess and_or_cb or'); |
|
| 2329 |
+set(data.and_button_h,'Callback','preprocess and_or_cb and'); |
|
| 2330 |
+set(data.and_button_h,'Value',1); |
|
| 2331 |
+set(data.all_button_h,'Callback','preprocess all_sel_cb all'); |
|
| 2332 |
+set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel'); |
|
| 2333 |
+set(data.big_val_h,'Callback','preprocess set_state_vals big'); |
|
| 2334 |
+set(data.small_val_h,'Callback','preprocess set_state_vals small'); |
|
| 2335 |
+set(data.equal_val_h,'Callback','preprocess set_state_vals equal'); |
|
| 2336 |
+set(data.replace_val_h,'Callback','preprocess set_state_vals replace'); |
|
| 2337 |
+set(data.OK_button_h,'Callback','preprocess clip_data clip'); |
|
| 2338 |
+set(h0,'UserData',data); |
|
| 2339 |
+ |
|
| 2340 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2341 |
+ |
|
| 2342 |
+function select(varargin) |
|
| 2343 |
+ |
|
| 2344 |
+if nargin ~= 1 |
|
| 2345 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 2346 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 2347 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 2348 |
+ '% Starting the ''Select'' -window...'; |
|
| 2349 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''select'',''foo'');';
|
|
| 2350 |
+ set(pre_h,'UserData',preh_udata); |
|
| 2351 |
+end |
|
| 2352 |
+ |
|
| 2353 |
+sel_h=findobj(get(0,'Children'),'Tag','Select'); |
|
| 2354 |
+ |
|
| 2355 |
+if ~isempty(sel_h) |
|
| 2356 |
+ figure(sel_h); |
|
| 2357 |
+ return; |
|
| 2358 |
+end |
|
| 2359 |
+ |
|
| 2360 |
+h0 = figure('Color',[0.8 0.8 0.8], ...
|
|
| 2361 |
+ 'PaperPosition',[18 180 576 432], ... |
|
| 2362 |
+ 'PaperUnits','points', ... |
|
| 2363 |
+ 'Position',[750 431 168 365], ... |
|
| 2364 |
+ 'Tag','Select'); |
|
| 2365 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2366 |
+ 'Units','normalized', ... |
|
| 2367 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2368 |
+ 'ListboxTop',0, ... |
|
| 2369 |
+ 'Position',[0.05357142857142857 0.2712328767123288 0.8333333333333333 0.6301369863013698], ... |
|
| 2370 |
+ 'Style','frame', ... |
|
| 2371 |
+ 'Tag','Frame1'); |
|
| 2372 |
+ |
|
| 2373 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2374 |
+ 'Units','normalized', ... |
|
| 2375 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2376 |
+ 'ListboxTop',0, ... |
|
| 2377 |
+ 'Position',[0.05357142857142857 0.1041095890410959 0.8333333333333333 0.1397260273972603], ... |
|
| 2378 |
+ 'Style','frame', ... |
|
| 2379 |
+ 'Tag','Frame2'); |
|
| 2380 |
+ |
|
| 2381 |
+h1 = uicontrol('Parent',h0,...
|
|
| 2382 |
+ 'Units','normalized', ... |
|
| 2383 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2384 |
+ 'ListboxTop',0, ... |
|
| 2385 |
+ 'Position',[0.09523809523809523 0.6547945205479452 0.75 0.2273972602739726], ... |
|
| 2386 |
+ 'Style','frame', ... |
|
| 2387 |
+ 'Tag','Frame3'); |
|
| 2388 |
+ |
|
| 2389 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2390 |
+ 'Units','normalized', ... |
|
| 2391 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2392 |
+ 'ListboxTop',0, ... |
|
| 2393 |
+ 'Position',[0.09523809523809523 0.4794520547945206 0.75 0.1506849315068493], ... |
|
| 2394 |
+ 'Style','frame', ... |
|
| 2395 |
+ 'Tag','Frame4'); |
|
| 2396 |
+ |
|
| 2397 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2398 |
+ 'Units','normalized', ... |
|
| 2399 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2400 |
+ 'ListboxTop',0, ... |
|
| 2401 |
+ 'Position',[0.09523809523809523 0.2986301369863014 0.75 0.1506849315068493], ... |
|
| 2402 |
+ 'Style','frame', ... |
|
| 2403 |
+ 'Tag','Frame5'); |
|
| 2404 |
+ |
|
| 2405 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2406 |
+ 'Units','normalized', ... |
|
| 2407 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2408 |
+ 'ListboxTop',0, ... |
|
| 2409 |
+ 'Position',[0.5535714285714285 0.8082191780821918 0.2678571428571429 0.06575342465753425], ... |
|
| 2410 |
+ 'Style','edit', ... |
|
| 2411 |
+ 'Tag','EditText1'); |
|
| 2412 |
+ |
|
| 2413 |
+data.big_val_h=h1; |
|
| 2414 |
+ |
|
| 2415 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2416 |
+ 'Units','normalized', ... |
|
| 2417 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2418 |
+ 'ListboxTop',0, ... |
|
| 2419 |
+ 'Position',[0.5535714285714285 0.7342465753424657 0.2678571428571429 0.06575342465753425], ... |
|
| 2420 |
+ 'Style','edit', ... |
|
| 2421 |
+ 'Tag','EditText2'); |
|
| 2422 |
+ |
|
| 2423 |
+data.small_val_h = h1; |
|
| 2424 |
+ |
|
| 2425 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2426 |
+ 'Units','normalized', ... |
|
| 2427 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2428 |
+ 'ListboxTop',0, ... |
|
| 2429 |
+ 'Position',[0.5535714285714285 0.6602739726027397 0.2678571428571429 0.06575342465753425], ... |
|
| 2430 |
+ 'Style','edit', ... |
|
| 2431 |
+ 'Tag','EditText3'); |
|
| 2432 |
+ |
|
| 2433 |
+data.equal_val_h=h1; |
|
| 2434 |
+ |
|
| 2435 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2436 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2437 |
+ 'Units','normalized', ... |
|
| 2438 |
+ 'FontWeight','demi', ... |
|
| 2439 |
+ 'FontSize',8,... |
|
| 2440 |
+ 'HorizontalAlignment','left', ... |
|
| 2441 |
+ 'ListboxTop',0, ... |
|
| 2442 |
+ 'Position',[0.1071 0.8247 0.3929 0.0384], ... |
|
| 2443 |
+ 'String','Bigger than', ... |
|
| 2444 |
+ 'Style','text', ... |
|
| 2445 |
+ 'Tag','StaticText1'); |
|
| 2446 |
+ |
|
| 2447 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2448 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2449 |
+ 'Units','normalized', ... |
|
| 2450 |
+ 'FontWeight','demi', ... |
|
| 2451 |
+ 'FontSize',8,... |
|
| 2452 |
+ 'HorizontalAlignment','left', ... |
|
| 2453 |
+ 'ListboxTop',0, ... |
|
| 2454 |
+ 'Position',[0.1071 0.7507 0.4286 0.0329], ... |
|
| 2455 |
+ 'String','Smaller than', ... |
|
| 2456 |
+ 'Style','text', ... |
|
| 2457 |
+ 'Tag','StaticText2'); |
|
| 2458 |
+ |
|
| 2459 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2460 |
+ 'Units','normalized', ... |
|
| 2461 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2462 |
+ 'FontWeight','demi', ... |
|
| 2463 |
+ 'FontSize',8,... |
|
| 2464 |
+ 'HorizontalAlignment','left', ... |
|
| 2465 |
+ 'ListboxTop',0, ... |
|
| 2466 |
+ 'Position',[0.1071 0.6630 0.3929 0.0493], ... |
|
| 2467 |
+ 'String','Equal to', ... |
|
| 2468 |
+ 'Style','text', ... |
|
| 2469 |
+ 'Tag','StaticText3'); |
|
| 2470 |
+ |
|
| 2471 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2472 |
+ 'Units','normalized', ... |
|
| 2473 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2474 |
+ 'ListboxTop',0, ... |
|
| 2475 |
+ 'Position',[0.125 0.5643835616438356 0.1130952380952381 0.04931506849315068], ... |
|
| 2476 |
+ 'Style','radiobutton', ... |
|
| 2477 |
+ 'Tag','Radiobutton1'); |
|
| 2478 |
+ |
|
| 2479 |
+data.and_button_h = h1; |
|
| 2480 |
+ |
|
| 2481 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2482 |
+ 'Units','normalized', ... |
|
| 2483 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2484 |
+ 'ListboxTop',0, ... |
|
| 2485 |
+ 'Position',[0.125 0.5013698630136987 0.1130952380952381 0.04931506849315068], ... |
|
| 2486 |
+ 'Style','radiobutton', ... |
|
| 2487 |
+ 'Tag','Radiobutton2'); |
|
| 2488 |
+ |
|
| 2489 |
+data.or_button_h = h1; |
|
| 2490 |
+ |
|
| 2491 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2492 |
+ 'Units','normalized', ... |
|
| 2493 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2494 |
+ 'FontWeight','demi', ... |
|
| 2495 |
+ 'FontSize',8,... |
|
| 2496 |
+ 'HorizontalAlignment','left', ... |
|
| 2497 |
+ 'ListboxTop',0, ... |
|
| 2498 |
+ 'Position',[0.2619047619047619 0.5561643835616439 0.3809523809523809 0.05205479452054795], ... |
|
| 2499 |
+ 'String','AND', ... |
|
| 2500 |
+ 'Style','text', ... |
|
| 2501 |
+ 'Tag','StaticText4'); |
|
| 2502 |
+ |
|
| 2503 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2504 |
+ 'Units','normalized', ... |
|
| 2505 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2506 |
+ 'FontWeight','demi', ... |
|
| 2507 |
+ 'FontSize',8,... |
|
| 2508 |
+ 'HorizontalAlignment','left', ... |
|
| 2509 |
+ 'ListboxTop',0, ... |
|
| 2510 |
+ 'Position',[0.2619047619047619 0.4986301369863014 0.3809523809523809 0.04657534246575343], ... |
|
| 2511 |
+ 'String','OR', ... |
|
| 2512 |
+ 'Style','text', ... |
|
| 2513 |
+ 'Tag','StaticText5'); |
|
| 2514 |
+ |
|
| 2515 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2516 |
+ 'Units','normalized', ... |
|
| 2517 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2518 |
+ 'ListboxTop',0, ... |
|
| 2519 |
+ 'Position',[0.125 0.3808219178082192 0.1130952380952381 0.04931506849315068], ... |
|
| 2520 |
+ 'Style','radiobutton', ... |
|
| 2521 |
+ 'Tag','Radiobutton3'); |
|
| 2522 |
+ |
|
| 2523 |
+data.all_button_h = h1; |
|
| 2524 |
+ |
|
| 2525 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2526 |
+ 'Units','normalized', ... |
|
| 2527 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2528 |
+ 'ListboxTop',0, ... |
|
| 2529 |
+ 'Position',[0.125 0.3095890410958904 0.1130952380952381 0.04931506849315068], ... |
|
| 2530 |
+ 'Style','radiobutton', ... |
|
| 2531 |
+ 'Tag','Radiobutton4'); |
|
| 2532 |
+ |
|
| 2533 |
+data.sel_vects_button_h = h1; |
|
| 2534 |
+ |
|
| 2535 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2536 |
+ 'Units','normalized', ... |
|
| 2537 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2538 |
+ 'FontWeight','demi', ... |
|
| 2539 |
+ 'FontSize',8,... |
|
| 2540 |
+ 'HorizontalAlignment','left', ... |
|
| 2541 |
+ 'ListboxTop',0, ... |
|
| 2542 |
+ 'Position',[0.2619047619047619 0.3780821917808219 0.4166666666666666 0.04931506849315068], ... |
|
| 2543 |
+ 'String','All vectors', ... |
|
| 2544 |
+ 'Style','text', ... |
|
| 2545 |
+ 'Tag','StaticText6'); |
|
| 2546 |
+ |
|
| 2547 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2548 |
+ 'Units','normalized', ... |
|
| 2549 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2550 |
+ 'FontWeight','demi', ... |
|
| 2551 |
+ 'FontSize',8,... |
|
| 2552 |
+ 'HorizontalAlignment','left', ... |
|
| 2553 |
+ 'ListboxTop',0, ... |
|
| 2554 |
+ 'Position',[0.2619047619047619 0.3123287671232877 0.5595238095238095 0.03835616438356165], ... |
|
| 2555 |
+ 'String','Among selected', ... |
|
| 2556 |
+ 'Style','text', ... |
|
| 2557 |
+ 'Tag','StaticText7'); |
|
| 2558 |
+ |
|
| 2559 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2560 |
+ 'Units','normalized', ... |
|
| 2561 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2562 |
+ 'ListboxTop',0, ... |
|
| 2563 |
+ 'Position',[0.0952 0.1178 0.7500 0.1068], ... |
|
| 2564 |
+ 'Style','frame', ... |
|
| 2565 |
+ 'Tag','Frame6'); |
|
| 2566 |
+ |
|
| 2567 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2568 |
+ 'Units','normalized', ... |
|
| 2569 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 2570 |
+ 'ListboxTop',0, ... |
|
| 2571 |
+ 'Position',[0.5298 0.1342 0.2738 0.0712], ... |
|
| 2572 |
+ 'Style','edit', ... |
|
| 2573 |
+ 'Tag','EditText4'); |
|
| 2574 |
+ |
|
| 2575 |
+data.replace_val_h = h1; |
|
| 2576 |
+ |
|
| 2577 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2578 |
+ 'Units','normalized', ... |
|
| 2579 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 2580 |
+ 'FontSize',8,... |
|
| 2581 |
+ 'FontWeight','demi', ... |
|
| 2582 |
+ 'HorizontalAlignment','left', ... |
|
| 2583 |
+ 'ListboxTop',0, ... |
|
| 2584 |
+ 'Position',[0.1369047619047619 0.136986301369863 0.3214285714285714 0.06027397260273973], ... |
|
| 2585 |
+ 'String','Vectors', ... |
|
| 2586 |
+ 'Style','text', ... |
|
| 2587 |
+ 'Tag','StaticText8'); |
|
| 2588 |
+ |
|
| 2589 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2590 |
+ 'Units','normalized', ... |
|
| 2591 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2592 |
+ 'FontWeight','demi', ... |
|
| 2593 |
+ 'ListboxTop',0, ... |
|
| 2594 |
+ 'Position',[0.05357142857142857 0.01917808219178082 0.3869047619047619 0.0684931506849315], ... |
|
| 2595 |
+ 'String','OK', ... |
|
| 2596 |
+ 'Tag','Pushbutton1'); |
|
| 2597 |
+ |
|
| 2598 |
+data.OK_button_h = h1; |
|
| 2599 |
+ |
|
| 2600 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 2601 |
+ 'Units','normalized', ... |
|
| 2602 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 2603 |
+ 'Callback','preprocess close_s',... |
|
| 2604 |
+ 'FontWeight','demi', ... |
|
| 2605 |
+ 'ListboxTop',0, ... |
|
| 2606 |
+ 'Position',[0.5 0.01917808219178082 0.3869047619047619 0.0684931506849315], ... |
|
| 2607 |
+ 'String','Close', ... |
|
| 2608 |
+ 'Tag','Pushbutton2'); |
|
| 2609 |
+ |
|
| 2610 |
+ |
|
| 2611 |
+ |
|
| 2612 |
+data.state.and=1; |
|
| 2613 |
+data.state.all=1; |
|
| 2614 |
+data.state.big=[]; |
|
| 2615 |
+data.state.small=[]; |
|
| 2616 |
+data.state.equal=[]; |
|
| 2617 |
+data.state.replace=[]; |
|
| 2618 |
+ |
|
| 2619 |
+set(data.or_button_h,'Callback','preprocess and_or_cb or'); |
|
| 2620 |
+set(data.and_button_h,'Callback','preprocess and_or_cb and'); |
|
| 2621 |
+set(data.and_button_h,'Value',1); |
|
| 2622 |
+set(data.all_button_h,'Callback','preprocess all_sel_cb all'); |
|
| 2623 |
+set(data.sel_vects_button_h,'Callback','preprocess all_sel_cb sel'); |
|
| 2624 |
+set(data.big_val_h,'Callback','preprocess set_state_vals big'); |
|
| 2625 |
+set(data.small_val_h,'Callback','preprocess set_state_vals small'); |
|
| 2626 |
+set(data.equal_val_h,'Callback','preprocess set_state_vals equal'); |
|
| 2627 |
+set(data.replace_val_h,'Callback','preprocess set_state_vals replace'); |
|
| 2628 |
+set(data.OK_button_h,'Callback','preprocess clip_data sel'); |
|
| 2629 |
+set(h0,'UserData',data); |
|
| 2630 |
+ |
|
| 2631 |
+ |
|
| 2632 |
+ |
|
| 2633 |
+%%% Subfunction: and_or_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2634 |
+ |
|
| 2635 |
+function and_or_cb(arg) |
|
| 2636 |
+ |
|
| 2637 |
+%AND_OR_CB A callback function. Checks that only one of the radiobox |
|
| 2638 |
+% buttons 'AND' and 'OR' is pressed down. |
|
| 2639 |
+% |
|
| 2640 |
+% |
|
| 2641 |
+ |
|
| 2642 |
+and_button_h=getfield(get(gcf,'UserData'),'and_button_h'); |
|
| 2643 |
+or_button_h=getfield(get(gcf,'UserData'),'or_button_h'); |
|
| 2644 |
+data=get(gcf,'UserData'); |
|
| 2645 |
+ |
|
| 2646 |
+switch arg |
|
| 2647 |
+ case 'or' |
|
| 2648 |
+ set(and_button_h,'Value',0); |
|
| 2649 |
+ set(or_button_h,'Value',1); |
|
| 2650 |
+ data.state.and=0; |
|
| 2651 |
+ case 'and' |
|
| 2652 |
+ set(or_button_h,'Value',0); |
|
| 2653 |
+ set(and_button_h,'Value',1); |
|
| 2654 |
+ data.state.and=1; |
|
| 2655 |
+end |
|
| 2656 |
+ |
|
| 2657 |
+set(gcf,'UserData',data); |
|
| 2658 |
+ |
|
| 2659 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2660 |
+ |
|
| 2661 |
+%%% Subfunction: all_sel_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2662 |
+ |
|
| 2663 |
+function all_sel_cb(arg) |
|
| 2664 |
+ |
|
| 2665 |
+all_button_h=getfield(get(gcf,'UserData'),'all_button_h'); |
|
| 2666 |
+sel_vects_button_h=getfield(get(gcf,'UserData'),'sel_vects_button_h'); |
|
| 2667 |
+data=get(gcf,'UserData'); |
|
| 2668 |
+ |
|
| 2669 |
+switch arg |
|
| 2670 |
+ case 'all' |
|
| 2671 |
+ set(sel_vects_button_h,'Value',0); |
|
| 2672 |
+ set(all_button_h,'Value',1); |
|
| 2673 |
+ data.state.all=1; |
|
| 2674 |
+ case 'sel' |
|
| 2675 |
+ set(all_button_h,'Value',0); |
|
| 2676 |
+ set(sel_vects_button_h,'Value',1); |
|
| 2677 |
+ data.state.all=0; |
|
| 2678 |
+end |
|
| 2679 |
+ |
|
| 2680 |
+set(gcf,'UserData',data); |
|
| 2681 |
+ |
|
| 2682 |
+%%% Subfunction: set_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2683 |
+ |
|
| 2684 |
+function set_state_vals(arg) |
|
| 2685 |
+ |
|
| 2686 |
+%SET_STATE_VALS sets the values to the UserData's state-struct. |
|
| 2687 |
+% |
|
| 2688 |
+% |
|
| 2689 |
+ |
|
| 2690 |
+ |
|
| 2691 |
+data=get(gcf,'UserData'); |
|
| 2692 |
+ |
|
| 2693 |
+switch arg |
|
| 2694 |
+ case 'big' |
|
| 2695 |
+ big_val_h=getfield(get(gcf,'UserData'),'big_val_h'); |
|
| 2696 |
+ val =str2num(get(big_val_h,'String')); |
|
| 2697 |
+ dims=size(val); |
|
| 2698 |
+ if dims(1) ~= 1 | dims(2) ~= 1 |
|
| 2699 |
+ errordlg('Argument of the operation must be scalar.');
|
|
| 2700 |
+ set(big_val_h,'String',''); |
|
| 2701 |
+ return; |
|
| 2702 |
+ end |
|
| 2703 |
+ if isreal(val) |
|
| 2704 |
+ data.state.big=val; |
|
| 2705 |
+ else |
|
| 2706 |
+ errordlg('Limits of the operation must be real.');
|
|
| 2707 |
+ set(big_val_h,'String',''); |
|
| 2708 |
+ return; |
|
| 2709 |
+ end |
|
| 2710 |
+ case 'small' |
|
| 2711 |
+ small_val_h=getfield(get(gcf,'UserData'),'small_val_h'); |
|
| 2712 |
+ val=str2num(get(small_val_h,'String')); |
|
| 2713 |
+ dims=size(val); |
|
| 2714 |
+ if dims(1) ~= 1 | dims(2) ~= 1 |
|
| 2715 |
+ errordlg('Argument of the operation must be scalar.')
|
|
| 2716 |
+ set(small_val_h,'String',''); |
|
| 2717 |
+ return; |
|
| 2718 |
+ end |
|
| 2719 |
+ if isreal(val) |
|
| 2720 |
+ data.state.small=val; |
|
| 2721 |
+ else |
|
| 2722 |
+ errordlg('Limits of the operation must be real.');
|
|
| 2723 |
+ set(small_val_h,'String',''); |
|
| 2724 |
+ return; |
|
| 2725 |
+ end |
|
| 2726 |
+ case 'equal' |
|
| 2727 |
+ equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h'); |
|
| 2728 |
+ val = str2num(get(equal_val_h,'String')); |
|
| 2729 |
+ dims=size(val); |
|
| 2730 |
+ if dims(1) ~= 1 | dims(2) ~= 1 |
|
| 2731 |
+ errordlg('Argument of the operation must be scalar.');
|
|
| 2732 |
+ set(equal_val_h,'String',''); |
|
| 2733 |
+ return; |
|
| 2734 |
+ end |
|
| 2735 |
+ if isreal(val) |
|
| 2736 |
+ data.state.equal=val; |
|
| 2737 |
+ else |
|
| 2738 |
+ errordlg('Limits of the operation must be real.');
|
|
| 2739 |
+ set(equal_val_h,'String',''); |
|
| 2740 |
+ return; |
|
| 2741 |
+ end |
|
| 2742 |
+ case 'replace' |
|
| 2743 |
+ replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h'); |
|
| 2744 |
+ val=str2num(get(replace_val_h,'String')); |
|
| 2745 |
+ dims=size(val); |
|
| 2746 |
+ if (dims(1) ~= 1 | dims(2) ~= 1) & ~strcmp(get(gcf,'Tag'),'Select') |
|
| 2747 |
+ errordlg('Argument of the operation must be scalar.');
|
|
| 2748 |
+ set(replace_val_h,'String',''); |
|
| 2749 |
+ return; |
|
| 2750 |
+ end |
|
| 2751 |
+ if isreal(val) |
|
| 2752 |
+ data.state.replace=val; |
|
| 2753 |
+ else |
|
| 2754 |
+ errordlg('Limits of the operation must be real.');
|
|
| 2755 |
+ set(replace_val_h,'String',''); |
|
| 2756 |
+ return; |
|
| 2757 |
+ end |
|
| 2758 |
+end |
|
| 2759 |
+ |
|
| 2760 |
+set(gcf,'UserData',data); |
|
| 2761 |
+ |
|
| 2762 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2763 |
+ |
|
| 2764 |
+%%% Subfunction: clip_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 2765 |
+ |
|
| 2766 |
+function clip_data(arg) |
|
| 2767 |
+ |
|
| 2768 |
+%CLIP_DATA A callback function. Filters the data. |
|
| 2769 |
+% |
|
| 2770 |
+% |
|
| 2771 |
+ |
|
| 2772 |
+i=1; |
|
| 2773 |
+while i <= length(arg) & arg(i) ~= ' ' |
|
| 2774 |
+ i=i+1; |
|
| 2775 |
+end |
|
| 2776 |
+ |
|
| 2777 |
+arg2=arg(i+1:length(arg)); |
|
| 2778 |
+arg=arg(1:i-1); |
|
| 2779 |
+ |
|
| 2780 |
+if ~isempty(arg2) |
|
| 2781 |
+ LOG=1; |
|
| 2782 |
+ if strcmp(arg,'sel') |
|
| 2783 |
+ c_h=findobj(get(0,'Children'),'Tag','Select'); |
|
| 2784 |
+ else |
|
| 2785 |
+ c_h=findobj(get(0,'Children'),'Tag','Clipping'); |
|
| 2786 |
+ end |
|
| 2787 |
+ set(0,'CurrentFigure',c_h); |
|
| 2788 |
+ i=1; |
|
| 2789 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 2790 |
+ i=i+1; |
|
| 2791 |
+ end |
|
| 2792 |
+ BT=str2num(arg2(1:i-1)); |
|
| 2793 |
+ i=i+1; |
|
| 2794 |
+ j=i; |
|
| 2795 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 2796 |
+ i=i+1; |
|
| 2797 |
+ end |
|
| 2798 |
+ ST=str2num(arg2(j:i-1)); |
|
| 2799 |
+ i=i+1; |
|
| 2800 |
+ j=i; |
|
| 2801 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 2802 |
+ i=i+1; |
|
| 2803 |
+ end |
|
| 2804 |
+ EQ=str2num(arg2(j:i-1)); |
|
| 2805 |
+ i=i+1; |
|
| 2806 |
+ j=i; |
|
| 2807 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 2808 |
+ i=i+1; |
|
| 2809 |
+ end |
|
| 2810 |
+ AND_OR=str2num(arg2(j:i-1)); |
|
| 2811 |
+ i=i+1; |
|
| 2812 |
+ j=i; |
|
| 2813 |
+ while i <= length(arg2) & arg2(i) ~= ' ' |
|
| 2814 |
+ i=i+1; |
|
| 2815 |
+ end |
|
| 2816 |
+ ALL_AMONG=str2num(arg2(j:i-1)); |
|
| 2817 |
+ i=i+1; |
|
| 2818 |
+ j=i; |
|
| 2819 |
+ while i <= length(arg2) |
|
| 2820 |
+ i=i+1; |
|
| 2821 |
+ end |
|
| 2822 |
+ VECT_REPL=str2num(arg2(j:i-1)); |
|
| 2823 |
+else |
|
| 2824 |
+ LOG=0; |
|
| 2825 |
+end |
|
| 2826 |
+ |
|
| 2827 |
+if ~LOG |
|
| 2828 |
+ big_val_h=getfield(get(gcf,'UserData'),'big_val_h'); |
|
| 2829 |
+ small_val_h=getfield(get(gcf,'UserData'),'small_val_h'); |
|
| 2830 |
+ equal_val_h=getfield(get(gcf,'UserData'),'equal_val_h'); |
|
| 2831 |
+ replace_val_h=getfield(get(gcf,'UserData'),'replace_val_h'); |
|
| 2832 |
+end |
|
| 2833 |
+ |
|
| 2834 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 2835 |
+ |
|
| 2836 |
+if isempty(pre_h) |
|
| 2837 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program...');
|
|
| 2838 |
+ pro_tools('close');
|
|
| 2839 |
+ return; |
|
| 2840 |
+end |
|
| 2841 |
+ |
|
| 2842 |
+comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 2843 |
+selected=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 2844 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 2845 |
+undo = sData; |
|
| 2846 |
+state=getfield(get(gcf,'UserData'),'state'); |
|
| 2847 |
+ |
|
| 2848 |
+if LOG |
|
| 2849 |
+ state.big=BT; |
|
| 2850 |
+ state.small=ST; |
|
| 2851 |
+ state.equal=EQ; |
|
| 2852 |
+ state.replace=VECT_REPL; |
|
| 2853 |
+ state.and=AND_OR; |
|
| 2854 |
+ state.all=ALL_AMONG; |
|
| 2855 |
+end |
|
| 2856 |
+ |
|
| 2857 |
+if isempty(pre_h) |
|
| 2858 |
+ pro_tools('close');
|
|
| 2859 |
+end |
|
| 2860 |
+ |
|
| 2861 |
+if isempty(get(comp_names_h,'Value')) |
|
| 2862 |
+ clear_state_vals; |
|
| 2863 |
+ errordlg('There must be one component chosen for the operation.');
|
|
| 2864 |
+ return; |
|
| 2865 |
+end |
|
| 2866 |
+ |
|
| 2867 |
+n_th_comp=getfield(get_indices,{1});
|
|
| 2868 |
+ |
|
| 2869 |
+if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ... |
|
| 2870 |
+ strcmp(arg,'clip') |
|
| 2871 |
+ clear_state_vals; |
|
| 2872 |
+ errordlg('At least one limit must be chosen for the-operation.');
|
|
| 2873 |
+ return; |
|
| 2874 |
+end |
|
| 2875 |
+ |
|
| 2876 |
+if ~isempty(state.replace) & strcmp(arg,'sel') |
|
| 2877 |
+ if ~all(state.replace == round(state.replace)) | any(state.replace < 1) |
|
| 2878 |
+ errordlg('Indices of vectors must be positive integers.');
|
|
| 2879 |
+ return; |
|
| 2880 |
+ elseif any(state.replace > length(sData.data(:,1))) |
|
| 2881 |
+ errordlg('Indices of the vectors to be selected are too big.');
|
|
| 2882 |
+ return; |
|
| 2883 |
+ end |
|
| 2884 |
+end |
|
| 2885 |
+ |
|
| 2886 |
+if isempty(state.replace) & strcmp(arg,'clip') |
|
| 2887 |
+ clear_state_vals; |
|
| 2888 |
+ errordlg('Replace value must be determined for Clipping-operation.');
|
|
| 2889 |
+ return; |
|
| 2890 |
+end |
|
| 2891 |
+ |
|
| 2892 |
+if isempty(state.big) & isempty(state.small) & isempty(state.equal) & ... |
|
| 2893 |
+ isempty(state.replace) |
|
| 2894 |
+ clear_state_vals; |
|
| 2895 |
+ return; |
|
| 2896 |
+end |
|
| 2897 |
+ |
|
| 2898 |
+bt_indices=[]; |
|
| 2899 |
+lt_indices=[]; |
|
| 2900 |
+equal_indices=[]; |
|
| 2901 |
+ |
|
| 2902 |
+ |
|
| 2903 |
+if ~isempty(state.big) |
|
| 2904 |
+ if state.all |
|
| 2905 |
+ bt_indices=find(sData.data(:,n_th_comp) > state.big); |
|
| 2906 |
+ else |
|
| 2907 |
+ bt_indices=selected(find(sData.data(selected,n_th_comp) > state.big)); |
|
| 2908 |
+ end |
|
| 2909 |
+end |
|
| 2910 |
+ |
|
| 2911 |
+if ~isempty(state.small) |
|
| 2912 |
+ if state.all |
|
| 2913 |
+ lt_indices=find(sData.data(:,n_th_comp) < state.small); |
|
| 2914 |
+ else |
|
| 2915 |
+ lt_indices=selected(find(sData.data(selected,n_th_comp) < state.small)); |
|
| 2916 |
+ end |
|
| 2917 |
+end |
|
| 2918 |
+ |
|
| 2919 |
+if ~isempty(state.equal) |
|
| 2920 |
+ if isnan(state.equal) |
|
| 2921 |
+ if state.all |
|
| 2922 |
+ equal_indices=find(isnan(sData.data(:,n_th_comp))); |
|
| 2923 |
+ else |
|
| 2924 |
+ equal_indices=selected(find(isnan(sData.data(selected,n_th_comp)))); |
|
| 2925 |
+ end |
|
| 2926 |
+ elseif state.all |
|
| 2927 |
+ equal_indices=find(sData.data(:,n_th_comp)==state.equal); |
|
| 2928 |
+ else |
|
| 2929 |
+ equal_indices=selected(find(sData.data(selected,n_th_comp)==state.equal)); |
|
| 2930 |
+ end |
|
| 2931 |
+end |
|
| 2932 |
+ |
|
| 2933 |
+if state.and |
|
| 2934 |
+ |
|
| 2935 |
+ if ~isempty(bt_indices) | ~isempty(lt_indices) | ~isempty(equal_indices)... |
|
| 2936 |
+ | strcmp(arg,'sel') |
|
| 2937 |
+ |
|
| 2938 |
+ if isempty(bt_indices) & isempty(lt_indices) & isempty(equal_indices) &... |
|
| 2939 |
+ isempty(state.replace) |
|
| 2940 |
+ clear_state_vals; |
|
| 2941 |
+ return; |
|
| 2942 |
+ end |
|
| 2943 |
+ if isempty(bt_indices) |
|
| 2944 |
+ if ~state.all |
|
| 2945 |
+ bt_indices=selected; |
|
| 2946 |
+ else |
|
| 2947 |
+ bt_indices=1:getfield(size(sData.data),{1});
|
|
| 2948 |
+ end |
|
| 2949 |
+ end |
|
| 2950 |
+ if isempty(lt_indices) |
|
| 2951 |
+ if ~state.all |
|
| 2952 |
+ lt_indices=selected; |
|
| 2953 |
+ else |
|
| 2954 |
+ lt_indices=1:getfield(size(sData.data),{1});
|
|
| 2955 |
+ end |
|
| 2956 |
+ end |
|
| 2957 |
+ if isempty(equal_indices) |
|
| 2958 |
+ if ~state.all |
|
| 2959 |
+ equal_indices=selected; |
|
| 2960 |
+ else |
|
| 2961 |
+ equal_indices=1:getfield(size(sData.data),{1});
|
|
| 2962 |
+ end |
|
| 2963 |
+ end |
|
| 2964 |
+ |
|
| 2965 |
+ indices=intersect(intersect(bt_indices,lt_indices),equal_indices); |
|
| 2966 |
+ if strcmp(arg,'sel') |
|
| 2967 |
+ if ~isempty(indices) | ~isempty(state.replace) |
|
| 2968 |
+ if isempty(state.replace) |
|
| 2969 |
+ NOTEMPTY=0; |
|
| 2970 |
+ if ~state.all |
|
| 2971 |
+ state.replace=selected; |
|
| 2972 |
+ else |
|
| 2973 |
+ state.replace=1:getfield(size(sData.data),{1});
|
|
| 2974 |
+ end |
|
| 2975 |
+ else |
|
| 2976 |
+ NOTEMPTY=1; |
|
| 2977 |
+ end |
|
| 2978 |
+ if isempty(indices) |
|
| 2979 |
+ indices=selected; |
|
| 2980 |
+ end |
|
| 2981 |
+ indices=intersect(indices,state.replace); |
|
| 2982 |
+ if isempty(indices) |
|
| 2983 |
+ indices=selected; |
|
| 2984 |
+ end |
|
| 2985 |
+ data=get(pre_h,'UserData'); |
|
| 2986 |
+ data.undo.sData=sData; |
|
| 2987 |
+ data.undo.selected=data.selected_vects; |
|
| 2988 |
+ data.selected_vects=indices; |
|
| 2989 |
+ if ~LOG |
|
| 2990 |
+ if ~NOTEMPTY |
|
| 2991 |
+ data.LOG{length(data.LOG)+1}='% Select vectors.';
|
|
| 2992 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',...
|
|
| 2993 |
+ arg,... |
|
| 2994 |
+ ' ',num2str(state.big),... |
|
| 2995 |
+ ' ',num2str(state.small),... |
|
| 2996 |
+ ' ',num2str(state.equal),... |
|
| 2997 |
+ ' ',num2str(state.and),... |
|
| 2998 |
+ ' ',num2str(state.all),... |
|
| 2999 |
+ ''');'); |
|
| 3000 |
+ else |
|
| 3001 |
+ code=write_log_code(state.replace,... |
|
| 3002 |
+ arg,... |
|
| 3003 |
+ state.big,... |
|
| 3004 |
+ state.small,... |
|
| 3005 |
+ state.equal,... |
|
| 3006 |
+ state.and,... |
|
| 3007 |
+ state.all); |
|
| 3008 |
+ data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; |
|
| 3009 |
+ end |
|
| 3010 |
+ end |
|
| 3011 |
+ set(pre_h,'UserData',data); |
|
| 3012 |
+ old=gcf; |
|
| 3013 |
+ set(0,'CurrentFigure',pre_h); |
|
| 3014 |
+ sel_comp; |
|
| 3015 |
+ cplot_mimema; |
|
| 3016 |
+ vect_means(data.sData,data.vect_mean_h,data.selected_vects); |
|
| 3017 |
+ set(0,'CurrentFigure',old); |
|
| 3018 |
+ end |
|
| 3019 |
+ clear_state_vals; |
|
| 3020 |
+ return; |
|
| 3021 |
+ end |
|
| 3022 |
+ sData.data(indices,n_th_comp) = state.replace; |
|
| 3023 |
+ sData.MODIFIED=1; |
|
| 3024 |
+ end |
|
| 3025 |
+else |
|
| 3026 |
+ indices=union(union(bt_indices,lt_indices),equal_indices); |
|
| 3027 |
+ if ~isempty(indices) | strcmp(arg,'sel') |
|
| 3028 |
+ if strcmp(arg,'sel') |
|
| 3029 |
+ if ~isempty(indices) | ~isempty(state.replace') |
|
| 3030 |
+ data=get(pre_h,'UserData'); |
|
| 3031 |
+ data.undo.sData=sData; |
|
| 3032 |
+ data.undo.selected=data.selected_vects; |
|
| 3033 |
+ data.selected_vects=union(indices,state.replace); |
|
| 3034 |
+ if ~LOG |
|
| 3035 |
+ if isempty(state.replace); |
|
| 3036 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',...
|
|
| 3037 |
+ arg,... |
|
| 3038 |
+ ' ',num2str(state.big),... |
|
| 3039 |
+ ' ',num2str(state.small),... |
|
| 3040 |
+ ' ',num2str(state.equal),... |
|
| 3041 |
+ ' ',num2str(state.and),... |
|
| 3042 |
+ ' ',num2str(state.all),... |
|
| 3043 |
+ ''');'); |
|
| 3044 |
+ else |
|
| 3045 |
+ code=write_log_code(state.replace,... |
|
| 3046 |
+ arg,... |
|
| 3047 |
+ state.big,... |
|
| 3048 |
+ state.small,... |
|
| 3049 |
+ state.equal,... |
|
| 3050 |
+ state.and,... |
|
| 3051 |
+ state.all); |
|
| 3052 |
+ data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; |
|
| 3053 |
+ end |
|
| 3054 |
+ end |
|
| 3055 |
+ set(pre_h,'UserData',data); |
|
| 3056 |
+ old=gcf; |
|
| 3057 |
+ set(0,'CurrentFigure',pre_h); |
|
| 3058 |
+ sel_comp; |
|
| 3059 |
+ vect_means(data.sData,data.vect_mean_h,data.selected_vects); |
|
| 3060 |
+ cplot_mimema; |
|
| 3061 |
+ set(0,'CurrentFigure',old); |
|
| 3062 |
+ end |
|
| 3063 |
+ clear_state_vals; |
|
| 3064 |
+ return; |
|
| 3065 |
+ end |
|
| 3066 |
+ sData.data(indices,n_th_comp)=state.replace; |
|
| 3067 |
+ sData.MODIFIED=1; |
|
| 3068 |
+ end |
|
| 3069 |
+end |
|
| 3070 |
+ |
|
| 3071 |
+if sData.MODIFIED |
|
| 3072 |
+ data=get(pre_h,'UserData'); |
|
| 3073 |
+ data.sData=sData; |
|
| 3074 |
+ data.undo.sData=undo; |
|
| 3075 |
+ if ~LOG |
|
| 3076 |
+ if strcmp(arg,'sel') |
|
| 3077 |
+ data.LOG{length(data.LOG)+1}='% Select vectors';
|
|
| 3078 |
+ else |
|
| 3079 |
+ data.LOG{length(data.LOG)+1}='% Clip values.';
|
|
| 3080 |
+ end |
|
| 3081 |
+ if strcmp(arg,'clip') | isempty(state.replace) |
|
| 3082 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''clip_data'',''',arg,...
|
|
| 3083 |
+ ' ',num2str(state.big),... |
|
| 3084 |
+ ' ',num2str(state.small),... |
|
| 3085 |
+ ' ',num2str(state.equal),... |
|
| 3086 |
+ ' ',num2str(state.and),... |
|
| 3087 |
+ ' ',num2str(state.all),... |
|
| 3088 |
+ ' ',num2str(state.replace),... |
|
| 3089 |
+ ''');'); |
|
| 3090 |
+ else |
|
| 3091 |
+ code=write_log_code(state.replace,... |
|
| 3092 |
+ arg,... |
|
| 3093 |
+ state.big,... |
|
| 3094 |
+ state.small,... |
|
| 3095 |
+ state.equal,... |
|
| 3096 |
+ state.and,... |
|
| 3097 |
+ state.all); |
|
| 3098 |
+ data.LOG(length(data.LOG)+1:length(data.LOG)+length(code))=code; |
|
| 3099 |
+ end |
|
| 3100 |
+ end |
|
| 3101 |
+ set(pre_h,'UserData',data); |
|
| 3102 |
+ old=gcf; |
|
| 3103 |
+ set(0,'CurrentFigure',pre_h) |
|
| 3104 |
+ |
|
| 3105 |
+ vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 3106 |
+ vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 3107 |
+ set(gcf,'CurrentAxes',vector_h); |
|
| 3108 |
+ vect_means(sData,vect_mean_h,selected); |
|
| 3109 |
+ cplot_mimema; |
|
| 3110 |
+ sel_comp; |
|
| 3111 |
+ |
|
| 3112 |
+ set(0,'CurrentFigure',old); |
|
| 3113 |
+end |
|
| 3114 |
+ |
|
| 3115 |
+clear_state_vals; |
|
| 3116 |
+ |
|
| 3117 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3118 |
+ |
|
| 3119 |
+%%% Subfunction: clear_state_vals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3120 |
+ |
|
| 3121 |
+function clear_state_vals |
|
| 3122 |
+ |
|
| 3123 |
+%CLEAR_STATE_VALS Sets the fields of the UserData's state-struct empty. |
|
| 3124 |
+% |
|
| 3125 |
+% |
|
| 3126 |
+ |
|
| 3127 |
+ |
|
| 3128 |
+data=get(gcf,'UserData'); |
|
| 3129 |
+set(data.big_val_h,'String',''); |
|
| 3130 |
+set(data.small_val_h,'String',''); |
|
| 3131 |
+set(data.equal_val_h,'String',''); |
|
| 3132 |
+set(data.replace_val_h,'String',''); |
|
| 3133 |
+data.state.big=[]; |
|
| 3134 |
+data.state.small=[]; |
|
| 3135 |
+data.state.equal=[]; |
|
| 3136 |
+data.state.replace=[]; |
|
| 3137 |
+set(gcf,'UserData',data); |
|
| 3138 |
+ |
|
| 3139 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3140 |
+ |
|
| 3141 |
+function delay(varargin) |
|
| 3142 |
+ |
|
| 3143 |
+delay_h=findobj(get(0,'Children'),'Tag','Delay'); |
|
| 3144 |
+ |
|
| 3145 |
+if nargin ~= 1 |
|
| 3146 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 3147 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 3148 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 3149 |
+ '% Starting the ''Delay'' -window...'; |
|
| 3150 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''delay'',''foo'');';
|
|
| 3151 |
+ set(pre_h,'UserData',preh_udata); |
|
| 3152 |
+end |
|
| 3153 |
+ |
|
| 3154 |
+if ~isempty(delay_h) |
|
| 3155 |
+ figure(delay_h); |
|
| 3156 |
+ return; |
|
| 3157 |
+end |
|
| 3158 |
+ |
|
| 3159 |
+h0 = figure('Color',[0.8 0.8 0.8], ...
|
|
| 3160 |
+ 'PaperPosition',[18 180 576 432], ... |
|
| 3161 |
+ 'PaperUnits','points', ... |
|
| 3162 |
+ 'Position',[759 664 162 215], ... |
|
| 3163 |
+ 'Tag','Delay'); |
|
| 3164 |
+ |
|
| 3165 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3166 |
+ 'Units','normalized', ... |
|
| 3167 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 3168 |
+ 'ListboxTop',0, ... |
|
| 3169 |
+ 'Position',[0.05555555555555555 0.2046511627906977 0.8950617283950617 0.7441860465116279], ... |
|
| 3170 |
+ 'Style','frame', ... |
|
| 3171 |
+ 'Tag','Frame1'); |
|
| 3172 |
+ |
|
| 3173 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3174 |
+ 'Units','normalized', ... |
|
| 3175 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3176 |
+ 'ListboxTop',0, ... |
|
| 3177 |
+ 'Position',[0.08641975308641975 0.6976744186046512 0.8333333333333333 0.2232558139534884], ... |
|
| 3178 |
+ 'Style','frame', ... |
|
| 3179 |
+ 'Tag','Frame2'); |
|
| 3180 |
+ |
|
| 3181 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3182 |
+ 'Units','normalized', ... |
|
| 3183 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3184 |
+ 'ListboxTop',0, ... |
|
| 3185 |
+ 'Position',[0.08641975308641975 0.227906976744186 0.8333333333333333 0.4418604651162791], ... |
|
| 3186 |
+ 'Style','frame', ... |
|
| 3187 |
+ 'Tag','Frame3'); |
|
| 3188 |
+ |
|
| 3189 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3190 |
+ 'Units','normalized', ... |
|
| 3191 |
+ 'Callback','preprocess delay_data',... |
|
| 3192 |
+ 'FontWeight','demi', ... |
|
| 3193 |
+ 'ListboxTop',0, ... |
|
| 3194 |
+ 'Position',[0.0556 0.0326 0.4012 0.1163], ... |
|
| 3195 |
+ 'String','OK', ... |
|
| 3196 |
+ 'Tag','Pushbutton1'); |
|
| 3197 |
+ |
|
| 3198 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3199 |
+ 'Units','normalized', ... |
|
| 3200 |
+ 'Callback','preprocess close_d',... |
|
| 3201 |
+ 'FontWeight','demi', ... |
|
| 3202 |
+ 'ListboxTop',0, ... |
|
| 3203 |
+ 'Position',[0.5494 0.0326 0.4012 0.1163], ... |
|
| 3204 |
+ 'String','Close', ... |
|
| 3205 |
+ 'Tag','Pushbutton2'); |
|
| 3206 |
+ |
|
| 3207 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3208 |
+ 'Units','normalized', ... |
|
| 3209 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 3210 |
+ 'ListboxTop',0, ... |
|
| 3211 |
+ 'Position',[0.4876543209876543 0.7534883720930232 0.3518518518518519 0.1255813953488372], ... |
|
| 3212 |
+ 'Style','edit', ... |
|
| 3213 |
+ 'Tag','EditText1'); |
|
| 3214 |
+ |
|
| 3215 |
+data.delay_val_h = h1; |
|
| 3216 |
+ |
|
| 3217 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3218 |
+ 'Units','normalized', ... |
|
| 3219 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3220 |
+ 'FontWeight','demi', ... |
|
| 3221 |
+ 'HorizontalAlignment','left', ... |
|
| 3222 |
+ 'ListboxTop',0, ... |
|
| 3223 |
+ 'Position',[0.1173 0.7860 0.3086 0.0651], ... |
|
| 3224 |
+ 'String','Delay', ... |
|
| 3225 |
+ 'Style','text', ... |
|
| 3226 |
+ 'Tag','StaticText1'); |
|
| 3227 |
+ |
|
| 3228 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3229 |
+ 'Units','normalized', ... |
|
| 3230 |
+ 'Callback','preprocess clip_exp_cb c_this',... |
|
| 3231 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3232 |
+ 'ListboxTop',0, ... |
|
| 3233 |
+ 'Position',[0.1173 0.5349 0.1173 0.0837], ... |
|
| 3234 |
+ 'Style','radiobutton', ... |
|
| 3235 |
+ 'Tag','Radiobutton1'); |
|
| 3236 |
+ |
|
| 3237 |
+data.c_this_button_h=h1; |
|
| 3238 |
+data.mode='c_this'; |
|
| 3239 |
+ |
|
| 3240 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3241 |
+ 'Units','normalized', ... |
|
| 3242 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3243 |
+ 'Callback','preprocess clip_exp_cb c_all',... |
|
| 3244 |
+ 'ListboxTop',0, ... |
|
| 3245 |
+ 'Position',[0.1173 0.4047 0.1173 0.0837], ... |
|
| 3246 |
+ 'Style','radiobutton', ... |
|
| 3247 |
+ 'Tag','Radiobutton2'); |
|
| 3248 |
+ |
|
| 3249 |
+data.c_all_button_h=h1; |
|
| 3250 |
+ |
|
| 3251 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3252 |
+ 'Units','normalized', ... |
|
| 3253 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3254 |
+ 'Callback','preprocess clip_exp_cb e_all',... |
|
| 3255 |
+ 'ListboxTop',0, ... |
|
| 3256 |
+ 'Position',[0.1173 0.2651 0.1173 0.0837], ... |
|
| 3257 |
+ 'Style','radiobutton', ... |
|
| 3258 |
+ 'Tag','Radiobutton3'); |
|
| 3259 |
+ |
|
| 3260 |
+data.e_all_button_h=h1; |
|
| 3261 |
+ |
|
| 3262 |
+ |
|
| 3263 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3264 |
+ 'Units','normalized', ... |
|
| 3265 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3266 |
+ 'FontWeight','demi', ... |
|
| 3267 |
+ 'FontSize',8,... |
|
| 3268 |
+ 'HorizontalAlignment','left', ... |
|
| 3269 |
+ 'ListboxTop',0, ... |
|
| 3270 |
+ 'Position',[0.26 0.5534883720930233 0.4135802469135802 0.06511627906976744], ... |
|
| 3271 |
+ 'String','Clip this', ... |
|
| 3272 |
+ 'Style','text', ... |
|
| 3273 |
+ 'Tag','StaticText2'); |
|
| 3274 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3275 |
+ 'Units','normalized', ... |
|
| 3276 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3277 |
+ 'FontWeight','demi', ... |
|
| 3278 |
+ 'FontSize',8,... |
|
| 3279 |
+ 'HorizontalAlignment','left', ... |
|
| 3280 |
+ 'ListboxTop',0, ... |
|
| 3281 |
+ 'Position',[0.26 0.413953488372093 0.3765432098765432 0.06511627906976744], ... |
|
| 3282 |
+ 'String','Clip all', ... |
|
| 3283 |
+ 'Style','text', ... |
|
| 3284 |
+ 'Tag','StaticText3'); |
|
| 3285 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3286 |
+ 'Units','normalized', ... |
|
| 3287 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3288 |
+ 'FontWeight','demi', ... |
|
| 3289 |
+ 'FontSize',8,... |
|
| 3290 |
+ 'HorizontalAlignment','left', ... |
|
| 3291 |
+ 'ListboxTop',0, ... |
|
| 3292 |
+ 'Position',[0.26 0.2744186046511628 0.4197530864197531 0.06511627906976744], ... |
|
| 3293 |
+ 'String','Expand all', ... |
|
| 3294 |
+ 'Style','text', ... |
|
| 3295 |
+ 'Tag','StaticText4'); |
|
| 3296 |
+ |
|
| 3297 |
+ |
|
| 3298 |
+set(gcf,'UserData',data); |
|
| 3299 |
+ |
|
| 3300 |
+%%% Subfunction clip_exp_cb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3301 |
+ |
|
| 3302 |
+function clip_exp_cb(arg) |
|
| 3303 |
+ |
|
| 3304 |
+c_this_button_h=getfield(get(gcf,'UserData'),'c_this_button_h'); |
|
| 3305 |
+c_all_button_h=getfield(get(gcf,'UserData'),'c_all_button_h'); |
|
| 3306 |
+e_all_button_h=getfield(get(gcf,'UserData'),'e_all_button_h'); |
|
| 3307 |
+data=get(gcf,'UserData'); |
|
| 3308 |
+ |
|
| 3309 |
+ |
|
| 3310 |
+switch arg |
|
| 3311 |
+ case 'c_this' |
|
| 3312 |
+ set(c_all_button_h,'Value',0); |
|
| 3313 |
+ set(e_all_button_h,'Value',0); |
|
| 3314 |
+ set(c_this_button_h,'Value',1); |
|
| 3315 |
+ data.mode='c_this'; |
|
| 3316 |
+ case 'c_all' |
|
| 3317 |
+ set(c_this_button_h,'Value',0); |
|
| 3318 |
+ set(e_all_button_h,'Value',0); |
|
| 3319 |
+ set(c_all_button_h,'Value',1); |
|
| 3320 |
+ data.mode='c_all'; |
|
| 3321 |
+ case 'e_all' |
|
| 3322 |
+ set(c_this_button_h,'Value',0); |
|
| 3323 |
+ set(c_all_button_h,'Value',0); |
|
| 3324 |
+ set(e_all_button_h,'Value',1); |
|
| 3325 |
+ data.mode='e_all'; |
|
| 3326 |
+end |
|
| 3327 |
+ |
|
| 3328 |
+set(gcf,'UserData',data); |
|
| 3329 |
+ |
|
| 3330 |
+%%% Subfunction: delay_data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3331 |
+ |
|
| 3332 |
+function delay_data(varargin) |
|
| 3333 |
+ |
|
| 3334 |
+if nargin == 1 |
|
| 3335 |
+ del_h=findobj(get(0,'Children'),'Tag','Delay'); |
|
| 3336 |
+ set(0,'CurrentFigure',del_h); |
|
| 3337 |
+ LOG=1; |
|
| 3338 |
+ arg=varargin{1};
|
|
| 3339 |
+ i=1; |
|
| 3340 |
+ while i <= length(arg) & arg(i) ~= ' ' |
|
| 3341 |
+ i=i+1; |
|
| 3342 |
+ end |
|
| 3343 |
+ delay=str2num(arg(1:i-1)); |
|
| 3344 |
+ no=str2num(arg(i+1:length(arg))); |
|
| 3345 |
+else |
|
| 3346 |
+ LOG=0; |
|
| 3347 |
+end |
|
| 3348 |
+ |
|
| 3349 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 3350 |
+q='Delay operation is not evaluated.'; |
|
| 3351 |
+t='Warning'; |
|
| 3352 |
+if isempty(pre_h) |
|
| 3353 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program...');
|
|
| 3354 |
+ pro_tools('close');
|
|
| 3355 |
+ return; |
|
| 3356 |
+end |
|
| 3357 |
+ |
|
| 3358 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 3359 |
+undo = sData; |
|
| 3360 |
+data=get(gcf,'UserData'); |
|
| 3361 |
+if ~LOG |
|
| 3362 |
+ delay=str2num(get(data.delay_val_h,'String')); |
|
| 3363 |
+ if isempty(delay) |
|
| 3364 |
+ errordlg('Value of ''Delay'' must be defined.');
|
|
| 3365 |
+ return |
|
| 3366 |
+ end |
|
| 3367 |
+ set(data.delay_val_h,'String',''); |
|
| 3368 |
+ if round(delay) ~= delay |
|
| 3369 |
+ errordlg('Value of ''Delay'' must be integer.');
|
|
| 3370 |
+ return; |
|
| 3371 |
+ end |
|
| 3372 |
+end |
|
| 3373 |
+comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 3374 |
+if isempty(get(comp_names_h,'Value')) |
|
| 3375 |
+ errordlg('There are not components chosen.');
|
|
| 3376 |
+ return; |
|
| 3377 |
+end |
|
| 3378 |
+n_th_comp=getfield(get_indices,{1});
|
|
| 3379 |
+len=length(sData.data(:,1)); |
|
| 3380 |
+ |
|
| 3381 |
+if LOG |
|
| 3382 |
+ switch no |
|
| 3383 |
+ case 1 |
|
| 3384 |
+ data.mode='c_this'; |
|
| 3385 |
+ preprocess('clip_exp_cb','c_this');
|
|
| 3386 |
+ case 2 |
|
| 3387 |
+ data.mode='c_all'; |
|
| 3388 |
+ preprocess('clip_exp_cb','c_all');
|
|
| 3389 |
+ case 3 |
|
| 3390 |
+ data.mode='e_all'; |
|
| 3391 |
+ preprocess('clip_exp_cb','e_all');
|
|
| 3392 |
+ end |
|
| 3393 |
+end |
|
| 3394 |
+ |
|
| 3395 |
+switch data.mode |
|
| 3396 |
+ case 'c_this' |
|
| 3397 |
+ MODE='1'; |
|
| 3398 |
+ if delay > 0 |
|
| 3399 |
+ sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay); |
|
| 3400 |
+ if delay >= len |
|
| 3401 |
+ errordlg(q,t); |
|
| 3402 |
+ return; |
|
| 3403 |
+ else |
|
| 3404 |
+ sData.data(1:delay,n_th_comp)=NaN; |
|
| 3405 |
+ end |
|
| 3406 |
+ elseif delay < 0 |
|
| 3407 |
+ sData.data(1:len+delay,n_th_comp)=... |
|
| 3408 |
+ sData.data(abs(delay)+1:len,n_th_comp); |
|
| 3409 |
+ if abs(delay) >= len |
|
| 3410 |
+ errordlg(q,t); |
|
| 3411 |
+ return; |
|
| 3412 |
+ else |
|
| 3413 |
+ sData.data(len+delay+1:len,n_th_comp)=NaN; |
|
| 3414 |
+ end |
|
| 3415 |
+ end |
|
| 3416 |
+ if delay ~= 0 |
|
| 3417 |
+ data=get(pre_h,'UserData'); |
|
| 3418 |
+ sData.MODIFIED=1; |
|
| 3419 |
+ sData.comp_norm(n_th_comp)=[]; |
|
| 3420 |
+ data.sData=sData; |
|
| 3421 |
+ data.undo.sData=undo; |
|
| 3422 |
+ set(pre_h,'UserData',data); |
|
| 3423 |
+ old = gcf; |
|
| 3424 |
+ set(0,'CurrentFigure',pre_h); |
|
| 3425 |
+ sel_comp; |
|
| 3426 |
+ cplot_mimema; |
|
| 3427 |
+ set(0,'CurrentFigure',old); |
|
| 3428 |
+ end |
|
| 3429 |
+ case 'c_all' |
|
| 3430 |
+ MODE='2'; |
|
| 3431 |
+ if delay > 0 |
|
| 3432 |
+ sData.data(delay+1:len,n_th_comp)=sData.data(1:len-delay,n_th_comp); |
|
| 3433 |
+ if delay >= len |
|
| 3434 |
+ errordlg(q,t); |
|
| 3435 |
+ return; |
|
| 3436 |
+ else |
|
| 3437 |
+ sData.data=sData.data(delay+1:len,:); |
|
| 3438 |
+ end |
|
| 3439 |
+ elseif delay < 0 |
|
| 3440 |
+ sData.data(1:len+delay,n_th_comp)=sData.data(abs(delay)+1:len,n_th_comp); |
|
| 3441 |
+ if abs(delay) >= len |
|
| 3442 |
+ errordlg(q,t); |
|
| 3443 |
+ return; |
|
| 3444 |
+ else |
|
| 3445 |
+ sData.data=sData.data(1:len+delay,:); |
|
| 3446 |
+ end |
|
| 3447 |
+ end |
|
| 3448 |
+ if delay ~= 0 |
|
| 3449 |
+ data=get(pre_h,'UserData'); |
|
| 3450 |
+ sData.MODIFIED=1; |
|
| 3451 |
+ sData.comp_norm(:,:)={[]};
|
|
| 3452 |
+ data.sData=sData; |
|
| 3453 |
+ data.undo.sData=undo; |
|
| 3454 |
+ data.undo.selected=data.selected_vects; |
|
| 3455 |
+ if delay > 0 |
|
| 3456 |
+ data.selected_vects=... |
|
| 3457 |
+ data.selected_vects(find(data.selected_vects>delay)); |
|
| 3458 |
+ data.selected_vects=data.selected_vects-delay; |
|
| 3459 |
+ elseif nargin == 1 |
|
| 3460 |
+ data.selected_vects=... |
|
| 3461 |
+ data.selected_vects(find(data.selected_vects<=len-abs(delay))); |
|
| 3462 |
+ end |
|
| 3463 |
+ set(pre_h,'UserData',data); |
|
| 3464 |
+ old=gcf; |
|
| 3465 |
+ set(0,'CurrentFigure',pre_h); |
|
| 3466 |
+ vects=zeros(1,length(sData.data(:,1))); |
|
| 3467 |
+ vects(data.selected_vects)=1; |
|
| 3468 |
+ write_sD_stats; |
|
| 3469 |
+ draw_vectors(vects,data.vector_h); |
|
| 3470 |
+ sel_comp; |
|
| 3471 |
+ cplot_mimema; |
|
| 3472 |
+ set(0,'CurrentFigure',old); |
|
| 3473 |
+ end |
|
| 3474 |
+ case 'e_all' |
|
| 3475 |
+ MODE='3'; |
|
| 3476 |
+ if delay > 0 |
|
| 3477 |
+ sData.data(len+1:len+delay,:)=NaN; |
|
| 3478 |
+ sData.data(1+delay:delay+len,n_th_comp)=sData.data(1:len,n_th_comp); |
|
| 3479 |
+ sData.data(1:delay,n_th_comp)=NaN; |
|
| 3480 |
+ elseif delay < 0 |
|
| 3481 |
+ delay=abs(delay); |
|
| 3482 |
+ sData.data(delay+1:len+delay,:)=sData.data; |
|
| 3483 |
+ sData.data(1:delay,:)=NaN; |
|
| 3484 |
+ sData.data(1:len,n_th_comp)=sData.data(delay+1:len+delay,n_th_comp); |
|
| 3485 |
+ sData.data(len+1:len+delay,n_th_comp)=NaN; |
|
| 3486 |
+ end |
|
| 3487 |
+ if delay ~= 0 |
|
| 3488 |
+ data=get(pre_h,'UserData'); |
|
| 3489 |
+ sData.MODIFIED=1; |
|
| 3490 |
+ sData.comp_norm(:,:)={[]};
|
|
| 3491 |
+ data.sData=sData; |
|
| 3492 |
+ data.undo.sData=undo; |
|
| 3493 |
+ data.undo.selected=data.selected_vects; |
|
| 3494 |
+ set(pre_h,'UserData',data); |
|
| 3495 |
+ old=gcf; |
|
| 3496 |
+ set(0,'CurrentFigure',pre_h); |
|
| 3497 |
+ write_sD_stats; |
|
| 3498 |
+ pro_tools('selall');
|
|
| 3499 |
+ set(0,'CurrentFigure',old); |
|
| 3500 |
+ end |
|
| 3501 |
+end |
|
| 3502 |
+ |
|
| 3503 |
+if ~LOG |
|
| 3504 |
+ data=get(pre_h,'UserData'); |
|
| 3505 |
+ data.LOG{length(data.LOG)+1}='% Delay a component.';
|
|
| 3506 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''delay_data'',''',...
|
|
| 3507 |
+ num2str(delay),' ',MODE,''');'); |
|
| 3508 |
+ set(pre_h,'UserData',data); |
|
| 3509 |
+end |
|
| 3510 |
+ |
|
| 3511 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3512 |
+ |
|
| 3513 |
+function window(varargin) |
|
| 3514 |
+ |
|
| 3515 |
+if nargin ~= 1 |
|
| 3516 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 3517 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 3518 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=...
|
|
| 3519 |
+ '% Starting the ''Windowed'' -window...'; |
|
| 3520 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}='preprocess(''window'',''foo'');';
|
|
| 3521 |
+ set(pre_h,'UserData',preh_udata); |
|
| 3522 |
+end |
|
| 3523 |
+ |
|
| 3524 |
+win_h=findobj(get(0,'Children'),'Tag','Window'); |
|
| 3525 |
+ |
|
| 3526 |
+if ~isempty(win_h) |
|
| 3527 |
+ figure(win_h); |
|
| 3528 |
+ return; |
|
| 3529 |
+end |
|
| 3530 |
+ |
|
| 3531 |
+h0 = figure('Color',[0.8 0.8 0.8], ...
|
|
| 3532 |
+ 'PaperPosition',[18 180 576 432], ... |
|
| 3533 |
+ 'PaperUnits','points', ... |
|
| 3534 |
+ 'Position',[513 703 288 219], ... |
|
| 3535 |
+ 'Tag','Window'); |
|
| 3536 |
+ |
|
| 3537 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3538 |
+ 'Units','normalized', ... |
|
| 3539 |
+ 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... |
|
| 3540 |
+ 'ListboxTop',0, ... |
|
| 3541 |
+ 'Position',[0.03125 0.1552511415525114 0.9375 0.7990867579908676], ... |
|
| 3542 |
+ 'Style','frame', ... |
|
| 3543 |
+ 'Tag','Frame1'); |
|
| 3544 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3545 |
+ 'Units','normalized', ... |
|
| 3546 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3547 |
+ 'ListboxTop',0, ... |
|
| 3548 |
+ 'Position',[0.04861111111111111 0.7214611872146118 0.9027777777777777 0.2009132420091324], ... |
|
| 3549 |
+ 'Style','frame', ... |
|
| 3550 |
+ 'Tag','Frame2'); |
|
| 3551 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3552 |
+ 'Units','normalized', ... |
|
| 3553 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3554 |
+ 'ListboxTop',0, ... |
|
| 3555 |
+ 'Position',[0.04861111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... |
|
| 3556 |
+ 'Style','frame', ... |
|
| 3557 |
+ 'Tag','Frame3'); |
|
| 3558 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3559 |
+ 'Units','normalized', ... |
|
| 3560 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3561 |
+ 'ListboxTop',0, ... |
|
| 3562 |
+ 'Position',[0.3611111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... |
|
| 3563 |
+ 'Style','frame', ... |
|
| 3564 |
+ 'Tag','Frame4'); |
|
| 3565 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3566 |
+ 'Units','normalized', ... |
|
| 3567 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3568 |
+ 'ListboxTop',0, ... |
|
| 3569 |
+ 'Position',[0.6736111111111111 0.1780821917808219 0.2777777777777778 0.5251141552511416], ... |
|
| 3570 |
+ 'Style','frame', ... |
|
| 3571 |
+ 'Tag','Frame5'); |
|
| 3572 |
+ |
|
| 3573 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3574 |
+ 'Callback','preprocess eval_windowed',... |
|
| 3575 |
+ 'Units','normalized', ... |
|
| 3576 |
+ 'FontWeight','demi', ... |
|
| 3577 |
+ 'ListboxTop',0, ... |
|
| 3578 |
+ 'Position',[0.03125 0.0319634703196347 0.2256944444444444 0.091324200913242], ... |
|
| 3579 |
+ 'String','OK', ... |
|
| 3580 |
+ 'Tag','Pushbutton1'); |
|
| 3581 |
+ |
|
| 3582 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3583 |
+ 'Callback','preprocess close_w', ... |
|
| 3584 |
+ 'Units','normalized', ... |
|
| 3585 |
+ 'FontWeight','demi', ... |
|
| 3586 |
+ 'ListboxTop',0, ... |
|
| 3587 |
+ 'Position',[0.7430555555555555 0.0319634703196347 0.2256944444444444 0.091324200913242], ... |
|
| 3588 |
+ 'String','Close', ... |
|
| 3589 |
+ 'Tag','Pushbutton2'); |
|
| 3590 |
+ |
|
| 3591 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3592 |
+ 'Units','normalized', ... |
|
| 3593 |
+ 'BackgroundColor',[1 1 1], ... |
|
| 3594 |
+ 'ListboxTop',0, ... |
|
| 3595 |
+ 'Position',[0.7083333333333333 0.7625570776255708 0.2083333333333333 0.1232876712328767], ... |
|
| 3596 |
+ 'Style','edit', ... |
|
| 3597 |
+ 'Tag','EditText1'); |
|
| 3598 |
+ |
|
| 3599 |
+data.win_len_h=h1; |
|
| 3600 |
+ |
|
| 3601 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3602 |
+ 'Units','normalized', ... |
|
| 3603 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3604 |
+ 'FontWeight','demi', ... |
|
| 3605 |
+ 'HorizontalAlignment','left', ... |
|
| 3606 |
+ 'ListboxTop',0, ... |
|
| 3607 |
+ 'Position',[0.07638888888888888 0.8036529680365296 0.3784722222222222 0.0547945205479452], ... |
|
| 3608 |
+ 'String','Window length', ... |
|
| 3609 |
+ 'Style','text', ... |
|
| 3610 |
+ 'Tag','StaticText1'); |
|
| 3611 |
+ |
|
| 3612 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3613 |
+ 'Units','normalized', ... |
|
| 3614 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3615 |
+ 'Callback','preprocess window_cb centered',... |
|
| 3616 |
+ 'ListboxTop',0, ... |
|
| 3617 |
+ 'Position',[0.06597222222222222 0.5616438356164384 0.06597222222222222 0.0821917808219178], ... |
|
| 3618 |
+ 'Style','radiobutton', ... |
|
| 3619 |
+ 'Tag','Radiobutton1'); |
|
| 3620 |
+ |
|
| 3621 |
+data.centered_h=h1; |
|
| 3622 |
+data.position='center'; |
|
| 3623 |
+ |
|
| 3624 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3625 |
+ 'Units','normalized', ... |
|
| 3626 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3627 |
+ 'Callback','preprocess window_cb previous',... |
|
| 3628 |
+ 'ListboxTop',0, ... |
|
| 3629 |
+ 'Position',[0.06597222222222222 0.4018264840182648 0.06597222222222222 0.0821917808219178], ... |
|
| 3630 |
+ 'Style','radiobutton', ... |
|
| 3631 |
+ 'Tag','Radiobutton2'); |
|
| 3632 |
+ |
|
| 3633 |
+data.previous_h=h1; |
|
| 3634 |
+ |
|
| 3635 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3636 |
+ 'Units','normalized', ... |
|
| 3637 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3638 |
+ 'Callback','preprocess window_cb next',... |
|
| 3639 |
+ 'ListboxTop',0, ... |
|
| 3640 |
+ 'Position',[0.06597222222222222 0.2465753424657534 0.06597222222222222 0.0821917808219178], ... |
|
| 3641 |
+ 'Style','radiobutton', ... |
|
| 3642 |
+ 'Tag','Radiobutton3'); |
|
| 3643 |
+ |
|
| 3644 |
+data.next_h=h1; |
|
| 3645 |
+ |
|
| 3646 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3647 |
+ 'Units','normalized', ... |
|
| 3648 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3649 |
+ 'Callback','preprocess window_cb mean',... |
|
| 3650 |
+ 'ListboxTop',0, ... |
|
| 3651 |
+ 'Position',[0.3784722222222222 0.5799086757990868 0.06597222222222222 0.0821917808219178], ... |
|
| 3652 |
+ 'Style','radiobutton', ... |
|
| 3653 |
+ 'Tag','Radiobutton4'); |
|
| 3654 |
+ |
|
| 3655 |
+data.mean_h=h1; |
|
| 3656 |
+data.mode='mean'; |
|
| 3657 |
+ |
|
| 3658 |
+ |
|
| 3659 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3660 |
+ 'Units','normalized', ... |
|
| 3661 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3662 |
+ 'Callback','preprocess window_cb median',... |
|
| 3663 |
+ 'ListboxTop',0, ... |
|
| 3664 |
+ 'Position',[0.3784722222222222 0.4611872146118721 0.06597222222222222 0.0821917808219178], ... |
|
| 3665 |
+ 'Style','radiobutton', ... |
|
| 3666 |
+ 'Tag','Radiobutton5'); |
|
| 3667 |
+ |
|
| 3668 |
+ |
|
| 3669 |
+data.median_h=h1; |
|
| 3670 |
+ |
|
| 3671 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3672 |
+ 'Units','normalized', ... |
|
| 3673 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3674 |
+ 'Callback','preprocess window_cb max',... |
|
| 3675 |
+ 'ListboxTop',0, ... |
|
| 3676 |
+ 'Position',[0.3784722222222222 0.3515981735159817 0.06597222222222222 0.0821917808219178], ... |
|
| 3677 |
+ 'Style','radiobutton', ... |
|
| 3678 |
+ 'Tag','Radiobutton6'); |
|
| 3679 |
+ |
|
| 3680 |
+data.max_h=h1; |
|
| 3681 |
+ |
|
| 3682 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3683 |
+ 'Units','normalized', ... |
|
| 3684 |
+ 'Callback','preprocess window_cb min',... |
|
| 3685 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3686 |
+ 'ListboxTop',0, ... |
|
| 3687 |
+ 'Position',[0.3784722222222222 0.2374429223744292 0.06597222222222222 0.0821917808219178], ... |
|
| 3688 |
+ 'Style','radiobutton', ... |
|
| 3689 |
+ 'Tag','Radiobutton7'); |
|
| 3690 |
+ |
|
| 3691 |
+data.min_h = h1; |
|
| 3692 |
+ |
|
| 3693 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3694 |
+ 'Units','normalized', ... |
|
| 3695 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3696 |
+ 'Callback','preprocess window_cb clip',... |
|
| 3697 |
+ 'ListboxTop',0, ... |
|
| 3698 |
+ 'Position',[0.6909722222222222 0.5525114155251141 0.06597222222222222 0.0821917808219178], ... |
|
| 3699 |
+ 'Style','radiobutton', ... |
|
| 3700 |
+ 'Tag','Radiobutton8'); |
|
| 3701 |
+ |
|
| 3702 |
+data.clip_h=h1; |
|
| 3703 |
+data.eval_mode='clip'; |
|
| 3704 |
+ |
|
| 3705 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3706 |
+ 'Units','normalized', ... |
|
| 3707 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3708 |
+ 'Callback','preprocess window_cb expand',... |
|
| 3709 |
+ 'ListboxTop',0, ... |
|
| 3710 |
+ 'Position',[0.6909722222222222 0.2922374429223744 0.06597222222222222 0.0821917808219178], ... |
|
| 3711 |
+ 'Style','radiobutton', ... |
|
| 3712 |
+ 'Tag','Radiobutton9'); |
|
| 3713 |
+ |
|
| 3714 |
+data.expand_h=h1; |
|
| 3715 |
+ |
|
| 3716 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3717 |
+ 'Units','normalized', ... |
|
| 3718 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3719 |
+ 'FontWeight','demi', ... |
|
| 3720 |
+ 'FontSize',8,... |
|
| 3721 |
+ 'HorizontalAlignment','left', ... |
|
| 3722 |
+ 'ListboxTop',0, ... |
|
| 3723 |
+ 'Position',[0.132 0.5799 0.19 0.0548], ... |
|
| 3724 |
+ 'String','Centered', ... |
|
| 3725 |
+ 'Style','text', ... |
|
| 3726 |
+ 'Tag','StaticText2'); |
|
| 3727 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3728 |
+ 'Units','normalized', ... |
|
| 3729 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3730 |
+ 'FontWeight','demi', ... |
|
| 3731 |
+ 'FontSize',8,... |
|
| 3732 |
+ 'HorizontalAlignment','left', ... |
|
| 3733 |
+ 'ListboxTop',0, ... |
|
| 3734 |
+ 'Position',[0.132 0.4247 0.1667 0.0548], ... |
|
| 3735 |
+ 'String','Previous', ... |
|
| 3736 |
+ 'Style','text', ... |
|
| 3737 |
+ 'Tag','StaticText3'); |
|
| 3738 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3739 |
+ 'Units','normalized', ... |
|
| 3740 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3741 |
+ 'FontWeight','demi', ... |
|
| 3742 |
+ 'FontSize',8,... |
|
| 3743 |
+ 'HorizontalAlignment','left', ... |
|
| 3744 |
+ 'ListboxTop',0, ... |
|
| 3745 |
+ 'Position',[0.132 0.2648 0.1632 0.0548], ... |
|
| 3746 |
+ 'String','Next', ... |
|
| 3747 |
+ 'Style','text', ... |
|
| 3748 |
+ 'Tag','StaticText4'); |
|
| 3749 |
+h1 = uicontrol('Parent',h0, ...,
|
|
| 3750 |
+ 'Units','normalized', ... |
|
| 3751 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3752 |
+ 'FontWeight','demi', ... |
|
| 3753 |
+ 'FontSize',8,... |
|
| 3754 |
+ 'HorizontalAlignment','left', ... |
|
| 3755 |
+ 'ListboxTop',0, ... |
|
| 3756 |
+ 'Position',[0.445 0.6027397260273972 0.19 0.0547945205479452], ... |
|
| 3757 |
+ 'String','Mean', ... |
|
| 3758 |
+ 'Style','text', ... |
|
| 3759 |
+ 'Tag','StaticText5'); |
|
| 3760 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3761 |
+ 'Units','normalized', ... |
|
| 3762 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3763 |
+ 'FontWeight','demi', ... |
|
| 3764 |
+ 'FontSize',8,... |
|
| 3765 |
+ 'HorizontalAlignment','left', ... |
|
| 3766 |
+ 'ListboxTop',0, ... |
|
| 3767 |
+ 'Position',[0.445 0.4795 0.1806 0.0548], ... |
|
| 3768 |
+ 'String','Median', ... |
|
| 3769 |
+ 'Style','text', ... |
|
| 3770 |
+ 'Tag','StaticText6'); |
|
| 3771 |
+ |
|
| 3772 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3773 |
+ 'Units','normalized', ... |
|
| 3774 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3775 |
+ 'FontWeight','demi', ... |
|
| 3776 |
+ 'FontSize',8,... |
|
| 3777 |
+ 'HorizontalAlignment','left', ... |
|
| 3778 |
+ 'ListboxTop',0, ... |
|
| 3779 |
+ 'Position',[0.445 0.3699 0.1667 0.0548], ... |
|
| 3780 |
+ 'String','Max', ... |
|
| 3781 |
+ 'Style','text', ... |
|
| 3782 |
+ 'Tag','StaticText7'); |
|
| 3783 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3784 |
+ 'Units','normalized', ... |
|
| 3785 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3786 |
+ 'FontWeight','demi', ... |
|
| 3787 |
+ 'FontSize',8,... |
|
| 3788 |
+ 'HorizontalAlignment','left', ... |
|
| 3789 |
+ 'ListboxTop',0, ... |
|
| 3790 |
+ 'Position',[0.445 0.2557077625570776 0.1597222222222222 0.0547945205479452], ... |
|
| 3791 |
+ 'String','Min', ... |
|
| 3792 |
+ 'Style','text', ... |
|
| 3793 |
+ 'Tag','StaticText8'); |
|
| 3794 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3795 |
+ 'Units','normalized', ... |
|
| 3796 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3797 |
+ 'FontWeight','demi', ... |
|
| 3798 |
+ 'FontSize',8,... |
|
| 3799 |
+ 'HorizontalAlignment','left', ... |
|
| 3800 |
+ 'ListboxTop',0, ... |
|
| 3801 |
+ 'Position',[0.7535 0.5753 0.1354 0.054], ... |
|
| 3802 |
+ 'String','Clip', ... |
|
| 3803 |
+ 'Style','text', ... |
|
| 3804 |
+ 'Tag','StaticText9'); |
|
| 3805 |
+h1 = uicontrol('Parent',h0, ...
|
|
| 3806 |
+ 'Units','normalized', ... |
|
| 3807 |
+ 'BackgroundColor',[0.8 0.8 0.8], ... |
|
| 3808 |
+ 'FontWeight','demi', ... |
|
| 3809 |
+ 'FontSize',8,... |
|
| 3810 |
+ 'HorizontalAlignment','left', ... |
|
| 3811 |
+ 'ListboxTop',0, ... |
|
| 3812 |
+ 'Position',[0.7534722222222222 0.3150684931506849 0.1527777777777778 0.0547945205479452], ... |
|
| 3813 |
+ 'String','Expand', ... |
|
| 3814 |
+ 'Style','text', ... |
|
| 3815 |
+ 'Tag','StaticText10'); |
|
| 3816 |
+ |
|
| 3817 |
+ |
|
| 3818 |
+ |
|
| 3819 |
+set(gcf,'UserData',data); |
|
| 3820 |
+ |
|
| 3821 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3822 |
+ |
|
| 3823 |
+function window_cb(arg) |
|
| 3824 |
+ |
|
| 3825 |
+data=get(gcf,'UserData'); |
|
| 3826 |
+ |
|
| 3827 |
+if any(strcmp(arg,[{'centered'},{'previous'},{'next'}]))
|
|
| 3828 |
+ switch arg |
|
| 3829 |
+ case 'centered' |
|
| 3830 |
+ data.position='center'; |
|
| 3831 |
+ set(data.previous_h,'Value',0); |
|
| 3832 |
+ set(data.next_h,'Value',0); |
|
| 3833 |
+ set(data.centered_h,'Value',1); |
|
| 3834 |
+ case 'previous' |
|
| 3835 |
+ data.position='previous'; |
|
| 3836 |
+ set(data.centered_h,'Value',0); |
|
| 3837 |
+ set(data.next_h,'Value',0); |
|
| 3838 |
+ set(data.previous_h,'Value',1); |
|
| 3839 |
+ case 'next' |
|
| 3840 |
+ data.position='next'; |
|
| 3841 |
+ set(data.centered_h,'Value',0); |
|
| 3842 |
+ set(data.previous_h,'Value',0); |
|
| 3843 |
+ set(data.next_h,'Value',1); |
|
| 3844 |
+ end |
|
| 3845 |
+elseif any(strcmp(arg,[{'mean'},{'median'},{'min'},{'max'}]))
|
|
| 3846 |
+ switch arg |
|
| 3847 |
+ case 'mean' |
|
| 3848 |
+ data.mode='mean'; |
|
| 3849 |
+ set(data.median_h,'Value',0); |
|
| 3850 |
+ set(data.min_h,'Value',0); |
|
| 3851 |
+ set(data.max_h,'Value',0); |
|
| 3852 |
+ set(data.mean_h,'Value',1); |
|
| 3853 |
+ case 'median' |
|
| 3854 |
+ data.mode='median'; |
|
| 3855 |
+ set(data.mean_h,'Value',0); |
|
| 3856 |
+ set(data.max_h,'Value',0); |
|
| 3857 |
+ set(data.min_h,'Value',0); |
|
| 3858 |
+ set(data.median_h,'Value',1); |
|
| 3859 |
+ case 'max' |
|
| 3860 |
+ data.mode='max'; |
|
| 3861 |
+ set(data.mean_h,'Value',0); |
|
| 3862 |
+ set(data.median_h,'Value',0); |
|
| 3863 |
+ set(data.min_h,'Value',0); |
|
| 3864 |
+ set(data.max_h,'Value',1); |
|
| 3865 |
+ case 'min' |
|
| 3866 |
+ data.mode='min'; |
|
| 3867 |
+ set(data.mean_h,'Value',0); |
|
| 3868 |
+ set(data.median_h,'Value',0); |
|
| 3869 |
+ set(data.max_h,'Value',0); |
|
| 3870 |
+ set(data.min_h,'Value',1); |
|
| 3871 |
+ end |
|
| 3872 |
+elseif any(strcmp(arg,[{'clip','expand'}]))
|
|
| 3873 |
+ switch arg |
|
| 3874 |
+ case 'clip' |
|
| 3875 |
+ data.eval_mode='clip'; |
|
| 3876 |
+ set(data.expand_h,'Value',0); |
|
| 3877 |
+ set(data.clip_h,'Value',1); |
|
| 3878 |
+ case 'expand' |
|
| 3879 |
+ data.eval_mode='expand'; |
|
| 3880 |
+ set(data.clip_h,'Value',0); |
|
| 3881 |
+ set(data.expand_h,'Value',1); |
|
| 3882 |
+ end |
|
| 3883 |
+end |
|
| 3884 |
+ |
|
| 3885 |
+set(gcf,'UserData',data); |
|
| 3886 |
+ |
|
| 3887 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 3888 |
+ |
|
| 3889 |
+function eval_windowed(varargin) |
|
| 3890 |
+ |
|
| 3891 |
+if nargin == 1 |
|
| 3892 |
+ LOG=1; |
|
| 3893 |
+ i=1; |
|
| 3894 |
+ arg=varargin{1};
|
|
| 3895 |
+ while i <= length(arg) & arg(i) ~= ' ' |
|
| 3896 |
+ i=i+1; |
|
| 3897 |
+ end |
|
| 3898 |
+ value=str2num(arg(1:i-1)); |
|
| 3899 |
+ i=i+1; |
|
| 3900 |
+ j=i; |
|
| 3901 |
+ while i <= length(arg) & arg(i) ~= ' ' |
|
| 3902 |
+ i=i+1; |
|
| 3903 |
+ end |
|
| 3904 |
+ position=arg(j:i-1); |
|
| 3905 |
+ i=i+1; |
|
| 3906 |
+ j=i; |
|
| 3907 |
+ while i <= length(arg) & arg(i) ~= ' ' |
|
| 3908 |
+ i=i+1; |
|
| 3909 |
+ end |
|
| 3910 |
+ mode=arg(j:i-1); |
|
| 3911 |
+ i=i+1; |
|
| 3912 |
+ j=i; |
|
| 3913 |
+ while i <= length(arg) & arg(i) ~= ' ' |
|
| 3914 |
+ i=i+1; |
|
| 3915 |
+ end |
|
| 3916 |
+ eval_mode=arg(j:i-1); |
|
| 3917 |
+else |
|
| 3918 |
+ LOG=0; |
|
| 3919 |
+end |
|
| 3920 |
+ |
|
| 3921 |
+data=get(gcf,'UserData'); |
|
| 3922 |
+if LOG |
|
| 3923 |
+ data.position=position; |
|
| 3924 |
+ data.eval_mode=eval_mode; |
|
| 3925 |
+ data.mode=mode; |
|
| 3926 |
+end |
|
| 3927 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 3928 |
+ |
|
| 3929 |
+if isempty(pre_h) |
|
| 3930 |
+ errordlg('''Preprocess''-window does not exist. Terminating program...');
|
|
| 3931 |
+ pro_tools('close');
|
|
| 3932 |
+ return; |
|
| 3933 |
+end |
|
| 3934 |
+ |
|
| 3935 |
+comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 3936 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 3937 |
+undo=sData; |
|
| 3938 |
+ |
|
| 3939 |
+if isempty(get(comp_names_h,'Value')) |
|
| 3940 |
+ errordlg('There are not components chosen.');
|
|
| 3941 |
+ return; |
|
| 3942 |
+end |
|
| 3943 |
+ |
|
| 3944 |
+if ~LOG |
|
| 3945 |
+ if isempty(get(data.win_len_h,'String')) |
|
| 3946 |
+ errordlg('Window length must be defined');
|
|
| 3947 |
+ return; |
|
| 3948 |
+ end |
|
| 3949 |
+ |
|
| 3950 |
+ value=str2num(get(data.win_len_h,'String')); |
|
| 3951 |
+end |
|
| 3952 |
+ |
|
| 3953 |
+set(data.win_len_h,'String',''); |
|
| 3954 |
+ |
|
| 3955 |
+if ~LOG |
|
| 3956 |
+ if isempty(value) | value < 0 | value ~= round(value) |
|
| 3957 |
+ errordlg('Window length must be positive integer.');
|
|
| 3958 |
+ return; |
|
| 3959 |
+ end |
|
| 3960 |
+ |
|
| 3961 |
+ if value > length(sData.data(:,1)) |
|
| 3962 |
+ errordlg('Length of window is too big.');
|
|
| 3963 |
+ return; |
|
| 3964 |
+ end |
|
| 3965 |
+end |
|
| 3966 |
+ |
|
| 3967 |
+index=getfield(get_indices,{1});
|
|
| 3968 |
+ |
|
| 3969 |
+sData=eval_operation(sData,value,data.mode,data.eval_mode,data.position,index); |
|
| 3970 |
+sData.comp_norm(index)={[]};
|
|
| 3971 |
+u_data=get(pre_h,'UserData'); |
|
| 3972 |
+u_data.sData=sData; |
|
| 3973 |
+u_data.undo.sData=undo; |
|
| 3974 |
+u_data.undo.selected=u_data.selected_vects; |
|
| 3975 |
+ |
|
| 3976 |
+if ~LOG |
|
| 3977 |
+ u_data.LOG{length(u_data.LOG)+1}=...
|
|
| 3978 |
+ '% Evaluating the wanted ''windowed'' -operation.'; |
|
| 3979 |
+ u_data.LOG{length(u_data.LOG)+1}=cat(2,'preprocess(''eval_windowed'',',...
|
|
| 3980 |
+ '''',num2str(value),... |
|
| 3981 |
+ ' ',data.position,' ',data.mode,... |
|
| 3982 |
+ ' ',data.eval_mode,''');'); |
|
| 3983 |
+end |
|
| 3984 |
+ |
|
| 3985 |
+set(pre_h,'UserData',u_data); |
|
| 3986 |
+old=gcf; |
|
| 3987 |
+set(0,'CurrentFigure',pre_h); |
|
| 3988 |
+ |
|
| 3989 |
+if strcmp(data.eval_mode,'expand'); |
|
| 3990 |
+ write_sD_stats; |
|
| 3991 |
+ pro_tools('selall');
|
|
| 3992 |
+else |
|
| 3993 |
+ sel_comp; |
|
| 3994 |
+ cplot_mimema; |
|
| 3995 |
+end |
|
| 3996 |
+ |
|
| 3997 |
+set(0,'CurrentFigure',old); |
|
| 3998 |
+ |
|
| 3999 |
+ |
|
| 4000 |
+ |
|
| 4001 |
+%%% Subfunction: eval_operation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4002 |
+ |
|
| 4003 |
+ |
|
| 4004 |
+function sData=eval_operation(sData,winlen,mode,evalmode,position,n) |
|
| 4005 |
+ |
|
| 4006 |
+ |
|
| 4007 |
+len=length(sData.data(:,1)); |
|
| 4008 |
+dim=length(sData.data(1,:)); |
|
| 4009 |
+ |
|
| 4010 |
+switch(position) |
|
| 4011 |
+ case 'center' |
|
| 4012 |
+ prev=round(winlen/2)-1; |
|
| 4013 |
+ next=winlen-round(winlen/2); |
|
| 4014 |
+ case 'previous' |
|
| 4015 |
+ prev=winlen-1; |
|
| 4016 |
+ next=0; |
|
| 4017 |
+ case 'next' |
|
| 4018 |
+ prev=0; |
|
| 4019 |
+ next=winlen-1; |
|
| 4020 |
+end |
|
| 4021 |
+ |
|
| 4022 |
+switch(evalmode) |
|
| 4023 |
+ case 'clip' |
|
| 4024 |
+ for center=1:len |
|
| 4025 |
+ win=center-prev:center-prev+winlen-1; |
|
| 4026 |
+ win=win(find(win > 0 & win <= len)); |
|
| 4027 |
+ str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))'); |
|
| 4028 |
+ tmp(center)=eval(str); |
|
| 4029 |
+ end |
|
| 4030 |
+ sData.data(:,n)=tmp; |
|
| 4031 |
+ case 'expand' |
|
| 4032 |
+ for i=1:len+winlen-1 |
|
| 4033 |
+ win=i-(winlen-1):i; |
|
| 4034 |
+ win=win(find(win > 0 & win <= len)); |
|
| 4035 |
+ str=cat(2,mode,'(sData.data(win(find(~isnan(sData.data(win,n)))),n))'); |
|
| 4036 |
+ tmp(i)=eval(str); |
|
| 4037 |
+ end |
|
| 4038 |
+ sData.data=cat(1,repmat(NaN,next,dim),sData.data,repmat(NaN,prev,dim)); |
|
| 4039 |
+ sData.data(:,n)=tmp; |
|
| 4040 |
+end |
|
| 4041 |
+ |
|
| 4042 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4043 |
+ |
|
| 4044 |
+ |
|
| 4045 |
+ |
|
| 4046 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4047 |
+ |
|
| 4048 |
+function pro_tools(arg) |
|
| 4049 |
+ |
|
| 4050 |
+switch arg |
|
| 4051 |
+ case 'close' |
|
| 4052 |
+ close_preprocess; |
|
| 4053 |
+ case 'c_stat' |
|
| 4054 |
+ write_c_stats; |
|
| 4055 |
+ case 'plot_hist' |
|
| 4056 |
+ plot_hist; |
|
| 4057 |
+ case 'plot' |
|
| 4058 |
+ plot_button; |
|
| 4059 |
+ case 'plxy' |
|
| 4060 |
+ plxy_button; |
|
| 4061 |
+ case 'bplo' |
|
| 4062 |
+ bplo_button; |
|
| 4063 |
+ case 'hist' |
|
| 4064 |
+ hist_button; |
|
| 4065 |
+end |
|
| 4066 |
+ |
|
| 4067 |
+ |
|
| 4068 |
+%%% Subfunction close_preprocess %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4069 |
+ |
|
| 4070 |
+function close_preprocess |
|
| 4071 |
+ |
|
| 4072 |
+ |
|
| 4073 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4074 |
+man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 4075 |
+clip_h=findobj(get(0,'Children'),'Tag','Clipping'); |
|
| 4076 |
+plot_h=findobj(get(0,'Children'),'Tag','PlotWin'); |
|
| 4077 |
+delay_h=findobj(get(0,'Children'),'Tag','Delay'); |
|
| 4078 |
+window_h=findobj(get(0,'Children'),'Tag','Window'); |
|
| 4079 |
+sel_h=findobj(get(0,'Children'),'Tag','Select'); |
|
| 4080 |
+ |
|
| 4081 |
+if ~isempty(man_h) |
|
| 4082 |
+ close(man_h); |
|
| 4083 |
+end |
|
| 4084 |
+if ~isempty(clip_h) |
|
| 4085 |
+ close(clip_h); |
|
| 4086 |
+end |
|
| 4087 |
+if ~isempty(plot_h) |
|
| 4088 |
+ close(plot_h); |
|
| 4089 |
+end |
|
| 4090 |
+if ~isempty(delay_h) |
|
| 4091 |
+ close(delay_h); |
|
| 4092 |
+end |
|
| 4093 |
+if ~isempty(window_h) |
|
| 4094 |
+ close(window_h); |
|
| 4095 |
+end |
|
| 4096 |
+if ~isempty(sel_h) |
|
| 4097 |
+ close(sel_h); |
|
| 4098 |
+end |
|
| 4099 |
+if ~isempty(pre_h) |
|
| 4100 |
+ close(pre_h); |
|
| 4101 |
+end |
|
| 4102 |
+ |
|
| 4103 |
+ |
|
| 4104 |
+ |
|
| 4105 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4106 |
+ |
|
| 4107 |
+%%% Subfunction: undo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4108 |
+ |
|
| 4109 |
+function undo(varargin) |
|
| 4110 |
+ |
|
| 4111 |
+if nargin == 1 |
|
| 4112 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4113 |
+ set(0,'CurrentFigure',pre_h); |
|
| 4114 |
+ LOG=1; |
|
| 4115 |
+else |
|
| 4116 |
+ LOG=0; |
|
| 4117 |
+end |
|
| 4118 |
+ |
|
| 4119 |
+data=get(gcf,'UserData'); |
|
| 4120 |
+if ~isempty(data.undo) |
|
| 4121 |
+ if any(strcmp('selected',fieldnames(data.undo)))
|
|
| 4122 |
+ data.selected_vects=data.undo.selected; |
|
| 4123 |
+ end |
|
| 4124 |
+ if ~any(strcmp('index',fieldnames(data.undo)))
|
|
| 4125 |
+ data.sData=data.undo.sData; |
|
| 4126 |
+ data.undo=[]; |
|
| 4127 |
+ if ~LOG |
|
| 4128 |
+ data.LOG{length(data.LOG)+1}='% Undo the most recent operation.';
|
|
| 4129 |
+ data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');';
|
|
| 4130 |
+ end |
|
| 4131 |
+ set(gcf,'UserData',data); |
|
| 4132 |
+ set_compnames(data.sData,data.comp_names_h); |
|
| 4133 |
+ write_sD_stats; |
|
| 4134 |
+ vect_means(data.sData,data.vect_mean_h,data.selected_vects); |
|
| 4135 |
+ sel_comp; |
|
| 4136 |
+ cplot_mimema; |
|
| 4137 |
+ return; |
|
| 4138 |
+ end |
|
| 4139 |
+ |
|
| 4140 |
+ % 'undo.sData' does not exist in sD_set - array |
|
| 4141 |
+ |
|
| 4142 |
+ index=data.undo.index; |
|
| 4143 |
+ data.undo.sData=rmfield(data.undo.sData,[{'INDEX'};{'MODIFIED'}]);
|
|
| 4144 |
+ if index<=length(data.sD_set) |
|
| 4145 |
+ rest=data.sD_set(index:length(data.sD_set)); |
|
| 4146 |
+ else |
|
| 4147 |
+ rest=[]; |
|
| 4148 |
+ end |
|
| 4149 |
+ data.sD_set=cat(2,data.sD_set(1:index-1),data.undo.sData,rest); |
|
| 4150 |
+ data.undo=[]; |
|
| 4151 |
+ if ~LOG |
|
| 4152 |
+ data.LOG{length(data.LOG)+1}='% Undo the most recent operation.';
|
|
| 4153 |
+ data.LOG{length(data.LOG)+1}='preprocess(''undo'',''foo'');';
|
|
| 4154 |
+ end |
|
| 4155 |
+ set(gcf,'UserData',data); |
|
| 4156 |
+ set(getfield(get(gcf,'UserData'),'sD_set_h'),'Value',index); |
|
| 4157 |
+ set_sD_stats; |
|
| 4158 |
+ sel_sD; |
|
| 4159 |
+else |
|
| 4160 |
+ msgbox('Can''t do...');
|
|
| 4161 |
+end |
|
| 4162 |
+ |
|
| 4163 |
+%%% Subfunction: write_c_stats %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4164 |
+ |
|
| 4165 |
+function write_c_stats(varargin) |
|
| 4166 |
+ |
|
| 4167 |
+ |
|
| 4168 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4169 |
+comp_names_h=getfield(get(pre_h,'UserData'),'comp_names_h'); |
|
| 4170 |
+sel_comp_h=getfield(get(pre_h,'UserData'),'sel_comp_h'); |
|
| 4171 |
+sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h'); |
|
| 4172 |
+ |
|
| 4173 |
+if nargin==1 |
|
| 4174 |
+ val1=varargin(1); |
|
| 4175 |
+else |
|
| 4176 |
+ val1=get(sel_comp_h,'String'); |
|
| 4177 |
+end |
|
| 4178 |
+ |
|
| 4179 |
+if ~isempty(val1) & iscell(val1) |
|
| 4180 |
+ selected_vects=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 4181 |
+ sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 4182 |
+ sel_cdata_h=getfield(get(pre_h,'UserData'),'sel_cdata_h'); |
|
| 4183 |
+ name=getfield(get(sel_comp_h,'String'),{get(sel_comp_h,'Value')});
|
|
| 4184 |
+ name=name{1};
|
|
| 4185 |
+ i=2; |
|
| 4186 |
+ |
|
| 4187 |
+ while ~isempty(str2num(name(i))) |
|
| 4188 |
+ value(i-1)=name(i); |
|
| 4189 |
+ i=i+1; |
|
| 4190 |
+ end |
|
| 4191 |
+ |
|
| 4192 |
+ value=str2num(value); |
|
| 4193 |
+ |
|
| 4194 |
+ |
|
| 4195 |
+ data=sData.data(selected_vects,value); |
|
| 4196 |
+ |
|
| 4197 |
+ string{1} = cat(2,'Min: ',sprintf('%-10.3g',min(data)));
|
|
| 4198 |
+ string{2} = cat(2,'Mean: ',sprintf('%-10.3g',mean(data(find(~isnan(data))))));
|
|
| 4199 |
+ string{3} = cat(2,'Max: ',sprintf('%-10.3g',max(data)));
|
|
| 4200 |
+ string{4} = cat(2,'Std: ',sprintf('%-10.3g',std(data(find(~isnan(data))))));
|
|
| 4201 |
+ string{5} = cat(2,'Number of NaNs: ',sprintf('%-10.3g',sum(isnan(data))));
|
|
| 4202 |
+ string{6} = cat(2,'NaN (%):',...
|
|
| 4203 |
+ sprintf('%-10.3g',100*sum(isnan(data))/length(data)));
|
|
| 4204 |
+ string{7} = cat(2,'Number of values: ',sprintf('%-10.3g',...
|
|
| 4205 |
+ length(find(~isnan(unique(data)))))); |
|
| 4206 |
+ set(sel_cdata_h,'String',string); |
|
| 4207 |
+ set(sel_cdata_h,'HorizontalAlignment','left'); |
|
| 4208 |
+end |
|
| 4209 |
+ |
|
| 4210 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4211 |
+ |
|
| 4212 |
+%%% Subfunction plot_hist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4213 |
+ |
|
| 4214 |
+function plot_hist |
|
| 4215 |
+ |
|
| 4216 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4217 |
+sel_chist_h=getfield(get(pre_h,'UserData'),'sel_chist_h'); |
|
| 4218 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 4219 |
+selected=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 4220 |
+ |
|
| 4221 |
+value=get(getfield(get(pre_h,'UserData'),'sel_comp_h'),'Value'); |
|
| 4222 |
+subplot(sel_chist_h); |
|
| 4223 |
+hold off; |
|
| 4224 |
+cla; |
|
| 4225 |
+if all(isnan(sData.data(:,value))); |
|
| 4226 |
+ return; |
|
| 4227 |
+end |
|
| 4228 |
+hold on; |
|
| 4229 |
+lim1=min(sData.data(:,value)); |
|
| 4230 |
+lim2=max(sData.data(:,value)); |
|
| 4231 |
+if lim2 - lim1 >= eps |
|
| 4232 |
+ x=lim1:(lim2-lim1)/(30-1):lim2; |
|
| 4233 |
+ set(sel_chist_h,'XLim',[lim1 lim2]); |
|
| 4234 |
+elseif lim1 ~= 0 |
|
| 4235 |
+ x=(lim1)/2:lim1/(30-1):lim1+(lim1)/2; |
|
| 4236 |
+ set(sel_chist_h,'Xlim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]); |
|
| 4237 |
+else |
|
| 4238 |
+ x=-1:2/(30-1):1; |
|
| 4239 |
+ set(sel_chist_h,'XLim',[-1 1]); |
|
| 4240 |
+end |
|
| 4241 |
+ |
|
| 4242 |
+hist(sData.data(selected,value),x); |
|
| 4243 |
+ |
|
| 4244 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4245 |
+ |
|
| 4246 |
+%%% Subfunction: select_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4247 |
+ |
|
| 4248 |
+function select_all(varargin) |
|
| 4249 |
+ |
|
| 4250 |
+if nargin == 1 |
|
| 4251 |
+ LOG=1; |
|
| 4252 |
+else |
|
| 4253 |
+ LOG=0; |
|
| 4254 |
+end |
|
| 4255 |
+ |
|
| 4256 |
+data=get(gcf,'UserData'); |
|
| 4257 |
+data.selected_vects=(1:length(data.sData.data(:,1))); |
|
| 4258 |
+if ~LOG |
|
| 4259 |
+ data.LOG{length(data.LOG)+1}='% Select all vectors.';
|
|
| 4260 |
+ data.LOG{length(data.LOG)+1}='selall(''foo'');';
|
|
| 4261 |
+end |
|
| 4262 |
+set(gcf,'UserData',data); |
|
| 4263 |
+tmp=zeros(1,length(data.sData.data(:,1))); |
|
| 4264 |
+tmp(data.selected_vects)=1; |
|
| 4265 |
+draw_vectors(tmp,data.vector_h); |
|
| 4266 |
+cplot_mimema; |
|
| 4267 |
+vect_means(data.sData,data.vect_mean_h,data.selected_vects); |
|
| 4268 |
+sel_comp; |
|
| 4269 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4270 |
+ |
|
| 4271 |
+%%% Subfunction: plot_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4272 |
+ |
|
| 4273 |
+function plot_button |
|
| 4274 |
+ |
|
| 4275 |
+%PLOT_BUTTON A callback function. Plots all the components and marks |
|
| 4276 |
+% the chosen components. |
|
| 4277 |
+% |
|
| 4278 |
+% |
|
| 4279 |
+ |
|
| 4280 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 4281 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 4282 |
+ |
|
| 4283 |
+indices=get_indices; |
|
| 4284 |
+if isempty(indices) |
|
| 4285 |
+ return; |
|
| 4286 |
+end |
|
| 4287 |
+h=findobj(get(0,'Children'),'Tag','PlotWin'); |
|
| 4288 |
+if isempty(h) |
|
| 4289 |
+ h= figure; |
|
| 4290 |
+ set(h,'Tag','PlotWin'); |
|
| 4291 |
+end |
|
| 4292 |
+ |
|
| 4293 |
+names=sData.comp_names(indices); |
|
| 4294 |
+data=sData.data(:,indices); |
|
| 4295 |
+ |
|
| 4296 |
+set(0,'CurrentFigure',h); |
|
| 4297 |
+hold off; |
|
| 4298 |
+clf; |
|
| 4299 |
+t=0:1/(getfield(size(data),{1})-1):1;
|
|
| 4300 |
+tmp=setdiff(1:length(data(:,1)),selected); |
|
| 4301 |
+for i=1:length(names) |
|
| 4302 |
+ subplot(length(names),1,i); |
|
| 4303 |
+ hold on; |
|
| 4304 |
+ if max(data(:,i))- min(data(:,i)) <= eps |
|
| 4305 |
+ set(gca,'YLim',[max(data(:,i))-1 max(data(:,i))+1]); |
|
| 4306 |
+ end |
|
| 4307 |
+ plot(t,data(:,i)); |
|
| 4308 |
+ if ~isempty(tmp); |
|
| 4309 |
+ data(tmp,i)=NaN; |
|
| 4310 |
+ end |
|
| 4311 |
+ plot(t,data(:,i),'red'); |
|
| 4312 |
+ ylabel(names{i});
|
|
| 4313 |
+ set(gca,'XTick',[]); |
|
| 4314 |
+end |
|
| 4315 |
+set(gcf,'Name','Plotted Data Components'); |
|
| 4316 |
+ |
|
| 4317 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4318 |
+ |
|
| 4319 |
+%%% Subfunction: plxy_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4320 |
+ |
|
| 4321 |
+function plxy_button |
|
| 4322 |
+ |
|
| 4323 |
+%PLXY_BUTTON A callback function. XY-plots the first and the second |
|
| 4324 |
+% components chosen. |
|
| 4325 |
+% |
|
| 4326 |
+% |
|
| 4327 |
+ |
|
| 4328 |
+ |
|
| 4329 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 4330 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 4331 |
+ |
|
| 4332 |
+inds = get_indices; |
|
| 4333 |
+if length(inds) < 2 |
|
| 4334 |
+ errordlg('There must be two components chosen for XY-plot.');
|
|
| 4335 |
+ return; |
|
| 4336 |
+end |
|
| 4337 |
+ |
|
| 4338 |
+inds=inds(1:2); |
|
| 4339 |
+names=getfield(sData,'comp_names',{inds});
|
|
| 4340 |
+ |
|
| 4341 |
+h=findobj(get(0,'Children'),'Tag','PlotWin'); |
|
| 4342 |
+ |
|
| 4343 |
+if isempty(h) |
|
| 4344 |
+ h= figure; |
|
| 4345 |
+ set(h,'Tag','PlotWin'); |
|
| 4346 |
+end |
|
| 4347 |
+ |
|
| 4348 |
+set(0,'CurrentFigure',h); |
|
| 4349 |
+clf; |
|
| 4350 |
+axes; |
|
| 4351 |
+if max(sData.data(:,inds(1))) - min(sData.data(:,inds(1))) <= eps |
|
| 4352 |
+ set(gca,'XLim',[max(sData.data(:,inds(1)))-1 max(sData.data(:,inds(1)))+1]); |
|
| 4353 |
+end |
|
| 4354 |
+if max(sData.data(:,inds(2))) - min(sData.data(:,inds(2))) <= eps |
|
| 4355 |
+ set(gca,'YLim',[max(sData.data(:,inds(2)))-1 max(sData.data(:,inds(2)))+1]); |
|
| 4356 |
+end |
|
| 4357 |
+hold on; |
|
| 4358 |
+plot(sData.data(:,inds(1)),sData.data(:,inds(2)),'o'); |
|
| 4359 |
+x=sData.data(selected,inds(1)); |
|
| 4360 |
+y=sData.data(selected,inds(2)); |
|
| 4361 |
+ |
|
| 4362 |
+plot(x,y,'ored','MarkerSize',4); |
|
| 4363 |
+xlabel(names(1)); |
|
| 4364 |
+ylabel(names(2)); |
|
| 4365 |
+set(h,'Name','Plotted Data Components'); |
|
| 4366 |
+ |
|
| 4367 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4368 |
+ |
|
| 4369 |
+%%% Sub_function: bplo_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4370 |
+ |
|
| 4371 |
+function bplo_button |
|
| 4372 |
+ |
|
| 4373 |
+%BPLO_BUTTON A callback function. Box-plots the first component chosen. |
|
| 4374 |
+ |
|
| 4375 |
+ |
|
| 4376 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 4377 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 4378 |
+ |
|
| 4379 |
+if length(selected) == 1 |
|
| 4380 |
+ errordlg('There are too few vectors chosen for box-plotting.');
|
|
| 4381 |
+else |
|
| 4382 |
+ indices=get_indices; |
|
| 4383 |
+ if isempty(indices) |
|
| 4384 |
+ return; |
|
| 4385 |
+ end |
|
| 4386 |
+ for i=1:length(indices) |
|
| 4387 |
+ if length(unique(sData.data(selected,indices(i))))==1 |
|
| 4388 |
+ errordlg('All the values are the same. Operation can''t be evaluated.');
|
|
| 4389 |
+ return; |
|
| 4390 |
+ end |
|
| 4391 |
+ end |
|
| 4392 |
+ names=getfield(sData,'comp_names',{indices});
|
|
| 4393 |
+ h= findobj(get(0,'Children'),'Tag','PlotWin'); |
|
| 4394 |
+ if isempty(h) |
|
| 4395 |
+ h= figure; |
|
| 4396 |
+ set(h,'Tag','PlotWin'); |
|
| 4397 |
+ end |
|
| 4398 |
+ |
|
| 4399 |
+ data=sData.data(selected,indices); |
|
| 4400 |
+ |
|
| 4401 |
+ set(0,'CurrentFigure',h); |
|
| 4402 |
+ hold off; |
|
| 4403 |
+ clf; |
|
| 4404 |
+ hold on; |
|
| 4405 |
+ for i=1:getfield(size(data),{2})
|
|
| 4406 |
+ subplot(getfield(size(data),{2}),1,i);
|
|
| 4407 |
+ if ~all(isnan(data(:,i))) |
|
| 4408 |
+ boxplot(data(:,i)); |
|
| 4409 |
+ end |
|
| 4410 |
+ name=names{i};
|
|
| 4411 |
+ tmp=get(get(gca,'YLabel'),'String'); |
|
| 4412 |
+ ylabel(cat(2,sprintf('[%s] ',name),tmp));
|
|
| 4413 |
+ end |
|
| 4414 |
+ set(h,'Name','Box-plot'); |
|
| 4415 |
+end |
|
| 4416 |
+ |
|
| 4417 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4418 |
+ |
|
| 4419 |
+%%% Subfunction: hist_button %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4420 |
+ |
|
| 4421 |
+function hist_button |
|
| 4422 |
+ |
|
| 4423 |
+no_of_bins_h=getfield(get(gcf,'UserData'),'no_of_bins_h'); |
|
| 4424 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 4425 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 4426 |
+n=str2num(get(no_of_bins_h,'String')); |
|
| 4427 |
+s1='Invalid number of bins.'; |
|
| 4428 |
+s2=sprintf('\nSet new value to the box under the ''Histogram''-button.');
|
|
| 4429 |
+ |
|
| 4430 |
+if isempty(n) |
|
| 4431 |
+ errordlg(cat(2,s1,s2)); |
|
| 4432 |
+else |
|
| 4433 |
+ indices=get_indices; |
|
| 4434 |
+ if isempty(indices) |
|
| 4435 |
+ return; |
|
| 4436 |
+ end |
|
| 4437 |
+ n=round(n); |
|
| 4438 |
+ if n < 1 |
|
| 4439 |
+ errordlg('Number of bins must be positive integer.');
|
|
| 4440 |
+ else |
|
| 4441 |
+ h= findobj(get(0,'Children'),'Tag','PlotWin'); |
|
| 4442 |
+ if isempty(h) |
|
| 4443 |
+ h= figure; |
|
| 4444 |
+ set(h,'Tag','PlotWin'); |
|
| 4445 |
+ end |
|
| 4446 |
+ |
|
| 4447 |
+ set(0,'CurrentFigure',h); |
|
| 4448 |
+ hold off; |
|
| 4449 |
+ clf; |
|
| 4450 |
+ data=sData.data(selected,indices); |
|
| 4451 |
+ names=sData.comp_names(indices); |
|
| 4452 |
+ for i=1:length(names) |
|
| 4453 |
+ subplot(length(names),1,i); |
|
| 4454 |
+ hold on; |
|
| 4455 |
+ lim1=min(sData.data(:,indices(i))); |
|
| 4456 |
+ lim2=max(sData.data(:,indices(i))); |
|
| 4457 |
+ if n > 1 |
|
| 4458 |
+ if lim2 - lim1 >= eps |
|
| 4459 |
+ x=lim1:(lim2-lim1)/(n-1):lim2; |
|
| 4460 |
+ set(gca,'XLim',[lim1 lim2]); |
|
| 4461 |
+ elseif lim1 ~= 0 |
|
| 4462 |
+ x=lim1/2:lim1/(n-1):lim1/2+lim1; |
|
| 4463 |
+ if ~all(isnan([lim1 lim2])) |
|
| 4464 |
+ set(gca,'XLim',[lim1-abs(lim1/2) lim1+abs(lim1/2)]); |
|
| 4465 |
+ end |
|
| 4466 |
+ else |
|
| 4467 |
+ x=-1:2/(n-1):1; |
|
| 4468 |
+ set(gca,'XLim',[-1 1]); |
|
| 4469 |
+ end |
|
| 4470 |
+ else |
|
| 4471 |
+ x=1; |
|
| 4472 |
+ if lim2 ~= lim1 |
|
| 4473 |
+ set(gca,'XLim',[lim1 lim2]); |
|
| 4474 |
+ else |
|
| 4475 |
+ set(gca,'XLim',[lim1/2 lim1/2+lim1]); |
|
| 4476 |
+ end |
|
| 4477 |
+ end |
|
| 4478 |
+ if ~all(isnan(data(:,i))) |
|
| 4479 |
+ hist(data(:,i),x); |
|
| 4480 |
+ end |
|
| 4481 |
+ name=names{i};
|
|
| 4482 |
+ xlabel(name); |
|
| 4483 |
+ end |
|
| 4484 |
+ set(h,'Name','Histogram'); |
|
| 4485 |
+ end |
|
| 4486 |
+end |
|
| 4487 |
+ |
|
| 4488 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4489 |
+ |
|
| 4490 |
+%%% Subfunction: no_of_values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4491 |
+ |
|
| 4492 |
+function no_of_values(varargin); |
|
| 4493 |
+ |
|
| 4494 |
+%NO_OF_VALUES A callback function. Calculates the number of different |
|
| 4495 |
+% values of the chosen components. |
|
| 4496 |
+% |
|
| 4497 |
+% |
|
| 4498 |
+ |
|
| 4499 |
+if nargin==1; |
|
| 4500 |
+ LOG=1; |
|
| 4501 |
+else |
|
| 4502 |
+ LOG=0; |
|
| 4503 |
+end |
|
| 4504 |
+ |
|
| 4505 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4506 |
+results_h=getfield(get(pre_h,'UserData'),'results_h'); |
|
| 4507 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 4508 |
+selected=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 4509 |
+str1='There must be one component chosen for ''Number of Values''-operation'; |
|
| 4510 |
+ |
|
| 4511 |
+ |
|
| 4512 |
+if ~LOG & isempty(get_indices) |
|
| 4513 |
+ errordlg(str1); |
|
| 4514 |
+else |
|
| 4515 |
+ indices=get_indices; |
|
| 4516 |
+ data=sData.data(selected,indices); |
|
| 4517 |
+ |
|
| 4518 |
+ string{1} = 'Number of different values:';
|
|
| 4519 |
+ |
|
| 4520 |
+ for i=1:getfield(size(data),{2})
|
|
| 4521 |
+ |
|
| 4522 |
+ tmp=data(:,i); |
|
| 4523 |
+ string{i+1}=cat(2,sprintf('#%d:',indices(i)),...
|
|
| 4524 |
+ sprintf('%d',length(find(~isnan(unique(data(:,i)))))));
|
|
| 4525 |
+ end |
|
| 4526 |
+ |
|
| 4527 |
+ set(results_h,'String',string); |
|
| 4528 |
+ set(results_h,'HorizontalAlignment','left'); |
|
| 4529 |
+ if ~LOG |
|
| 4530 |
+ data=get(pre_h,'UserData'); |
|
| 4531 |
+ data.LOG{length(data.LOG)+1}='% Number of values';
|
|
| 4532 |
+ data.LOG{length(data.LOG)+1}='preprocess(''noof'',''foo'');';
|
|
| 4533 |
+ set(pre_h,'UserData',data); |
|
| 4534 |
+ end |
|
| 4535 |
+end |
|
| 4536 |
+ |
|
| 4537 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4538 |
+ |
|
| 4539 |
+%%% Subfunction: correlation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4540 |
+ |
|
| 4541 |
+function correlation(varargin) |
|
| 4542 |
+ |
|
| 4543 |
+if nargin == 1 |
|
| 4544 |
+ LOG=1; |
|
| 4545 |
+else |
|
| 4546 |
+ LOG=0; |
|
| 4547 |
+end |
|
| 4548 |
+ |
|
| 4549 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 4550 |
+results_h=getfield(get(pre_h,'UserData'),'results_h'); |
|
| 4551 |
+selected=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 4552 |
+sData=getfield(get(pre_h,'UserData'),'sData'); |
|
| 4553 |
+ |
|
| 4554 |
+if length(get_indices) < 2 |
|
| 4555 |
+ errordlg('There must be two components chosen for Correlation');
|
|
| 4556 |
+else |
|
| 4557 |
+ indices=getfield(get_indices,{1:2});
|
|
| 4558 |
+ data=sData.data(selected,indices); |
|
| 4559 |
+ inds=find(~isnan(data(:,1)) & ~isnan(data(:,2))); |
|
| 4560 |
+ value=getfield(corrcoef(data(inds,1),data(inds,2)),{1,2});
|
|
| 4561 |
+ names=sData.comp_names(indices); |
|
| 4562 |
+ string{1}='Correlation between';
|
|
| 4563 |
+ string{2}=cat(2,names{1},' and ',names{2},':');
|
|
| 4564 |
+ string{3}=sprintf('%-10.3g',value);
|
|
| 4565 |
+ |
|
| 4566 |
+ set(results_h,'String',string); |
|
| 4567 |
+ set(results_h,'HorizontalAlignment','left'); |
|
| 4568 |
+ if ~LOG |
|
| 4569 |
+ data=get(pre_h,'UserData'); |
|
| 4570 |
+ data.LOG{length(data.LOG)+1}='% Correlation';
|
|
| 4571 |
+ data.LOG{length(data.LOG)+1}='preprocess(''corr'',''foo'');';
|
|
| 4572 |
+ set(pre_h,'UserData',data); |
|
| 4573 |
+ end |
|
| 4574 |
+end |
|
| 4575 |
+ |
|
| 4576 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4577 |
+ |
|
| 4578 |
+%%% Subfunction: unit_length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4579 |
+ |
|
| 4580 |
+function unit_length(varargin) |
|
| 4581 |
+ |
|
| 4582 |
+%UNIT_LENGTH A callback function Scales all the vectors to the unit |
|
| 4583 |
+% length. |
|
| 4584 |
+% |
|
| 4585 |
+% |
|
| 4586 |
+ |
|
| 4587 |
+if nargin==1 |
|
| 4588 |
+ LOG=1; |
|
| 4589 |
+else |
|
| 4590 |
+ LOG=0; |
|
| 4591 |
+end |
|
| 4592 |
+ |
|
| 4593 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 4594 |
+sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 4595 |
+sData.MODIFIED=1; |
|
| 4596 |
+scaled=sData.data; |
|
| 4597 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 4598 |
+ |
|
| 4599 |
+if ~LOG & isempty(get(comp_names_h,'Value')) |
|
| 4600 |
+ errordlg('There must be components chosen for the ''unit length''- operation');
|
|
| 4601 |
+ return; |
|
| 4602 |
+end |
|
| 4603 |
+inds=get_indices; |
|
| 4604 |
+for i=1:length(scaled(:,1)); |
|
| 4605 |
+ x=find(~isnan(scaled(i,inds))); |
|
| 4606 |
+ scaled(i,inds(x))=(1/sqrt(sum(scaled(i,inds(x)).^2)))*scaled(i,inds(x)); |
|
| 4607 |
+end |
|
| 4608 |
+ |
|
| 4609 |
+data=get(gcf,'UserData'); |
|
| 4610 |
+ |
|
| 4611 |
+ |
|
| 4612 |
+data.undo.sData = sData; |
|
| 4613 |
+data.sData.data=scaled; |
|
| 4614 |
+ |
|
| 4615 |
+for i=1:length(inds) |
|
| 4616 |
+ data.sData.comp_norm{inds(i)}=[];
|
|
| 4617 |
+end |
|
| 4618 |
+ |
|
| 4619 |
+if ~LOG |
|
| 4620 |
+ data.LOG{length(data.LOG)+1}='% Unit length';
|
|
| 4621 |
+ data.LOG{length(data.LOG)+1}='preprocess(''unit'',''foo'');';
|
|
| 4622 |
+end |
|
| 4623 |
+set(gcf,'UserData',data); |
|
| 4624 |
+ |
|
| 4625 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 4626 |
+vects(data.selected_vects)=1; |
|
| 4627 |
+ |
|
| 4628 |
+draw_vectors(vects,data.vector_h); |
|
| 4629 |
+vect_means(sData,vect_mean_h,data.selected_vects); |
|
| 4630 |
+cplot_mimema; |
|
| 4631 |
+plot_hist; |
|
| 4632 |
+ |
|
| 4633 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4634 |
+ |
|
| 4635 |
+%%% Subfunction: one_of_n %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4636 |
+ |
|
| 4637 |
+function one_of_n(varargin) |
|
| 4638 |
+ |
|
| 4639 |
+if nargin==1 |
|
| 4640 |
+ LOG=1; |
|
| 4641 |
+else |
|
| 4642 |
+ LOG=0; |
|
| 4643 |
+end |
|
| 4644 |
+ |
|
| 4645 |
+data=get(gcf,'UserData'); |
|
| 4646 |
+vector_h=getfield(get(gcf,'Userdata'),'vector_h'); |
|
| 4647 |
+comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h'); |
|
| 4648 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 4649 |
+sData=data.sData; |
|
| 4650 |
+undo=data.sData; |
|
| 4651 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 4652 |
+msg='Creating over 10 new components. Stop operation?'; |
|
| 4653 |
+ |
|
| 4654 |
+if ~LOG |
|
| 4655 |
+ if isempty(get(data.comp_names_h,'Value')) |
|
| 4656 |
+ errordlg('There must be one component chosen for ''Add: N binary types'' -operation');
|
|
| 4657 |
+ return; |
|
| 4658 |
+ end |
|
| 4659 |
+end |
|
| 4660 |
+ |
|
| 4661 |
+index=getfield(get_indices,{1});
|
|
| 4662 |
+ |
|
| 4663 |
+tmp=unique(sData.data(:,index)); |
|
| 4664 |
+n=length(tmp); |
|
| 4665 |
+ |
|
| 4666 |
+if ~LOG |
|
| 4667 |
+ if n>10 |
|
| 4668 |
+ answer=questdlg(msg,'Question','Yes','No','Yes'); |
|
| 4669 |
+ |
|
| 4670 |
+ if strcmp(answer,'Yes') |
|
| 4671 |
+ msgbox('Operation stopped.');
|
|
| 4672 |
+ return; |
|
| 4673 |
+ end |
|
| 4674 |
+ |
|
| 4675 |
+ end |
|
| 4676 |
+end |
|
| 4677 |
+ |
|
| 4678 |
+dim1=getfield(size(sData.data),{1});
|
|
| 4679 |
+dim2=getfield(size(sData.data),{2});
|
|
| 4680 |
+sData.data=cat(2,sData.data,zeros(dim1,n)); |
|
| 4681 |
+ |
|
| 4682 |
+dim=dim2+n; |
|
| 4683 |
+for i=1:n |
|
| 4684 |
+ sData.data(:,dim-(n-i))=(sData.data(:,index) == tmp(i)); |
|
| 4685 |
+end |
|
| 4686 |
+ |
|
| 4687 |
+INDEX=sData.INDEX; |
|
| 4688 |
+for i=1:n |
|
| 4689 |
+ sData.comp_names{dim2+i}=sprintf('%dNewVar',dim2+i);
|
|
| 4690 |
+end |
|
| 4691 |
+tmp_norm=cat(1,sData.comp_norm,cell(n,1)); |
|
| 4692 |
+sData=som_data_struct(sData.data,... |
|
| 4693 |
+ 'name',sData.name,... |
|
| 4694 |
+ 'labels',sData.labels,... |
|
| 4695 |
+ 'comp_names',sData.comp_names); |
|
| 4696 |
+ |
|
| 4697 |
+sData.MODIFIED=1; |
|
| 4698 |
+sData.INDEX=INDEX; |
|
| 4699 |
+sData.comp_norm=tmp_norm; |
|
| 4700 |
+data.undo.sData=undo; |
|
| 4701 |
+data.sData=sData; |
|
| 4702 |
+data.selected_vects=1:length(sData.data(:,1)); |
|
| 4703 |
+if ~LOG |
|
| 4704 |
+ data.LOG{length(data.LOG)+1}='% Add: N binary types';
|
|
| 4705 |
+ data.LOG{length(data.LOG)+1}='preprocess(''oneo'',''foo'');';
|
|
| 4706 |
+end |
|
| 4707 |
+set(gcf,'UserData',data); |
|
| 4708 |
+clear_button; |
|
| 4709 |
+write_sD_stats; |
|
| 4710 |
+set_compnames(sData,comp_names_h); |
|
| 4711 |
+tmp=ones(1,length(sData.data(:,1))); |
|
| 4712 |
+draw_vectors(tmp,vector_h); |
|
| 4713 |
+vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); |
|
| 4714 |
+cplot_mimema; |
|
| 4715 |
+sel_comp; |
|
| 4716 |
+ |
|
| 4717 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4718 |
+ |
|
| 4719 |
+%%% Subfunction: add_zeros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4720 |
+ |
|
| 4721 |
+function add_zeros(varargin) |
|
| 4722 |
+ |
|
| 4723 |
+if nargin == 1 |
|
| 4724 |
+ LOG=1; |
|
| 4725 |
+else |
|
| 4726 |
+ LOG=0; |
|
| 4727 |
+end |
|
| 4728 |
+ |
|
| 4729 |
+data=get(gcf,'UserData'); |
|
| 4730 |
+vector_h=getfield(get(gcf,'Userdata'),'vector_h'); |
|
| 4731 |
+comp_names_h=getfield(get(gcf,'Userdata'),'comp_names_h'); |
|
| 4732 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 4733 |
+sData=data.sData; |
|
| 4734 |
+undo=sData; |
|
| 4735 |
+ |
|
| 4736 |
+dim1=getfield(size(sData.data),{1});
|
|
| 4737 |
+dim2=getfield(size(sData.data),{2});
|
|
| 4738 |
+sData.data=cat(2,sData.data,zeros(dim1,1)); |
|
| 4739 |
+ |
|
| 4740 |
+INDEX=sData.INDEX; |
|
| 4741 |
+ |
|
| 4742 |
+sData.comp_names{dim2+1}=sprintf('%dNewVar',dim2+1);
|
|
| 4743 |
+tmp_norm=cat(1,sData.comp_norm,cell(1,1)); |
|
| 4744 |
+sData=som_data_struct(sData.data,... |
|
| 4745 |
+ 'name',sData.name,... |
|
| 4746 |
+ 'labels',sData.labels,... |
|
| 4747 |
+ 'comp_names',sData.comp_names); |
|
| 4748 |
+ |
|
| 4749 |
+sData.MODIFIED=1; |
|
| 4750 |
+sData.INDEX=INDEX; |
|
| 4751 |
+sData.comp_norm=tmp_norm; |
|
| 4752 |
+data.sData=sData; |
|
| 4753 |
+data.undo.sData=undo; |
|
| 4754 |
+data.selected_vects=1:length(sData.data(:,1)); |
|
| 4755 |
+if ~LOG |
|
| 4756 |
+ data.LOG{length(data.LOG)+1}='% Add: zeros';
|
|
| 4757 |
+ data.LOG{length(data.LOG)+1}='preprocess(''zero'',''foo'');';
|
|
| 4758 |
+end |
|
| 4759 |
+set(gcf,'UserData',data); |
|
| 4760 |
+clear_button; |
|
| 4761 |
+write_sD_stats; |
|
| 4762 |
+set_compnames(sData,comp_names_h); |
|
| 4763 |
+tmp=ones(1,length(sData.data(:,1))); |
|
| 4764 |
+draw_vectors(tmp,vector_h); |
|
| 4765 |
+vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); |
|
| 4766 |
+cplot_mimema; |
|
| 4767 |
+sel_comp; |
|
| 4768 |
+ |
|
| 4769 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4770 |
+ |
|
| 4771 |
+%%% Subfunction: move_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4772 |
+ |
|
| 4773 |
+function move_component(varargin) |
|
| 4774 |
+ |
|
| 4775 |
+%MOVE_COMPONENT A callback function. Moves one component of vectors to |
|
| 4776 |
+% the position wanted. |
|
| 4777 |
+% |
|
| 4778 |
+% |
|
| 4779 |
+ |
|
| 4780 |
+if nargin == 1 |
|
| 4781 |
+ LOG=1; |
|
| 4782 |
+ i=1; |
|
| 4783 |
+ while varargin{1}(i) ~= ' '
|
|
| 4784 |
+ value(i)=varargin{1}(i);
|
|
| 4785 |
+ i=i+1; |
|
| 4786 |
+ end |
|
| 4787 |
+ value=str2num(value); % the new place |
|
| 4788 |
+ index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen
|
|
| 4789 |
+ % component |
|
| 4790 |
+else |
|
| 4791 |
+ LOG=0; |
|
| 4792 |
+end |
|
| 4793 |
+ |
|
| 4794 |
+data=get(gcf,'UserData'); |
|
| 4795 |
+sData=data.sData; |
|
| 4796 |
+undo=sData; |
|
| 4797 |
+prompt='Enter the number of the new component place:'; |
|
| 4798 |
+ |
|
| 4799 |
+ |
|
| 4800 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 4801 |
+ errordlg('There must be one component chosen for ''Move Component''-operation');
|
|
| 4802 |
+ return; |
|
| 4803 |
+end |
|
| 4804 |
+ |
|
| 4805 |
+if ~LOG |
|
| 4806 |
+ index=getfield(get_indices,{1});
|
|
| 4807 |
+ answer=inputdlg(prompt); |
|
| 4808 |
+ |
|
| 4809 |
+ if isempty(answer) | (iscell(answer) & isempty(answer{1}))
|
|
| 4810 |
+ msgbox('No components moved');
|
|
| 4811 |
+ return; |
|
| 4812 |
+ end |
|
| 4813 |
+ |
|
| 4814 |
+ value=str2num(answer{1});
|
|
| 4815 |
+ |
|
| 4816 |
+ |
|
| 4817 |
+ dims=size(value); |
|
| 4818 |
+ |
|
| 4819 |
+ if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) |
|
| 4820 |
+ errordlg('The new component place must be positive integer.')
|
|
| 4821 |
+ return; |
|
| 4822 |
+ end |
|
| 4823 |
+ |
|
| 4824 |
+ if value <= 0 | round(value) ~= value |
|
| 4825 |
+ errordlg('The new component place must be positive integer.');
|
|
| 4826 |
+ return; |
|
| 4827 |
+ end |
|
| 4828 |
+ |
|
| 4829 |
+ if value > getfield(size(sData.data),{2})
|
|
| 4830 |
+ errordlg('Too big value for the new component place.');
|
|
| 4831 |
+ return; |
|
| 4832 |
+ end |
|
| 4833 |
+end |
|
| 4834 |
+ |
|
| 4835 |
+sData.MODIFIED=1; |
|
| 4836 |
+if index < value |
|
| 4837 |
+ indices1=setdiff(1:value,index); |
|
| 4838 |
+ indices2=setdiff(value+1:length(sData.data(1,:)),index); |
|
| 4839 |
+elseif index > value |
|
| 4840 |
+ indices1=setdiff(1:value-1,index); |
|
| 4841 |
+ indices2=setdiff(value:length(sData.data(1,:)),index); |
|
| 4842 |
+else |
|
| 4843 |
+ data.sData=sData; |
|
| 4844 |
+ data.undo.sData=undo; |
|
| 4845 |
+ set(gcf,'UserData',data); |
|
| 4846 |
+ return; |
|
| 4847 |
+end |
|
| 4848 |
+ |
|
| 4849 |
+tmp1=sData.data(:,indices1); |
|
| 4850 |
+tmp2=sData.data(:,indices2); |
|
| 4851 |
+sData.data=cat(2,tmp1,sData.data(:,index),tmp2); |
|
| 4852 |
+ |
|
| 4853 |
+tmp1=sData.comp_names(indices1); |
|
| 4854 |
+tmp2=sData.comp_names(indices2); |
|
| 4855 |
+sData.comp_names=cat(1,tmp1,sData.comp_names(index),tmp2); |
|
| 4856 |
+ |
|
| 4857 |
+tmp1=sData.comp_norm(indices1); |
|
| 4858 |
+tmp2=sData.comp_norm(indices2); |
|
| 4859 |
+sData.comp_norm=cat(1,tmp1,sData.comp_norm(index),tmp2); |
|
| 4860 |
+ |
|
| 4861 |
+data.sData=sData; |
|
| 4862 |
+data.undo.sData=undo; |
|
| 4863 |
+if ~LOG |
|
| 4864 |
+ data.LOG{length(data.LOG)+1}='% Move component.';
|
|
| 4865 |
+ data.LOG{length(data.LOG)+1}=sprintf('preprocess(''move'',''%s %s'');',...
|
|
| 4866 |
+ num2str(value),num2str(index)); |
|
| 4867 |
+end |
|
| 4868 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 4869 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 4870 |
+vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 4871 |
+data.selected_vects=1:length(sData.data(:,1)); |
|
| 4872 |
+set(gcf,'UserData',data); |
|
| 4873 |
+clear_button; |
|
| 4874 |
+set_compnames(sData,comp_names_h); |
|
| 4875 |
+draw_vectors(ones(1,length(sData.data(:,1))),vector_h); |
|
| 4876 |
+vect_means(sData,vect_mean_h,data.selected_vects); |
|
| 4877 |
+cplot_mimema; |
|
| 4878 |
+sel_comp; |
|
| 4879 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4880 |
+ |
|
| 4881 |
+%%% Subfunction: copy_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4882 |
+ |
|
| 4883 |
+function copy_component(varargin) |
|
| 4884 |
+ |
|
| 4885 |
+%COPY_COMPONENT Copies one component of vectors to the position wanted. |
|
| 4886 |
+% |
|
| 4887 |
+% |
|
| 4888 |
+ |
|
| 4889 |
+if nargin == 1 |
|
| 4890 |
+ LOG=1; |
|
| 4891 |
+ i=1; |
|
| 4892 |
+ while varargin{1}(i) ~= ' '
|
|
| 4893 |
+ value(i)=varargin{1}(i);
|
|
| 4894 |
+ i=i+1; |
|
| 4895 |
+ end |
|
| 4896 |
+ value=str2num(value); % the new place |
|
| 4897 |
+ index=str2num(varargin{1}(i:length(varargin{1}))); % index of the chosen
|
|
| 4898 |
+ % component |
|
| 4899 |
+else |
|
| 4900 |
+ LOG=0; |
|
| 4901 |
+end |
|
| 4902 |
+ |
|
| 4903 |
+ |
|
| 4904 |
+data=get(gcf,'UserData'); |
|
| 4905 |
+sData=data.sData; |
|
| 4906 |
+undo=sData; |
|
| 4907 |
+if ~LOG |
|
| 4908 |
+ prompt='Enter the number of the new component place:'; |
|
| 4909 |
+ |
|
| 4910 |
+ |
|
| 4911 |
+ if isempty(get(data.comp_names_h,'Value')) |
|
| 4912 |
+ errordlg('There must be one component chosen for ''Copy Component''-operation');
|
|
| 4913 |
+ return; |
|
| 4914 |
+ end |
|
| 4915 |
+ |
|
| 4916 |
+ index=getfield(get_indices,{1});
|
|
| 4917 |
+ answer=inputdlg(prompt); |
|
| 4918 |
+ |
|
| 4919 |
+ if isempty(answer) | (iscell(answer) & isempty(answer{1}))
|
|
| 4920 |
+ msgbox('No components moved');
|
|
| 4921 |
+ return |
|
| 4922 |
+ end |
|
| 4923 |
+ |
|
| 4924 |
+ |
|
| 4925 |
+ value=str2num(answer{1});
|
|
| 4926 |
+ dims=size(value); |
|
| 4927 |
+ |
|
| 4928 |
+ if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) |
|
| 4929 |
+ errordlg('The new component place must be positive integer.')
|
|
| 4930 |
+ return; |
|
| 4931 |
+ end |
|
| 4932 |
+ |
|
| 4933 |
+ if value <= 0 | round(value) ~= value |
|
| 4934 |
+ errordlg('The new component place must be positive integer.');
|
|
| 4935 |
+ return; |
|
| 4936 |
+ end |
|
| 4937 |
+ |
|
| 4938 |
+ if value > getfield(size(sData.data),{2}) + 1
|
|
| 4939 |
+ errordlg('Too big value for the new component place.');
|
|
| 4940 |
+ return; |
|
| 4941 |
+ end |
|
| 4942 |
+end |
|
| 4943 |
+ |
|
| 4944 |
+sData.MODIFIED=1; |
|
| 4945 |
+ |
|
| 4946 |
+indices1=1:value-1; |
|
| 4947 |
+indices2=value:length(sData.data(1,:)); |
|
| 4948 |
+tmp1=sData.data(:,indices1); |
|
| 4949 |
+tmp2=sData.data(:,indices2); |
|
| 4950 |
+sData.data=cat(2,tmp1,sData.data(:,index),tmp2); |
|
| 4951 |
+ |
|
| 4952 |
+tmp1=sData.comp_names(indices1); |
|
| 4953 |
+tmp2=sData.comp_names(indices2); |
|
| 4954 |
+name=cell(1,1); |
|
| 4955 |
+name{1}=cat(2,'Copied',sData.comp_names{index});
|
|
| 4956 |
+sData.comp_names=cat(1,tmp1,name,tmp2); |
|
| 4957 |
+ |
|
| 4958 |
+tmp1=sData.comp_norm(indices1); |
|
| 4959 |
+tmp2=sData.comp_norm(indices2); |
|
| 4960 |
+norm=cell(1,1); |
|
| 4961 |
+norm{1}=sData.comp_norm{index};
|
|
| 4962 |
+sData.comp_norm=cat(1,tmp1,norm,tmp2); |
|
| 4963 |
+ |
|
| 4964 |
+data.sData=sData; |
|
| 4965 |
+data.undo.sData=undo; |
|
| 4966 |
+if ~LOG |
|
| 4967 |
+ data.LOG{length(data.LOG)+1}='% Copy component';
|
|
| 4968 |
+ data.LOG{length(data.LOG)+1}=sprintf('preprocess(''copy'',''%s %s'');',...
|
|
| 4969 |
+ num2str(value),num2str(index)); |
|
| 4970 |
+end |
|
| 4971 |
+ |
|
| 4972 |
+ |
|
| 4973 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 4974 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 4975 |
+vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 4976 |
+data.selected_vects=1:length(sData.data(:,1)); |
|
| 4977 |
+set(gcf,'UserData',data); |
|
| 4978 |
+clear_button; |
|
| 4979 |
+write_sD_stats; |
|
| 4980 |
+set_compnames(sData,comp_names_h); |
|
| 4981 |
+draw_vectors(ones(1,length(sData.data(:,1))),vector_h); |
|
| 4982 |
+vect_means(sData,vect_mean_h,data.selected_vects); |
|
| 4983 |
+cplot_mimema; |
|
| 4984 |
+sel_comp; |
|
| 4985 |
+ |
|
| 4986 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4987 |
+ |
|
| 4988 |
+%%% Subfunction: remove_component %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 4989 |
+ |
|
| 4990 |
+function remove_component(varargin) |
|
| 4991 |
+ |
|
| 4992 |
+if nargin == 1 |
|
| 4993 |
+ LOG=1; |
|
| 4994 |
+ value=str2num(varargin{1});
|
|
| 4995 |
+else |
|
| 4996 |
+ LOG=0; |
|
| 4997 |
+end |
|
| 4998 |
+ |
|
| 4999 |
+data=get(gcf,'UserData'); |
|
| 5000 |
+vect_mean_h=getfield(get(gcf,'UserData'),'vect_mean_h'); |
|
| 5001 |
+vector_h=getfield(get(gcf,'UserData'),'vector_h'); |
|
| 5002 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 5003 |
+sData=data.sData; |
|
| 5004 |
+undo=sData; |
|
| 5005 |
+prompt='Enter the number of component to be removed.'; |
|
| 5006 |
+dim=length(sData.data(1,:)); |
|
| 5007 |
+ |
|
| 5008 |
+if ~LOG |
|
| 5009 |
+ answer=inputdlg(prompt); |
|
| 5010 |
+ |
|
| 5011 |
+ if isempty(answer) | (iscell(answer) & isempty(answer{1}))
|
|
| 5012 |
+ msgbox('Components not removed.');
|
|
| 5013 |
+ return; |
|
| 5014 |
+ end |
|
| 5015 |
+ |
|
| 5016 |
+ value=str2num(answer{1});
|
|
| 5017 |
+ dims=size(value); |
|
| 5018 |
+ |
|
| 5019 |
+ if dims(1) ~= 1 | dims(2) ~= 1 | ~isreal(value) |
|
| 5020 |
+ errordlg('Number of the component to be removed must be positive integer.')
|
|
| 5021 |
+ return; |
|
| 5022 |
+ end |
|
| 5023 |
+ |
|
| 5024 |
+ if value <= 0 | round(value) ~= value |
|
| 5025 |
+ errordlg('Number of the component to be removed must be positive integer.');
|
|
| 5026 |
+ return; |
|
| 5027 |
+ end |
|
| 5028 |
+ |
|
| 5029 |
+ if value > getfield(size(sData.data),{2})
|
|
| 5030 |
+ errordlg('There are less components.');
|
|
| 5031 |
+ return; |
|
| 5032 |
+ end |
|
| 5033 |
+end |
|
| 5034 |
+ |
|
| 5035 |
+sD_set_h=getfield(get(gcf,'UserData'),'sD_set_h'); |
|
| 5036 |
+index=get(sD_set_h,'Value'); |
|
| 5037 |
+if value == 1 & getfield(size(sData.data),{2}) == 1
|
|
| 5038 |
+ if length(get(sD_set_h,'String')) == 1 |
|
| 5039 |
+ msgbox('No data left. Closing program...')
|
|
| 5040 |
+ pro_tools('close');
|
|
| 5041 |
+ return; |
|
| 5042 |
+ end |
|
| 5043 |
+ |
|
| 5044 |
+ set1=data.sD_set(1:index-1); |
|
| 5045 |
+ set2=data.sD_set(index+1:length(data.sD_set)); |
|
| 5046 |
+ data.sD_set=[set1 set2]; |
|
| 5047 |
+ set(gcf,'UserData',data); |
|
| 5048 |
+ |
|
| 5049 |
+ set_sD_stats; |
|
| 5050 |
+ sel_sD; |
|
| 5051 |
+ data=get(gcf,'UserData'); |
|
| 5052 |
+ data.undo.sData=undo; |
|
| 5053 |
+ data.undo.index=index; |
|
| 5054 |
+ set(gcf,'UserData',data); |
|
| 5055 |
+ return; |
|
| 5056 |
+end |
|
| 5057 |
+dims=size(sData.data); |
|
| 5058 |
+tmp_data=cat(2,sData.data(:,1:value-1),sData.data(:,value+1:dims(2))); |
|
| 5059 |
+tmp_norm=cat(1,sData.comp_norm(1:value-1),sData.comp_norm(value+1:dims(2))); |
|
| 5060 |
+names=cat(1,sData.comp_names(1:value-1),sData.comp_names(value+1:dims(2))); |
|
| 5061 |
+INDEX=sData.INDEX; |
|
| 5062 |
+comp_norm=sData.comp_norm; |
|
| 5063 |
+sData=som_data_struct(tmp_data,... |
|
| 5064 |
+ 'name',sData.name,... |
|
| 5065 |
+ 'labels',sData.labels,... |
|
| 5066 |
+ 'comp_names',names); |
|
| 5067 |
+sData.comp_norm=tmp_norm; |
|
| 5068 |
+sData.MODIFIED=1; |
|
| 5069 |
+sData.INDEX=INDEX; |
|
| 5070 |
+data=get(gcf,'UserData'); |
|
| 5071 |
+data.sData=sData; |
|
| 5072 |
+data.undo.sData=undo; |
|
| 5073 |
+data.selected_vects=1:length(sData.data(:,1)); |
|
| 5074 |
+if ~LOG |
|
| 5075 |
+ data.LOG{length(data.LOG)+1}='% Remove component';
|
|
| 5076 |
+ data.LOG{length(data.LOG)+1}=sprintf('preprocess(''remove'',''%s'');',...
|
|
| 5077 |
+ answer{1});
|
|
| 5078 |
+end |
|
| 5079 |
+set(gcf,'UserData',data); |
|
| 5080 |
+clear_button; |
|
| 5081 |
+write_sD_stats; |
|
| 5082 |
+set_compnames(sData,comp_names_h); |
|
| 5083 |
+tmp=ones(1,length(sData.data(:,1))); |
|
| 5084 |
+draw_vectors(tmp,vector_h); |
|
| 5085 |
+vect_means(sData,vect_mean_h,1:length(sData.data(:,1))); |
|
| 5086 |
+cplot_mimema; |
|
| 5087 |
+sel_comp; |
|
| 5088 |
+ |
|
| 5089 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5090 |
+ |
|
| 5091 |
+%%% Subfunction: remove_vects %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5092 |
+ |
|
| 5093 |
+function remove_vects(varargin) |
|
| 5094 |
+ |
|
| 5095 |
+if nargin==1 |
|
| 5096 |
+ LOG=1; |
|
| 5097 |
+ tmp_str=varargin{1};
|
|
| 5098 |
+else |
|
| 5099 |
+ LOG=0; |
|
| 5100 |
+ tmp_str='_foo'; |
|
| 5101 |
+end |
|
| 5102 |
+data=get(gcf,'UserData'); |
|
| 5103 |
+vect_mean_h=data.vect_mean_h; |
|
| 5104 |
+vector_h=data.vector_h; |
|
| 5105 |
+sData=data.sData; |
|
| 5106 |
+undo=sData; |
|
| 5107 |
+ |
|
| 5108 |
+if length(data.selected_vects) == getfield(size(sData.data),{1})
|
|
| 5109 |
+ if LOG |
|
| 5110 |
+ answer='Yes'; |
|
| 5111 |
+ else |
|
| 5112 |
+ answer=questdlg('Do you want to delete this data set?');
|
|
| 5113 |
+ end |
|
| 5114 |
+ if strcmp(answer,'No') |
|
| 5115 |
+ return; |
|
| 5116 |
+ else |
|
| 5117 |
+ index=get(data.sD_set_h,'Value'); |
|
| 5118 |
+ if length(get(data.sD_set_h,'String')) == 1 |
|
| 5119 |
+ msgbox('No data left. Closing program...')
|
|
| 5120 |
+ pro_tools('close');
|
|
| 5121 |
+ return; |
|
| 5122 |
+ end |
|
| 5123 |
+ |
|
| 5124 |
+ set1=data.sD_set(1:index-1); |
|
| 5125 |
+ set2=data.sD_set(index+1:length(data.sD_set)); |
|
| 5126 |
+ data.sD_set=[set1 set2]; |
|
| 5127 |
+ set(gcf,'UserData',data); |
|
| 5128 |
+ |
|
| 5129 |
+ set(data.sD_set_h,'Value',1); |
|
| 5130 |
+ set_sD_stats; |
|
| 5131 |
+ sel_sD; |
|
| 5132 |
+ data=get(gcf,'UserData'); |
|
| 5133 |
+ data.undo.sData=undo; |
|
| 5134 |
+ data.undo.index=index; |
|
| 5135 |
+ if ~LOG |
|
| 5136 |
+ data.LOG{length(data.LOG)+1}='% Remove selected vectors';
|
|
| 5137 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',...
|
|
| 5138 |
+ tmp_str,''');'); |
|
| 5139 |
+ end |
|
| 5140 |
+ set(gcf,'UserData',data); |
|
| 5141 |
+ return; |
|
| 5142 |
+ end |
|
| 5143 |
+end |
|
| 5144 |
+ |
|
| 5145 |
+tmp=sData.data(data.selected_vects,:); |
|
| 5146 |
+if ~LOG |
|
| 5147 |
+ answer=questdlg('Do you want to save removed values to workspace?');
|
|
| 5148 |
+else |
|
| 5149 |
+ if ~strcmp(tmp_str,'_foo') |
|
| 5150 |
+ answer='Yes'; |
|
| 5151 |
+ else |
|
| 5152 |
+ answer='No'; |
|
| 5153 |
+ end |
|
| 5154 |
+end |
|
| 5155 |
+old=gcf; |
|
| 5156 |
+if strcmp(answer,'Yes') |
|
| 5157 |
+ if ~LOG |
|
| 5158 |
+ answer=inputdlg('Give the name of the output -variable.');
|
|
| 5159 |
+ else |
|
| 5160 |
+ answer={tmp_str};
|
|
| 5161 |
+ end |
|
| 5162 |
+ if isvalid_var_name(answer) |
|
| 5163 |
+ assignin('base',answer{1},tmp);
|
|
| 5164 |
+ disp(sprintf('Removed values are set to workspace as''%s''.',answer{1}));
|
|
| 5165 |
+ tmp_str=answer{1};
|
|
| 5166 |
+ end |
|
| 5167 |
+end |
|
| 5168 |
+set(0,'CurrentFigure',old); |
|
| 5169 |
+sData.data(data.selected_vects,:)=[]; |
|
| 5170 |
+sData.labels(data.selected_vects,:)=[]; |
|
| 5171 |
+sData.MODIFIED=1; |
|
| 5172 |
+data.sData=sData; |
|
| 5173 |
+data.selected=1:length(sData.data(:,1)); |
|
| 5174 |
+data.undo.sData=undo; |
|
| 5175 |
+if ~LOG |
|
| 5176 |
+ data.LOG{length(data.LOG)}='% Remove selected vectors';
|
|
| 5177 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''remove_vects'',''',...
|
|
| 5178 |
+ tmp_str,''');'); |
|
| 5179 |
+end |
|
| 5180 |
+set(gcf,'UserData',data); |
|
| 5181 |
+ |
|
| 5182 |
+ |
|
| 5183 |
+draw_vectors(ones(1,length(data.selected)),data.vector_h); |
|
| 5184 |
+write_sD_stats; |
|
| 5185 |
+select_all('foo');
|
|
| 5186 |
+ |
|
| 5187 |
+ |
|
| 5188 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5189 |
+ |
|
| 5190 |
+ |
|
| 5191 |
+ |
|
| 5192 |
+ |
|
| 5193 |
+%%% Subfunction: eval1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5194 |
+ |
|
| 5195 |
+function eval1(varargin); |
|
| 5196 |
+ |
|
| 5197 |
+if nargin == 1 |
|
| 5198 |
+ answer=varargin |
|
| 5199 |
+ LOG=1; |
|
| 5200 |
+else |
|
| 5201 |
+ LOG=0; |
|
| 5202 |
+end |
|
| 5203 |
+ |
|
| 5204 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 5205 |
+if isempty(pre_h) |
|
| 5206 |
+ errordlg('''Preprocess''-figure does not exist. Terminating program...');
|
|
| 5207 |
+ pro_tools('close');
|
|
| 5208 |
+ return; |
|
| 5209 |
+end |
|
| 5210 |
+ |
|
| 5211 |
+undo=getfield(get(pre_h,'UserData'),'sData'); |
|
| 5212 |
+ |
|
| 5213 |
+if ~LOG |
|
| 5214 |
+ prompt={'Enter the expression to be evaluated.',...
|
|
| 5215 |
+ 'Enter the inverse normalization method (optional).'}; |
|
| 5216 |
+ title='Single component eval.'; |
|
| 5217 |
+ answer= inputdlg(prompt,title,1); |
|
| 5218 |
+end |
|
| 5219 |
+ |
|
| 5220 |
+if ~isempty(answer) |
|
| 5221 |
+ tmp=[]; |
|
| 5222 |
+ if ~isempty(answer{1})
|
|
| 5223 |
+ [tmp,method]=build_expr(answer{1},'single');
|
|
| 5224 |
+ if ~isstr(tmp) |
|
| 5225 |
+ sData=getfield(get(gcf,'UserData'),'sData'); |
|
| 5226 |
+ tmp='Done.'; |
|
| 5227 |
+ %if ~isempty(answer{2})
|
|
| 5228 |
+ % sN=som_norm_struct('eval',{method,answer{2}});
|
|
| 5229 |
+ %else |
|
| 5230 |
+ % sN=som_norm_struct('eval',{method});
|
|
| 5231 |
+ %end |
|
| 5232 |
+ %sN=som_set(sN,'status','done'); |
|
| 5233 |
+ params={answer{1};answer{2}};
|
|
| 5234 |
+ ind=getfield(get_indices,{1});
|
|
| 5235 |
+ x.type=''; |
|
| 5236 |
+ x.method='eval'; |
|
| 5237 |
+ x.params={answer{1};answer{2}};
|
|
| 5238 |
+ x.status=''; |
|
| 5239 |
+ sData.comp_norm{ind}=x;
|
|
| 5240 |
+ data=get(gcf,'UserData'); |
|
| 5241 |
+ data.undo.sData=undo; |
|
| 5242 |
+ data.sData=sData; |
|
| 5243 |
+ if ~LOG |
|
| 5244 |
+ data.LOG{length(data.LOG)+1}='% Eval (1-comp)';
|
|
| 5245 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess eval1 ',...
|
|
| 5246 |
+ sprintf('{''%s'' ''%s''};',answer{1},answer{2}));
|
|
| 5247 |
+ end |
|
| 5248 |
+ set(pre_h,'UserData',data); |
|
| 5249 |
+ |
|
| 5250 |
+ end |
|
| 5251 |
+ end |
|
| 5252 |
+ set(getfield(get(pre_h,'UserData'),'results_h'),'String',tmp); |
|
| 5253 |
+end |
|
| 5254 |
+ |
|
| 5255 |
+ |
|
| 5256 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5257 |
+ |
|
| 5258 |
+%%% Subfunction: eval2 |
|
| 5259 |
+ |
|
| 5260 |
+function eval2(varargin) |
|
| 5261 |
+ |
|
| 5262 |
+if nargin == 1 |
|
| 5263 |
+ answer=varargin{1};
|
|
| 5264 |
+ LOG=1; |
|
| 5265 |
+else |
|
| 5266 |
+ LOG=0; |
|
| 5267 |
+end |
|
| 5268 |
+ |
|
| 5269 |
+undo=getfield(get(gcf,'UserData'),'sData'); |
|
| 5270 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 5271 |
+ |
|
| 5272 |
+if isempty(pre_h) |
|
| 5273 |
+ errordlg('''Preprocess''-figure does not exist. Terminating program.');
|
|
| 5274 |
+ pro_tools('close');
|
|
| 5275 |
+ return; |
|
| 5276 |
+end |
|
| 5277 |
+ |
|
| 5278 |
+if ~LOG |
|
| 5279 |
+ prompt='Enter the expression to be evaluated.'; |
|
| 5280 |
+ title ='Eval'; |
|
| 5281 |
+ answer=inputdlg(prompt,title,1); |
|
| 5282 |
+end |
|
| 5283 |
+ |
|
| 5284 |
+if ~isempty(answer) & ~isempty(answer{1})
|
|
| 5285 |
+ str=answer{1};
|
|
| 5286 |
+ [answer,foo]=build_expr(answer{1},'multiple');
|
|
| 5287 |
+ if ~isstr(answer) |
|
| 5288 |
+ |
|
| 5289 |
+ answer='Done.'; |
|
| 5290 |
+ data=get(gcf,'UserData'); |
|
| 5291 |
+ data.undo.sData=undo; |
|
| 5292 |
+ if ~LOG |
|
| 5293 |
+ data.LOG{length(data.LOG)+1}='% Eval';
|
|
| 5294 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''eval2'',',...
|
|
| 5295 |
+ sprintf('{''%s''});',str));
|
|
| 5296 |
+ end |
|
| 5297 |
+ set(gcf,'UserData',data); |
|
| 5298 |
+ end |
|
| 5299 |
+end |
|
| 5300 |
+ |
|
| 5301 |
+set(getfield(get(pre_h,'UserData'),'results_h'),'String',answer); |
|
| 5302 |
+ |
|
| 5303 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5304 |
+ |
|
| 5305 |
+%%% Subfunction: zero2one_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5306 |
+ |
|
| 5307 |
+function zero2one_scale(varargin) |
|
| 5308 |
+ |
|
| 5309 |
+if nargin == 1 |
|
| 5310 |
+ LOG=1; |
|
| 5311 |
+else |
|
| 5312 |
+ LOG=0; |
|
| 5313 |
+end |
|
| 5314 |
+ |
|
| 5315 |
+ |
|
| 5316 |
+data=get(gcf,'UserData'); |
|
| 5317 |
+sData=data.sData; |
|
| 5318 |
+undo=sData; |
|
| 5319 |
+INDEX=sData.INDEX; |
|
| 5320 |
+sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
|
|
| 5321 |
+ |
|
| 5322 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 5323 |
+ errordlg('There must be components chosen for scaling.');
|
|
| 5324 |
+ return; |
|
| 5325 |
+end |
|
| 5326 |
+ |
|
| 5327 |
+sData=som_normalize(sData,'range',get_indices); |
|
| 5328 |
+sData.MODIFIED=1; |
|
| 5329 |
+sData.INDEX=INDEX; |
|
| 5330 |
+ |
|
| 5331 |
+data.sData=sData; |
|
| 5332 |
+data.undo.sData=undo; |
|
| 5333 |
+if ~LOG |
|
| 5334 |
+ data.LOG{length(data.LOG)+1}='% Scale [0,1]';
|
|
| 5335 |
+ data.LOG{length(data.LOG)+1}='preprocess(''zscale'', ''foo'');';
|
|
| 5336 |
+end |
|
| 5337 |
+set(gcf,'UserData',data); |
|
| 5338 |
+ |
|
| 5339 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 5340 |
+vects(data.selected_vects)=1; |
|
| 5341 |
+ |
|
| 5342 |
+cplot_mimema; |
|
| 5343 |
+plot_hist; |
|
| 5344 |
+vect_means(sData,data.vect_mean_h,data.selected_vects); |
|
| 5345 |
+draw_vectors(vects,data.vector_h); |
|
| 5346 |
+ |
|
| 5347 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5348 |
+ |
|
| 5349 |
+%%% Subfunction: var_scale %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5350 |
+ |
|
| 5351 |
+function var_scale(varargin) |
|
| 5352 |
+ |
|
| 5353 |
+if nargin == 1 |
|
| 5354 |
+ LOG=1; |
|
| 5355 |
+else |
|
| 5356 |
+ LOG=0; |
|
| 5357 |
+end |
|
| 5358 |
+ |
|
| 5359 |
+data=get(gcf,'UserData'); |
|
| 5360 |
+sData=data.sData; |
|
| 5361 |
+undo=sData; |
|
| 5362 |
+INDEX=sData.INDEX; |
|
| 5363 |
+sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
|
|
| 5364 |
+ |
|
| 5365 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 5366 |
+ errordlg('There must be components chosen for scaling.');
|
|
| 5367 |
+ return; |
|
| 5368 |
+end |
|
| 5369 |
+ |
|
| 5370 |
+sData=som_normalize(sData,'var',get_indices); |
|
| 5371 |
+ |
|
| 5372 |
+sData.INDEX=INDEX; |
|
| 5373 |
+sData.MODIFIED=1; |
|
| 5374 |
+ |
|
| 5375 |
+data.sData=sData; |
|
| 5376 |
+data.undo.sData=undo; |
|
| 5377 |
+if ~LOG |
|
| 5378 |
+ data.LOG{length(data.LOG)+1}='% Scale var=1';
|
|
| 5379 |
+ data.LOG{length(data.LOG)+1}='preprocess(''vscale'', ''foo'');';
|
|
| 5380 |
+end |
|
| 5381 |
+set(gcf,'UserData',data); |
|
| 5382 |
+ |
|
| 5383 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 5384 |
+vects(data.selected_vects)=1; |
|
| 5385 |
+ |
|
| 5386 |
+cplot_mimema; |
|
| 5387 |
+plot_hist; |
|
| 5388 |
+vect_means(sData,data.vect_mean_h,data.selected_vects); |
|
| 5389 |
+draw_vectors(vects,data.vector_h); |
|
| 5390 |
+ |
|
| 5391 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5392 |
+ |
|
| 5393 |
+%%% Subfunction: hist_eq %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5394 |
+ |
|
| 5395 |
+function hist_eq(varargin) |
|
| 5396 |
+ |
|
| 5397 |
+if nargin == 1 |
|
| 5398 |
+ LOG=1; |
|
| 5399 |
+else |
|
| 5400 |
+ LOG=0; |
|
| 5401 |
+end |
|
| 5402 |
+ |
|
| 5403 |
+data=get(gcf,'UserData'); |
|
| 5404 |
+sData=data.sData; |
|
| 5405 |
+undo=sData; |
|
| 5406 |
+INDEX=sData.INDEX; |
|
| 5407 |
+sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]);
|
|
| 5408 |
+ |
|
| 5409 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 5410 |
+ errordlg('There must be components chosen for ''Histogram eq''.');
|
|
| 5411 |
+ return; |
|
| 5412 |
+end |
|
| 5413 |
+ |
|
| 5414 |
+sData=som_normalize(sData,'histD',get_indices); |
|
| 5415 |
+ |
|
| 5416 |
+sData.INDEX=INDEX; |
|
| 5417 |
+sData.MODIFIED=1; |
|
| 5418 |
+ |
|
| 5419 |
+data.sData=sData; |
|
| 5420 |
+data.undo.sData=undo; |
|
| 5421 |
+if ~LOG |
|
| 5422 |
+ data.LOG{length(data.LOG)+1}='% Histogram eq';
|
|
| 5423 |
+ data.LOG{length(data.LOG)+1}='preprocess(''histeq'', ''foo'');';
|
|
| 5424 |
+end |
|
| 5425 |
+set(gcf,'UserData',data); |
|
| 5426 |
+ |
|
| 5427 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 5428 |
+vects(data.selected_vects)=1; |
|
| 5429 |
+ |
|
| 5430 |
+cplot_mimema; |
|
| 5431 |
+plot_hist; |
|
| 5432 |
+vect_means(sData,data.vect_mean_h,data.selected_vects); |
|
| 5433 |
+draw_vectors(vects,data.vector_h); |
|
| 5434 |
+ |
|
| 5435 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5436 |
+ |
|
| 5437 |
+%%% Subfunction: hist_eq2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5438 |
+ |
|
| 5439 |
+function hist_eq2(varargin) |
|
| 5440 |
+ |
|
| 5441 |
+if nargin == 1 |
|
| 5442 |
+ LOG=1; |
|
| 5443 |
+else |
|
| 5444 |
+ LOG=0; |
|
| 5445 |
+end |
|
| 5446 |
+ |
|
| 5447 |
+ |
|
| 5448 |
+data=get(gcf,'UserData'); |
|
| 5449 |
+sData=data.sData; |
|
| 5450 |
+undo=sData; |
|
| 5451 |
+ |
|
| 5452 |
+INDEX=sData.INDEX; |
|
| 5453 |
+sData=rmfield(sData,[{'INDEX'};{'MODIFIED'}]);
|
|
| 5454 |
+ |
|
| 5455 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 5456 |
+ errordlg('There must be components chosen for ''Histogram eq2''.');
|
|
| 5457 |
+ return; |
|
| 5458 |
+end |
|
| 5459 |
+ |
|
| 5460 |
+inds=get_indices; |
|
| 5461 |
+%%%[sData,ok]=som_normalize(sData,inds,'histC'); |
|
| 5462 |
+sData=som_normalize(sData,'histC',inds); |
|
| 5463 |
+sData.INDEX=INDEX; |
|
| 5464 |
+sData.MODIFIED=1; |
|
| 5465 |
+ |
|
| 5466 |
+data.sData=sData; |
|
| 5467 |
+data.undo.sData=undo; |
|
| 5468 |
+if ~LOG |
|
| 5469 |
+ data.LOG{length(data.LOG)+1}='% Histogram eq2';
|
|
| 5470 |
+ data.LOG{length(data.LOG)+1}='preprocess(''histeq2'', ''foo'');';
|
|
| 5471 |
+end |
|
| 5472 |
+set(gcf,'UserData',data); |
|
| 5473 |
+ |
|
| 5474 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 5475 |
+vects(data.selected_vects)=1; |
|
| 5476 |
+ |
|
| 5477 |
+cplot_mimema; |
|
| 5478 |
+plot_hist; |
|
| 5479 |
+vect_means(sData,data.vect_mean_h,data.selected_vects); |
|
| 5480 |
+draw_vectors(vects,data.vector_h); |
|
| 5481 |
+ |
|
| 5482 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5483 |
+ |
|
| 5484 |
+%%% Subfunction: logarithm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5485 |
+ |
|
| 5486 |
+function logarithm(varargin) |
|
| 5487 |
+ |
|
| 5488 |
+if nargin == 1 |
|
| 5489 |
+ LOG=1; |
|
| 5490 |
+else |
|
| 5491 |
+ LOG=0; |
|
| 5492 |
+end |
|
| 5493 |
+ |
|
| 5494 |
+data=get(gcf,'UserData'); |
|
| 5495 |
+sData=data.sData; |
|
| 5496 |
+undo=sData; |
|
| 5497 |
+ |
|
| 5498 |
+INDEX=sData.INDEX; |
|
| 5499 |
+sData=rmfield(sData,[{'INDEX'},{'MODIFIED'}]);
|
|
| 5500 |
+ |
|
| 5501 |
+if isempty(get(data.comp_names_h,'Value')) |
|
| 5502 |
+ errordlg('There must be components chosen for ''Log''.');
|
|
| 5503 |
+ return; |
|
| 5504 |
+end |
|
| 5505 |
+ |
|
| 5506 |
+Data=som_normalize(sData,'log',get_indices); |
|
| 5507 |
+ |
|
| 5508 |
+sData.INDEX=INDEX; |
|
| 5509 |
+sData.MODIFIED=1; |
|
| 5510 |
+ |
|
| 5511 |
+data.sData=sData; |
|
| 5512 |
+data.undo.sData=undo; |
|
| 5513 |
+if ~LOG |
|
| 5514 |
+ data.LOG{length(data.LOG)+1}='% Log';
|
|
| 5515 |
+ data.LOG{length(data.LOG)+1}='preprocess(''log'', ''foo'');';
|
|
| 5516 |
+end |
|
| 5517 |
+set(gcf,'UserData',data); |
|
| 5518 |
+ |
|
| 5519 |
+vects=zeros(1,length(sData.data(:,1))); |
|
| 5520 |
+vects(data.selected_vects)=1; |
|
| 5521 |
+ |
|
| 5522 |
+cplot_mimema; |
|
| 5523 |
+plot_hist; |
|
| 5524 |
+vect_means(sData,data.vect_mean_h,data.selected_vects); |
|
| 5525 |
+draw_vectors(vects,data.vector_h); |
|
| 5526 |
+ |
|
| 5527 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5528 |
+ |
|
| 5529 |
+function [answer,method]=build_expr(string,evaltype) |
|
| 5530 |
+ |
|
| 5531 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 5532 |
+ |
|
| 5533 |
+method=[]; |
|
| 5534 |
+if isempty(pre_h) |
|
| 5535 |
+ close_preprocess; |
|
| 5536 |
+ errordlg('''Preprocess'' -figure does not exist. Terminating program...');
|
|
| 5537 |
+ return; |
|
| 5538 |
+ |
|
| 5539 |
+end |
|
| 5540 |
+ |
|
| 5541 |
+if isempty(string) |
|
| 5542 |
+ str = '[]'; |
|
| 5543 |
+ return; |
|
| 5544 |
+end |
|
| 5545 |
+ |
|
| 5546 |
+tmp=[]; |
|
| 5547 |
+[name,assign,skip]=check_assign(string,evaltype); |
|
| 5548 |
+ |
|
| 5549 |
+if ~strcmp(assign,'NOTASSIGN') & ~strcmp(assign,'error') |
|
| 5550 |
+ string=string(skip:length(string)); |
|
| 5551 |
+end |
|
| 5552 |
+ |
|
| 5553 |
+if ~strcmp(assign,'error') |
|
| 5554 |
+ if isempty(string) |
|
| 5555 |
+ answer='Illegal expression.'; |
|
| 5556 |
+ return; |
|
| 5557 |
+ end |
|
| 5558 |
+ [str,skip]=check_token(string,evaltype); |
|
| 5559 |
+ method=string; |
|
| 5560 |
+ while ~strcmp(str,'error') & ~strcmp(tmp,'error') & skip < length(string) |
|
| 5561 |
+ if ~strcmp(tmp,')') |
|
| 5562 |
+ str=cat(2,str,tmp); |
|
| 5563 |
+ end |
|
| 5564 |
+ [tmp,skip2]=check_token(string(skip+1:length(string)),evaltype); |
|
| 5565 |
+ skip=skip+skip2; |
|
| 5566 |
+ |
|
| 5567 |
+ end |
|
| 5568 |
+ if ~strcmp(tmp,')') & ~strcmp(tmp,'error') |
|
| 5569 |
+ str=cat(2,str,tmp); |
|
| 5570 |
+ elseif strcmp(tmp,'error') |
|
| 5571 |
+ str='error'; |
|
| 5572 |
+ end |
|
| 5573 |
+end |
|
| 5574 |
+ |
|
| 5575 |
+if ~strcmp(assign,'error') & ~strcmp(str,'error'); |
|
| 5576 |
+ answer=evalin('caller',str,'lasterr');
|
|
| 5577 |
+else |
|
| 5578 |
+ answer='??? Illegal expression.'; |
|
| 5579 |
+end |
|
| 5580 |
+ |
|
| 5581 |
+ |
|
| 5582 |
+data=get(pre_h,'UserData'); |
|
| 5583 |
+sData=data.sData; |
|
| 5584 |
+if strcmp(assign,'NOTASSIGN') & strcmp(evaltype,'single') & ~isstr(answer) |
|
| 5585 |
+ if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) |
|
| 5586 |
+ errordlg('There are not components chosen.');
|
|
| 5587 |
+ answer='??? Illegal expression.'; |
|
| 5588 |
+ return; |
|
| 5589 |
+ end |
|
| 5590 |
+ index=getfield(get_indices,{1});
|
|
| 5591 |
+ if strcmp(assign,'NOTASSIGN') |
|
| 5592 |
+ if length(sData.data(:,index)) ~=length(answer) & ~isscalar(answer) |
|
| 5593 |
+ answer='??? Illegal assignment.'; |
|
| 5594 |
+ else |
|
| 5595 |
+ sData.data(:,index)=answer; |
|
| 5596 |
+ sData.MODIFIED=1; |
|
| 5597 |
+ data.sData=sData; |
|
| 5598 |
+ set(pre_h,'UserData',data); |
|
| 5599 |
+ end |
|
| 5600 |
+ else |
|
| 5601 |
+ if length(sData.data(str2num(assign),index)) ~=length(answer) & ~isscalar(answer) |
|
| 5602 |
+ answer='??? Illegal assignment.'; |
|
| 5603 |
+ else |
|
| 5604 |
+ sData.data(str2num(assign),index)=answer; |
|
| 5605 |
+ sData.MODIFIED=1; |
|
| 5606 |
+ data.sData=sData; |
|
| 5607 |
+ set(pre_h,'UserData',data); |
|
| 5608 |
+ end |
|
| 5609 |
+ end |
|
| 5610 |
+elseif ~strcmp(assign,'error') & ~isstr(answer) & ~strcmp(assign,'NOTASSIGN') |
|
| 5611 |
+ switch name |
|
| 5612 |
+ case 'x' |
|
| 5613 |
+ if isempty(get(data.comp_names_h,'Value')) |
|
| 5614 |
+ return; |
|
| 5615 |
+ end |
|
| 5616 |
+ index = getfield(get_indices,{1});
|
|
| 5617 |
+ if isempty(assign) |
|
| 5618 |
+ if length(sData.data(:,index)) ~= length(answer) & ~isscalar(answer) |
|
| 5619 |
+ answer='??? Illegal assignment.'; |
|
| 5620 |
+ else |
|
| 5621 |
+ sData.data(:,index)=answer; |
|
| 5622 |
+ sData.MODIFIED=1; |
|
| 5623 |
+ data.sData=sData; |
|
| 5624 |
+ if strcmp(evaltype,'multiple') |
|
| 5625 |
+ data.sData.comp_norm(index)={[]};
|
|
| 5626 |
+ end |
|
| 5627 |
+ set(pre_h,'UserData',data); |
|
| 5628 |
+ end |
|
| 5629 |
+ else |
|
| 5630 |
+ args=create_args(assign,'x'); |
|
| 5631 |
+ if length(args) == 1 |
|
| 5632 |
+ len=max(str2num(args{1}));
|
|
| 5633 |
+ if ~isscalar(len) |
|
| 5634 |
+ answer='??? Illegal assignment.'; |
|
| 5635 |
+ return; |
|
| 5636 |
+ elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
|
|
| 5637 |
+ answer='??? Illegal assignment.'; |
|
| 5638 |
+ return; |
|
| 5639 |
+ elseif ~all(size(sData.data(str2num(args{1}),index))) == size(answer) & ~isscalar(answer)
|
|
| 5640 |
+ answer='??? Illegal assignment.'; |
|
| 5641 |
+ return; |
|
| 5642 |
+ else |
|
| 5643 |
+ sData.data(str2num(args{1}),index)=answer;
|
|
| 5644 |
+ sData.MODIFIED=1; |
|
| 5645 |
+ data.sData=sData; |
|
| 5646 |
+ if strcmp(evaltype,'multiple') |
|
| 5647 |
+ data.sData.comp_norm(index)={[]};
|
|
| 5648 |
+ end |
|
| 5649 |
+ set(pre_h,'UserData',data); |
|
| 5650 |
+ end |
|
| 5651 |
+ else |
|
| 5652 |
+ len=max(str2num(args{1}));
|
|
| 5653 |
+ dim=max(str2num(args{2}));
|
|
| 5654 |
+ asize=size(answer); |
|
| 5655 |
+ msize=size(sData.data); |
|
| 5656 |
+ if ~isscalar(len) | ~isscalar(dim) |
|
| 5657 |
+ answer='??? Illegal assignment.'; |
|
| 5658 |
+ return; |
|
| 5659 |
+ elseif len > length(sData.data(:,1)) | len < 1 |
|
| 5660 |
+ answer='??? Illegal assignment.'; |
|
| 5661 |
+ return; |
|
| 5662 |
+ elseif dim > 1 | dim > msize(2) | min(str2num(args{2})) < 1
|
|
| 5663 |
+ answer='??? Illegal assignment.'; |
|
| 5664 |
+ return; |
|
| 5665 |
+ end |
|
| 5666 |
+ len=length(str2num(args{1}));
|
|
| 5667 |
+ dim=length(str2num(args{1}));
|
|
| 5668 |
+ if ~all([len dim] == asize) & ~isscalar(answer) |
|
| 5669 |
+ answer='??? Illegal assignment.'; |
|
| 5670 |
+ return; |
|
| 5671 |
+ else |
|
| 5672 |
+ tmp=sData.data(:,index); |
|
| 5673 |
+ tmp([str2num(args{1})],[str2num(args{2})])=answer;
|
|
| 5674 |
+ sData.data(:,index)=tmp; |
|
| 5675 |
+ sData.MODIFIED=1; |
|
| 5676 |
+ data.sData=sData; |
|
| 5677 |
+ if strcmp(evaltype,'multiple') |
|
| 5678 |
+ data.sData.comp_norm(index)={[]};
|
|
| 5679 |
+ end |
|
| 5680 |
+ set(pre_h,'UserData',data); |
|
| 5681 |
+ end |
|
| 5682 |
+ end |
|
| 5683 |
+ end |
|
| 5684 |
+ |
|
| 5685 |
+ case 'xs' |
|
| 5686 |
+ if isempty(get(data.comp_names_h,'Value')) |
|
| 5687 |
+ return; |
|
| 5688 |
+ end |
|
| 5689 |
+ indices=get_indices; |
|
| 5690 |
+ if isempty(assign) |
|
| 5691 |
+ if ~all(size(answer) == size(sData.data(:,indices))) & ~isscalar(answer) |
|
| 5692 |
+ answer='??? Illegal assignment.'; |
|
| 5693 |
+ else |
|
| 5694 |
+ sData.data(:,indices) = answer; |
|
| 5695 |
+ sData.MODIFIED=1; |
|
| 5696 |
+ data.sData=sData; |
|
| 5697 |
+ data.sData.comp_norm(indices)={[]};
|
|
| 5698 |
+ set(pre_h,'UserData',data); |
|
| 5699 |
+ end |
|
| 5700 |
+ else |
|
| 5701 |
+ args=create_args(assign,'xs'); |
|
| 5702 |
+ if length(args) == 1 |
|
| 5703 |
+ len=max(str2num(args{1}));
|
|
| 5704 |
+ if ~isscalar(len) |
|
| 5705 |
+ answer='??? Illegal assignment.'; |
|
| 5706 |
+ return; |
|
| 5707 |
+ elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
|
|
| 5708 |
+ answer='??? Illegal assignment.'; |
|
| 5709 |
+ return; |
|
| 5710 |
+ end |
|
| 5711 |
+ if ~all(size(answer) == size(sData.data(str2num(args{1})))) &...
|
|
| 5712 |
+ ~isscalar(answer) |
|
| 5713 |
+ answer='??? Illegal assignment.'; |
|
| 5714 |
+ return; |
|
| 5715 |
+ else |
|
| 5716 |
+ tmp=sData.data(:,indices); |
|
| 5717 |
+ tmp(str2num(args{1}))=answer;
|
|
| 5718 |
+ sData.data(:,indices)=tmp; |
|
| 5719 |
+ sData.MODIFIED=1; |
|
| 5720 |
+ sData.comp_norm{indices}={[]};
|
|
| 5721 |
+ data.sData=sData; |
|
| 5722 |
+ set(pre_h,'UserData',data); |
|
| 5723 |
+ end |
|
| 5724 |
+ else |
|
| 5725 |
+ len=max(str2num(args{1}));
|
|
| 5726 |
+ dim=max(str2num(args{2}));
|
|
| 5727 |
+ asize=size(answer); |
|
| 5728 |
+ msize=size(sData.data(:,indices)); |
|
| 5729 |
+ if ~isscalar(len) | ~isscalar(dim) |
|
| 5730 |
+ answer='??? Illegal assignment.'; |
|
| 5731 |
+ return; |
|
| 5732 |
+ elseif len > msize(1) | min(str2num(args{1})) < 1
|
|
| 5733 |
+ answer='??? Illegal assignment.'; |
|
| 5734 |
+ return; |
|
| 5735 |
+ elseif dim > msize(2) | min(str2num(args{2})) < 1
|
|
| 5736 |
+ answer='??? Illegal assignment.'; |
|
| 5737 |
+ return; |
|
| 5738 |
+ end |
|
| 5739 |
+ len=length(str2num(args{1}));
|
|
| 5740 |
+ dim=length(str2num(args{2}));
|
|
| 5741 |
+ if ~all([len dim] == asize) & ~isscalar(answer) |
|
| 5742 |
+ answer='??? Illegal assignment'; |
|
| 5743 |
+ return; |
|
| 5744 |
+ else |
|
| 5745 |
+ tmp=sData.data(:,indices); |
|
| 5746 |
+ tmp([str2num(args{1})],[str2num(args{2})])=answer;
|
|
| 5747 |
+ sData.MODIFIED=1; |
|
| 5748 |
+ sData.data(:,indices)=tmp; |
|
| 5749 |
+ data.sData=sData; |
|
| 5750 |
+ data.sData.comp_norm(indices)={[]};
|
|
| 5751 |
+ set(pre_h,'UserData',data); |
|
| 5752 |
+ end |
|
| 5753 |
+ |
|
| 5754 |
+ end |
|
| 5755 |
+ end |
|
| 5756 |
+ |
|
| 5757 |
+ case 'D' |
|
| 5758 |
+ if isempty(assign) |
|
| 5759 |
+ if ~all(size(answer) == size(sData.data)) & ~isscalar(answer) |
|
| 5760 |
+ answer='??? Illegal assignment.'; |
|
| 5761 |
+ else |
|
| 5762 |
+ if isscalar(answer) |
|
| 5763 |
+ sData.data(:,:)=answer; |
|
| 5764 |
+ else |
|
| 5765 |
+ sData.data=answer; |
|
| 5766 |
+ end |
|
| 5767 |
+ sData.MODIFIED=1; |
|
| 5768 |
+ data.sData=sData; |
|
| 5769 |
+ data.sData.comp_norm(1:length(sData.data(1,:)))={[]};
|
|
| 5770 |
+ set(pre_h,'UserData',data); |
|
| 5771 |
+ end |
|
| 5772 |
+ else |
|
| 5773 |
+ args=create_args(assign,'D'); |
|
| 5774 |
+ if length(args) == 1 |
|
| 5775 |
+ len=max(str2num(args{1}));
|
|
| 5776 |
+ if ~isscalar(len) |
|
| 5777 |
+ answer='??? Illegal assignment.'; |
|
| 5778 |
+ return; |
|
| 5779 |
+ elseif len > length(sData.data(:,1)) | min(str2num(args{1})) < 1
|
|
| 5780 |
+ answer='??? Illegal assignment.'; |
|
| 5781 |
+ return; |
|
| 5782 |
+ end |
|
| 5783 |
+ if ~all(size(answer) == size(sData.data(str2num(args{1})))) &...
|
|
| 5784 |
+ ~isscalar(answer) |
|
| 5785 |
+ answer='??? Illegal assignment.'; |
|
| 5786 |
+ else |
|
| 5787 |
+ sData.data(str2num(args{1}))=answer;
|
|
| 5788 |
+ sData.MODIFIED=1; |
|
| 5789 |
+ data.sData=sData; |
|
| 5790 |
+ [i,j]=ind2sub(size(sData.data),str2num(args{1}));
|
|
| 5791 |
+ data.sData.comp_norm(j)={[]};
|
|
| 5792 |
+ set(pre_h,'UserData',data); |
|
| 5793 |
+ end |
|
| 5794 |
+ else |
|
| 5795 |
+ len=max(str2num(args{1}));
|
|
| 5796 |
+ dim=max(str2num(args{2}));
|
|
| 5797 |
+ asize=size(answer); |
|
| 5798 |
+ msize=size(sData.data); |
|
| 5799 |
+ if ~isscalar(len) | ~isscalar(dim) |
|
| 5800 |
+ answer='??? Illegal assignment.'; |
|
| 5801 |
+ return; |
|
| 5802 |
+ elseif len > msize(1) | min(str2num(args{1})) < 1
|
|
| 5803 |
+ answer='??? Illegal assignment.'; |
|
| 5804 |
+ return; |
|
| 5805 |
+ elseif dim > msize(2) | min(str2num(args{2})) < 1
|
|
| 5806 |
+ answer= '??? Illegal assignment.'; |
|
| 5807 |
+ return; |
|
| 5808 |
+ end |
|
| 5809 |
+ len = length(str2num(args{1}));
|
|
| 5810 |
+ dim = length(str2num(args{2}));
|
|
| 5811 |
+ if ~all([len dim] == asize) & ~isscalar(answer) |
|
| 5812 |
+ answer='??? Illegal assignment.'; |
|
| 5813 |
+ return; |
|
| 5814 |
+ else |
|
| 5815 |
+ sData.data([str2num(args{1})],[str2num(args{2})])=answer;
|
|
| 5816 |
+ sData.MODIFIED=1; |
|
| 5817 |
+ data.sData=sData; |
|
| 5818 |
+ data.sData.comp_norm(str2num(args{2}))={[]};
|
|
| 5819 |
+ set(pre_h,'UserData',data); |
|
| 5820 |
+ end |
|
| 5821 |
+ end |
|
| 5822 |
+ end |
|
| 5823 |
+ end |
|
| 5824 |
+end |
|
| 5825 |
+if sData.MODIFIED |
|
| 5826 |
+ selected=getfield(get(pre_h,'UserData'),'selected_vects'); |
|
| 5827 |
+ vector_h=getfield(get(pre_h,'UserData'),'vector_h'); |
|
| 5828 |
+ vect_mean_h=getfield(get(pre_h,'UserData'),'vect_mean_h'); |
|
| 5829 |
+ vects=zeros(length(sData.data(:,1))); |
|
| 5830 |
+ vects(selected)=1; |
|
| 5831 |
+ draw_vectors(vects,vector_h); |
|
| 5832 |
+ vect_means(sData,vect_mean_h,selected); |
|
| 5833 |
+ pro_tools('plot_hist');
|
|
| 5834 |
+ pro_tools('c_stat');
|
|
| 5835 |
+ cplot_mimema; |
|
| 5836 |
+end |
|
| 5837 |
+ |
|
| 5838 |
+ |
|
| 5839 |
+%%% Subfunction: check_assign %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5840 |
+ |
|
| 5841 |
+function [name,string,skip]=check_assign(string,evaltype) |
|
| 5842 |
+ |
|
| 5843 |
+ |
|
| 5844 |
+reswords=[{'D'};{'x'};{'xs'}];
|
|
| 5845 |
+flag=0; |
|
| 5846 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 5847 |
+ |
|
| 5848 |
+if isempty(pre_h) |
|
| 5849 |
+ man_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 5850 |
+ clip_h=findobj(get(0,'Children'),'Tag','Clipping'); |
|
| 5851 |
+ errordlg('''Preprocess'' -window does not exist. Terminating program.');
|
|
| 5852 |
+ if ~isempty(man_h) |
|
| 5853 |
+ close man_h; |
|
| 5854 |
+ end |
|
| 5855 |
+ if ~isempty(clip_h) |
|
| 5856 |
+ close clip_h; |
|
| 5857 |
+ end |
|
| 5858 |
+ return; |
|
| 5859 |
+end |
|
| 5860 |
+ |
|
| 5861 |
+EMPTY=isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')); |
|
| 5862 |
+ |
|
| 5863 |
+[name,s]=give_token(string,evaltype); |
|
| 5864 |
+skip=length(s); |
|
| 5865 |
+ |
|
| 5866 |
+if strcmp(evaltype,'single') & ~strcmp(name,'x') |
|
| 5867 |
+ string='NOTASSIGN'; |
|
| 5868 |
+ return; |
|
| 5869 |
+end |
|
| 5870 |
+ |
|
| 5871 |
+if strcmp(name,'other') & ~strcmp(s,'x') |
|
| 5872 |
+ string = 'error'; |
|
| 5873 |
+ return; |
|
| 5874 |
+end |
|
| 5875 |
+ |
|
| 5876 |
+if strcmp(name,[{'x'};{'xs'}])
|
|
| 5877 |
+ comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 5878 |
+ if isempty(get(comp_names_h,'Value')) |
|
| 5879 |
+ errordlg('There are not components chosen.');
|
|
| 5880 |
+ string='error'; |
|
| 5881 |
+ return; |
|
| 5882 |
+ end |
|
| 5883 |
+end |
|
| 5884 |
+ |
|
| 5885 |
+ |
|
| 5886 |
+if skip == length(string) | ~strcmp(name,reswords) |
|
| 5887 |
+ string = 'NOTASSIGN'; |
|
| 5888 |
+ return; |
|
| 5889 |
+end |
|
| 5890 |
+ |
|
| 5891 |
+if (strcmp(name,'x') | strcmp(name,'xs')) & EMPTY |
|
| 5892 |
+ errordlg('There are not components chosen.');
|
|
| 5893 |
+ string = 'error'; |
|
| 5894 |
+ return; |
|
| 5895 |
+end |
|
| 5896 |
+ |
|
| 5897 |
+[t,s]=give_token(string(length(name)+1),evaltype); |
|
| 5898 |
+ |
|
| 5899 |
+if strcmp(t,'(')
|
|
| 5900 |
+ flag=1; |
|
| 5901 |
+end |
|
| 5902 |
+ |
|
| 5903 |
+[foo,skip]=check_token(string,evaltype); |
|
| 5904 |
+if length(name) ~= skip-1 |
|
| 5905 |
+ skip=skip-1; |
|
| 5906 |
+ tmp=string(length(name)+1:skip); |
|
| 5907 |
+else |
|
| 5908 |
+ tmp = []; |
|
| 5909 |
+end |
|
| 5910 |
+ |
|
| 5911 |
+if flag & tmp(length(tmp)) ~= ')' |
|
| 5912 |
+ tmp(length(tmp)+1)=')'; |
|
| 5913 |
+end |
|
| 5914 |
+ |
|
| 5915 |
+if skip==length(string) |
|
| 5916 |
+ return; |
|
| 5917 |
+end |
|
| 5918 |
+ |
|
| 5919 |
+skip=skip+1; |
|
| 5920 |
+if length(string) ~= skip |
|
| 5921 |
+ [t,s]=give_token(string(skip+1:length(string)),evaltype); |
|
| 5922 |
+else |
|
| 5923 |
+ string='NOTASSIGN'; |
|
| 5924 |
+ return; |
|
| 5925 |
+end |
|
| 5926 |
+ |
|
| 5927 |
+if ~strcmp(t,'=') |
|
| 5928 |
+ string = 'NOTASSIGN'; |
|
| 5929 |
+ return; |
|
| 5930 |
+end |
|
| 5931 |
+string=tmp; |
|
| 5932 |
+skip = skip+2; |
|
| 5933 |
+ |
|
| 5934 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5935 |
+ |
|
| 5936 |
+%%% Subfunction: isscalar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5937 |
+ |
|
| 5938 |
+function bool = isscalar(x) |
|
| 5939 |
+ |
|
| 5940 |
+ m= size(x); |
|
| 5941 |
+ |
|
| 5942 |
+ bool = m(1) == 1 & m(2) == 1; |
|
| 5943 |
+ |
|
| 5944 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5945 |
+ |
|
| 5946 |
+%%% Subfunction: create_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 5947 |
+ |
|
| 5948 |
+function args=create_args(string,type) |
|
| 5949 |
+ |
|
| 5950 |
+arg2=''; |
|
| 5951 |
+i=2; |
|
| 5952 |
+j=1; |
|
| 5953 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 5954 |
+msize=size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')); |
|
| 5955 |
+ |
|
| 5956 |
+ |
|
| 5957 |
+if string(i) == ':' |
|
| 5958 |
+ arg1=num2str(cat(2,'1:',num2str(msize(1)))); |
|
| 5959 |
+ i=i+1; |
|
| 5960 |
+ j=j+length(arg1); |
|
| 5961 |
+end |
|
| 5962 |
+ |
|
| 5963 |
+while string(i) ~=',' & string(i) ~=')' |
|
| 5964 |
+ arg1(j)=string(i); |
|
| 5965 |
+ i=i+1; |
|
| 5966 |
+ j=j+1; |
|
| 5967 |
+end |
|
| 5968 |
+ |
|
| 5969 |
+ |
|
| 5970 |
+ |
|
| 5971 |
+if string(i) ==',' |
|
| 5972 |
+ j=1; |
|
| 5973 |
+ i=i+1; |
|
| 5974 |
+ if string(i)==':' |
|
| 5975 |
+ switch type |
|
| 5976 |
+ case 'x' |
|
| 5977 |
+ arg2='1'; |
|
| 5978 |
+ case 'cs' |
|
| 5979 |
+ arg2=num2str(get_indices); |
|
| 5980 |
+ case 'D' |
|
| 5981 |
+ arg2=num2str(cat(2,'1:',num2str(msize(2)))); |
|
| 5982 |
+ end |
|
| 5983 |
+ i=i+1; |
|
| 5984 |
+ j=j+length(arg2); |
|
| 5985 |
+ end |
|
| 5986 |
+ |
|
| 5987 |
+ while string(i) ~= ')' |
|
| 5988 |
+ arg2(j)=string(i); |
|
| 5989 |
+ j=j+1; |
|
| 5990 |
+ i=i+1; |
|
| 5991 |
+ end |
|
| 5992 |
+end |
|
| 5993 |
+ |
|
| 5994 |
+ |
|
| 5995 |
+args{1}=arg1;
|
|
| 5996 |
+if ~isempty(arg2) |
|
| 5997 |
+ args{2} = arg2;
|
|
| 5998 |
+end |
|
| 5999 |
+ |
|
| 6000 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6001 |
+ |
|
| 6002 |
+function [str,skip] = check_token(string,evaltype) |
|
| 6003 |
+ |
|
| 6004 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6005 |
+ |
|
| 6006 |
+tmp_string=string; |
|
| 6007 |
+[t,s]=give_token(tmp_string,evaltype); |
|
| 6008 |
+skip=length(s); |
|
| 6009 |
+ |
|
| 6010 |
+if strcmp(t,'c') |
|
| 6011 |
+ if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) |
|
| 6012 |
+ errordlg('There are no components chosen.');
|
|
| 6013 |
+ str='error'; |
|
| 6014 |
+ return; |
|
| 6015 |
+ end |
|
| 6016 |
+ index=getfield(get_indices,{1});
|
|
| 6017 |
+ str=cat(2,'[',num2str(index),']'); |
|
| 6018 |
+ if skip == length(tmp_string) |
|
| 6019 |
+ return; |
|
| 6020 |
+ end |
|
| 6021 |
+ tmp_string=tmp_string(skip+1:length(tmp_string)); |
|
| 6022 |
+ [t,s] = give_token(tmp_string,evaltype); |
|
| 6023 |
+ if ~strcmp(t,'(')
|
|
| 6024 |
+ return; |
|
| 6025 |
+ end |
|
| 6026 |
+ [args,skip2] = get_args(tmp_string(length(s)+1:length(tmp_string)),'c',... |
|
| 6027 |
+ evaltype); |
|
| 6028 |
+ skip=skip+skip2+2; |
|
| 6029 |
+ if strcmp(args,'error') |
|
| 6030 |
+ str = 'error' |
|
| 6031 |
+ return; |
|
| 6032 |
+ elseif ~strcmp(args,'all') |
|
| 6033 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6034 |
+ else |
|
| 6035 |
+ str=cat(2,'getfield(',str,',{[1]})');
|
|
| 6036 |
+ end |
|
| 6037 |
+elseif strcmp(t,'cs') |
|
| 6038 |
+ if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) |
|
| 6039 |
+ errordlg('There are no components chosen.');
|
|
| 6040 |
+ str='error'; |
|
| 6041 |
+ return; |
|
| 6042 |
+ end |
|
| 6043 |
+ str =cat(2,'[',num2str(get_indices),']'); |
|
| 6044 |
+ if length(s) == length(string) |
|
| 6045 |
+ return; |
|
| 6046 |
+ end |
|
| 6047 |
+ tmp_string=tmp_string(1+length(s):length(string)); |
|
| 6048 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6049 |
+ if ~strcmp(t,'(')
|
|
| 6050 |
+ return; |
|
| 6051 |
+ else |
|
| 6052 |
+ [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'cs',... |
|
| 6053 |
+ evaltype); |
|
| 6054 |
+ skip=2+skip+skip2; |
|
| 6055 |
+ if strcmp(args,'error') |
|
| 6056 |
+ str='error'; |
|
| 6057 |
+ return; |
|
| 6058 |
+ elseif ~strcmp(args,'all') |
|
| 6059 |
+ str = cat(2,'getfield(',str,',',args,')');
|
|
| 6060 |
+ else |
|
| 6061 |
+ tmp_str=str; |
|
| 6062 |
+ str=cat(2,'[getfield(',str,',','{1})');
|
|
| 6063 |
+ for i=2:length(get_indices) |
|
| 6064 |
+ str=cat(2,str,';getfield(',tmp_str,',',sprintf('{%d})',i));
|
|
| 6065 |
+ end |
|
| 6066 |
+ str=cat(2,str,']'); |
|
| 6067 |
+ end |
|
| 6068 |
+ end |
|
| 6069 |
+elseif strcmp(t,'dim') |
|
| 6070 |
+ ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{2});
|
|
| 6071 |
+ str=cat(2,'[',num2str(ind1),']'); |
|
| 6072 |
+ if length(s)==length(string) |
|
| 6073 |
+ return; |
|
| 6074 |
+ end |
|
| 6075 |
+ tmp_string=string(1+length(s):length(string)); |
|
| 6076 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6077 |
+ if ~strcmp(t,'(')
|
|
| 6078 |
+ return; |
|
| 6079 |
+ end |
|
| 6080 |
+ skip=1+skip+length(s); |
|
| 6081 |
+ [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dim',... |
|
| 6082 |
+ evaltype); |
|
| 6083 |
+ if strcmp(args,'error') |
|
| 6084 |
+ str = 'error'; |
|
| 6085 |
+ return; |
|
| 6086 |
+ else |
|
| 6087 |
+ skip=skip+skip2; |
|
| 6088 |
+ if ~strcmp(args,'all') |
|
| 6089 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6090 |
+ end |
|
| 6091 |
+ end |
|
| 6092 |
+ |
|
| 6093 |
+elseif strcmp(t,'dlen') |
|
| 6094 |
+ ind1=getfield(size(getfield(getfield(get(pre_h,'UserData'),'sData'),'data')),{1});
|
|
| 6095 |
+ str=cat(2,'[',num2str(ind1),']'); |
|
| 6096 |
+ if length(s)==length(string) |
|
| 6097 |
+ return; |
|
| 6098 |
+ end |
|
| 6099 |
+ tmp_string=string(1+length(s):length(string)); |
|
| 6100 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6101 |
+ if ~strcmp(t,'(')
|
|
| 6102 |
+ return; |
|
| 6103 |
+ end |
|
| 6104 |
+ skip=skip+length(s); |
|
| 6105 |
+ [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'dlen',... |
|
| 6106 |
+ evaltype); |
|
| 6107 |
+ if strcmp(args,'error') |
|
| 6108 |
+ str='error'; |
|
| 6109 |
+ return; |
|
| 6110 |
+ else |
|
| 6111 |
+ skip=1+skip+skip2; |
|
| 6112 |
+ if ~strcmp(args,'all') |
|
| 6113 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6114 |
+ end |
|
| 6115 |
+ end |
|
| 6116 |
+ |
|
| 6117 |
+elseif strcmp(t,'x') |
|
| 6118 |
+ if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) |
|
| 6119 |
+ errordlg('There are not components chosen.');
|
|
| 6120 |
+ str='error'; |
|
| 6121 |
+ return; |
|
| 6122 |
+ end |
|
| 6123 |
+ len=getfield(size(getfield(getfield(get(pre_h,'UserData'),... |
|
| 6124 |
+ 'sData'),'data')),{1});
|
|
| 6125 |
+ index=num2str(getfield(get_indices,{1}));
|
|
| 6126 |
+ h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; |
|
| 6127 |
+ get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')');
|
|
| 6128 |
+ get_str=cat(2,'getfield(',get_str,',''data'')');
|
|
| 6129 |
+ str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})');
|
|
| 6130 |
+ if length(s) == length(string) |
|
| 6131 |
+ return; |
|
| 6132 |
+ end |
|
| 6133 |
+ tmp_string=string(1+length(s):length(string)); |
|
| 6134 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6135 |
+ if ~strcmp(t,'(');
|
|
| 6136 |
+ return; |
|
| 6137 |
+ end |
|
| 6138 |
+ skip=skip+length(s); |
|
| 6139 |
+ [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'x',... |
|
| 6140 |
+ evaltype); |
|
| 6141 |
+ if strcmp(args,'error') |
|
| 6142 |
+ str = 'error'; |
|
| 6143 |
+ return; |
|
| 6144 |
+ else |
|
| 6145 |
+ skip=1+skip+skip2; |
|
| 6146 |
+ if ~strcmp(args,'all') |
|
| 6147 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6148 |
+ end |
|
| 6149 |
+ end |
|
| 6150 |
+ |
|
| 6151 |
+elseif strcmp(t,'xs') |
|
| 6152 |
+ if isempty(get(getfield(get(pre_h,'UserData'),'comp_names_h'),'Value')) |
|
| 6153 |
+ errordlg('There are not components chosen.');
|
|
| 6154 |
+ str='error'; |
|
| 6155 |
+ return; |
|
| 6156 |
+ end |
|
| 6157 |
+ len=getfield(size(getfield(getfield(get(pre_h,'UserData'),... |
|
| 6158 |
+ 'sData'),'data')),{1});
|
|
| 6159 |
+ index=get_indices; |
|
| 6160 |
+ index=cat(2,'[',num2str(index),']'); |
|
| 6161 |
+ h_str='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; |
|
| 6162 |
+ get_str=cat(2,'getfield(get(',h_str,',''UserData''),''sData'')');
|
|
| 6163 |
+ get_str=cat(2,'getfield(',get_str,',''data'')');
|
|
| 6164 |
+ str=cat(2,'getfield(',get_str,',{[1:',num2str(len),'],',index,'})');
|
|
| 6165 |
+ if length(s) == length(string) |
|
| 6166 |
+ return; |
|
| 6167 |
+ end |
|
| 6168 |
+ tmp_string=string(1+length(s):length(string)); |
|
| 6169 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6170 |
+ if ~strcmp(t,'(')
|
|
| 6171 |
+ return; |
|
| 6172 |
+ end |
|
| 6173 |
+ skip=1+skip+length(s); |
|
| 6174 |
+ |
|
| 6175 |
+ [args,skip2]=get_args(tmp_string(1+length(s):length(tmp_string)),'xs',... |
|
| 6176 |
+ evaltype); |
|
| 6177 |
+ if strcmp(args,'error') |
|
| 6178 |
+ str = 'error'; |
|
| 6179 |
+ return; |
|
| 6180 |
+ elseif ~strcmp(args,'all') |
|
| 6181 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6182 |
+ skip=skip+skip2; |
|
| 6183 |
+ else |
|
| 6184 |
+ skip=skip+skip2; |
|
| 6185 |
+ [dlen,dim]=size(eval(str)); |
|
| 6186 |
+ tmp_str=str; |
|
| 6187 |
+ str=cat(2,'[','getfield(',tmp_str,sprintf(',{1:%d,1})',dlen));
|
|
| 6188 |
+ for i=2:dim |
|
| 6189 |
+ tmp=sprintf(',{1:%d,%d})',dlen,dim);
|
|
| 6190 |
+ str=cat(2,str,';','getfield(',tmp_str,tmp);
|
|
| 6191 |
+ end |
|
| 6192 |
+ str=cat(2,str,']'); |
|
| 6193 |
+ end |
|
| 6194 |
+elseif strcmp(t,'D') |
|
| 6195 |
+ get_h='findobj(get(0,''Children''),''Tag'',''Preprocess'')'; |
|
| 6196 |
+ str=cat(2,'getfield(getfield(get(',get_h,',''UserData''),''sData''),''data'')');
|
|
| 6197 |
+ |
|
| 6198 |
+ if length(s) >= length(tmp_string) |
|
| 6199 |
+ return; |
|
| 6200 |
+ end |
|
| 6201 |
+ |
|
| 6202 |
+ tmp_string=tmp_string(1+length(s):length(tmp_string)); |
|
| 6203 |
+ [t,s]=give_token(tmp_string,evaltype); |
|
| 6204 |
+ if ~strcmp(t,'(')
|
|
| 6205 |
+ return; |
|
| 6206 |
+ else |
|
| 6207 |
+ tmp_string=tmp_string(1+length(s):length(tmp_string)); |
|
| 6208 |
+ skip = skip+length(s); |
|
| 6209 |
+ [args, skip2]=get_args(tmp_string,'D',evaltype); |
|
| 6210 |
+ if strcmp(args,'error') |
|
| 6211 |
+ str='error'; |
|
| 6212 |
+ return; |
|
| 6213 |
+ elseif ~strcmp(args,'all') |
|
| 6214 |
+ str=cat(2,'getfield(',str,',',args,')');
|
|
| 6215 |
+ skip=1+skip+skip2; |
|
| 6216 |
+ else |
|
| 6217 |
+ skip=1+skip+skip2; |
|
| 6218 |
+ [dlen,dim]=size(eval(str)); |
|
| 6219 |
+ tmp_str=str; |
|
| 6220 |
+ str=cat(2,'[getfield(',str,sprintf(',{1:%d,1})',dlen));
|
|
| 6221 |
+ for i=2:dim |
|
| 6222 |
+ tmp=sprintf(',{1:%d,%d}',dlen,i);
|
|
| 6223 |
+ str=cat(2,str,';getfield(',tmp_str,tmp,')');
|
|
| 6224 |
+ end |
|
| 6225 |
+ str=cat(2,str,']'); |
|
| 6226 |
+ end |
|
| 6227 |
+ end |
|
| 6228 |
+else |
|
| 6229 |
+ if strcmp(t,'(')
|
|
| 6230 |
+ str = t; |
|
| 6231 |
+ str2=''; |
|
| 6232 |
+ tmp_string=tmp_string(1+length(s):length(tmp_string)); |
|
| 6233 |
+ while ~strcmp(str2,')') & ~isempty(tmp_string) |
|
| 6234 |
+ [str2,skip2]=check_token(tmp_string,evaltype); |
|
| 6235 |
+ if strcmp(str2,'error') |
|
| 6236 |
+ str='error'; |
|
| 6237 |
+ return; |
|
| 6238 |
+ end |
|
| 6239 |
+ skip=skip+skip2; |
|
| 6240 |
+ tmp_string=tmp_string(skip2+1:length(tmp_string)); |
|
| 6241 |
+ str=cat(2,str,str2); |
|
| 6242 |
+ end |
|
| 6243 |
+ if ~strcmp(str2,')') |
|
| 6244 |
+ str = 'error'; |
|
| 6245 |
+ end |
|
| 6246 |
+ else |
|
| 6247 |
+ str = s; |
|
| 6248 |
+ end |
|
| 6249 |
+end |
|
| 6250 |
+ |
|
| 6251 |
+%%% Subfunction: get_args %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6252 |
+ |
|
| 6253 |
+function [str,skip] = get_args(string,flag,evaltype) |
|
| 6254 |
+ |
|
| 6255 |
+res_words=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'}];
|
|
| 6256 |
+NOTALL=1; |
|
| 6257 |
+if isempty(string) |
|
| 6258 |
+ str='error' |
|
| 6259 |
+ skip=[]; |
|
| 6260 |
+ return; |
|
| 6261 |
+end |
|
| 6262 |
+[t,s] = give_token(string,evaltype); |
|
| 6263 |
+ |
|
| 6264 |
+ |
|
| 6265 |
+skip=length(s); |
|
| 6266 |
+if any(strcmp(t,res_words)); |
|
| 6267 |
+ [str,skip2] = check_token(string,evaltype); |
|
| 6268 |
+ string=string(1+length(s):length(string)); |
|
| 6269 |
+ str=cat(2,'{[',str);
|
|
| 6270 |
+ [t,s]=give_token(string,evaltype); |
|
| 6271 |
+elseif t==')' | t==',' |
|
| 6272 |
+ str = 'error'; |
|
| 6273 |
+ return; |
|
| 6274 |
+elseif strcmp(t,':'); |
|
| 6275 |
+ if length(s) == length(string) |
|
| 6276 |
+ str='error'; |
|
| 6277 |
+ return; |
|
| 6278 |
+ end |
|
| 6279 |
+ [t,s]=give_token(string(1+length(s):length(string)),evaltype); |
|
| 6280 |
+ if t == ')' |
|
| 6281 |
+ str = 'all'; |
|
| 6282 |
+ return; |
|
| 6283 |
+ end |
|
| 6284 |
+ switch flag |
|
| 6285 |
+ case {'c','cs','dim','dlen'}
|
|
| 6286 |
+ str= '{[1';
|
|
| 6287 |
+ otherwise |
|
| 6288 |
+ str=cat(2,'{[',get_all('vect'));
|
|
| 6289 |
+ end |
|
| 6290 |
+ NOTALL=0; |
|
| 6291 |
+ string=string(1+length(s):length(string)); |
|
| 6292 |
+ [t,s]=give_token(string,evaltype); |
|
| 6293 |
+ skip=skip+1; |
|
| 6294 |
+else |
|
| 6295 |
+ str = cat(2,'{[',s);
|
|
| 6296 |
+end |
|
| 6297 |
+str2 =[]; |
|
| 6298 |
+ |
|
| 6299 |
+ |
|
| 6300 |
+if ~strcmp(t,',') & ~strcmp(t,')') |
|
| 6301 |
+ skip=skip-length(s); |
|
| 6302 |
+end |
|
| 6303 |
+ |
|
| 6304 |
+ |
|
| 6305 |
+ |
|
| 6306 |
+while ~strcmp(t,',') & ~strcmp(t,')') & NOTALL; |
|
| 6307 |
+ str=cat(2,str,str2); |
|
| 6308 |
+ [t,s] = give_token(string,evaltype); |
|
| 6309 |
+ if length(s) == length(string) |
|
| 6310 |
+ str = 'error'; |
|
| 6311 |
+ return; |
|
| 6312 |
+ end |
|
| 6313 |
+ string=string(1+length(s):length(string)); |
|
| 6314 |
+ skip=skip+length(s); |
|
| 6315 |
+ [t,s]=give_token(string,evaltype); |
|
| 6316 |
+ if length(s) == length(string) & ~strcmp(t,')') |
|
| 6317 |
+ str = 'error'; |
|
| 6318 |
+ return; |
|
| 6319 |
+ end |
|
| 6320 |
+ |
|
| 6321 |
+ [str2,foo]=check_token(string,evaltype); |
|
| 6322 |
+end |
|
| 6323 |
+ |
|
| 6324 |
+if NOTALL & ~strcmp(t,')') |
|
| 6325 |
+ skip=skip+1; |
|
| 6326 |
+end |
|
| 6327 |
+ |
|
| 6328 |
+if strcmp(t,')') |
|
| 6329 |
+ str=cat(2,str,']}'); |
|
| 6330 |
+ return |
|
| 6331 |
+end |
|
| 6332 |
+ |
|
| 6333 |
+str=cat(2,str,']',',','['); |
|
| 6334 |
+str2 = []; |
|
| 6335 |
+ |
|
| 6336 |
+ |
|
| 6337 |
+[t,s] = give_token(string,evaltype); |
|
| 6338 |
+if strcmp(t,')') |
|
| 6339 |
+ str = 'error' |
|
| 6340 |
+ return; |
|
| 6341 |
+end |
|
| 6342 |
+NOTALL=1; |
|
| 6343 |
+string=string(1+length(s):length(string)); |
|
| 6344 |
+[t,s]=give_token(string,evaltype); |
|
| 6345 |
+if strcmp(t,':'); |
|
| 6346 |
+ switch flag |
|
| 6347 |
+ case {'c','dim','dlen','x'}
|
|
| 6348 |
+ str=cat(2,str,'1'); |
|
| 6349 |
+ case 'D' |
|
| 6350 |
+ str=cat(2,str,get_all('comp'));
|
|
| 6351 |
+ case {'cs','xs'}
|
|
| 6352 |
+ str=cat(2,str,'1:',num2str(length(get_indices))); |
|
| 6353 |
+ end |
|
| 6354 |
+ NOTALL=0; |
|
| 6355 |
+ if length(s) == length(string) |
|
| 6356 |
+ str='error'; |
|
| 6357 |
+ return; |
|
| 6358 |
+ end |
|
| 6359 |
+ string=string(1+length(s):length(string)); |
|
| 6360 |
+ [t,s]=give_token(string,evaltype); |
|
| 6361 |
+end |
|
| 6362 |
+ |
|
| 6363 |
+if ~strcmp(t,')') & NOTALL |
|
| 6364 |
+ skip=skip-1; |
|
| 6365 |
+end |
|
| 6366 |
+ |
|
| 6367 |
+while ~strcmp(t,')') & NOTALL |
|
| 6368 |
+ str=cat(2,str,str2); |
|
| 6369 |
+ skip=skip+length(s); |
|
| 6370 |
+ if length(s) == length(string) & ~strcmp(t,')') |
|
| 6371 |
+ str='error'; |
|
| 6372 |
+ return; |
|
| 6373 |
+ end |
|
| 6374 |
+ [str2,foo]=check_token(string,evaltype); |
|
| 6375 |
+ string=string(1+length(s):length(string)); |
|
| 6376 |
+ [t,s]=give_token(string,evaltype); |
|
| 6377 |
+end |
|
| 6378 |
+if ~strcmp(t,')') |
|
| 6379 |
+ str='error'; |
|
| 6380 |
+ return; |
|
| 6381 |
+end |
|
| 6382 |
+ |
|
| 6383 |
+ |
|
| 6384 |
+str=cat(2,str,str2,']}'); |
|
| 6385 |
+skip=skip+length(s); |
|
| 6386 |
+ |
|
| 6387 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6388 |
+ |
|
| 6389 |
+%%% Subfunction: get_all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6390 |
+ |
|
| 6391 |
+function str=get_all(vect_or_comp) |
|
| 6392 |
+ |
|
| 6393 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6394 |
+ |
|
| 6395 |
+switch vect_or_comp |
|
| 6396 |
+ case 'vect' |
|
| 6397 |
+ dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),... |
|
| 6398 |
+ 'sData'),'data')),{1});
|
|
| 6399 |
+ str=cat(2,'1:',num2str(dim)); |
|
| 6400 |
+ case 'comp' |
|
| 6401 |
+ dim=getfield(size(getfield(getfield(get(pre_h,'UserData'),... |
|
| 6402 |
+ 'sData'),'data')),{2});
|
|
| 6403 |
+ str=cat(2,'1:',num2str(dim)); |
|
| 6404 |
+end |
|
| 6405 |
+ |
|
| 6406 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6407 |
+ |
|
| 6408 |
+function [token,str]=give_token(string,evaltype) |
|
| 6409 |
+ |
|
| 6410 |
+n=length(string); |
|
| 6411 |
+i=1; |
|
| 6412 |
+char=string(i); |
|
| 6413 |
+ |
|
| 6414 |
+switch analyze_char(string(i)); |
|
| 6415 |
+ case 'num' |
|
| 6416 |
+ token='num'; |
|
| 6417 |
+ while i <= n & strcmp('num',analyze_char(string(i)))
|
|
| 6418 |
+ str(i)=string(i); |
|
| 6419 |
+ i=i+1; |
|
| 6420 |
+ end |
|
| 6421 |
+ case 'other' |
|
| 6422 |
+ switch string(i) |
|
| 6423 |
+ case ':' |
|
| 6424 |
+ token = ':'; |
|
| 6425 |
+ case ',' |
|
| 6426 |
+ token = ','; |
|
| 6427 |
+ case '('
|
|
| 6428 |
+ token = '(';
|
|
| 6429 |
+ case ')' |
|
| 6430 |
+ token = ')'; |
|
| 6431 |
+ case '=' |
|
| 6432 |
+ token = '='; |
|
| 6433 |
+ otherwise |
|
| 6434 |
+ token='other'; |
|
| 6435 |
+ end |
|
| 6436 |
+ str=string(i); |
|
| 6437 |
+ case 'alpha' |
|
| 6438 |
+ while i <= n & strcmp('alpha',analyze_char(string(i)))
|
|
| 6439 |
+ str(i)=string(i); |
|
| 6440 |
+ i=i+1; |
|
| 6441 |
+ end |
|
| 6442 |
+ token = find_res_word(str,evaltype); |
|
| 6443 |
+end |
|
| 6444 |
+ |
|
| 6445 |
+%%% Subfunction: analyze_char %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6446 |
+ |
|
| 6447 |
+function type=analyze_char(char) |
|
| 6448 |
+ |
|
| 6449 |
+ |
|
| 6450 |
+if ((char-0) >= ('0'-0) & (char-0) <= ('9'-0))
|
|
| 6451 |
+ type='num'; |
|
| 6452 |
+elseif ((char-0) >= ('a'-0) & (char-0) <= ('z'-0)) ...
|
|
| 6453 |
+ | ((char-0) >= ('A'-0) & (char-0) <= ('Z'-0))
|
|
| 6454 |
+ type='alpha'; |
|
| 6455 |
+else |
|
| 6456 |
+ type='other'; |
|
| 6457 |
+end |
|
| 6458 |
+ |
|
| 6459 |
+ |
|
| 6460 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6461 |
+ |
|
| 6462 |
+%%% Subfunction: find_res_word %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6463 |
+ |
|
| 6464 |
+function token = find_res_word(string,evaltype) |
|
| 6465 |
+ |
|
| 6466 |
+reswords=[{'D'};{'c'};{'cs'};{'dim'};{'dlen'};{'x'};{'xs'};{'other'}];
|
|
| 6467 |
+ |
|
| 6468 |
+for i=1:length(reswords); |
|
| 6469 |
+ token=reswords{i};
|
|
| 6470 |
+ if strcmp(string,reswords{i})
|
|
| 6471 |
+ if strcmp(evaltype,'single') & ~strcmp(string,'x') |
|
| 6472 |
+ token = 'other'; |
|
| 6473 |
+ end |
|
| 6474 |
+ return; |
|
| 6475 |
+ end |
|
| 6476 |
+end |
|
| 6477 |
+ |
|
| 6478 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6479 |
+ |
|
| 6480 |
+function close_func(varargin) |
|
| 6481 |
+ |
|
| 6482 |
+switch varargin{1}
|
|
| 6483 |
+ case 'close_c' |
|
| 6484 |
+ str='% Closing the ''Clipping'' -window...'; |
|
| 6485 |
+ clip_h=findobj(get(0,'Children'),'Tag','Clipping'); |
|
| 6486 |
+ close(clip_h); |
|
| 6487 |
+ case 'close_sD' |
|
| 6488 |
+ str='% Closing the ''Data Set Management'' -window...'; |
|
| 6489 |
+ sD_h=findobj(get(0,'Children'),'Tag','Management'); |
|
| 6490 |
+ close(sD_h); |
|
| 6491 |
+ case 'close_w' |
|
| 6492 |
+ str='% Closing the ''Windowed'' -window...'; |
|
| 6493 |
+ win_h=findobj(get(0,'Children'),'Tag','Window'); |
|
| 6494 |
+ close(win_h); |
|
| 6495 |
+ case 'close_s' |
|
| 6496 |
+ str='% Closing the ''Select'' -window...'; |
|
| 6497 |
+ sel_h=findobj(get(0,'Children'),'Tag','Select'); |
|
| 6498 |
+ close(sel_h); |
|
| 6499 |
+ case 'close_d' |
|
| 6500 |
+ str='% Closing the ''Delay'' -window...'; |
|
| 6501 |
+ del_h=findobj(get(0,'Children'),'Tag','Delay'); |
|
| 6502 |
+ close(del_h); |
|
| 6503 |
+end |
|
| 6504 |
+ |
|
| 6505 |
+if nargin ~= 2 |
|
| 6506 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6507 |
+ preh_udata=get(pre_h,'UserData'); |
|
| 6508 |
+ str2=cat(2,'preprocess(''',varargin{1},''',''foo'');');
|
|
| 6509 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=str;
|
|
| 6510 |
+ preh_udata.LOG{length(preh_udata.LOG)+1}=str2;
|
|
| 6511 |
+ set(pre_h,'UserData',preh_udata); |
|
| 6512 |
+end |
|
| 6513 |
+ |
|
| 6514 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6515 |
+ |
|
| 6516 |
+function log_file |
|
| 6517 |
+ |
|
| 6518 |
+answer=inputdlg('Give the name of the outputfile:','LOG function',1,...
|
|
| 6519 |
+ {'log_function'});
|
|
| 6520 |
+ |
|
| 6521 |
+if isempty(answer) |
|
| 6522 |
+ return; |
|
| 6523 |
+end |
|
| 6524 |
+ |
|
| 6525 |
+ |
|
| 6526 |
+tmp=clock; |
|
| 6527 |
+str =cat(2,'% Created: ',... |
|
| 6528 |
+ date,... |
|
| 6529 |
+ ' ',sprintf('%d:%d\n%\n\n',tmp(4),tmp(5)));
|
|
| 6530 |
+pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6531 |
+LOG=getfield(get(pre_h,'UserData'),'LOG'); |
|
| 6532 |
+file=cat(2,pwd,'/',answer{1},'.m');
|
|
| 6533 |
+fid =fopen(file,'w'); |
|
| 6534 |
+ |
|
| 6535 |
+arg=LOG{2}(12:length(LOG{2})-2);
|
|
| 6536 |
+fprintf(fid,'%s\n \n',cat(2,'function ',answer{1},'(',arg,')'));
|
|
| 6537 |
+fprintf(fid,'%s\n',str); |
|
| 6538 |
+for i=1:length(LOG) |
|
| 6539 |
+ fprintf(fid,'%s\n',LOG{i});
|
|
| 6540 |
+end |
|
| 6541 |
+fclose(fid); |
|
| 6542 |
+disp(sprintf('LOG-file ''%s'' is done.',file));
|
|
| 6543 |
+ |
|
| 6544 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6545 |
+ |
|
| 6546 |
+function get_selected_inds(varargin) |
|
| 6547 |
+ |
|
| 6548 |
+if nargin == 1 |
|
| 6549 |
+ LOG=1; |
|
| 6550 |
+ answer = {varargin{1}};
|
|
| 6551 |
+else |
|
| 6552 |
+ LOG=0; |
|
| 6553 |
+end |
|
| 6554 |
+ |
|
| 6555 |
+selected=getfield(get(gcf,'UserData'),'selected_vects'); |
|
| 6556 |
+if ~LOG |
|
| 6557 |
+ answer=inputdlg('Give the name of the output variable:',...
|
|
| 6558 |
+ '',1,{'indices'});
|
|
| 6559 |
+end |
|
| 6560 |
+ |
|
| 6561 |
+if isempty(answer) | isempty(answer{1})
|
|
| 6562 |
+ return; |
|
| 6563 |
+else |
|
| 6564 |
+ assignin('base',answer{1},selected);
|
|
| 6565 |
+ disp(cat(2,'Indices of the selected vectors are set to the workspace ',... |
|
| 6566 |
+ sprintf(' as ''%s''.',answer{1})));
|
|
| 6567 |
+ if ~LOG |
|
| 6568 |
+ data=get(gcf,'UserData'); |
|
| 6569 |
+ data.LOG{length(data.LOG)+1}=...
|
|
| 6570 |
+ '% Saving indices of the selected vectors to the workspace.'; |
|
| 6571 |
+ data.LOG{length(data.LOG)+1}=cat(2,'preprocess(''get_inds'',',...
|
|
| 6572 |
+ '''',answer{1},''');');
|
|
| 6573 |
+ set(gcf,'UserData',data); |
|
| 6574 |
+ end |
|
| 6575 |
+end |
|
| 6576 |
+ |
|
| 6577 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6578 |
+ |
|
| 6579 |
+function no_of_selected(varargin) |
|
| 6580 |
+ |
|
| 6581 |
+if nargin == 1 |
|
| 6582 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6583 |
+ set(0,'CurrentFigure',pre_h); |
|
| 6584 |
+ LOG = 1; |
|
| 6585 |
+else |
|
| 6586 |
+ LOG = 0; |
|
| 6587 |
+end |
|
| 6588 |
+ |
|
| 6589 |
+results_h=getfield(get(gcf,'UserData'),'results_h'); |
|
| 6590 |
+no=length(getfield(get(gcf,'UserData'),'selected_vects')); |
|
| 6591 |
+str={sprintf('Number of selected vectors: %d\n', no)};
|
|
| 6592 |
+set(results_h,'String',str,'HorizontalAlignment','left'); |
|
| 6593 |
+ |
|
| 6594 |
+if ~LOG |
|
| 6595 |
+ data=get(gcf,'UserData'); |
|
| 6596 |
+ data.LOG{length(data.LOG)+1}='% Number of selected vectors';
|
|
| 6597 |
+ data.LOG{length(data.LOG)+1}='preprocess(''no_of_sel'',''foo'');';
|
|
| 6598 |
+ set(gcf,'UserData',data); |
|
| 6599 |
+end |
|
| 6600 |
+ |
|
| 6601 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6602 |
+ |
|
| 6603 |
+function select_all_comps(varargin) |
|
| 6604 |
+ |
|
| 6605 |
+if nargin == 1 |
|
| 6606 |
+ pre_h=findobj(get(0,'Children'),'Tag','Preprocess'); |
|
| 6607 |
+ set(0,'CurrentFigure',pre_h); |
|
| 6608 |
+ LOG=1; |
|
| 6609 |
+else |
|
| 6610 |
+ LOG=0; |
|
| 6611 |
+end |
|
| 6612 |
+ |
|
| 6613 |
+comp_names_h=getfield(get(gcf,'UserData'),'comp_names_h'); |
|
| 6614 |
+ |
|
| 6615 |
+set(comp_names_h,'Value',[1:length(get(comp_names_h,'String'))]); |
|
| 6616 |
+sel_comp; |
|
| 6617 |
+ |
|
| 6618 |
+if ~LOG |
|
| 6619 |
+ data=get(gcf,'UserData'); |
|
| 6620 |
+ data.LOG{length(data.LOG)+1}='% Select all components';
|
|
| 6621 |
+ data.LOG{length(data.LOG)+1}='preprocess(''sel_all_comps'',''foo'');';
|
|
| 6622 |
+ set(gcf,'UserData',data); |
|
| 6623 |
+end |
|
| 6624 |
+ |
|
| 6625 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 6626 |
+ |
|
| 6627 |
+function code=write_log_code(indices,arg1,arg2,arg3,arg4,arg5,arg6); |
|
| 6628 |
+ |
|
| 6629 |
+str=textwrap({num2str(indices)},500);
|
|
| 6630 |
+ |
|
| 6631 |
+code{1}=sprintf('inds=[];');
|
|
| 6632 |
+for i=1:length(str); |
|
| 6633 |
+ code{i+1}=sprintf(' inds=cat(2,inds,[%s]);',str{i});
|
|
| 6634 |
+end |
|
| 6635 |
+str=cat(2,'preprocess(''''clip_data'''',''''',arg1,' ',num2str(arg2),' ',...
|
|
| 6636 |
+ num2str(arg3),' ',num2str(arg4),... |
|
| 6637 |
+ ' ',num2str(arg5),' ',num2str(arg6),' '); |
|
| 6638 |
+code{length(code)+1}=cat(2,'eval(cat(2,',...
|
|
| 6639 |
+ '''',str,'''',... |
|
| 6640 |
+ ',num2str(inds),'''''');''));'); |
|
| 6641 |
+ |
|
| 6642 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| ... | ... |
@@ -0,0 +1,572 @@ |
| 1 |
+function aout = rep_utils(action,fmt,fid) |
|
| 2 |
+ |
|
| 3 |
+%REP_UTILS Utilities for print reports and report elements. |
|
| 4 |
+% |
|
| 5 |
+% aout = rep_utils(action,fmt,[fid]) |
|
| 6 |
+% |
|
| 7 |
+% Input and output arguments ([]'s are optional): |
|
| 8 |
+% action (string) action identifier |
|
| 9 |
+% (cell array) {action,par1,par2,...}
|
|
| 10 |
+% the action identifier, followed by action |
|
| 11 |
+% parameters |
|
| 12 |
+% [fmt] (string) format of output, 'txt' by default |
|
| 13 |
+% [fid] (scalar) output file id, by default NaN in which |
|
| 14 |
+% case output is not written, only returned |
|
| 15 |
+% in aout |
|
| 16 |
+% |
|
| 17 |
+% aout (varies) output of the action |
|
| 18 |
+% |
|
| 19 |
+% Here are the actions and their arguments: |
|
| 20 |
+% 'printlines' par1 (cellstr) print par1, each cell on a new line |
|
| 21 |
+% 'header' par1 (string) print document header using par1 as title |
|
| 22 |
+% 'footer' print document footer |
|
| 23 |
+% 'compile' par1 (string) compile the named document (only 'ps' and 'pdf') |
|
| 24 |
+% 'inserttable' par1 (struct) print given table |
|
| 25 |
+% par2 (scalar) print lines between rows if par2=1 |
|
| 26 |
+% par3 (scalar) use longtable format (only 'ps' and 'pdf') |
|
| 27 |
+% 'printfigure' par1 (string) print current figure to file, par1 = filename |
|
| 28 |
+% par2 (scalar) used resolution (150 dpi by default) |
|
| 29 |
+% par3 (scalar) if par3=1, insert figure in minipage |
|
| 30 |
+% 'insertfigure' par1 (string) insert figure to report, par1 = filename of figure |
|
| 31 |
+% par2 (vector) size 2 x 1, size of figure relative to page size |
|
| 32 |
+% NaN = automatic scaling |
|
| 33 |
+% par3 (scalar) if par3=1, insert figure in minipage (only 'ps' and 'pdf') |
|
| 34 |
+% 'insertbreak' insert paragraph break into report |
|
| 35 |
+% |
|
| 36 |
+% See also REP_STATS. |
|
| 37 |
+ |
|
| 38 |
+% Contributed to SOM Toolbox 2.0, January 2nd, 2002 by Juha Vesanto |
|
| 39 |
+% Copyright (c) by Juha Vesanto |
|
| 40 |
+% http://www.cis.hut.fi/projects/somtoolbox/ |
|
| 41 |
+ |
|
| 42 |
+% Version 2.0beta juuso 020102 |
|
| 43 |
+ |
|
| 44 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 45 |
+%% input arguments |
|
| 46 |
+ |
|
| 47 |
+pars = {''};
|
|
| 48 |
+if iscell(action), |
|
| 49 |
+ if length(action)>1, pars = action(2:end); end |
|
| 50 |
+ action = action{1};
|
|
| 51 |
+end |
|
| 52 |
+ |
|
| 53 |
+if nargin<2 | isempty(fmt), fmt = 'txt'; end |
|
| 54 |
+global REPORT_OUTPUT_FMT |
|
| 55 |
+REPORT_OUTPUT_FMT = fmt; |
|
| 56 |
+ |
|
| 57 |
+if nargin<3 | isempty(fid), fid = NaN; end |
|
| 58 |
+ |
|
| 59 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 60 |
+%% action |
|
| 61 |
+ |
|
| 62 |
+aout = []; |
|
| 63 |
+printable = 0; |
|
| 64 |
+ |
|
| 65 |
+switch action, |
|
| 66 |
+case 'printlines', |
|
| 67 |
+ aout = pars{1};
|
|
| 68 |
+case 'header', |
|
| 69 |
+ switch fmt, |
|
| 70 |
+ case {'ps','pdf'}, aout = tex_startdocument(pars{1});
|
|
| 71 |
+ case 'html', aout = html_startpage(pars{1});
|
|
| 72 |
+ case 'txt', aout = cell(0); |
|
| 73 |
+ end |
|
| 74 |
+ printable = 1; |
|
| 75 |
+case 'footer', |
|
| 76 |
+ switch fmt, |
|
| 77 |
+ case {'ps','pdf'}, aout = tex_enddocument;
|
|
| 78 |
+ case 'html', aout = html_endpage; |
|
| 79 |
+ case 'txt', aout = cell(0); |
|
| 80 |
+ end |
|
| 81 |
+ printable = 1; |
|
| 82 |
+case 'compile', aout = compiledocument(pars{1});
|
|
| 83 |
+case 'inserttable', aout = inserttable(pars{:}); printable = 1;
|
|
| 84 |
+case 'printfigure', printfigure(pars{:});
|
|
| 85 |
+case 'insertfigure', aout = insertfigure(pars{:}); printable = 1;
|
|
| 86 |
+case 'insertbreak', aout = insertbreak; printable = 1; |
|
| 87 |
+case 'joinstr', aout = joinstr(pars{:}); printable = 1;
|
|
| 88 |
+case 'rulestr', aout = rulestr(pars{:}); printable = 1;
|
|
| 89 |
+case 'c_and_p_str', aout = c_and_p_str(pars{:}); printable = 1;
|
|
| 90 |
+case 'p_str', aout = p_str(pars{:}); printable = 1;
|
|
| 91 |
+end |
|
| 92 |
+ |
|
| 93 |
+% if output file is given, print lines |
|
| 94 |
+if ~isnan(fid) & printable, |
|
| 95 |
+ if ~iscell(aout), aout = {aout}; end
|
|
| 96 |
+ for i = 1:length(aout), fprintf(fid,'%s\n',fmtline(aout{i})); end
|
|
| 97 |
+end |
|
| 98 |
+ |
|
| 99 |
+return; |
|
| 100 |
+ |
|
| 101 |
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
| 102 |
+%% subfunctions |
|
| 103 |
+ |
|
| 104 |
+%% simple formatter strings |
|
| 105 |
+ |
|
| 106 |
+function s = joinstr(cs, sep1, sep2) |
|
| 107 |
+ if nargin==1, sep1 = ', '; sep2 = ' and '; end |
|
| 108 |
+ if nargin<3, sep2 = sep1; end |
|
| 109 |
+ if isempty(cs), |
|
| 110 |
+ s = ''; |
|
| 111 |
+ elseif strcmp(sep1,'\n'), |
|
| 112 |
+ if size(cs,1)==1, cs = cs'; end |
|
| 113 |
+ s = char(cs); |
|
| 114 |
+ else |
|
| 115 |
+ s = cs{1};
|
|
| 116 |
+ for i=2:length(cs)-1, s = [s sep1 cs{i}]; end
|
|
| 117 |
+ if length(cs)>1, s = [s sep2 cs{end}]; end
|
|
| 118 |
+ end |
|
| 119 |
+ return; |
|
| 120 |
+ |
|
| 121 |
+function str = c_and_p_str(n,m) |
|
| 122 |
+ |
|
| 123 |
+ % return a string of form # (%), e.g. '23 (12%)' |
|
| 124 |
+ if n==m, p = '100'; |
|
| 125 |
+ elseif n==0, p = '0'; |
|
| 126 |
+ else p = sprintf('%.2g',100*n/m);
|
|
| 127 |
+ end |
|
| 128 |
+ str = sprintf('%d (%s%%)',round(n),p);
|
|
| 129 |
+ return; |
|
| 130 |
+ |
|
| 131 |
+function str = p_str(p) |
|
| 132 |
+ % return a string of form %, e.g. '12%' |
|
| 133 |
+ if round(p*100)>=100, p = sprintf('%3g',100*p);
|
|
| 134 |
+ elseif abs(p)<eps, p = '0'; |
|
| 135 |
+ else p = sprintf('%.2g',100*p);
|
|
| 136 |
+ end |
|
| 137 |
+ str = sprintf('%s%%',p);
|
|
| 138 |
+ return; |
|
| 139 |
+ |
|
| 140 |
+function cs = rulestr(sR,cnames) |
|
| 141 |
+ global REPORT_OUTPUT_FMT |
|
| 142 |
+ switch REPORT_OUTPUT_FMT |
|
| 143 |
+ case {'ps','pdf'}, [leq,geq,infi,m,less,in] = deal('\leq','\geq','\inf','$','<','\in');
|
|
| 144 |
+ case 'html', [leq,geq,infi,m,less,in] = deal('<=','>=','Inf',' ','<',' ');
|
|
| 145 |
+ case 'txt', [leq,geq,infi,m,less,in] = deal('<=','>=','inf',' ','<','');
|
|
| 146 |
+ end |
|
| 147 |
+ nr = length(sR); |
|
| 148 |
+ cs = cell(nr,1); |
|
| 149 |
+ fmt = '%.2g'; |
|
| 150 |
+ if nargin<2, cnames = {sR.name}; end
|
|
| 151 |
+ if isempty(cnames), cnames = cell(nr,1); cnames(:) = {''}; end
|
|
| 152 |
+ for i=1:nr, |
|
| 153 |
+ low = sR(i).low; |
|
| 154 |
+ high = sR(i).high; |
|
| 155 |
+ switch isfinite(low) + 2*isfinite(high), |
|
| 156 |
+ case 0, cs{i} = [cnames{i} ' ' 'any'];
|
|
| 157 |
+ case 1, cs{i} = [cnames{i} ' ' m geq sprintf(fmt,low) m];
|
|
| 158 |
+ case 2, cs{i} = [cnames{i} ' ' m less sprintf(fmt,high) m];
|
|
| 159 |
+ case 3, cs{i} = [cnames{i} ' ' m in '[' sprintf(fmt,low) ',' sprintf(fmt,high) ']' m];
|
|
| 160 |
+ end |
|
| 161 |
+ end |
|
| 162 |
+ return; |
|
| 163 |
+ |
|
| 164 |
+%% print figure |
|
| 165 |