It runs a macro on the selected image, saves the result as a new image, and then opens the new image in a new tab
190 {
191 if (!Initialized)
192 {
194 }
195 string filename = "";
196 string dir = Path.GetDirectoryName(ImageView.SelectedImage.file);
197
198 if (ImageView.SelectedImage.ID.EndsWith(".ome.tif"))
199 {
200 filename = Path.GetFileNameWithoutExtension(ImageView.SelectedImage.ID);
201 filename = filename.Remove(filename.Length - 4, 4);
202 }
203 else
204 filename = Path.GetFileNameWithoutExtension(ImageView.SelectedImage.ID);
205 string file = dir + "\\" + filename + "-temp" + ".ome.tif";
206 file = file.Replace("\\", "/");
207 string st =
208 "run(\"Bio-Formats Importer\", \"open=\" + getArgument + \" autoscale color_mode=Default open_all_series display_rois rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT\"); " + con +
209 "run(\"Bio-Formats Exporter\", \"save=" + file + " export compression=Uncompressed\"); " +
210 "dir = getDir(\"startup\"); " +
211 "File.saveString(\"done\", dir + \"/done.txt\");";
212 if(bioformats)
213 st =
214 "open(getArgument); " + con +
215 "run(\"Bio-Formats Exporter\", \"save=" + file + " export compression=Uncompressed\"); " +
216 "dir = getDir(\"startup\"); " +
217 "File.saveString(\"done\", dir + \"/done.txt\");";
218
219 RunString(st, ImageView.SelectedImage.file, headless);
220
221 if (!File.Exists(file))
222 return;
223
224 string ffile = dir + "/" + filename + ".ome.tif";
225 File.Delete(ffile);
226 File.Copy(file, ffile);
227 File.Delete(file);
228 if (ImageView.SelectedImage.Filename != filename + ".ome.tif" || ImageView.SelectedImage.Filename != filename + ".tif")
229 {
230 if (ImageView.SelectedImage.filename.EndsWith(".tif"))
231 BioImage.OpenFile(ffile, newTab);
232 else
233 BioImage.OpenFile(ffile, true);
234 }
235 else
236 {
237 App.viewer.Images[App.viewer.SelectedIndex] = BioImage.OpenFile(ffile, 0, false, false);
238 }
239 App.viewer.UpdateImage();
240 App.viewer.UpdateView();
241 Recorder.AddLine("RunOnImage(\"" + con + "\"," + headless + "," + onTab + "," + newTab + ");");
242 }
static void RunString(string con, string param, bool headless)