Charting automation

Need to write a charting automation and feeling a little daunted?

Well there is really no need to be worried about!

Lets take a closer look at the fundamentals of writing an automation to chart intensity.

The first important factor in a measure and plot automation is to draw the regions of interest that you want to measure and convert them to a binary layer.

Remember to use a non-modal tell task to prompt you to draw the regions of interest.

Use the task above to create a binary layer from the regions of interest that you have drawn.

We need a graph to put the measurements into - use the task below.

You might want to think about setting the axes for the graph so use the following task.

Now the question is, how many traces do you need on the graph? This will depend on how many regions of interest you have drawn.

First you need to count any measurements which already exist in the Measurements table, which you can find out by using a "Count Measurements" task.

We are only interested in the number of ROI measurements, so set-up the task as shown above. Notice that I have put the result into a number variable "A".

Now measure any layer in the image document with the binary mask that you have created.

The next step is to re-count the number of measurements in the Measurements table using another "Count Measurements" task. Put the result for this task into a number variable "B".

Now to you can calculate the number of traces (C) you need in your graph, because the number of regions of interest you have measured will be the difference between B and A


Next its time to use one of the three essential loops of the measure and plot automation.

Use a similar set-up to the one below.

Use the loop count to define the trace name.

So we now have the binary mask at the ready and have the graph document waiting to receive those all important measurements.

The next phase of the automation can be seen below.

You will notice that I have 3 if tasks in the loop these merely act as filters to ignore the layers that you don’t want to measure within the layered file (namely "Original image", "Video Preview" and "Mask")

Essentially the automation measures the image then moves to the next one.

To do this you need to set up the view layer task as follows.

Okay, so the main loop is measuring away, but how do I get the measurements into my graph and how do I make sure that I get the right measurement into the right trace?

Just after the automation has measured with the mask I have used yet another "Count Measurements" task, lets put the result of this task into a number variable "D".

The loop task is a carbon copy of the one we used previously, take a look.

I am re-using the "trace_number" variable to put the loop count into as there no point in squandering good variables.

So the task will loop the same number as there are traces/objects in the binary layer.

Now to target the measurement row.

I have put this into a separate variable to illustrate clearly how you target the correct row.

D-C will give you the number of measurements before the last measurement operation was executed.

Adding on the loop count (trace_number) will increment giving the correct row number to target per trace number.

The measurement is extracted with the task below.

The measurement is then plotted, I have chosen to plot it against the layer number.

The "count" value is just the loop count from the main loop

Okay, so that about wraps it up.