Save real-time plot


I have a time series stack of images, I drew a segmented line and created intensity plot with cmnd+K; when I play the stack and press live on the plot, the plot is dynamic (like a movie). I want to save this plot as a movie such as I can show it with other programs (powerpoint, quicktime for example) and also save the values in a table for analysis with other tools. Any suggestions?

Thanks a lot,

Hello @wacguy and welcome to the forum!

There are probably better options, but I’ve made this script which should do what you want:

import ij.ImageStack
import ij.ImagePlus
#@ImagePlus(label="your image containing the ROI", description="your image") myImage
#@Integer (label="initial slice") iniSlice
#@Integer (label="final slice") endSlice
#@Integer (label="step slice", value=1) stepSlice
#@ImagePlus(label="your live graph", description="live graph") myGraph
#@Integer (label="delay for GUI update (ms)", value=100) delayInMs
#@output ImagePlus outputGraph

// Initializes new stack
stack = new ImageStack(myGraph.width, myGraph.height)  

for (slice=iniSlice;slice<=endSlice;slice=slice+stepSlice) {
	// sets position of input image
	// waits for live graph update...
	// copy and adds slice to new stack
	stack.addSlice(null, myGraph.getProcessor().clone())	

// builds output ImagePlus
outputGraph = new ImagePlus(myGraph.getTitle()+"-stack", stack)

Let me know how it goes!
Be aware that this script is not ideal: it waits for a GUI update a rather long time between slices ( Thread.sleep ) as the livegraph is GUI dependent. If you notice duplicate images in the output stack, just set the delay to a higher value (300).



Thanks a lot for making the effort, that is really really kind! and thanks for the welcome greeting; since I’m not an experience FIJI user, can you tell me exactly how to run it.

Thanks again,

Sure, no pb. You can either unzip this file: (606 Bytes)
and open it on Fiji or you can create a new text file (File > New > Text window), then copy-paste the code and save it with a .groovy extension (it’s the language used for the script).

Before running the script, you need to have both your source image and your live graph opened. Then just run the script. I think it should be self-explanatory.


Hey @wacguy

Just to add to @NicoKiaru’s response and awesome script to help you… you can also just copy/paste that code into the Script Editor of Fiji. (NOTE: Fiji is Just ImageJ - it is simply a distribution of ImageJ that comes with a bunch of plugins bundled - ready for you to use out-of-the-box. If you are just getting started, we recommend downloading/using Fiji. ) And once you paste it in there - just select ‘Groovy’ language and save it as @NicoKiaru told you - as a .groovy file. You can run it straight from the script editor window then.

Hope this helps!


1 Like

thank you both for the help; worked like charm

Hi Nico,

I have one more question (that I mentioned in my first one). How do I get the values of each image in a stack along a line; the output should preferably have three columns: first is the image in a stack (z position), second, the position along the line and third, the intensity; hope it is clear.

Thanks a lot again,

Hi @wacguy,

I can see two ways to do that, even if the output will not be exactly as you want, but it’s close.

The first and easy way, is to reslice your stack.

  1. Select a line in your stack
  2. Execute Image > Stack > Reslice [/]. This commands outputs a slice in the z (or t) direction of your stack, as an image (it’s also nice to get a full overview of your data)
  3. Save the output image as a text image (File > Save As > Text Image)

You can open this file as a spreadsheet for instance. You can retrieve for each value the z position and the position along the line because it the x and y coordinates of each cell.

Here’s a second way, a bit more painful:

  1. You store in the roi manager the line for each slice of your stack
  2. In the roimanager, do More >> Multi Plot
  3. In the generated “Profiles” image, click the button “List”

There you have almost what you want!


1 Like

Thanks a lot Nico; I think that Analyze>tools>save xy coordinates will also do the trick

Hi Nico,

I saw the comment that is used in Fiji. I am a beginner with Image J and also want to make a “live plot profile”. In my case, I have a stack video (the file.tif) and used Image J to measure the intensity over time (I have 1000 images). Finally, I want to save it like a movie so that I can put in my slide for presentation. Could your code also be used in Image J?


Hello @Xavier and welcome to the forum,

As is it now, no. While it is definitely possible to adapt it to work on pure ImageJ1, this requires some work. Is there a really good reason for you to use ImageJ rather than FIJI ?

If not, then just use Fiji!

Let me know,


so many thanks for this! i have found a solution for my problem by reading through your posts (now that i sit home doing nothing because of health issues i thought that at least i could browse forums and learn). thanks a lot Nico! do you mind if i am going to have some other questions for you in the future? you seem to know these things very well!

Hi @Excemu,

Thanks! And you’re welcome. There are many people who are active and very involved in this forum. (Many of them know much more than me, by the way). So just post your questions/problems in the forum, and contribute if you can help anyone!


Okay! I’ll try to use this code on Fiji and see how amazing code to work. :slight_smile: Thanks Nico!