private ImagePlus openImage(String directory, String name, String path) {
    Object o = tryOpen(directory, name, path);
    // if an image was returned, assume success
    if (o instanceof ImagePlus) return (ImagePlus) o;

    // try opening the file with LOCI Bio-Formats plugin - always check this last!
    // Do not call Bio-Formats if File>Import>Image Sequence is opening this file.
    if (o == null
        && (IJ.getVersion().compareTo("1.38j") < 0 || !IJ.redirectingErrorMessages())
        && (new File(path).exists())) {
      Object loci = IJ.runPlugIn("loci.plugins.LociImporter", path);
      if (loci != null) {
        // plugin exists and was launched
        try {
          // check whether plugin was successful
          Class c = loci.getClass();
          boolean success = c.getField("success").getBoolean(loci);
          boolean canceled = c.getField("canceled").getBoolean(loci);
          if (success || canceled) {
            width = IMAGE_OPENED;
            return null;
          }
        } catch (Exception exc) {
        }
      }
    }

    return null;
  } // openImage