Issue with opening images in side bar of script editor

Hello @albertcardona,

I tried by chance to double click on the side bar of the script editor to open an image in FIJI, and it worked! So that’s great, but instead of having the proper image LUT and B&C (which I have when I directly drag and drop the image [tiff]):


I get a weirdly displayed virtual stack (actually it’s even fully red before I adjust the brightness):


Is that easily solvable ?



Hi @NikoKiaru,

The Script Editor uses:

  final Object o =;
  // Open in whatever way possible
  if (null != o);


So this is a scijava services question for @ctrueden.




Note also that, if the current set of file system tree listeners in the Script Editor don’t suit you, you can change them. Either in the java code, and then running this to compile it and store it into your Fiji jars folder:

mvn -Dmaven.test.skip=true clean install

Or, in a live session, by grabbing the Frame of the Script Editor, removing the listener from the tree and replacing it with your own, for example:

from java.awt import Frame
from org.scijava.ui.swing.script import FileSystemTree
from ij import IJ

class CustomLeafListener(FileSystemTree.LeafListener):
  def __init__(self, texteditor):
    self.texteditor = texteditor
  def leafDoubleClicked(self, fileOb):
    name = fileOb.getName()
    idot = name.rfind('.')
    if -1 == idot:
      print "File name lacks extension"
    # Open depending on what it is  
    extension = name[idot+1:].lower() # in lowercase
    languages = set(["py", "clj", "js", "java", "bs", "ijm", "r", "rb", "sc", "txt", "md"])
    if extension in languages:
      # Let ImageJ handle it
      print "Asking ImageJ to open file", fileOb

# Find the java.awt.Frame of the ScriptEditor
for frame in Frame.getFrames():
  if frame.getClass().getSimpleName() == "TextEditor":
    # Grab its private "tree" instance of FileSystemTree
    field = frame.getClass().getDeclaredField("tree")
    tree = field.get(frame)
    # Remove any registered LeafListener
    map(tree.removeLeafListener, tree.getLeafListeners())
    # Add your own

Push “Run” and that’s that. Adjust as needed to open whatever you want, then “Run” again: it replaces itself as the listener.

In the example above, I used, so that’s exactly equivalent to drag and drop over the Fiji toolbar, or the “File - Open…” menu item.


Pretty cool! And i wasn’t aware at all about the Frame.getFrames() static function. This looks very convenient for horrible hacks, so I will use it reasonably (or not).

1 Like

Your “horrible hack” is my “this software gets out of my way and lets me get things done” :slight_smile:


I’ve seen this bug; it’s a deep bug in the imglib2-ij layer. It manifests because invokes SCIFIO via the DatasetIOPlugin, and SCIFIO opens an ImgLib2 image, which gets wrapped to ImageJ1 for display by imglib2-ij. I debugged deeply into it a couple months ago with @elevans, but we didn’t end up solving it. Unfortunately, it doesn’t look like we filed an issue for it in imglib2-ij. Ed, do you remember if there is an existing issue for this problem anywhere else?