Changeset 4693


Ignore:
Timestamp:
12/11/08 15:30:23 (11 years ago)
Author:
curtis
Message:

Add macro functions for querying plane timings, and add an example macro.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r4359 r4693  
    260260    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); 
    261261    seriesName[0] = retrieve.getImageName(r.getSeries()); 
     262  } 
     263 
     264  public void getImageCreationDate(String[] creationDate) { 
     265    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); 
     266    creationDate[0] = retrieve.getImageCreationDate(r.getSeries()); 
     267  } 
     268 
     269  public void getPlaneTimingDeltaT(Double[] deltaT, Double no) { 
     270    int imageIndex = r.getSeries(); 
     271    int planeIndex = getPlaneIndex(r, no.intValue()); 
     272    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); 
     273    Float val = null; 
     274    if (planeIndex >= 0) { 
     275      val = retrieve.getPlaneTimingDeltaT(imageIndex, 0, planeIndex); 
     276    } 
     277    deltaT[0] = new Double(val == null ? Double.NaN : val.doubleValue()); 
     278  } 
     279 
     280  public void getPlaneTimingExposureTime(Double[] exposureTime, Double no) { 
     281    int imageIndex = r.getSeries(); 
     282    int planeIndex = getPlaneIndex(r, no.intValue()); 
     283    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); 
     284    Float val = null; 
     285    if (planeIndex >= 0) { 
     286      val = retrieve.getPlaneTimingExposureTime(imageIndex, 0, planeIndex); 
     287    } 
     288    exposureTime[0] = new Double(val == null ? Double.NaN : val.doubleValue()); 
    262289  } 
    263290 
     
    418445      IJ.write("Ext.getSeriesName(seriesName)"); 
    419446      IJ.write("-- Obtains the name of the current series."); 
    420       IJ.write(""); 
    421       IJ.write("For more information, see the online Javadocs for the"); 
    422       IJ.write("loci.formats.IFormatReader interface, available at:"); 
     447      IJ.write("Ext.getImageCreationDate(creationDate)"); 
     448      IJ.write("-- Obtains the creation date of the dataset"); 
     449      IJ.write("-- in ISO 8601 format."); 
     450      IJ.write("Ext.getPlaneTimingDeltaT(deltaT, no)"); 
     451      IJ.write("-- Obtains the time offset (seconds since the beginning "); 
     452      IJ.write("-- of the experiment) for the no'th plane, or NaN if none."); 
     453      IJ.write("Ext.getPlaneTimingExposureTime(exposureTime, no)"); 
     454      IJ.write("-- Obtains the exposure time (in seconds) for the no'th"); 
     455      IJ.write("-- plane, or NaN if none."); 
     456      IJ.write(""); 
     457      IJ.write("For more information, see the online Javadocs"); 
     458      IJ.write("for the loci.formats.IFormatReader and "); 
     459      IJ.write("loci.formats.meta.MetadataRetrieve interfaces:"); 
    423460      IJ.write("http://www.loci.wisc.edu/software/docs/"); 
    424461    } 
    425462  } 
    426463 
     464  // -- Utility methods -- 
     465 
     466  /** Finds the Plane index corresponding to the given image plane number. */ 
     467  private static int getPlaneIndex(IFormatReader r, int no) { 
     468    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore(); 
     469    int imageIndex = r.getSeries(); 
     470    int planeCount = retrieve.getPlaneCount(imageIndex, 0); 
     471    int[] zct = r.getZCTCoords(no); 
     472    for (int i=0; i<planeCount; i++) { 
     473      Integer theC = retrieve.getPlaneTheC(imageIndex, 0, i); 
     474      Integer theT = retrieve.getPlaneTheT(imageIndex, 0, i); 
     475      Integer theZ = retrieve.getPlaneTheZ(imageIndex, 0, i); 
     476      if (zct[0] == theZ.intValue() && zct[1] == theC.intValue() && 
     477        zct[2] == theT.intValue()) 
     478      { 
     479        return i; 
     480      } 
     481    } 
     482    return -1; 
     483  } 
     484 
    427485} 
Note: See TracChangeset for help on using the changeset viewer.