Changeset 3955


Ignore:
Timestamp:
04/18/08 15:14:26 (12 years ago)
Author:
curtis
Message:

Fix some problems with Bio-Formats macro extensions,
add a few missing methods, and improve documentation.

Location:
trunk/loci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/IFormatReader.java

    r3773 r3955  
    181181   * C have one sub-dimension interleaved, and the other not—e.g., 
    182182   * {@link loci.formats.in.SDTReader} handles spectral-lifetime data with 
    183    * the interleaved lifetime bins and non-interleaved spectral channels. 
     183   * interleaved lifetime bins and non-interleaved spectral channels. 
    184184   */ 
    185185  boolean isInterleaved(int subC); 
  • trunk/loci/plugins/LociFunctions.java

    r3815 r3955  
    2727 
    2828import ij.IJ; 
     29import ij.ImagePlus; 
     30import ij.process.ImageProcessor; 
     31import java.awt.Rectangle; 
    2932import java.io.IOException; 
    3033import loci.formats.*; 
     
    6467  public void getSizeT(Double[] sizeT) { sizeT[0] = new Double(r.getSizeT()); } 
    6568 
    66   public void getPixelType(Double[] pixelType) { 
    67     pixelType[0] = new Double(r.getPixelType()); 
     69  public void getPixelType(String[] pixelType) { 
     70    pixelType[0] = FormatTools.getPixelTypeString(r.getPixelType()); 
    6871  } 
    6972 
     
    9295  } 
    9396 
    94   public void getThumbSizeX(Double[] thumbSizeX) { 
    95     thumbSizeX[0] = new Double(r.getThumbSizeX()); 
    96   } 
    97  
    98   public void getThumbSizeY(Double[] thumbSizeY) { 
    99     thumbSizeY[0] = new Double(r.getThumbSizeY()); 
    100   } 
     97//  public void getThumbSizeX(Double[] thumbSizeX) { 
     98//    thumbSizeX[0] = new Double(r.getThumbSizeX()); 
     99//  } 
     100 
     101//  public void getThumbSizeY(Double[] thumbSizeY) { 
     102//    thumbSizeY[0] = new Double(r.getThumbSizeY()); 
     103//  } 
    101104 
    102105  public void isLittleEndian(String[] littleEndian) { 
     
    120123  } 
    121124 
     125  public void openImage(String title, Integer no) 
     126    throws FormatException, IOException 
     127  { 
     128    ImageProcessor ip = Util.openProcessor(r, no.intValue()); 
     129    new ImagePlus(title, ip).show(); 
     130  } 
     131 
     132  public void openImage(String title, Integer no, Integer x, Integer y, 
     133    Integer width, Integer height) throws FormatException, IOException 
     134  { 
     135    Rectangle crop = new Rectangle(x.intValue(), y.intValue(), 
     136      width.intValue(), height.intValue()); 
     137    ImageProcessor ip = Util.openProcessor(r, no.intValue(), crop); 
     138    new ImagePlus(title, ip).show(); 
     139  } 
     140 
    122141  public void close() throws IOException { r.close(); } 
    123142  public void closeFileOnly() throws IOException { r.close(true); } 
     
    133152  public void getSeries(Double[] seriesNum) { 
    134153    seriesNum[0] = new Double(r.getSeries()); 
     154  } 
     155 
     156  public void setNormalized(Boolean normalize) { 
     157    r.setNormalized(normalize.booleanValue()); 
     158  } 
     159 
     160  public void isNormalized(Boolean[] normalize) { 
     161    normalize[0] = new Boolean(r.isNormalized()); 
     162  } 
     163 
     164  public void setMetadataCollected(Boolean collect) { 
     165    r.setMetadataCollected(collect.booleanValue()); 
     166  } 
     167 
     168  public void isMetadataCollected(Boolean[] collect) { 
     169    collect[0] = new Boolean(r.isMetadataCollected()); 
     170  } 
     171 
     172  public void setOriginalMetadataPopulated(Boolean populate) { 
     173    r.setOriginalMetadataPopulated(populate.booleanValue()); 
     174  } 
     175 
     176  public void isOriginalMetadataPopulated(Boolean[] populate) { 
     177    populate[0] = new Boolean(r.isOriginalMetadataPopulated()); 
    135178  } 
    136179 
     
    217260    if (IJ.macroRunning()) super.run(arg); 
    218261    else { 
     262      IJ.showMessage("LOCI Plugins for ImageJ", 
     263        "The macro extensions are designed to be used within a macro.\n" + 
     264        "Instructions on doing so will be printed to the Results window."); 
     265 
    219266      IJ.write("To gain access to more advanced features of Bio-Formats"); 
    220267      IJ.write("from within a macro, put the following line at the"); 
     
    228275      IJ.write(""); 
    229276      IJ.write("Ext.setId(id)"); 
    230       IJ.write("-- opens a file"); 
     277      IJ.write("-- Initializes the given id (filename)."); 
    231278      IJ.write("Ext.isMetadataComplete(complete)"); 
     279      IJ.write("-- True if Bio-Formats completely parses the current"); 
     280      IJ.write("   dataset's file format. If this function returns false,"); 
     281      IJ.write("   there are known limitations or missing features in how"); 
     282      IJ.write("   Bio-Formats handles this file format."); 
    232283      IJ.write("Ext.fileGroupOption(id, fileGroupOption)"); 
    233       IJ.write(""); 
    234       IJ.write("-= Usable before opening a file =-"); 
     284      IJ.write("-- Returns a code indicating the file grouping policy for"); 
     285      IJ.write("   for the current dataset. Possible values are:"); 
     286      IJ.write("     must, can, cannot, unknown"); 
     287      IJ.write(""); 
     288      IJ.write("-= Usable before initializing a file =-"); 
    235289      IJ.write(""); 
    236290      IJ.write("Ext.setNormalized(normalize)"); 
     291      IJ.write("-- Sets whether to normalize floating point data to [0-1]."); 
    237292      IJ.write("Ext.isNormalized(normalize)"); 
     293      IJ.write("-- Gets whether float data is being normalized to [0-1]."); 
    238294      IJ.write("Ext.setMetadataCollected(collect)"); 
     295      IJ.write("-- Sets whether Bio-Formats should extract metadata at all."); 
    239296      IJ.write("Ext.isMetadataCollected(collect)"); 
     297      IJ.write("-- Gets whether Bio-Formats is supposed to extract metadata."); 
    240298      IJ.write("Ext.setOriginalMetadataPopulated(populate)"); 
     299      IJ.write("-- Sets whether Bio-Formats should save proprietary metadata"); 
     300      IJ.write("   to the OME metadata store as custom attributes."); 
    241301      IJ.write("Ext.isOriginalMetadataPopulated(populate)"); 
     302      IJ.write("-- Sets whether Bio-Formats is saving proprietary metadata"); 
     303      IJ.write("   to the OME metadata store as custom attributes."); 
    242304      IJ.write("Ext.setGroupFiles(group)"); 
     305      IJ.write("-- For multi-file formats, sets whether to force grouping."); 
    243306      IJ.write("Ext.isGroupFiles(group)"); 
     307      IJ.write("-- Gets whether grouping is forced for multi-file formats.."); 
    244308      IJ.write("Ext.setMetadataFiltered(filter)"); 
     309      IJ.write("-- Sets whether to filter out ugly metadata from the table"); 
     310      IJ.write("   (i.e., entries with unprintable characters, and extremely"); 
     311      IJ.write("   long values)."); 
    245312      IJ.write("Ext.isMetadataFiltered(filter)"); 
    246       IJ.write(""); 
    247       IJ.write("-== Usable after opening a file ==-"); 
     313      IJ.write("-- Gets whether ugly metadata is being filtered out."); 
     314      IJ.write(""); 
     315      IJ.write("-== Usable after initializing a file ==-"); 
    248316      IJ.write(""); 
    249317      IJ.write("Ext.getSeriesCount(seriesCount)"); 
    250       IJ.write("-- gets the number of image series in the active dataset"); 
     318      IJ.write("-- Gets the number of image series in the active dataset."); 
    251319      IJ.write("Ext.setSeries(seriesNum)"); 
    252       IJ.write("-- sets the current series within the active dataset"); 
     320      IJ.write("-- Sets the current series within the active dataset."); 
    253321      IJ.write("Ext.getSeries(seriesNum)"); 
    254       IJ.write("-- gets the current series within the active dataset"); 
     322      IJ.write("-- Gets the current series within the active dataset."); 
    255323      IJ.write("Ext.getUsedFileCount(count)"); 
     324      IJ.write("-- Gets the number of files that are part of this dataset."); 
    256325      IJ.write("Ext.getUsedFile(i, used)"); 
     326      IJ.write("-- Gets the i'th filename part of this dataset."); 
    257327      IJ.write("Ext.getCurrentFile(file)"); 
     328      IJ.write("-- Gets the base filename used to initialize this dataset."); 
     329      IJ.write("Ext.openImage(title, no)"); 
     330      IJ.write("-- Opens the no'th plane in a new window named 'title'."); 
     331      IJ.write("Ext.openImage(title, no, x, y, width, height)"); 
     332      IJ.write("-- Opens a subset of the no'th plane in a new window"); 
     333      IJ.write("   named 'title'."); 
    258334      IJ.write("Ext.close()"); 
    259       IJ.write("-- closes the active dataset"); 
     335      IJ.write("-- Closes the active dataset."); 
    260336      IJ.write("Ext.closeFileOnly()"); 
    261       IJ.write("-- closes open files, leaving the current dataset active"); 
     337      IJ.write("-- Closes open files, leaving the current dataset active."); 
    262338      IJ.write(""); 
    263339      IJ.write("-== Applying to the current series ==-"); 
    264340      IJ.write(""); 
    265341      IJ.write("Ext.getSizeX(sizeX)"); 
     342      IJ.write("-- Gets the width of each image plane in pixels."); 
    266343      IJ.write("Ext.getSizeY(sizeY)"); 
     344      IJ.write("-- Gets the height of each image plane in pixels."); 
    267345      IJ.write("Ext.getSizeZ(sizeZ)"); 
     346      IJ.write("-- Gets the number of focal planes in the dataset."); 
    268347      IJ.write("Ext.getSizeC(sizeC)"); 
     348      IJ.write("-- Gets the number of channels in the dataset."); 
    269349      IJ.write("Ext.getSizeT(sizeT)"); 
     350      IJ.write("-- Gets the number of time points in the dataset."); 
    270351      IJ.write("Ext.getPixelType(pixelType)"); 
     352      IJ.write("-- Gets a code representing the pixel type of the image."); 
     353      IJ.write("   Possible values include:"); 
     354      IJ.write("     int8, uint8, int16, uint16, int32, uint32, float, double"); 
    271355      IJ.write("Ext.getEffectiveSizeC(effectiveSizeC)"); 
     356      IJ.write("-- Gets the 'effective' number of channels, such that:"); 
     357      IJ.write("   effectiveSizeC * sizeZ * sizeT == imageCount"); 
    272358      IJ.write("Ext.getRGBChannelCount(rgbChannelCount)"); 
     359      IJ.write("-- Gets the number of channels per composite image plane:"); 
     360      IJ.write("   sizeC / rgbChannelCount == effectiveSizeC"); 
    273361      IJ.write("Ext.isIndexed(indexed)"); 
     362      IJ.write("-- Gets whether the image planes are stored as indexed color"); 
     363      IJ.write("   (i.e., whether they have embedded LUTs)."); 
    274364      IJ.write("Ext.getChannelDimCount(channelDimCount)"); 
     365      IJ.write("-- For highly multidimensional image data, the C dimension"); 
     366      IJ.write("   may consist of multiple embedded 'sub' dimensions."); 
     367      IJ.write("   This function returns the number of such dimensions."); 
    275368      IJ.write("Ext.getChannelDimLength(i, channelDimLength)"); 
     369      IJ.write("-- Gets the length of the i'th embedded 'sub' dimension."); 
    276370      IJ.write("Ext.getChannelDimType(i, channelDimType)"); 
    277       IJ.write("Ext.getThumbSizeX(thumbSizeX)"); 
    278       IJ.write("Ext.getThumbSizeY(thumbSizeY)"); 
     371      IJ.write("-- Gets a string label for the i'th embedded 'sub' channel."); 
    279372      IJ.write("Ext.isLittleEndian(littleEndian)"); 
     373      IJ.write("-- For multi-byte pixel types, get the data's endianness."); 
    280374      IJ.write("Ext.getDimensionOrder(dimOrder)"); 
     375      IJ.write("-- Gets a five-character string representing the dimensional"); 
     376      IJ.write("   rasterization order within the dataset. Valid orders are:"); 
     377      IJ.write("     XYCTZ, XYCZT, XYTCZ, XYTZC, XYZCT, XYZTC"); 
     378      IJ.write("   In cases where the channels are interleaved (e.g., CXYTZ),"); 
     379      IJ.write("   C will be the first dimension after X and Y (e.g., XYCTZ)"); 
     380      IJ.write("   and the isInterleaved function will return true."); 
    281381      IJ.write("Ext.isOrderCertain(orderCertain)"); 
     382      IJ.write("-- Gets whether the dimension order and sizes are known,"); 
     383      IJ.write("   or merely guesses."); 
    282384      IJ.write("Ext.isInterleaved(interleaved)"); 
     385      IJ.write("-- Gets whether or not the channels are interleaved."); 
     386      IJ.write("   This function exists because X and Y must appear first"); 
     387      IJ.write("   in the dimension order. For interleaved data, XYCTZ or"); 
     388      IJ.write("   XYCZT is used, and this method returns true."); 
    283389      IJ.write("Ext.isInterleavedSubC(subC, interleaved)"); 
     390      IJ.write("-- Gets whether the given 'sub' channel is interleaved."); 
     391      IJ.write("   This method exists because some data with multiple"); 
     392      IJ.write("   rasterized sub-dimensions within C have one sub-dimension"); 
     393      IJ.write("   interleaved, and the other not -- e.g., the SDT reader"); 
     394      IJ.write("   handles spectral-lifetime data with interleaved lifetime"); 
     395      IJ.write("   bins and non-interleaved spectral channels."); 
    284396      IJ.write("Ext.getIndex(z, c, t, index)"); 
     397      IJ.write("-- Gets the rasterized index corresponding to the given"); 
     398      IJ.write("   Z, C and T coordinates, according to the dataset's"); 
     399      IJ.write("   dimension order."); 
    285400      IJ.write("Ext.getZCTCoords(index, z, c, t)"); 
     401      IJ.write("-- Gets the Z, C and T coordinates corresponding to the given"); 
     402      IJ.write("   rasterized index value, according to the dataset's"); 
     403      IJ.write("   dimension order."); 
    286404      IJ.write("Ext.getMetadataValue(field, value)"); 
     405      IJ.write("-- Obtains the specified metadata field's value."); 
    287406      IJ.write("Ext.getSeriesName(seriesName)"); 
    288  
    289       IJ.showMessage("LOCI Plugins for ImageJ", 
    290         "The macro extensions are designed to be used within a macro.\n" + 
    291         "Instructions on doing so have been printed to the Results window."); 
     407      IJ.write("-- Obtains the name of the current series."); 
     408      IJ.write(""); 
     409      IJ.write("For more information, see the online Javadocs for the"); 
     410      IJ.write("loci.formats.IFormatReader interface, available at:"); 
     411      IJ.write("http://www.loci.wisc.edu/software/docs/"); 
    292412    } 
    293413  } 
Note: See TracChangeset for help on using the changeset viewer.