/matlab_tools/Converted/kcappendROIcoords.m

http://github.com/aludnam/MATLAB · Objective C · 203 lines · 200 code · 3 blank · 0 comment · 60 complexity · 8cb3bbf11c3045a9efa0eaf119d11910 MD5 · raw file

  1. %kcappendROIcoords 'Append and label multiple ROI coordinates files '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros cappendROIcoords.pane file
  3. %
  4. % Parameters:
  5. % InputFile: ipre 'Input Pre-appended', optional: 'input pre-appended multiple coordinates file'
  6. % InputFile: i1 'Input 1', required: 'Input first single coordinates file'
  7. % InputFile: i2 'Input 2', optional: 'Input second single coordinates file'
  8. % InputFile: i3 'Input 3', optional: 'Input third single coordinates file'
  9. % InputFile: i4 'Input 4', optional: 'Input fourth single coordinates file'
  10. % InputFile: i5 'Input 5', optional: 'Input fifth single coordinates file'
  11. % InputFile: i6 'Input 6', optional: 'Input sixth single coordinates file'
  12. % InputFile: i7 'Input 7', optional: 'Input seventh coordinates file'
  13. % InputFile: i8 'Input 8', optional: 'Input eight coordinates file'
  14. % InputFile: i9 'Input 9', optional: 'Input ninth coordinates file'
  15. % InputFile: i10 'Input 10', optional: 'Input tenth coordinates file'
  16. % OutputFile: o 'Output', required: 'Resulting output appended coordinates file'
  17. %
  18. % Example: o = kcappendROIcoords({ipre, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10}, {'ipre','';'i1','';'i2','';'i3','';'i4','';'i5','';'i6','';'i7','';'i8','';'i9','';'i10','';'o',''})
  19. %
  20. % Khoros helpfile follows below:
  21. %
  22. % PROGRAM
  23. % cappendROIcoords - Append and label multiple ROI coordinates files
  24. %
  25. % DESCRIPTION
  26. % This routine is used to create a file with several coordinate files with indexes. Its input are several files in the Coords file format ([-i1], [-i2] ... [-i10] parameters). The indexes or labels for the output file will be created based on the order of the input files.
  27. % The Coords file is an ASCII file, its format is:
  28. % * lines starting with # or / are considered as comments
  29. % * lines with less than 7 characters on it are ignored
  30. % * each line should have 4 coordinates: start column, start row, width, height, separated by one or more spaces.
  31. % The MCoords (multiple coordinates) format of the output file is:
  32. % * lines starting with # or / are considered as comments
  33. % * lines with less than 9 characters on it are ignored
  34. % * each line should have 5 values: index of class, start column, start row, width, height, separated by one or more spaces.
  35. % The output of this routine ([-o] parameter) will usually be used by a "cROIfrommcoords" file to create a image for classification and evaluation of the samples, please see the kman page for \fIcROIfrommcoords\fP for more information. If more than 10 Coords file must be concatenated by this routine, the output of this routine can also serve as a pre-appended input to it ([-ipre] parameter), so multiple instances of this routine can be called in cascade to append more than 10 files.
  36. %
  37. %
  38. %
  39. % EXAMPLES
  40. % All examples for the Classify toolbox are listed on the Classify Toolbox Manual. For an example of the usage of this routine, please see the example workspace Classify:workspaces:MINDIST-EvalSamples.
  41. %
  42. % "SEE ALSO"
  43. % cROIfrommcoords
  44. %
  45. % RESTRICTIONS
  46. % Expect the input files to be on the Coords format. If a pre-appended file is given (in the case there are more than 10 files to be appended) this file must be in the MCoords format.
  47. %
  48. % REFERENCES
  49. % All references for the Classify toolbox are listed on the Classify Toolbox Manual.
  50. %
  51. % COPYRIGHT
  52. % Copyright (C) 1997 Rafael Santos. Khoros (C) Khoral Research, Inc.
  53. %
  54. function varargout = kcappendROIcoords(varargin)
  55. if nargin ==0
  56. Inputs={};arglist={'',''};
  57. elseif nargin ==1
  58. Inputs=varargin{1};arglist={'',''};
  59. elseif nargin ==2
  60. Inputs=varargin{1}; arglist=varargin{2};
  61. else error('Usage: [out1,..] = kcappendROIcoords(Inputs,arglist).');
  62. end
  63. if size(arglist,2)~=2
  64. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  65. end
  66. narglist={'ipre', '__input';'i1', '__input';'i2', '__input';'i3', '__input';'i4', '__input';'i5', '__input';'i6', '__input';'i7', '__input';'i8', '__input';'i9', '__input';'i10', '__input';'o', '__output'};
  67. maxval={1,0,1,1,1,1,1,1,1,1,1,0};
  68. minval={1,0,1,1,1,1,1,1,1,1,1,0};
  69. istoggle=[1,0,1,1,1,1,1,1,1,1,1,0];
  70. was_set=istoggle * 0;
  71. paramtype={'InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','OutputFile'};
  72. % identify the input arrays and assign them to the arguments as stated by the user
  73. if ~iscell(Inputs)
  74. Inputs = {Inputs};
  75. end
  76. NumReqOutputs=1; nextinput=1; nextoutput=1;
  77. for ii=1:size(arglist,1)
  78. wasmatched=0;
  79. for jj=1:size(narglist,1)
  80. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  81. wasmatched = 1;
  82. was_set(jj) = 1;
  83. if strcmp(narglist{jj,2}, '__input')
  84. if (nextinput > length(Inputs))
  85. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  86. end
  87. narglist{jj,2} = 'OK_in';
  88. nextinput = nextinput + 1;
  89. elseif strcmp(narglist{jj,2}, '__output')
  90. if (nextoutput > nargout)
  91. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  92. end
  93. if (isempty(arglist{ii,2}))
  94. narglist{jj,2} = 'OK_out';
  95. else
  96. narglist{jj,2} = arglist{ii,2};
  97. end
  98. nextoutput = nextoutput + 1;
  99. if (minval{jj} == 0)
  100. NumReqOutputs = NumReqOutputs - 1;
  101. end
  102. elseif isstr(arglist{ii,2})
  103. narglist{jj,2} = arglist{ii,2};
  104. else
  105. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  106. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  107. end
  108. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  109. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  110. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  111. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  112. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  113. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  114. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  115. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  116. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  117. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  118. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  119. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  120. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  121. end
  122. end
  123. end
  124. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  125. narglist{jj,2} = arglist{ii,2};
  126. end
  127. end
  128. end
  129. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  130. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  131. end
  132. end
  133. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  134. for jj=1:size(narglist,1)
  135. if strcmp(paramtype{jj}, 'Toggle')
  136. if (narglist{jj,2} ==0)
  137. narglist{jj,1} = '';
  138. end;
  139. narglist{jj,2} = '';
  140. end;
  141. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  142. narglist{jj,1} = '';
  143. narglist{jj,2} = '';
  144. end;
  145. if strcmp(narglist{jj,2}, '__input')
  146. if (minval{jj} == 0) % meaning this input is required
  147. if (nextinput > size(Inputs))
  148. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  149. else
  150. narglist{jj,2} = 'OK_in';
  151. nextinput = nextinput + 1;
  152. end
  153. else % this is an optional input
  154. if (nextinput <= length(Inputs))
  155. narglist{jj,2} = 'OK_in';
  156. nextinput = nextinput + 1;
  157. else
  158. narglist{jj,1} = '';
  159. narglist{jj,2} = '';
  160. end;
  161. end;
  162. else
  163. if strcmp(narglist{jj,2}, '__output')
  164. if (minval{jj} == 0) % this is a required output
  165. if (nextoutput > nargout & nargout > 1)
  166. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  167. else
  168. narglist{jj,2} = 'OK_out';
  169. nextoutput = nextoutput + 1;
  170. NumReqOutputs = NumReqOutputs-1;
  171. end
  172. else % this is an optional output
  173. if (nargout - nextoutput >= NumReqOutputs)
  174. narglist{jj,2} = 'OK_out';
  175. nextoutput = nextoutput + 1;
  176. else
  177. narglist{jj,1} = '';
  178. narglist{jj,2} = '';
  179. end;
  180. end
  181. end
  182. end
  183. end
  184. if nargout
  185. varargout = cell(1,nargout);
  186. else
  187. varargout = cell(1,1);
  188. end
  189. global KhorosRoot
  190. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  191. w=['"' KhorosRoot];
  192. else
  193. if ispc
  194. w='"C:\Program Files\dip\khorosBin\';
  195. else
  196. [s,w] = system('which cantata');
  197. w=['"' w(1:end-8)];
  198. end
  199. end
  200. [varargout{:}]=callKhoros([w 'cappendROIcoords" '],Inputs,narglist);