this post was submitted on 14 Jul 2023
1 points (100.0% liked)

Image Processing and Analysis

94 readers
1 users here now

A community for sharing knowledge (interesting or new methods, scripts, theoretical concepts, etc), asking questions (troubleshooting, asking for suggestions, general concepts, etc) and discussing all topics related to image processing and analysis (show and tell, careers, software, etc).

founded 1 year ago
MODERATORS
QZM
 

I came across a small script that opens a window with a progress bar that increases after the completion of every iteration in a for loop. It's pretty useful in a big macro cycling through many images. Sometimes you just want to know your progress in batch mode. So here is the helpful script (from https://imagej.nih.gov/ij/macros/ProgressBar.txt):

// Progress Bar
//
// This macro demonstrates how to display status
// information and a progress bar in a text window. 
// It uses the Plugins>New>Text Window command
// to open a text window without a menu bar.

  title = "[Progress]";
  run("Text Window...", "name="+ title +" width=25 height=2 monospaced");
  for (i=0; i<100; i++) {
     print(title, "\\Update:"+i+"/"+100+" ("+(i*100)/100+"%)\n"+getBar(i, 100));
     wait(200);
  }
  print(title, "\\Close");

  function getBar(p1, p2) {
        n = 20;
        bar1 = "--------------------";
        bar2 = "********************";
        index = round(n*(p1/p2));
        if (index<1) index = 1;
        if (index>n-1) index = n-1;
        return substring(bar2, 0, index) + substring(bar1, index+1, n);
  }

Note: if you using other nested for loops, ensure that the variable you choose isn't the same as the one here (i), except of course the for loop you're actually trying to find track the process of. Happy macroing!

you are viewing a single comment's thread
view the rest of the comments
[–] QZM 1 points 1 year ago

Another small note: You can also adjust this script to include time taken per image and in total. Just using the timestamp commands and some math at the end of the macro spit out in the a userprompt window :)