Help needed with batch processing of XY-coordinates with ImageJ

For an scientific experiment we are using a Wave Machine to analyse wave propagation. We have recorded footage and converted them to about 600 frames. For every frame we would like to know the XY-coordinates of the rods of the wave machine (the centroid coordinates, that is). This is easily done for a single image. We used a fluorescent substance so that, in a dark room, only the rods are visible on camera, here is a frame for example. For a single image the process is as follows with ImageJ:

  1. Convert tiff-image to 8-Bit
  2. Use a threshold of 118-255 which gives this result.
  3. Analyse particles and export the coordinates to a csv file.

For your information, with the current images the lamps would indeed be analysed as a particle. However, this can be filtered out with python later or we can use video-editing. We will deal with the after we’ve got the process working, which is our main concern for now.

Now comes the point where we need help: how can we do this process automatically for all 600 frames? Ideally, we would like a single CSV-file containing centroid coordinates of all frames, but a single CSV-file per frame with a name like “results frame 1.csv” would also be acceptable since this is easily imported with Python.

I did some googling already and used the internal macro recorded and ended up with this:

function action(output, filename) {
	setOption("BlackBackground", true)
	run("Convert to Mask");
	run("Analyze Particles...", "display clear include add");
	saveAs("Results", output + filename);
input = "C:\Users\<userprofile>\Pictures\frames"
output = "C:\Users\<userprofile>\Pictures\framesoutput"

list = getFileList(input);
for (i = 0, i < list.length; i++)
	action(input, output, list[i]);

However, when I try to run this with the batch macro processor, it simply exports the images. How can I make this work?

Thanks in advance!!

EDIT 1: After some testing with editing the video, we noticed a significant loss of quality and addition of motion blur. Thus, an additional step between steps 2 and 3 would include deleting the upper part. I don’t think this will be too hard to add to the macro.