Changeset 6711


Ignore:
Timestamp:
07/20/10 08:40:23 (9 years ago)
Author:
melissa
Message:

Speed up plane access by using one reader for each constituent file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/MetamorphReader.java

    r6700 r6711  
    107107  private int mmPlanes; //number of metamorph planes 
    108108 
    109   private MetamorphReader stkReader; 
     109  private MetamorphReader[][] stkReaders; 
    110110 
    111111  /** List of STK files in the dataset. */ 
     
    198198    // the original file is a .nd file, so we need to construct a new reader 
    199199    // for the constituent STK files 
    200     if (stkReader == null) { 
    201       stkReader = new MetamorphReader(); 
    202       stkReader.setCanLookForND(false); 
    203     } 
    204     stkReader.setId(file); 
     200    stkReaders[series][ndx].setId(file); 
    205201    int plane = stks[series].length == 1 ? no : coords[0]; 
    206     stkReader.openBytes(plane, buf, x, y, w, h); 
    207     stkReader.close(); 
     202    stkReaders[series][ndx].openBytes(plane, buf, x, y, w, h); 
    208203    return buf; 
    209204  } 
     
    212207  public void close(boolean fileOnly) throws IOException { 
    213208    super.close(fileOnly); 
    214     if (stkReader != null) stkReader.close(fileOnly); 
     209    if (stkReaders != null) { 
     210      for (MetamorphReader[] s : stkReaders) { 
     211        if (s != null) { 
     212          for (MetamorphReader reader : s) { 
     213            if (reader != null) reader.close(fileOnly); 
     214          } 
     215        } 
     216      } 
     217    } 
    215218    if (!fileOnly) { 
    216       stkReader = null; 
    217219      imageName = imageCreationDate = null; 
    218220      emWavelength = null; 
     
    232234      tempZ = 0d; 
    233235      validZ = false; 
     236      stkReaders = null; 
    234237    } 
    235238  } 
     
    488491        } 
    489492        core = newCore; 
     493      } 
     494    } 
     495 
     496    if (stks == null) { 
     497      stkReaders = new MetamorphReader[1][1]; 
     498      stkReaders[0][0] = new MetamorphReader(); 
     499      stkReaders[0][0].setCanLookForND(false); 
     500    } 
     501    else { 
     502      stkReaders = new MetamorphReader[stks.length][]; 
     503      for (int i=0; i<stks.length; i++) { 
     504        stkReaders[i] = new MetamorphReader[stks[i].length]; 
     505        for (int j=0; j<stkReaders[i].length; j++) { 
     506          stkReaders[i][j] = new MetamorphReader(); 
     507          stkReaders[i][j].setCanLookForND(false); 
     508          if (j > 0) { 
     509            stkReaders[i][j].setMetadataOptions( 
     510              new DefaultMetadataOptions(MetadataLevel.MINIMUM)); 
     511          } 
     512        } 
    490513      } 
    491514    } 
Note: See TracChangeset for help on using the changeset viewer.