PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kDeconvAxial.m

http://github.com/aludnam/MATLAB
Objective C | 196 lines | 193 code | 3 blank | 0 comment | 58 complexity | 7f8411302b9ad8a6b1a48c1995dcf98e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kDeconvAxial 'Deconvolution using ML/EM algorithm '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros DeconvAxial.pane file
  3. %
  4. % Parameters:
  5. % Integer: n 'Iterations', default: 60: 'Number of iterations until algorythm stops'
  6. % Integer: rW 'Border (Pixels)', default: 4: 'a gaussian Window will be applied'
  7. % Toggle: norichardson 'No Richardson', default: 0: 'do not use the richardson iteration, but the stadard ML-correction method instead'
  8. % Toggle: noPSFnorm 'Do not normalize PSFs', default: 0: 'The integral intensity of the PSFs will then not be normalized'
  9. % Double: mf 'Maximal Rel. Frequency X/Y', default: 0.8: 'Higher frequencies are suppressed in X/Y direction'
  10. % Double: mzf 'Z', default: 0.4: 'Higher frequencies are suppressed in Z-direction'
  11. % InputFile: i 'Measured Image', required: 'Measured confocal image'
  12. % InputFile: p 'PSF', required: 'PSF needed for ML algorithm (same size as measured data)'
  13. % InputFile: s 'Start File', optional: 'file to start iteration with'
  14. % InputFile: Over 'Overrelaxation Table', optional: 'Table for Overrelaxation Factors'
  15. % InputFile: patterns 'Pattern File', optional: 'File containing the different patterns (along elements)'
  16. % Toggle: patsep 'Separable Patterns', default: 0: 'If selected, it is assumed, that the pattern can be described as a sum of separable components. In this case, the pattern-file has to consist of N planes (stacked along depth) for each element. The PSF elements are then assumed to contain the Z-modified PSFs.'
  17. % Toggle: HolmesLiu 'Holmes & Liu', default: 0: 'If selected, the overrelaxation is choosen according to the Holmes&Liu paper. This specific implementation is however rather slow.'
  18. % OutputFile: o 'Recon. Image', required: 'Resulting output data object'
  19. % OutputFile: c 'Correction Image', required: 'Correction Image'
  20. % OutputFile: f 'Fwd Projected File', optional: 'forward proj. guess'
  21. % OutputFile: hf 'HF Content Output', optional: 'energy of highest 10% frequences'
  22. % Toggle: background 'Estimate Background', default: 0: 'For patterned excitation data, a background (out-of-focus, not deconvolved) can be estimated.'
  23. % OutputFile: bgFile 'Background', optional: 'Only for patterned excitation data, Estimate Background active'
  24. %
  25. % Example: [o, c, f, hf, bgFile] = kDeconvAxial({i, p, s, Over, patterns}, {'n',60;'rW',4;'norichardson',0;'noPSFnorm',0;'mf',0.8;'mzf',0.4;'i','';'p','';'s','';'Over','';'patterns','';'patsep',0;'HolmesLiu',0;'o','';'c','';'f','';'hf','';'background',0;'bgFile',''})
  26. %
  27. % Khoros helpfile follows below:
  28. %
  29. % PROGRAM
  30. % DeconvAxial - Deconvolutes using many Psfs
  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 = kDeconvAxial(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,..] = kDeconvAxial(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;'rW', 4;'norichardson', 0;'noPSFnorm', 0;'mf', 0.8;'mzf', 0.4;'i', '__input';'p', '__input';'s', '__input';'Over', '__input';'patterns', '__input';'patsep', 0;'HolmesLiu', 0;'o', '__output';'c', '__output';'f', '__output';'hf', '__output';'background', 0;'bgFile', '__output'};
  60. maxval={1000,2,0,0,2,2,0,0,1,1,1,0,0,0,0,1,1,0,1};
  61. minval={1,2,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,1};
  62. istoggle=[0,1,1,1,1,1,0,0,1,1,1,1,1,0,0,1,1,1,1];
  63. was_set=istoggle * 0;
  64. paramtype={'Integer','Integer','Toggle','Toggle','Double','Double','InputFile','InputFile','InputFile','InputFile','InputFile','Toggle','Toggle','OutputFile','OutputFile','OutputFile','OutputFile','Toggle','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 'axialrec" -k'],Inputs,narglist);