Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro results vary over multiple executions #174

Closed
haesleinhuepf opened this issue Nov 11, 2021 · 7 comments
Closed

Macro results vary over multiple executions #174

haesleinhuepf opened this issue Nov 11, 2021 · 7 comments

Comments

@haesleinhuepf
Copy link
Member

Repeatedly calling the same macro code from pyimagej leads to different results.

See detailed description: https://forum.image.sc/t/macro-results-vary-when-calling-it-via-pyimagej/57744

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/macro-results-vary-when-calling-it-via-pyimagej/57744/5

@ctrueden
Copy link
Member

ctrueden commented Apr 18, 2022

The Troubleshooting doc now mentions this issue as of imagej/pyimagej@e1b2554. But no one has had time to solve it, unfortunately.

@imagejan
Copy link
Member

imagejan commented Sep 7, 2022

I commented on the forum thread with some insights:

For what it’s worth, I was able to reproduce the issue within Fiji’s script editor (i.e., independent of #pyimagej). Running the following macro code repeatedly:

run("Blobs (25K)");
setAutoThreshold("Otsu");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "  show=[Count Masks]");
getStatistics(area, mean, min, max, std, histogram);
print(max);

… will print ever increasing values. It seems like there’s a counter for the Count Masks images that doesn’t get reset properly.

Judging from this line:

case ROI_MASKS: drawRoiFilledParticle(drawIP, roi, mask, rt.size()); break;

			case ROI_MASKS: drawRoiFilledParticle(drawIP, roi, mask, rt.size()); break;

… the value for each drawn ROI is determined from the size of the internal ResultsTable (rt.size()).


I can work around the issue by adding Table.reset("Results"); to my macro code:

run("Blobs (25K)");
setAutoThreshold("Otsu");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "  show=[Count Masks]");
getStatistics(area, mean, min, max, std, histogram);
Table.reset("Results");
print(max); // will now always print 64

@ctrueden
Copy link
Member

ctrueden commented Sep 7, 2022

@imagejan Would you consider this a bug in ImageJ? I.e. should we move this issue to imagej/ImageJ?

@imagejan
Copy link
Member

imagejan commented Sep 7, 2022

Would you consider this a bug in ImageJ?

Yes. I just tested it with plain ImageJ, and observe the same behavior as seen with Fiji.

@ctrueden ctrueden transferred this issue from imagej/pyimagej Sep 7, 2022
@ctrueden ctrueden changed the title Macro results vary when calling it via pyimagej Macro results vary over multiple executions Sep 7, 2022
@ctrueden
Copy link
Member

ctrueden commented Sep 7, 2022

@rasband I transferred this issue here from PyImageJ. Based on your forum post I infer this might actually be working as intended, in which case this issue could be closed as not planned.

@rasband
Copy link
Member

rasband commented Sep 7, 2022

The particle analyzer is working as expected. The Count Masks are filled with a grayscale value corresponding to the particle number. To insure the particle numbers start at 1, use the “Clear results” option, as in this example:

  run("Blobs (25K)");
  setAutoThreshold("Otsu");
  setOption("BlackBackground", true);
  run("Analyze Particles...", "clear show=[Count Masks]");
  getStatistics(area, mean, min, max, std, histogram);
  print(max);

@rasband rasband closed this as completed Sep 7, 2022
@imagejan imagejan closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants