Dear scijava gurus,
I’d like for an imagej2 script to know about all the currently open images, but ran into something confusing.
Summary is that the
DatasetService seemed not to always be “up-to-date,” but rather needed me to click through things.
Secondary question: is the
DatasetService approach even the right one for this task?
- Opened ImageJ
- Opened two images.
- Ran this script
// @DatasetService ds // @LogService log log.info( "datasets: " + ds.getDatasets() )
- and got this output ( didn’t get either image)
[INFO] datasets: 
- Ran this script:
// @DatasetService ds // @LogService log // @ImageDisplayService ids log.info( ds.getDatasets( ids.getActiveImageDisplay())) log.info( "datasets: " + ds.getDatasets() )
and got this output ( only the active image in both lines )
[INFO] [mri-stack.tif] [INFO] datasets: [mri-stack.tif]
- Clicked the previously non-active image, ran that second script again, and got this output (what I expected all along):
[INFO] [mri-stack-1.tif] [INFO] datasets: [mri-stack.tif, mri-stack-1.tif]
- Ran that first script one more time (
DatasetServiceonly), and got the output (also as expected)
[INFO] datasets: [mri-stack.tif, mri-stack-1.tif]
Any guidance would be much appreciated.