Search code examples
eclipsepluginsimagej

ImageJ: Debug with bioformats


I have downloaded imageJ source and imported into Eclipse. At the moment, I'm working on a plugin for imageJ and I can run imageJ with my plugin from eclipse and debug if I want. My problem is that I wish to init imageJ from eclipse but with the bioformats reader plugin loaded so I could open .lif files. How can I introduce this plugin into the imageJ source code? I have tried to add dependecies to the .jar file of bioformats in my project but it doesn't work.


Solution

  • Just for who ever is looking at the same problem:

    1. Download all the source code: https://github.com/openmicroscopy/bioformats
    2. Copy the folder: bioformats-develop\components\bio-formats-plugins\src to your project.
    3. Copy loci.plugins.LociImporter.java to ij.plugin.
    4. Delete loci.plugins.LociImporter.java
    5. Modify ij.plugin.LociImporter.java and add the line of arg:

       public void run(String arg) {
           DebugTools.enableLogging("INFO");
           arg = "location=[Local machine] windowless=false "; //<-This one
           [...]
       }
      
    6. Modify loci.plugins.in.Importer.java:

      //import loci.plugins.LociImporter;//substitute this import per
        import ij.plugin.LociImporter;//this one
      
    7. Modify ij.Menus.java:

      [...]
      Menu importMenu = getMenu("File>Import", true); 
      addPlugInItem(importMenu, "Bio-Formats", "ij.plugin.LociImporter",0,false);  //<-Add this line
      [...]
      
    8. Add bioformats.jar as an external lib to the project.

    Run the project. Now you can open .lif from file->import->Bio-Formats. With this modification you won't be able to do drag and drop but you will be able to use this plugin just opening files with this menu. As this is only using the "import" this is only useful for opening. If you want something about saving, you should call loci.plugins.LociExporter("") in the same way I did for the import. (actually with my modification we are calling ij.plugin.LociImporter("location=[Local machine] windowless=false ")