MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

ij/src/main/java/ij/plugin/AVI_Reader.java:316–363  ·  view source on GitHub ↗

The plugin is invoked by ImageJ using this method. @param arg String 'arg' may be used to select the path. If it is an empty string, a file open dialog is shown, and the resulting ImagePlus is displayed thereafter. The ImagePlus is not displayed if 'arg' is a non-empty String; it can be retrieved w

(String arg)

Source from the content-addressed store, hash-verified

314 * retrieved with getImagePlus().
315 */
316 public void run (String arg) {
317 String options = IJ.isMacro()?Macro.getOptions():null;
318 if (options!=null && options.contains("select=") && !options.contains("open="))
319 Macro.setOptions(options.replaceAll("select=", "open="));
320 path = arg;
321 if (displayDialog && !showDialog()) //ask for parameters
322 return;
323 try {
324 openAndReadHeader(path); //open and read header
325 } catch (Exception e) {
326 error(exceptionMessage(e));
327 return;
328 } finally {
329 closeFile(raFile);
330 }
331 errorText = null;
332 ImageStack stack = makeStack(path, firstFrame, lastFrame, isVirtual, convertToGray, flipVertical); //read data
333 if (aborting)
334 return; //error message has been shown already
335 if (stack==null || stack.size() == 0 || stack.getProcessor(1)==null) { //read nothing?
336 if (errorText != null)
337 error(errorText);
338 else {
339 String rangeText = "";
340 if (firstFrame > 1 || (lastFrame != 0 && lastFrame != dwTotalFrames))
341 rangeText = "\nin Range "+firstFrame+
342 (lastFrame>0 ? " - "+lastFrame : " - end");
343 error("Error: No Frames Found"+rangeText);
344 }
345 return;
346 } else if (errorText != null)
347 IJ.showMessage("AVI Reader", errorText); //show the error, e.g. we may have an incomplete stack
348 if (fileName==null) {
349 File f = new File(path);
350 fileName = f.getName();
351 }
352 imp = new ImagePlus(WindowManager.makeUniqueName(fileName), stack);
353 if (imp.getBitDepth()==16)
354 imp.getProcessor().resetMinAndMax();
355 setFramesPerSecond(imp);
356 FileInfo fi = new FileInfo();
357 fi.fileName = fileName;
358 fi.directory = fileDir;
359 imp.setFileInfo(fi);
360 if (arg.equals(""))
361 imp.show();
362 IJ.showTime(imp, startTime, "Read AVI in ", stack.size());
363 }
364
365 /** Returns the ImagePlus opened by run(). */
366 public ImagePlus getImagePlus() {

Callers 1

openImageMethod · 0.95

Calls 15

isMacroMethod · 0.95
getOptionsMethod · 0.95
setOptionsMethod · 0.95
showDialogMethod · 0.95
openAndReadHeaderMethod · 0.95
errorMethod · 0.95
exceptionMessageMethod · 0.95
closeFileMethod · 0.95
makeStackMethod · 0.95
sizeMethod · 0.95
getProcessorMethod · 0.95
showMessageMethod · 0.95

Tested by

no test coverage detected