Open gselzer opened 2 hours ago
The reason is that trying to keep ImagePlus and ImageDisplay objects in sync completely is a wild goose chase. Some data structures like the color tables are not wrapped but rather copied, and knowing under which circumstances exactly to trigger automatic sync is fraught: if you do it too often there is a potentially severe performance hit, and if you do it not often enough then things get out of sync. So in recent years we have not tried to improve this. My preference would be to actually back off the syncing approach altogether in favor of code wanting to utilize both kinds of data structures doing it themselves.
Some data structures like the color tables are not wrapped but rather copied,
Looking a bit at the API, I'm not sure I understand why they couldn't be wrapped - is there a reason that you know?
My preference would be to actually back off the syncing approach altogether in favor of code wanting to utilize both kinds of data structures doing it themselves.
Well, then at the very least we need to expose the logic that is used to perform the conversion, namely Converter
plugins that go between ij.process.LUT
s and net.imglib2.display.ColorTable
s.
On a broader scale though, I'm not sure what you mean by "code wanting to utilize both data structures". This repository, pyimagej/napari-imagej, and the example script listed above are all versions of such. If you really think the synchronization code does not belong here, maybe pyimagej
is the correct place for this, within ij.py.sync_image
? It's really unfortunate, though, that some of the synchronization code is there, and more is here...or do you think the script author should be doing the synchronization?
@ctrueden provided me with a script that can be run in Fiji-future with a SNAPSHOT
scijava/scripting-python
jar, which does the following:Dataset
.ImagePlus
using PyImageJ (which uses theDatasetToImagePlusConverter
).ImagePlus
, such that one channel isMagenta
.ImagePlus
. From there, I want to interact with the activeImageDisplay
, so I callLegacyImageDisplayService.getActiveImageDisplay
. This taps into theLegacyImageMap
, finds the associatedImageDisplay
within its internal map, and returns it after synchronizing the associated attachments (i.e. ROIs and Tables, but not LUT)s. Therefore, the returned dataset does not have the editedMagenta
that I see in the active image display.LegacyImageMap
makes aHarmonizer
object on events - is there a reason why it cannot have one of these all the time, such thatsyncrhonizeAttachmentsToDataset
could utilize it?