简体   繁体   中英

How can I disable a dialog in ImageJ?

I'm using ImageJ a lot to look at image stacks composed of a number of single images sitting in one folder. I can just drag and drop the respective folder into the ImageJ GUI and it creates a scrollable visualization, which is very convenient. It could be even more convenient though since each time I do it, a dialog appears asking whether I want to open all images in the folder as a stack. Is it possible to make it default to "Yes"? Would I need to change the source code and compile it myself..? If that is the case, where could I start looking?

A suggestion would be to make a feature request to the author of Imagej Wayne rasband, eg, at the Github repository:

https://github.com/imagej/imagej1

Or you can write a small macro (use the macro recorder with the menu actions!) which can be also be installed in ImageJ. Something like:

run("Image Sequence...", "open=C:\\images\\ sort");

Here the macro docs:

https://imagej.nih.gov/ij/developer/macro/macros.html

https://imagej.nih.gov/ij/docs/guide/146-14.html

To disable the dialog in the source code: Find the source file ij>plugin>DragAndDrop.java . From its openDirectory method, delete the dialog-related lines and assign boolean values to convertToRGB and virtualStack , both of which are normally defined by check boxes in the now defunct dialog window. The code should now look like this:

    private void openDirectory(File f, String path) {
        if (path==null) return;
        if (!(path.endsWith(File.separator)||path.endsWith("/")))
            path += File.separator;
        String[] names = f.list();
        names = (new FolderOpener()).trimFileList(names);
        if (names==null)
            return;
        convertToRGB = false;
        virtualStack = false;
        String options  = " sort";
        if (convertToRGB) options += " convert_to_rgb";
        if (virtualStack) options += " use";
        IJ.run("Image Sequence...", "open=[" + path + "]"+options);
        DirectoryChooser.setDefaultDirectory(path);
        IJ.register(DragAndDrop.class);
    }

I did this with ImageJ 1.51p. The source code can be downloaded here . After making these changes, just run the build.xml ant script.

Note that writing a macro might provide a cleaner and more portable way to achieve this--refer to Marcel's answer for further reading.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM