Writing Macro with MorphoLibJ Segmentation Plugin settings

I am trying to write a macro to segment and count muscle fibers using a plugin called MorpholibJ (macro pasted below). I tried using the macro reader output however when I run the macro it basically stalls and gives an error message (screenshot attached).
How can I write the macro to enable me to use the settings defined in the macro?
I have also attached a sample tiff image.
Your assistance will be highly appreciated.
Kind regards.

40AKO muscle WGA, Dapi 210619_TileScan 4_s25.tif (3.6 MB)

Macro from macro recorder

run("Set Scale...", "distance=185.6670 known=100 pixel=1 unit=µm");
title = getTitle();
run("Split Channels");
selectWindow(title + " (green)");
run("Gaussian Blur...", "sigma=2");
run("Smooth");
wait( 2000 );
run("Morphological Segmentation");
selectWindow("Morphological Segmentation");
//setTool("multipoint");
call("inra.ijpb.plugins.MorphologicalSegmentation.segment", "tolerance=2.0", "calculateDams=true", "connectivity=4");
call("inra.ijpb.plugins.MorphologicalSegmentation.setDisplayFormat", "Watershed lines");
selectWindow("40AKO muscle WGA, Dapi 210619_TileScan 4_s25-watershed-lines.tif (green)");
call("inra.ijpb.plugins.MorphologicalSegmentation.createResultImage");

Hi ,

what about this slightly modified version of your macro:

run("Set Scale...", "distance=185.6670 known=100 pixel=1 unit=µm");
title = getTitle();
run("Split Channels");
selectWindow(title + " (green)");
run("Gaussian Blur...", "sigma=2");
run("Smooth");
run("Morphological Segmentation");

wait( 2000 );

selectWindow("Morphological Segmentation");
//setTool("multipoint");
call("inra.ijpb.plugins.MorphologicalSegmentation.segment", "tolerance=2.0", "calculateDams=true", "connectivity=4");
call("inra.ijpb.plugins.MorphologicalSegmentation.setDisplayFormat", "Watershed lines");

wait(2000);

call("inra.ijpb.plugins.MorphologicalSegmentation.createResultImage"); // changed order

selectWindow("40AKO muscle WGA, Dapi 210619_TileScan 4_s25-watershed-lines.tif (green)"); // changed order

I think you mixed up the last two lines in your macro. The image first has to be created, then it can be selected. I added some more waiting, otherwise the previous step wasn’t finished in time (but don’t have a in depth explaination why necessary).

Can you try it out if it works