Changeset 6475


Ignore:
Timestamp:
06/03/10 19:37:21 (9 years ago)
Author:
curtis
Message:

Organize methods a little better.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/src/loci/plugins/in/ImagePlusReader.java

    r6473 r6475  
    126126  } 
    127127 
    128   // -- Helper methods -- 
     128  // -- Helper methods - image reading -- 
    129129 
    130130  private List<ImagePlus> readImages() 
     
    298298  } 
    299299 
     300  // -- Helper methods - concatenation -- 
     301 
    300302  private List<ImagePlus> concatenate(List<ImagePlus> imps) { 
    301303    final ImporterOptions options = process.getOptions(); 
     
    303305    return imps; 
    304306  } 
     307 
     308  // -- Helper methods - colorization -- 
    305309 
    306310  private List<ImagePlus> applyColors(List<ImagePlus> imps) { 
     
    339343  } 
    340344 
    341   private List<ImagePlus> splitDims(List<ImagePlus> imps) { 
    342     final ImporterOptions options = process.getOptions(); 
    343  
    344     boolean sliceC = options.isSplitChannels(); 
    345     boolean sliceZ = options.isSplitFocalPlanes(); 
    346     boolean sliceT = options.isSplitTimepoints(); 
    347     if (sliceC || sliceZ || sliceT) { 
    348       String stackOrder = process.getStackOrder(); 
    349       List<ImagePlus> slicedImps = new ArrayList<ImagePlus>(); 
    350       for (ImagePlus imp : imps) { 
    351         ImagePlus[] results = new Slicer().reslice(imp, 
    352           sliceC, sliceZ, sliceT, stackOrder); 
    353         for (ImagePlus result : results) slicedImps.add(result); 
    354       } 
    355       imps = slicedImps; 
    356     } 
    357     return imps; 
    358   } 
    359  
    360345  private LUT[] makeLUTs(int series) { 
    361346    final ImageProcessorReader reader = process.getReader(); 
     
    389374    return new LUT(r, g, b); 
    390375  } 
     376 
     377  // -- Helper methods - window splitting -- 
     378 
     379  private List<ImagePlus> splitDims(List<ImagePlus> imps) { 
     380    final ImporterOptions options = process.getOptions(); 
     381 
     382    boolean sliceC = options.isSplitChannels(); 
     383    boolean sliceZ = options.isSplitFocalPlanes(); 
     384    boolean sliceT = options.isSplitTimepoints(); 
     385    if (sliceC || sliceZ || sliceT) { 
     386      String stackOrder = process.getStackOrder(); 
     387      List<ImagePlus> slicedImps = new ArrayList<ImagePlus>(); 
     388      for (ImagePlus imp : imps) { 
     389        ImagePlus[] results = new Slicer().reslice(imp, 
     390          sliceC, sliceZ, sliceT, stackOrder); 
     391        for (ImagePlus result : results) slicedImps.add(result); 
     392      } 
     393      imps = slicedImps; 
     394    } 
     395    return imps; 
     396  } 
     397 
     398  // -- Helper methods - timing -- 
     399 
     400  private long startTime, time; 
     401 
     402  private void startTiming() { 
     403    startTime = time = System.currentTimeMillis(); 
     404  } 
     405 
     406  private void updateTiming(int s, int i, int current, int total) { 
     407    final ImageProcessorReader reader = process.getReader(); 
     408 
     409    long clock = System.currentTimeMillis(); 
     410    if (clock - time >= 100) { 
     411      String sLabel = reader.getSeriesCount() > 1 ? 
     412        ("series " + (s + 1) + ", ") : ""; 
     413      String pLabel = "plane " + (i + 1) + "/" + total; 
     414      notifyListeners(new StatusEvent("Reading " + sLabel + pLabel)); 
     415      time = clock; 
     416    } 
     417    notifyListeners(new StatusEvent(current, total, null)); 
     418  } 
     419 
     420  private void finishTiming() { 
     421    final ImageProcessorReader reader = process.getReader(); 
     422 
     423    long endTime = System.currentTimeMillis(); 
     424    double elapsed = (endTime - startTime) / 1000.0; 
     425    if (reader.getImageCount() == 1) { 
     426      notifyListeners(new StatusEvent("Bio-Formats: " + elapsed + " seconds")); 
     427    } 
     428    else { 
     429      long average = (endTime - startTime) / reader.getImageCount(); 
     430      notifyListeners(new StatusEvent("Bio-Formats: " + 
     431        elapsed + " seconds (" + average + " ms per plane)")); 
     432    } 
     433  } 
     434 
     435  // -- Helper methods -- miscellaneous -- 
    391436 
    392437  private FileInfo createFileInfo() { 
     
    574619  } 
    575620 
    576   // -- Helper methods - timing -- 
    577  
    578   private long startTime, time; 
    579  
    580   private void startTiming() { 
    581     startTime = time = System.currentTimeMillis(); 
    582   } 
    583  
    584   private void updateTiming(int s, int i, int current, int total) { 
    585     final ImageProcessorReader reader = process.getReader(); 
    586  
    587     long clock = System.currentTimeMillis(); 
    588     if (clock - time >= 100) { 
    589       String sLabel = reader.getSeriesCount() > 1 ? 
    590         ("series " + (s + 1) + ", ") : ""; 
    591       String pLabel = "plane " + (i + 1) + "/" + total; 
    592       notifyListeners(new StatusEvent("Reading " + sLabel + pLabel)); 
    593       time = clock; 
    594     } 
    595     notifyListeners(new StatusEvent(current, total, null)); 
    596   } 
    597  
    598   private void finishTiming() { 
    599     final ImageProcessorReader reader = process.getReader(); 
    600  
    601     long endTime = System.currentTimeMillis(); 
    602     double elapsed = (endTime - startTime) / 1000.0; 
    603     if (reader.getImageCount() == 1) { 
    604       notifyListeners(new StatusEvent("Bio-Formats: " + elapsed + " seconds")); 
    605     } 
    606     else { 
    607       long average = (endTime - startTime) / reader.getImageCount(); 
    608       notifyListeners(new StatusEvent("Bio-Formats: " + 
    609         elapsed + " seconds (" + average + " ms per plane)")); 
    610     } 
    611   } 
    612  
    613621} 
Note: See TracChangeset for help on using the changeset viewer.