PageRenderTime 89ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kprest_bayes.m

http://github.com/aludnam/MATLAB
Objective C | 185 lines | 182 code | 3 blank | 0 comment | 54 complexity | 0f4109f8dc737a2d0aaaa1639c11c5c2 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kprest_bayes 'Performs Bayes MLC with bootstrapped Prior Probability Estimate '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros prest_bayes.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input Data Object ', required: 'Input data object'
  6. % InputFile: p 'Pre-Classification', required: 'File containing input predetermined classification'
  7. % InputFile: gt 'Ground Truth label object', optional: 'Ground truth label object'
  8. % Integer: window 'Prior Probability Estimate Window Size (odd)', default: 11: 'Prior probablity estimation window size'
  9. % InputFile: clkf 'Class\'n Key File', optional: 'Classification key file'
  10. % OutputFile: o 'Classified Data Object', optional: 'Classified data object'
  11. % OutputFile: mlo 'Output maxlik Object', optional: 'Output maximum likelihood data object'
  12. % OutputFile: priors 'Output priors Object', optional: 'Output prior probability data object'
  13. %
  14. % Example: [o, mlo, priors] = kprest_bayes({i, p, gt, clkf}, {'i','';'p','';'gt','';'window',11;'clkf','';'o','';'mlo','';'priors',''})
  15. %
  16. % Khoros helpfile follows below:
  17. %
  18. % PROGRAM
  19. % prest_bayes - Performs Bayes MLC with bootstrapped Prior Probablity Estimate
  20. %
  21. % DESCRIPTION
  22. %
  23. %
  24. %
  25. % EXAMPLES
  26. %
  27. % "SEE ALSO"
  28. %
  29. % RESTRICTIONS
  30. %
  31. % REFERENCES
  32. %
  33. % COPYRIGHT
  34. % Copyright (C) 1993 - 1997, Khoral Research, Inc. All rights reserved.
  35. %
  36. function varargout = kprest_bayes(varargin)
  37. if nargin ==0
  38. Inputs={};arglist={'',''};
  39. elseif nargin ==1
  40. Inputs=varargin{1};arglist={'',''};
  41. elseif nargin ==2
  42. Inputs=varargin{1}; arglist=varargin{2};
  43. else error('Usage: [out1,..] = kprest_bayes(Inputs,arglist).');
  44. end
  45. if size(arglist,2)~=2
  46. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  47. end
  48. narglist={'i', '__input';'p', '__input';'gt', '__input';'window', 11;'clkf', '__input';'o', '__output';'mlo', '__output';'priors', '__output'};
  49. maxval={0,0,1,33,1,1,1,1};
  50. minval={0,0,1,1,1,1,1,1};
  51. istoggle=[0,0,1,1,1,1,1,1];
  52. was_set=istoggle * 0;
  53. paramtype={'InputFile','InputFile','InputFile','Integer','InputFile','OutputFile','OutputFile','OutputFile'};
  54. % identify the input arrays and assign them to the arguments as stated by the user
  55. if ~iscell(Inputs)
  56. Inputs = {Inputs};
  57. end
  58. NumReqOutputs=0; nextinput=1; nextoutput=1;
  59. for ii=1:size(arglist,1)
  60. wasmatched=0;
  61. for jj=1:size(narglist,1)
  62. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  63. wasmatched = 1;
  64. was_set(jj) = 1;
  65. if strcmp(narglist{jj,2}, '__input')
  66. if (nextinput > length(Inputs))
  67. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  68. end
  69. narglist{jj,2} = 'OK_in';
  70. nextinput = nextinput + 1;
  71. elseif strcmp(narglist{jj,2}, '__output')
  72. if (nextoutput > nargout)
  73. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  74. end
  75. if (isempty(arglist{ii,2}))
  76. narglist{jj,2} = 'OK_out';
  77. else
  78. narglist{jj,2} = arglist{ii,2};
  79. end
  80. nextoutput = nextoutput + 1;
  81. if (minval{jj} == 0)
  82. NumReqOutputs = NumReqOutputs - 1;
  83. end
  84. elseif isstr(arglist{ii,2})
  85. narglist{jj,2} = arglist{ii,2};
  86. else
  87. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  88. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  89. end
  90. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  91. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  92. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  93. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  94. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  95. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  96. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  97. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  98. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  99. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  100. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  101. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  102. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  103. end
  104. end
  105. end
  106. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  107. narglist{jj,2} = arglist{ii,2};
  108. end
  109. end
  110. end
  111. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  112. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  113. end
  114. end
  115. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  116. for jj=1:size(narglist,1)
  117. if strcmp(paramtype{jj}, 'Toggle')
  118. if (narglist{jj,2} ==0)
  119. narglist{jj,1} = '';
  120. end;
  121. narglist{jj,2} = '';
  122. end;
  123. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  124. narglist{jj,1} = '';
  125. narglist{jj,2} = '';
  126. end;
  127. if strcmp(narglist{jj,2}, '__input')
  128. if (minval{jj} == 0) % meaning this input is required
  129. if (nextinput > size(Inputs))
  130. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  131. else
  132. narglist{jj,2} = 'OK_in';
  133. nextinput = nextinput + 1;
  134. end
  135. else % this is an optional input
  136. if (nextinput <= length(Inputs))
  137. narglist{jj,2} = 'OK_in';
  138. nextinput = nextinput + 1;
  139. else
  140. narglist{jj,1} = '';
  141. narglist{jj,2} = '';
  142. end;
  143. end;
  144. else
  145. if strcmp(narglist{jj,2}, '__output')
  146. if (minval{jj} == 0) % this is a required output
  147. if (nextoutput > nargout & nargout > 1)
  148. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  149. else
  150. narglist{jj,2} = 'OK_out';
  151. nextoutput = nextoutput + 1;
  152. NumReqOutputs = NumReqOutputs-1;
  153. end
  154. else % this is an optional output
  155. if (nargout - nextoutput >= NumReqOutputs)
  156. narglist{jj,2} = 'OK_out';
  157. nextoutput = nextoutput + 1;
  158. else
  159. narglist{jj,1} = '';
  160. narglist{jj,2} = '';
  161. end;
  162. end
  163. end
  164. end
  165. end
  166. if nargout
  167. varargout = cell(1,nargout);
  168. else
  169. varargout = cell(1,1);
  170. end
  171. global KhorosRoot
  172. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  173. w=['"' KhorosRoot];
  174. else
  175. if ispc
  176. w='"C:\Program Files\dip\khorosBin\';
  177. else
  178. [s,w] = system('which cantata');
  179. w=['"' w(1:end-8)];
  180. end
  181. end
  182. [varargout{:}]=callKhoros([w 'prest_bayes" '],Inputs,narglist);