PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kMlDeconv.m

http://github.com/aludnam/MATLAB
Objective C | 196 lines | 193 code | 3 blank | 0 comment | 57 complexity | a0b733d1442658467919a6f809b8c7b2 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kMlDeconv 'Deconvolution using ML/EM algorithm '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros MlDeconv.pane file
  3. %
  4. % Parameters:
  5. % Integer: n 'Iterations', default: 60: 'Number of iterations until algorythm stops'
  6. % Double: fX 'Reduction Factor X', default: 1: 'Reduction Factor X '
  7. % Double: fY 'Y', default: 1: 'Reduction Factor Y'
  8. % Double: fZ 'Z', default: 1: 'Reduction Factor Z'
  9. % Double: ZX 'ZX Aspect', default: 1: 'Pixel-Z-Size / Pixel-X-Size'
  10. % Double: HD 'HD Aspect', default: 0: 'Hight of Objetc above 0-Plane / Distance from turning-point of movable table'
  11. % Integer: rW 'Border (Pixels)', default: 4: 'a gaussian Window will be applied'
  12. % Toggle: SepRec 'No first Measurement', default: 0: 'first coordinates are only used for defining reconstruction geometry'
  13. % Double: mf 'Maximal Rel. Frequency X/Y', default: 0.8: 'Higher frequencies are suppressed in X/Y direction'
  14. % Double: mzf 'Z', default: 0.4: 'Higher frequencies are suppressed in Z-direction'
  15. % InputFile: i 'Measured Image', required: 'Measured confocal image'
  16. % InputFile: p 'PSF', required: 'PSF needed for ML algorithm (same size as measured data)'
  17. % InputFile: s 'Start File', optional: 'file to start iteration with'
  18. % InputFile: Over 'Overrelaxation Table', optional: 'Table for Overrelaxation Factors'
  19. % InputFile: v 'Match File', optional: 'file containing points to match'
  20. % OutputFile: o 'Recon. Image', required: 'Resulting output data object'
  21. % OutputFile: c 'Correction Image', required: 'Correction Image'
  22. % OutputFile: f 'Fwd Projected File', optional: 'forward proj. guess'
  23. % OutputFile: hf 'HF Content Output', optional: 'energy of highest 10% frequences'
  24. %
  25. % Example: [o, c, f, hf] = kMlDeconv({i, p, s, Over, v}, {'n',60;'fX',1;'fY',1;'fZ',1;'ZX',1;'HD',0;'rW',4;'SepRec',0;'mf',0.8;'mzf',0.4;'i','';'p','';'s','';'Over','';'v','';'o','';'c','';'f','';'hf',''})
  26. %
  27. % Khoros helpfile follows below:
  28. %
  29. % PROGRAM
  30. % MlDeconv - Deconvolution using ML/EM algorithm
  31. %
  32. % DESCRIPTION
  33. %
  34. %
  35. %
  36. % EXAMPLES
  37. %
  38. % "SEE ALSO"
  39. %
  40. % RESTRICTIONS
  41. %
  42. % REFERENCES
  43. %
  44. % COPYRIGHT
  45. % Copyright (C) 1996-2003, Rainer Heintzmann, All rights reserved.
  46. %
  47. function varargout = kMlDeconv(varargin)
  48. if nargin ==0
  49. Inputs={};arglist={'',''};
  50. elseif nargin ==1
  51. Inputs=varargin{1};arglist={'',''};
  52. elseif nargin ==2
  53. Inputs=varargin{1}; arglist=varargin{2};
  54. else error('Usage: [out1,..] = kMlDeconv(Inputs,arglist).');
  55. end
  56. if size(arglist,2)~=2
  57. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  58. end
  59. narglist={'n', 60;'fX', 1;'fY', 1;'fZ', 1;'ZX', 1;'HD', 0;'rW', 4;'SepRec', 0;'mf', 0.8;'mzf', 0.4;'i', '__input';'p', '__input';'s', '__input';'Over', '__input';'v', '__input';'o', '__output';'c', '__output';'f', '__output';'hf', '__output'};
  60. maxval={1000,10,10,10,10,10,2,0,2,2,0,0,1,1,1,0,0,1,1};
  61. minval={1,0,0,0,0,-10,2,0,0,0,0,0,1,1,1,0,0,1,1};
  62. istoggle=[0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,1,1];
  63. was_set=istoggle * 0;
  64. paramtype={'Integer','Double','Double','Double','Double','Double','Integer','Toggle','Double','Double','InputFile','InputFile','InputFile','InputFile','InputFile','OutputFile','OutputFile','OutputFile','OutputFile'};
  65. % identify the input arrays and assign them to the arguments as stated by the user
  66. if ~iscell(Inputs)
  67. Inputs = {Inputs};
  68. end
  69. NumReqOutputs=2; nextinput=1; nextoutput=1;
  70. for ii=1:size(arglist,1)
  71. wasmatched=0;
  72. for jj=1:size(narglist,1)
  73. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  74. wasmatched = 1;
  75. was_set(jj) = 1;
  76. if strcmp(narglist{jj,2}, '__input')
  77. if (nextinput > length(Inputs))
  78. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  79. end
  80. narglist{jj,2} = 'OK_in';
  81. nextinput = nextinput + 1;
  82. elseif strcmp(narglist{jj,2}, '__output')
  83. if (nextoutput > nargout)
  84. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  85. end
  86. if (isempty(arglist{ii,2}))
  87. narglist{jj,2} = 'OK_out';
  88. else
  89. narglist{jj,2} = arglist{ii,2};
  90. end
  91. nextoutput = nextoutput + 1;
  92. if (minval{jj} == 0)
  93. NumReqOutputs = NumReqOutputs - 1;
  94. end
  95. elseif isstr(arglist{ii,2})
  96. narglist{jj,2} = arglist{ii,2};
  97. else
  98. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  99. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  100. end
  101. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  102. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  103. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  104. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  105. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  106. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  107. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  108. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  109. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  110. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  111. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  112. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  113. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  114. end
  115. end
  116. end
  117. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  118. narglist{jj,2} = arglist{ii,2};
  119. end
  120. end
  121. end
  122. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  123. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  124. end
  125. end
  126. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  127. for jj=1:size(narglist,1)
  128. if strcmp(paramtype{jj}, 'Toggle')
  129. if (narglist{jj,2} ==0)
  130. narglist{jj,1} = '';
  131. end;
  132. narglist{jj,2} = '';
  133. end;
  134. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  135. narglist{jj,1} = '';
  136. narglist{jj,2} = '';
  137. end;
  138. if strcmp(narglist{jj,2}, '__input')
  139. if (minval{jj} == 0) % meaning this input is required
  140. if (nextinput > size(Inputs))
  141. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  142. else
  143. narglist{jj,2} = 'OK_in';
  144. nextinput = nextinput + 1;
  145. end
  146. else % this is an optional input
  147. if (nextinput <= length(Inputs))
  148. narglist{jj,2} = 'OK_in';
  149. nextinput = nextinput + 1;
  150. else
  151. narglist{jj,1} = '';
  152. narglist{jj,2} = '';
  153. end;
  154. end;
  155. else
  156. if strcmp(narglist{jj,2}, '__output')
  157. if (minval{jj} == 0) % this is a required output
  158. if (nextoutput > nargout & nargout > 1)
  159. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  160. else
  161. narglist{jj,2} = 'OK_out';
  162. nextoutput = nextoutput + 1;
  163. NumReqOutputs = NumReqOutputs-1;
  164. end
  165. else % this is an optional output
  166. if (nargout - nextoutput >= NumReqOutputs)
  167. narglist{jj,2} = 'OK_out';
  168. nextoutput = nextoutput + 1;
  169. else
  170. narglist{jj,1} = '';
  171. narglist{jj,2} = '';
  172. end;
  173. end
  174. end
  175. end
  176. end
  177. if nargout
  178. varargout = cell(1,nargout);
  179. else
  180. varargout = cell(1,1);
  181. end
  182. global KhorosRoot
  183. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  184. w=['"' KhorosRoot];
  185. else
  186. if ispc
  187. w='"C:\Program Files\dip\khorosBin\';
  188. else
  189. [s,w] = system('which cantata');
  190. w=['"' w(1:end-8)];
  191. end
  192. end
  193. [varargout{:}]=callKhoros([w 'confocrec" -k'],Inputs,narglist);