How to re-analyze an image without starting the program over again

I’ve written an image analysis plugin for skeletal muscle cross sections. After the user inputs channel information, they enter prominence and thresholding values that are critical for the analysis. If these values are off, the user must start all over again. What I want is for the user to be able to go back and enter that information again and re-analyze the image with the new prominence and threshold values without having to start the program over again and lose all the channel information they entered.

Is there a way to do this? I just need to be pointed in the right direction. Thanks!

If you use the macro recorder, then values that the user inputs should appear recorded in the generated macro file.

The inputs need to be in a dialog box, and the user needs to be able to revisit that dialog box without starting the program over. I’ve tried some looping, but the start of the loop would need input from the end of that same loop, so the first time it is run it returns an error for unknown variable. Is there a way to loop large sections of code (~200 lines) where at the end of the loop the user can determine whether not to start the loop again?

To get some help you need to be more precise and post an example. It is impossible to work out what the problem is so far.

Hi @LyleB,

what about the following workflow, would that work for you:

isFinished=false;

while (isFinished==false) {
	// do some complicated analysis here

	print("Doing analysis");

	// make a dialog to ask the user if he is happy
	Dialog.create("Finish Check")
	Dialog.addMessage("Check the box if you are happpy, otherwise program will redo analysis");
	Dialog.addCheckbox("is finished", false);
	Dialog.show();

	isFinished=Dialog.getCheckbox();

}

// if the user checked the box, we exit the loop
print("User was happy");

At the end of each round, the user is asked whether he/she is happy, and if not, everything in the while statement will be executed again. Right now it’s just printing “Doing analysis” , obviously that would have to be filled with some real image analysis.

PS: If you modify your original image in your macro you should duplicate it at the beginning, otherwise you lose your input for the re-run.

Perfect!!! I was unaware of how to do “while” loops.

I tried your suggestion and it worked perfectly. Thank you.

1 Like