Changeset 7744


Ignore:
Timestamp:
08/31/11 16:18:18 (8 years ago)
Author:
curtis
Message:

Improvements to Stitch OME-TIFFs plugin:

  • Write tile configuration to same folder as data.
    • Add "perform stitching now" checkbox.
    • Remove "compute overlap" checkbox since it doesn't work.
    • Misc. style and documentation fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/misc-plugins/src/main/java/loci/plugins/StitchOmeTiff.java

    r7739 r7744  
    4343import java.io.IOException; 
    4444import java.io.PrintWriter; 
     45import java.text.SimpleDateFormat; 
    4546import java.util.ArrayList; 
     47import java.util.Calendar; 
    4648import java.util.Collections; 
     49import java.util.Date; 
    4750import java.util.Map; 
    4851import java.util.concurrent.ConcurrentHashMap; 
     
    109112        private double threshold = 20.0; 
    110113        private boolean invert = true; 
     114        private boolean stitch = true; 
    111115        private boolean computeOverlap = true; 
    112116        private FusionMethod method = FusionMethod.LINEAR_BLENDING; 
     
    127131 
    128132                final String tileConfigPath = createTileConfiguration(file); 
    129                 if (tileConfigPath == null) { 
    130                         IJ.showStatus(""); 
    131                         return; 
    132                 } 
    133  
    134                 IJ.showStatus("Performing stitching..."); 
    135                 executeStitching(tileConfigPath); 
    136  
    137                 IJ.showStatus("Stitching complete."); 
     133                IJ.showStatus(""); 
     134                if (tileConfigPath == null) return; 
     135 
     136                if (stitch) { 
     137                        IJ.showStatus("Performing stitching..."); 
     138                        executeStitching(tileConfigPath); 
     139                        IJ.showStatus("Stitching complete."); 
     140                } 
    138141        } 
    139142 
     
    160163        private boolean chooseOptions() { 
    161164                final GenericDialog gd = new GenericDialog("Options"); 
     165                gd.addMessage("Tile layout parameters:"); 
    162166                gd.addNumericField("Overlap (%)", overlap, 0); 
    163167                gd.addNumericField("Stage_unit_threshold", threshold, 2); 
    164168                gd.addCheckbox("Invert_X_coordinates (hack)", invert); 
    165                 gd.addCheckbox("compute_overlap (otherwise use the coordinates as-is)", 
    166                         computeOverlap); 
     169                gd.addCheckbox("Perform_stitching now", stitch); 
     170                // NB: For now, commented out ability to disable overlap computation, 
     171                // because ImageJ is not passing the flag to the stitching plugin properly. 
     172                // So regardless of whether the box is checked, the overlap gets computed. 
     173//              gd.addCheckbox("compute_overlap (otherwise use the coordinates as-is)", 
     174//                      computeOverlap); 
     175                gd.addMessage("Stitching parameters:"); 
    167176                gd.addChoice("Fusion_Method", FusionMethod.labels(), 
    168177                        FusionMethod.LINEAR_BLENDING.toString()); 
     
    176185                threshold = gd.getNextNumber(); 
    177186                invert = gd.getNextBoolean(); 
    178                 computeOverlap = gd.getNextBoolean(); 
     187                stitch = gd.getNextBoolean(); 
     188//              computeOverlap = gd.getNextBoolean(); 
    179189                method = FusionMethod.get(gd.getNextChoice()); 
    180190                fusion = gd.getNextNumber(); 
     
    195205 
    196206                        IJ.showStatus("Generating tile configuration file..."); 
    197                         final double[] scaleFactors = computeScale(meta, overlap, threshold, 
    198                                 invert); 
     207                        final double[] scaleFactors = 
     208                                computeScale(meta, overlap, threshold, invert); 
    199209                        final File tileFile = 
    200210                                writeTileFile(dataFile.getParentFile(), meta, scaleFactors); 
     
    216226        /** Executes the stitching plugin using the given tile configuration. */ 
    217227        private void executeStitching(final String tileConfigPath) { 
    218                 StringBuilder sb = new StringBuilder(); 
     228                final StringBuilder sb = new StringBuilder(); 
    219229                sb.append("layout=[" + tileConfigPath + "]"); 
    220230                if (computeOverlap) sb.append(" compute_overlap"); 
     
    331341         * Writes the tile configuration to disk. 
    332342         *  
     343         * @param dir The directory where the data files are. 
    333344         * @param meta Metadata from which to extract the tile configuration. 
     345         * @param scaleFactors The scale factors to use when converting from stage 
     346         *          coordinates to pixels. 
    334347         * @return The full path to the file where tile configuration was written. 
    335348         * @throws IOException If something goes wrong writing the file. 
     
    339352        { 
    340353                // create temp file for tile configuration 
    341                 final File tileFile = File.createTempFile("TileConfiguration-", ".txt"); 
    342                 tileFile.deleteOnExit(); 
     354                final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'-'HHmmss"); 
     355                final Date now = Calendar.getInstance().getTime(); 
     356                final File tileFile = 
     357                        new File(dir, "TileConfiguration-" + sdf.format(now) + ".txt"); 
    343358                final PrintWriter out = new PrintWriter(tileFile); 
    344359 
     
    402417        } 
    403418 
    404         private static boolean hasZ(IMetadata meta) { 
     419        private static boolean hasZ(final IMetadata meta) { 
    405420                return meta.getPixelsSizeZ(0).getValue() > 1; 
    406421        } 
Note: See TracChangeset for help on using the changeset viewer.