thorstenwagner / ij-ridgedetection

Detect ridges / lines with imagej
GNU General Public License v2.0
42 stars 27 forks source link

Make macro recordable #13

Closed hinerm closed 8 years ago

hinerm commented 8 years ago

I would really like to call this plugin from a macro, recording all parameters so that a dialog does not need to be shown.

@thorstenwagner I spent a few minutes on it this morning but gave up. It is not clear to me what would need to be done to make this nicely macro recordable in the ImageJ 1.x framework.

If you can give me some direction I am willing to do the work. But I looked at other plugins that I know are fully recordable and still couldn't figure it out. :(

Anyway another option would be to just convert to ImageJ 2 where we could use @Parameter notation and get rid of the generic dialog and macro language restrictions altogether. I would be happy to work on this as well but only if you are OK moving to IJ2.

Let me know! :)

imagejan commented 8 years ago

@hinerm I just tried and macro recording worked as expected:

run("Ridge Detection", "line=3.5 high=230 low=87 darkline extend display add sigma=1.50 lower=3.06 upper=7.99");

The only issue currently is the duplicate keyword show (recorded when you check both Show junction points and Show IDs) that can be eliminated by introducing an underscore in one of the labels, e.g. _ShowIDs.

@thorstenwagner Why are you re-implementing GenericDialogPlus when you can just use the one included in Fiji (fiji.util.gui.GenericDialogPlus)?

That said, I agree that switching to ImageJ2 parameter notation is the preferred solution in the long term, of course.

thorstenwagner commented 8 years ago

@imagejan @hinerm As I read this issue I thought that this is probably the problem... I've just forgotten to add an underscore.. Sorry!

Why are you re-implementing GenericDialogPlus when you can just use the one included in Fiji (fiji.util.gui.GenericDialogPlus)?

The reason is that most of my plugins are implemented on the basis of ImageJ.

That said, I agree that switching to ImageJ2 parameter notation is the preferred solution in the long term, of course.

As for the ImageJ2 switch: Unfortunately, I'm not an expert with imagej2. I know you are! But I want to get some practice too. So, if it is not to urgent, I would like to do it myself and come back to you when I've questions.

hinerm commented 8 years ago

I just tried and macro recording worked as expected:

@imagejan odd. It works for me too now. I must have ran the wrong command or had some global state infecting things... the first time I tried it just put a commented out //run("Ridge Detection"); line in.

In my tests it isn't recording the overlap resolution method... any thoughts on what I need to do to get that to record and then run properly?

imagejan commented 8 years ago

It works for me too now. I must have ran the wrong command or had some global state infecting things.

@hinerm I previously encountered "premature" recording when a plugin was running a preview and using IJ helper functions that trigger the recording before the GenericDialog was actually OKed. But I tried with Preview activated, and it worked for me with this plugin.

In my tests it isn't recording the overlap resolution method... any thoughts on what I need to do to get that to record and then run properly?

You'd have to a choice to the plugin dialog for IJ1 to pick it up:

gd.addChoice("Overlap resolver", String[] choices, "My great OverlapResolver");

and later read it out (which triggers the actual recording):

String overlapOptionName = gd.getNextChoice();
hinerm commented 8 years ago

and later read it out (which triggers the actual recording):

Thanks @imagejan . This is what I was trying to find. :)

thorstenwagner commented 8 years ago

@hinerm The problem was that the method for overlap resolving it not read out in the dialogItemChanged method. It now record nicely.

hinerm commented 8 years ago

@thorstenwagner awesome! thank you!