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?
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.