PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kkinsertseg.m

http://github.com/aludnam/MATLAB
Objective C | 198 lines | 195 code | 3 blank | 0 comment | 55 complexity | 3bfe17a2b1cd85e2496aa9a0cd4f1b97 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkinsertseg 'Insert Selected Data Segments from Input 1 into Input 2'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros kinsertseg.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input 1', required: 'Source Input File'
  6. % InputFile: i2 'Input 2', required: 'Destination Input File'
  7. % OutputFile: o 'Output ', required: 'output file'
  8. % Toggle: val 'Value', default: 0: 'If -val flag is selected, operate on Value segment'
  9. % Toggle: map 'Map', default: 0: 'If -map flag is selected, operate on map segment'
  10. % Toggle: mask 'Mask', default: 0: 'If -mask flag is selected, operate on Mask segment'
  11. % Toggle: loc 'Location', default: 0: 'If -loc flag is selected, operate on Location segment'
  12. % Toggle: time 'Time', default: 0: 'If -time flag is selected, operate on Time segment'
  13. %
  14. % Example: o = kkinsertseg({i1, i2}, {'i1','';'i2','';'o','';'val',0;'map',0;'mask',0;'loc',0;'time',0})
  15. %
  16. % Khoros helpfile follows below:
  17. %
  18. % PROGRAM
  19. % kinsertseg - Insert Selected Data Segments from Input 1 into Input 2
  20. %
  21. % DESCRIPTION
  22. % This program will insert the specified
  23. % segment(s) for the first input object into
  24. % the second input object producing a new
  25. % or output object. If -segment is
  26. % "Insert All" all the segments and
  27. % their associated attributes will be inserted.
  28. % The -segment parameter can also specify
  29. % multiple segments by typing a string
  30. % containing the segment names separated
  31. % by space(s):
  32. %
  33. % "segment1 segment2 segment3"
  34. %
  35. %
  36. %
  37. %
  38. % EXAMPLES
  39. %
  40. % "SEE ALSO"
  41. %
  42. % RESTRICTIONS
  43. %
  44. % REFERENCES
  45. %
  46. % COPYRIGHT
  47. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  48. %
  49. function varargout = kkinsertseg(varargin)
  50. if nargin ==0
  51. Inputs={};arglist={'',''};
  52. elseif nargin ==1
  53. Inputs=varargin{1};arglist={'',''};
  54. elseif nargin ==2
  55. Inputs=varargin{1}; arglist=varargin{2};
  56. else error('Usage: [out1,..] = kkinsertseg(Inputs,arglist).');
  57. end
  58. if size(arglist,2)~=2
  59. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  60. end
  61. narglist={'i1', '__input';'i2', '__input';'o', '__output';'val', 0;'map', 0;'mask', 0;'loc', 0;'time', 0};
  62. maxval={0,0,0,0,0,0,0,0};
  63. minval={0,0,0,0,0,0,0,0};
  64. istoggle=[0,0,0,1,1,1,1,1];
  65. was_set=istoggle * 0;
  66. paramtype={'InputFile','InputFile','OutputFile','Toggle','Toggle','Toggle','Toggle','Toggle'};
  67. % identify the input arrays and assign them to the arguments as stated by the user
  68. if ~iscell(Inputs)
  69. Inputs = {Inputs};
  70. end
  71. NumReqOutputs=1; nextinput=1; nextoutput=1;
  72. for ii=1:size(arglist,1)
  73. wasmatched=0;
  74. for jj=1:size(narglist,1)
  75. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  76. wasmatched = 1;
  77. was_set(jj) = 1;
  78. if strcmp(narglist{jj,2}, '__input')
  79. if (nextinput > length(Inputs))
  80. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  81. end
  82. narglist{jj,2} = 'OK_in';
  83. nextinput = nextinput + 1;
  84. elseif strcmp(narglist{jj,2}, '__output')
  85. if (nextoutput > nargout)
  86. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  87. end
  88. if (isempty(arglist{ii,2}))
  89. narglist{jj,2} = 'OK_out';
  90. else
  91. narglist{jj,2} = arglist{ii,2};
  92. end
  93. nextoutput = nextoutput + 1;
  94. if (minval{jj} == 0)
  95. NumReqOutputs = NumReqOutputs - 1;
  96. end
  97. elseif isstr(arglist{ii,2})
  98. narglist{jj,2} = arglist{ii,2};
  99. else
  100. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  101. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  102. end
  103. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  104. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  105. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  106. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  107. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  108. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  109. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  110. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  111. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  112. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  113. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  114. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  115. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  116. end
  117. end
  118. end
  119. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  120. narglist{jj,2} = arglist{ii,2};
  121. end
  122. end
  123. end
  124. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  125. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  126. end
  127. end
  128. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  129. for jj=1:size(narglist,1)
  130. if strcmp(paramtype{jj}, 'Toggle')
  131. if (narglist{jj,2} ==0)
  132. narglist{jj,1} = '';
  133. end;
  134. narglist{jj,2} = '';
  135. end;
  136. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  137. narglist{jj,1} = '';
  138. narglist{jj,2} = '';
  139. end;
  140. if strcmp(narglist{jj,2}, '__input')
  141. if (minval{jj} == 0) % meaning this input is required
  142. if (nextinput > size(Inputs))
  143. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  144. else
  145. narglist{jj,2} = 'OK_in';
  146. nextinput = nextinput + 1;
  147. end
  148. else % this is an optional input
  149. if (nextinput <= length(Inputs))
  150. narglist{jj,2} = 'OK_in';
  151. nextinput = nextinput + 1;
  152. else
  153. narglist{jj,1} = '';
  154. narglist{jj,2} = '';
  155. end;
  156. end;
  157. else
  158. if strcmp(narglist{jj,2}, '__output')
  159. if (minval{jj} == 0) % this is a required output
  160. if (nextoutput > nargout & nargout > 1)
  161. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  162. else
  163. narglist{jj,2} = 'OK_out';
  164. nextoutput = nextoutput + 1;
  165. NumReqOutputs = NumReqOutputs-1;
  166. end
  167. else % this is an optional output
  168. if (nargout - nextoutput >= NumReqOutputs)
  169. narglist{jj,2} = 'OK_out';
  170. nextoutput = nextoutput + 1;
  171. else
  172. narglist{jj,1} = '';
  173. narglist{jj,2} = '';
  174. end;
  175. end
  176. end
  177. end
  178. end
  179. if nargout
  180. varargout = cell(1,nargout);
  181. else
  182. varargout = cell(1,1);
  183. end
  184. global KhorosRoot
  185. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  186. w=['"' KhorosRoot];
  187. else
  188. if ispc
  189. w='"C:\Program Files\dip\khorosBin\';
  190. else
  191. [s,w] = system('which cantata');
  192. w=['"' w(1:end-8)];
  193. end
  194. end
  195. [varargout{:}]=callKhoros([w 'kinsertseg" '],Inputs,narglist);