Ignore:
Timestamp:
02/03/12 12:22:36 (8 years ago)
Author:
curtis
Message:

Extract planar indices from filename using a regex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/prairie-ome-tiff/src/main/java/loci/apps/prairie/PrairieInjector.java

    r7883 r7884  
    3838import java.util.Map; 
    3939import java.util.UUID; 
     40import java.util.regex.Matcher; 
     41import java.util.regex.Pattern; 
    4042 
    4143import loci.common.RandomAccessInputStream; 
     
    109111    reader.close(); 
    110112 
     113    // define regex for matching Prairie TIFF filenames 
     114    Pattern p = Pattern.compile(".*_Cycle([\\d]+).*_Ch([\\d]+)_([\\d])+.*"); 
     115 
    111116    // set the TiffData elements to describe the planar ordering 
    112117    int tiffDataIndex = 0; 
     
    115120      if (!isTiff(file)) continue; 
    116121 
    117       // TODO: populate these values from the current filename 
    118       int c = 0, z = 0, t = 0; 
     122      // extract CZT values from the current filename 
     123      Matcher m = p.matcher(file); 
     124      if (!m.matches() || m.groupCount() != 3) { 
     125        System.err.println("Warning: " + file + " does not conform to " + 
     126          "Prairie naming convention; skipping."); 
     127        continue; 
     128      } 
     129      int t = Integer.parseInt(m.group(1)); 
     130      int c = Integer.parseInt(m.group(2)); 
     131      int z = Integer.parseInt(m.group(3)); 
    119132 
    120133      meta.setTiffDataFirstC(new NonNegativeInteger(c), 0, tiffDataIndex); 
Note: See TracChangeset for help on using the changeset viewer.