Changeset 6528


Ignore:
Timestamp:
06/11/10 17:34:21 (10 years ago)
Author:
bdezonia
Message:

started work on testCompositeSubcases(). Began refactor for general support of indexed data values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/test/loci/plugins/in/ImporterTest.java

    r6519 r6528  
    3636// TODO 
    3737 
     38// left off 
     39//   why does seriesInCorrectOrder() behave so differently depending upon how it loads index values? 
     40//     ImagePlus.setPosition() sets the slice based on CZT order. My other code assumes ZCT order and never messes with 
     41//     setPosition(). Somehow I have to look in order of stack but order not via czt but zct. I started changin getPixelValue() 
     42//     to lookup slices in ZCT order. My change did not work as I expected. It temporarily broke memorySpecRange(). 
     43 
    3844// seem broken but don't know status from Curtis 
    3945//   colorized: 1/1/indexed (all indices 0 for all images), 3/1/indexed (iIndex,cIndex) (although w/ falseColor its okay), 
     
    4349 
    4450// broken 
    45 //   comboCropAndAutoscale for INT32. I think its a limitation of Fake. The values of the cropped image are outside 
    46 //   the minimum represntable value of an int as a float. So when we make a FloatProcessor on the int[] data the 
    47 //   huge negative values get clamped to the lowest representable point and thus max and min are not set correctly 
     51//   comboCropAndAutoscale for INT32. I think its a limitation of Fake. The values of the cropped image are less 
     52//   than the minimum representable value of an int as a float. So when we make a FloatProcessor on the int[] data 
     53//   the huge negative values get clamped to the lowest representable point and thus max and min are not set correctly 
    4854//   by IJ. I have verified that the pixel data that is sent to FloatProcessor() is correct. Limitation we'll live 
    4955//   with I guess. 
     
    6268//     thought flip would be easier to use for predicting actual values rather than special case code with invert. As 
    6369//     I'm only doing UINT8 for now this is not a problem. 
     70//   I removed the mergePixel() routine. BF does merging somewhere but I don't yet know where to test it. 
    6471 
    6572// waiting on BF implementations for 
     
    263270  // note : for now assumes default ZCT ordering 
    264271  /** Tests that an ImageStack is ordered according to specified from/to/by points of z/c/t */ 
    265   private boolean seriesInCorrectOrder(ImageStack st, 
     272  private boolean seriesInCorrectOrder(ImagePlus imp, boolean indexed, 
    266273      int zFrom, int zTo, int zBy, 
    267274      int cFrom, int cTo, int cBy, 
     
    271278    int cs = numInSeries(cFrom,cTo,cBy); 
    272279    int ts = numInSeries(tFrom,tTo,tBy); 
     280     
     281    ImageStack st = imp.getStack(); 
    273282     
    274283    if ((zs * cs * ts) != st.getSize()) 
     
    283292        for (int z = zFrom; z <= zTo; z += zBy) 
    284293        { 
    285           ImageProcessor proc = st.getProcessor(procNum); 
    286           if ((zIndex(proc) != z) || (cIndex(proc) != c) || (tIndex(proc) != t)) 
     294          int zIndex=0, cIndex=0, tIndex=0; 
     295           
     296          // TODO - this code fails with C/Z calced in wrong order - determine why 
     297           
     298          zIndex = zIndex(imp,z,c,t,indexed); 
     299          cIndex = cIndex(imp,z,c,t,indexed); 
     300          tIndex = tIndex(imp,z,c,t,indexed); 
     301 
     302          //System.out.println("  after wrong way z("+imp.getSlice()+") c("+imp.getChannel()+") t("+imp.getFrame()+")"); 
     303           
     304          // TODO - this code works but can't support indexed data 
     305           
     306          //ImageProcessor proc = imp.getStack().getProcessor(procNum); 
     307           
     308          //zIndex = zIndex(proc); 
     309          //cIndex = cIndex(proc); 
     310          //tIndex = tIndex(proc); 
     311           
     312          //System.out.println("  after right way z("+imp.getSlice()+") c("+imp.getChannel()+") t("+imp.getFrame()+")"); 
     313 
     314          if ((zIndex != z) || (cIndex != c) || (tIndex != t)) 
    287315          { 
    288             System.out.println("seriesInCorrectOrder() - slices out of order: exp z"+z+" c"+c+" t"+t+" != act z"+ 
    289                 zIndex(proc)+" c"+cIndex(proc)+" t"+tIndex(proc)+" for proc number "+procNum); 
     316            System.out.println("seriesInCorrectOrder() - slices out of order: expZ("+z+") expC("+c+") expT("+t+") != actZ("+ 
     317                zIndex+") actC("+cIndex+") actT("+tIndex+") for proc number "+procNum); 
    290318            return false; 
    291319          } 
     
    322350  /** The number of effective C slices in an ImagePlus */ 
    323351  private int getEffectiveSizeC(ImagePlus imp) { return getField(imp, "nChannels"); } 
    324  
    325   // used by the color merge code. calcs a pixel value in our ramped data for a 3 channel merged image 
    326   private int mergedPixel(int i) 
    327   { 
    328     if ((i < 0) || (i > 15)) 
    329       throw new IllegalArgumentException("mergedPixel() can only handle 1st 16 cases. Wants 0<=i<=15 but i = " + i); 
    330      
    331     return i*65536 + i*256 + i; 
    332   } 
    333352 
    334353  // TODO : this code written to pass tests - looks wrong on a number of pixel types 
     
    395414  } 
    396415   
     416  private void mySetPos(ImagePlus imp,int z, int c, int t, int maxZ, int maxC, int maxT) 
     417  { 
     418    imp.setSlice(t*maxC*maxZ + c*maxZ + z); 
     419  } 
     420 
    397421  /** get the actual pixel value (lookup when data is indexed) of the index of a fake image at a given z,c,t */ 
    398422  private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed) 
    399423  { 
    400424    // our indices are 0-based while IJ's are 1-based 
    401     imp.setPosition(c+1, z+1, t+1); 
     425    //imp.setPosition(c+1, z+1, t+1);  // TODO - old way 
     426    mySetPos(imp,z,c,t,imp.getNSlices(),imp.getNChannels(),imp.getNFrames()); // TODO - why doesn't this result in correct behavior? 
    402427     
    403428    int rawValue = (int) (imp.getProcessor().getPixelValue(x, y)); 
     
    512537  } 
    513538   
     539  // ******** specific testers  ********************************** 
     540   
    514541  /** tests BioFormats when directly calling BF.openImagePlus(path) (no options set) */ 
    515   private void defaultBehaviorTest(int pixType, int x, int y, int z, int c, int t) 
     542  private void defaultBehaviorTester(int pixType, int x, int y, int z, int c, int t) 
    516543  { 
    517544    String path = constructFakeFilename("default", pixType, x, y, z, c, t, -1, false, -1, false, -1); 
     
    535562  } 
    536563   
    537   private void outputStackOrderTest(int pixType, ChannelOrder order, int x, int y, int z, int c, int t) 
     564  private void outputStackOrderTester(int pixType, ChannelOrder order, int x, int y, int z, int c, int t) 
    538565  { 
    539566    String bfChOrder = bfChanOrd(order); 
     
    591618  } 
    592619   
    593   private void datasetSwapDimsTest(int pixType, int x, int y, int z, int t) 
     620  private void datasetSwapDimsTester(int pixType, int x, int y, int z, int t) 
    594621  { 
    595622    int c = 3; 
     
    645672  } 
    646673 
    647   private void datasetOpenAllSeriesTest(int x, int y, int z, int c, int t, int s) 
     674  private void datasetOpenAllSeriesTester(int x, int y, int z, int c, int t, int s) 
    648675  { 
    649676    String path = constructFakeFilename("openAllSeries", FormatTools.UINT32, x, y, z, c, t, s, false, -1, false, -1); 
     
    697724  } 
    698725   
    699   private void datasetConcatenateTest(int pixType, int x, int y, int z, int c, int t, int s) 
     726  private void datasetConcatenateTester(int pixType, int x, int y, int z, int c, int t, int s) 
    700727  { 
    701728    assertTrue(s >= 1);  // necessary for this test 
     
    743770  } 
    744771   
    745   private void autoscaleTest(int pixType, boolean wantAutoscale) 
     772  private void autoscaleTester(int pixType, boolean wantAutoscale) 
    746773  { 
    747774    final int sizeZ = 2, sizeC = 3, sizeT = 4, sizeX = 51, sizeY = 16; 
     
    814841  } 
    815842   
    816   private void colorCompositeTest(int pixType, boolean indexed, int rgb, boolean falseColor, int sizeC, int numSeries) 
     843  private void colorCompositeTester(int pixType, boolean indexed, int rgb, boolean falseColor, int sizeC, int numSeries) 
    817844  { 
    818845    int sizeX = 55, sizeY = 71, sizeZ = 3, sizeT = 4; 
     
    883910  } 
    884911   
    885   private void colorColorizedTest() 
     912  private void colorColorizedTester() 
    886913  { 
    887914    // TODO: temp first attempt: sizeC == 1 and rgb matches 
     
    932959  } 
    933960   
    934   private void colorGrayscaleTest() 
     961  private void colorGrayscaleTester() 
    935962  { 
    936963    int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4; 
     
    9741001  } 
    9751002 
    976   private void colorCustomTest(int pixType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int numSeries) 
     1003  private void colorCustomTester(int pixType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int numSeries) 
    9771004  { 
    9781005    // reportedly works in BF for 2<=sizeC<=7 and also numSeries*sizeC*3 <= 25 
     
    10221049  } 
    10231050   
    1024   private void memoryVirtualStackTest(boolean desireVirtual) 
     1051  private void memoryVirtualStackTester(boolean desireVirtual) 
    10251052  { 
    10261053      int x = 604, y = 531, z = 7, c = 1, t = 1; 
     
    10511078  } 
    10521079 
    1053   private void memoryRecordModificationsTest(boolean wantToRemember) 
     1080  private void memoryRecordModificationsTester(boolean wantToRemember) 
    10541081  { 
    10551082    int x = 50, y = 15, z = 3, c = 1, t = 1; 
     
    10991126  } 
    11001127   
    1101   private void memorySpecifyRangeTest(int z, int c, int t, 
     1128  private void memorySpecifyRangeTester(int z, int c, int t, 
    11021129      int zFrom, int zTo, int zBy, 
    11031130      int cFrom, int cTo, int cBy, 
     
    11501177    ImagePlus imp = imps[0]; 
    11511178    xyzctTest(imp,x,y,numInSeries(zFrom,zTo,zBy),numInSeries(cFrom,cTo,cBy),numInSeries(tFrom,tTo,tBy)); 
    1152     ImageStack st = imp.getStack(); 
    11531179 
    11541180    // should be in correct order 
    1155     assertTrue(seriesInCorrectOrder(st,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy)); 
    1156   } 
    1157    
    1158   private void memoryCropTest(int x, int y, int ox, int oy, int cropSize) 
     1181    assertTrue(seriesInCorrectOrder(imp,false,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy)); 
     1182  } 
     1183   
     1184  private void memoryCropTester(int x, int y, int ox, int oy, int cropSize) 
    11591185  { 
    11601186    verifyCropInput(x, y, ox, oy, cropSize);  // needed for this test 
     
    11921218  // note - this test needs to rely on crop() to get predictable nonzero minimums 
    11931219   
    1194   private void comboCropAndAutoscaleTest(int pixType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, 
     1220  private void comboCropAndAutoscaleTester(int pixType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, 
    11951221      int originCropX, int originCropY, int sizeCrop) 
    11961222  { 
     
    12641290  } 
    12651291   
    1266   private void comboConcatSplitFocalPlanesTest() 
     1292  private void comboConcatSplitFocalPlanesTester() 
    12671293  { 
    12681294    // take a nontrivial zct set of series 
     
    13191345  } 
    13201346   
    1321   private void comboConcatSplitChannelsTest() 
     1347  private void comboConcatSplitChannelsTester() 
    13221348  { 
    13231349    // take a nontrivial zct set of series 
     
    13731399  } 
    13741400   
    1375   private void comboConcatSplitTimepointsTest() 
     1401  private void comboConcatSplitTimepointsTester() 
    13761402  { 
    13771403    // take a nontrivial zct set of series 
     
    14321458  public void testDefaultBehavior() 
    14331459  { 
    1434     defaultBehaviorTest(FormatTools.UINT16, 400, 300, 1, 1, 1); 
    1435     defaultBehaviorTest(FormatTools.INT16, 107, 414, 1, 1, 1); 
    1436     defaultBehaviorTest(FormatTools.UINT32, 323, 206, 3, 2, 1); 
    1437     defaultBehaviorTest(FormatTools.UINT8, 57, 78, 5, 4, 3); 
    1438     defaultBehaviorTest(FormatTools.INT32, 158, 99, 2, 3, 4); 
    1439     defaultBehaviorTest(FormatTools.INT8, 232, 153, 3, 7, 5); 
    1440     defaultBehaviorTest(FormatTools.FLOAT, 73, 99, 3, 4, 5); 
    1441     defaultBehaviorTest(FormatTools.DOUBLE, 106, 44, 5, 5, 4); 
     1460    defaultBehaviorTester(FormatTools.UINT16, 400, 300, 1, 1, 1); 
     1461    defaultBehaviorTester(FormatTools.INT16, 107, 414, 1, 1, 1); 
     1462    defaultBehaviorTester(FormatTools.UINT32, 323, 206, 3, 2, 1); 
     1463    defaultBehaviorTester(FormatTools.UINT8, 57, 78, 5, 4, 3); 
     1464    defaultBehaviorTester(FormatTools.INT32, 158, 99, 2, 3, 4); 
     1465    defaultBehaviorTester(FormatTools.INT8, 232, 153, 3, 7, 5); 
     1466    defaultBehaviorTester(FormatTools.FLOAT, 73, 99, 3, 4, 5); 
     1467    defaultBehaviorTester(FormatTools.DOUBLE, 106, 44, 5, 5, 4); 
    14421468  } 
    14431469 
     
    14461472  { 
    14471473    for (ChannelOrder order : ChannelOrder.values()) 
    1448       outputStackOrderTest(FormatTools.UINT8, order,  82, 47, 2, 3, 4); 
     1474      outputStackOrderTester(FormatTools.UINT8, order,  82, 47, 2, 3, 4); 
    14491475  } 
    14501476     
     
    15491575    //   Note that testComboManyOptions() tests another swap order 
    15501576 
    1551     datasetSwapDimsTest(FormatTools.UINT8, 82, 47, 1, 3); 
    1552     datasetSwapDimsTest(FormatTools.UINT16, 82, 47, 3, 1); 
    1553     datasetSwapDimsTest(FormatTools.UINT16, 82, 47, 5, 2); 
    1554     datasetSwapDimsTest(FormatTools.UINT32, 82, 47, 5, 2); 
    1555     datasetSwapDimsTest(FormatTools.INT8, 44, 108, 1, 4); 
    1556     datasetSwapDimsTest(FormatTools.INT16, 44, 108, 2, 1); 
    1557     datasetSwapDimsTest(FormatTools.INT32, 44, 108, 4, 3); 
    1558     datasetSwapDimsTest(FormatTools.FLOAT, 67, 109, 4, 3); 
    1559     datasetSwapDimsTest(FormatTools.DOUBLE, 67, 100, 3, 2); 
     1577    datasetSwapDimsTester(FormatTools.UINT8, 82, 47, 1, 3); 
     1578    datasetSwapDimsTester(FormatTools.UINT16, 82, 47, 3, 1); 
     1579    datasetSwapDimsTester(FormatTools.UINT16, 82, 47, 5, 2); 
     1580    datasetSwapDimsTester(FormatTools.UINT32, 82, 47, 5, 2); 
     1581    datasetSwapDimsTester(FormatTools.INT8, 44, 108, 1, 4); 
     1582    datasetSwapDimsTester(FormatTools.INT16, 44, 108, 2, 1); 
     1583    datasetSwapDimsTester(FormatTools.INT32, 44, 108, 4, 3); 
     1584    datasetSwapDimsTester(FormatTools.FLOAT, 67, 109, 4, 3); 
     1585    datasetSwapDimsTester(FormatTools.DOUBLE, 67, 100, 3, 2); 
    15601586  } 
    15611587 
     
    15631589  public void testDatasetOpenAllSeries() 
    15641590  { 
    1565     datasetOpenAllSeriesTest(73,107,1,1,1,1);  // one series 
    1566     datasetOpenAllSeriesTest(73,107,1,1,1,2);  // two series 
    1567     datasetOpenAllSeriesTest(73,107,5,3,4,4);  // multiple series with Z,C,T larger than 1 
     1591    datasetOpenAllSeriesTester(73,107,1,1,1,1);  // one series 
     1592    datasetOpenAllSeriesTester(73,107,1,1,1,2);  // two series 
     1593    datasetOpenAllSeriesTester(73,107,5,3,4,4);  // multiple series with Z,C,T larger than 1 
    15681594  } 
    15691595 
     
    15721598  { 
    15731599    // open a dataset that has multiple series and should get back a single series 
    1574     datasetConcatenateTest(FormatTools.UINT8, 82, 47, 1, 1, 1, 1); 
    1575     datasetConcatenateTest(FormatTools.UINT8, 82, 47, 1, 1, 1, 17); 
    1576     datasetConcatenateTest(FormatTools.UINT8, 82, 47, 4, 5, 2, 9); 
     1600    datasetConcatenateTester(FormatTools.UINT8, 82, 47, 1, 1, 1, 1); 
     1601    datasetConcatenateTester(FormatTools.UINT8, 82, 47, 1, 1, 1, 17); 
     1602    datasetConcatenateTester(FormatTools.UINT8, 82, 47, 4, 5, 2, 9); 
    15771603  } 
    15781604 
     
    16191645 
    16201646    // these here to simplify debugging 
    1621     colorCompositeTest(FormatTools.UINT8,false,1,false,3,1); 
    1622     colorCompositeTest(FormatTools.UINT8,true,1,false,3,1); 
     1647    colorCompositeTester(FormatTools.UINT8,false,1,false,3,1); 
     1648    colorCompositeTester(FormatTools.UINT8,true,1,false,3,1); 
    16231649 
    16241650    int[] pixTypes = new int[] {FormatTools.UINT8}; 
     
    16381664                  { 
    16391665                    //System.out.println(" format "+pixFormat+"indexed "+indexed+" rgb "+rgb+" fasleColor "+falseColor+" c "+c+" s "+s); 
    1640                     colorCompositeTest(pixFormat,indexed,rgb,falseColor,c,s); 
     1666                    colorCompositeTester(pixFormat,indexed,rgb,falseColor,c,s); 
    16411667                  } 
    16421668  } 
     
    16451671  public void testColorColorized() 
    16461672  { 
    1647     colorColorizedTest(); 
     1673    colorColorizedTester(); 
    16481674  } 
    16491675   
     
    16511677  public void testColorGrayscale() 
    16521678  { 
    1653     colorGrayscaleTest(); 
     1679    colorGrayscaleTester(); 
    16541680  } 
    16551681   
     
    16771703                  { 
    16781704                    //System.out.println("format "+pixFormat+" x "+x+" y "+y+" z "+z+" c "+c+" t "+t+" s "+s); 
    1679                     colorCustomTest(pixFormat,x,y,z,c,t,s); 
     1705                    colorCustomTester(pixFormat,x,y,z,c,t,s); 
    16801706                  } 
    16811707  } 
     
    16941720      { 
    16951721        //System.out.println("testColorAutoscale(): pixType = "+FormatTools.getPixelTypeString(pixType)+" autoscale = "+autoscale); 
    1696         autoscaleTest(pixType,autoscale); 
     1722        autoscaleTester(pixType,autoscale); 
    16971723      } 
    16981724    } 
     
    17021728  public void testMemoryVirtualStack() 
    17031729  { 
    1704     memoryVirtualStackTest(false); 
    1705     memoryVirtualStackTest(true); 
     1730    memoryVirtualStackTester(false); 
     1731    memoryVirtualStackTester(true); 
    17061732  } 
    17071733 
     
    17091735  public void testMemoryRecordModifications() 
    17101736  { 
    1711     memoryRecordModificationsTest(false); 
    1712     memoryRecordModificationsTest(true); 
     1737    memoryRecordModificationsTester(false); 
     1738    memoryRecordModificationsTester(true); 
    17131739  } 
    17141740 
     
    17201746    // test partial z: from 
    17211747    z=8; c=3; t=2; zFrom=2; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1722     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1748    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17231749     
    17241750    // test partial z: to 
    17251751    z=8; c=3; t=2; zFrom=0; zTo=4; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1726     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1752    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17271753 
    17281754    // test partial z: by 
    17291755    z=8; c=3; t=2; zFrom=0; zTo=z-1; zBy=3; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1730     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1756    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17311757 
    17321758    // test full z 
    17331759    z=8; c=3; t=2; zFrom=2; zTo=7; zBy=3; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1734     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1760    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17351761     
    17361762    // test partial c: from 
    17371763    z=6; c=14; t=4; zFrom=0; zTo=z-1; zBy=1; cFrom=3; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1738     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1764    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17391765     
    17401766    // test partial c: to 
    17411767    z=6; c=14; t=4; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=6; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1742     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1768    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17431769     
    17441770    // test partial c: by 
    17451771    z=6; c=14; t=4; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=4; tFrom=0; tTo=t-1; tBy=1; 
    1746     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1772    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17471773     
    17481774    // test full c 
    17491775    z=6; c=14; t=4; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=12; cBy=4; tFrom=0; tTo=t-1; tBy=1; 
    1750     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1776    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17511777     
    17521778    // test partial t: from 
    17531779    z=3; c=5; t=13; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=4; tTo=t-1; tBy=1; 
    1754     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1780    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17551781     
    17561782    // test partial t: to 
    17571783    z=3; c=5; t=13; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=8; tBy=1; 
    1758     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1784    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17591785     
    17601786    // test partial t: by 
    17611787    z=3; c=5; t=13; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=2; 
    1762     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1788    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17631789     
    17641790    // test full t 
    17651791    z=3; c=5; t=13; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=4; tTo=13; tBy=2; 
    1766     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1792    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17671793     
    17681794    // test edge case combo with an invalid by 
    17691795    z=2; c=2; t=2; zFrom=0; zTo=0; zBy=2; cFrom=1; cTo=1; cBy=1; tFrom=0; tTo=1; tBy=1; 
    1770     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1796    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17711797 
    17721798    // test a combination of zct's 
    17731799    z=5; c=4; t=6; zFrom=1; zTo=4; zBy=2; cFrom=1; cTo=3; cBy=1; tFrom=2; tTo=5; tBy=2; 
    1774     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1800    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17751801     
    17761802    // test another combination of zct's 
    17771803    z=7; c=7; t=7; zFrom=3; zTo=6; zBy=4; cFrom=1; cTo=6; cBy=3; tFrom=0; tTo=2; tBy=2; 
    1778     memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1804    memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17791805     
    17801806    // test bad combination of zct's - choosing beyond ends of ranges 
     
    17831809    try { 
    17841810      z=7; c=7; t=7; zFrom=-1; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1785       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1811      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17861812      fail(); 
    17871813    } catch (IllegalArgumentException e) { 
     
    17921818    try { 
    17931819      z=7; c=7; t=7; zFrom=0; zTo=z; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1794       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1820      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    17951821      fail(); 
    17961822    } catch (IllegalArgumentException e) { 
     
    18011827    try { 
    18021828      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=0; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1803       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1829      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18041830      fail(); 
    18051831    } catch (IllegalArgumentException e) { 
     
    18101836    try { 
    18111837      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=-1; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1812       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1838      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18131839      fail(); 
    18141840    } catch (IllegalArgumentException e) { 
     
    18191845    try { 
    18201846      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c; cBy=1; tFrom=0; tTo=t-1; tBy=1; 
    1821       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1847      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18221848      fail(); 
    18231849    } catch (IllegalArgumentException e) { 
     
    18281854    try { 
    18291855      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=0; tFrom=0; tTo=t-1; tBy=1; 
    1830       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1856      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18311857      fail(); 
    18321858    } catch (IllegalArgumentException e) { 
     
    18371863    try { 
    18381864      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=-1; tTo=t-1; tBy=1; 
    1839       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1865      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18401866      fail(); 
    18411867    } catch (IllegalArgumentException e) { 
     
    18461872    try { 
    18471873      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t; tBy=1; 
    1848       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1874      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18491875      fail(); 
    18501876    } catch (IllegalArgumentException e) { 
     
    18551881    try { 
    18561882      z=7; c=7; t=7; zFrom=0; zTo=z-1; zBy=1; cFrom=0; cTo=c-1; cBy=1; tFrom=0; tTo=t-1; tBy=0; 
    1857       memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1883      memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18581884      fail(); 
    18591885    } catch (IllegalArgumentException e) { 
     
    18861912                        // expect failure 
    18871913                        try { 
    1888                           memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     1914                          memorySpecifyRangeTester(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    18891915                          System.out.println("memorySpecifyRange() test failed: combo = zct "+z+" "+c+" "+t+ 
    18901916                            " z vals "+zFrom+" "+zTo+" "+zBy+ 
     
    18981924                      else 
    18991925                        // expect success 
    1900                         memorySpecifyRangeTest(z,c,t,zStart,zEnd,zInc,cStart,cEnd,cInc,tStart,tEnd,tInc); 
     1926                        memorySpecifyRangeTester(z,c,t,zStart,zEnd,zInc,cStart,cEnd,cInc,tStart,tEnd,tInc); 
    19011927    */ 
    19021928     
     
    19061932  public void testMemoryCrop() 
    19071933  { 
    1908     memoryCropTest(203, 255, 55, 20, 3); 
    1909     memoryCropTest(203, 184, 55, 40, 2); 
    1910     memoryCropTest(101, 76, 0, 25, 4); 
    1911     memoryCropTest(100, 122, 0, 15, 3); 
     1934    memoryCropTester(203, 255, 55, 20, 3); 
     1935    memoryCropTester(203, 184, 55, 40, 2); 
     1936    memoryCropTester(101, 76, 0, 25, 4); 
     1937    memoryCropTester(100, 122, 0, 15, 3); 
    19121938  } 
    19131939   
     
    20552081  { 
    20562082    // try a simple test: single small byte type image  
    2057     comboCropAndAutoscaleTest(FormatTools.UINT8,240,240,1,1,1,70,40,25); 
     2083    comboCropAndAutoscaleTester(FormatTools.UINT8,240,240,1,1,1,70,40,25); 
    20582084     
    20592085    // try multiple dimensions 
    2060     comboCropAndAutoscaleTest(FormatTools.UINT8,240,240,4,3,2,51,15,13); 
     2086    comboCropAndAutoscaleTester(FormatTools.UINT8,240,240,4,3,2,51,15,13); 
    20612087     
    20622088    // try various pixTypes 
    20632089    for (int pixType : PixelTypes) 
    2064       comboCropAndAutoscaleTest(pixType,240,240,2,2,2,225,225,10); 
     2090      comboCropAndAutoscaleTester(pixType,240,240,2,2,2,225,225,10); 
    20652091  } 
    20662092   
     
    20742100  public void testComboConcatSplitZ() 
    20752101  { 
    2076     comboConcatSplitFocalPlanesTest(); 
     2102    comboConcatSplitFocalPlanesTester(); 
    20772103  } 
    20782104 
     
    20802106  public void testComboConcatSplitC() 
    20812107  { 
    2082     comboConcatSplitChannelsTest(); 
     2108    comboConcatSplitChannelsTester(); 
    20832109  } 
    20842110 
     
    20862112  public void testComboConcatSplitT() 
    20872113  { 
    2088     comboConcatSplitTimepointsTest(); 
     2114    comboConcatSplitTimepointsTester(); 
    20892115  } 
    20902116 
     
    22492275          getIndexValue(imp, zIndex, cIndex, tIndex, indexed); 
    22502276          //assertEquals(iIndex++,getIndexValue(imp, zIndex, cIndex, tIndex, indexed)); 
     2277          // testValues(imp,0,zIndex,cIndex,tIndex,iIndex,indexed); 
    22512278  } 
    22522279 
     
    23162343    fail("Numerous failures : actual tests commented out to see all print statements."); 
    23172344  } 
    2318    
     2345 
     2346  private void compositeTester(int sizeC, boolean indexed) 
     2347  { 
     2348    System.out.println("compositeTest: sizeC = "+sizeC); 
     2349     
     2350    int pixType = FormatTools.UINT8, sizeX = 60, sizeY = 30, sizeZ = 2, sizeT = 3, numSeries = 1, rgb = -1, lutLen = -1; 
     2351    boolean falseColor = false; 
     2352     
     2353    String path = constructFakeFilename("colorComposite", pixType, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries, indexed, 
     2354                                          rgb, falseColor, lutLen); 
     2355 
     2356    ImagePlus[] imps = null; 
     2357    ImagePlus imp = null; 
     2358    CompositeImage ci = null; 
     2359     
     2360    try { 
     2361      ImporterOptions options = new ImporterOptions(); 
     2362      options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE); 
     2363      options.setId(path); 
     2364      imps = BF.openImagePlus(options); 
     2365    } 
     2366    catch (IOException e) { 
     2367      fail(e.getMessage()); 
     2368    } 
     2369    catch (FormatException e) { 
     2370      fail(e.getMessage()); 
     2371    } 
     2372 
     2373    impsCountTest(imps,1); 
     2374     
     2375    imp = imps[0]; 
     2376    
     2377    /* 
     2378    System.out.println("  Returned imp: Z = " +imp.getNSlices()+ " C = " +imp.getNChannels()+" T = "+imp.getNFrames()); 
     2379    for (int tIndex = 0; tIndex < imp.getNFrames(); tIndex++) 
     2380      for (int zIndex = 0; zIndex < imp.getNSlices(); zIndex++) 
     2381        for (int cIndex = 0; cIndex < imp.getNChannels(); cIndex++) 
     2382        { 
     2383          imp.setPosition(cIndex+1,zIndex+1,tIndex+1); 
     2384          ImageProcessor proc = imp.getProcessor(); 
     2385          printVals(proc); 
     2386        } 
     2387    */ 
     2388     
     2389    xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 
     2390 
     2391    assertTrue(imp.isComposite()); 
     2392 
     2393    ci = (CompositeImage)imp; 
     2394     
     2395    assertFalse(ci.hasCustomLuts()); 
     2396 
     2397    assertEquals(CompositeImage.COMPOSITE, ci.getMode()); 
     2398     
     2399    colorTests(ci,sizeC,DefaultColorOrder); 
     2400       
     2401    int iIndex = 0; 
     2402    for (int tIndex = 0; tIndex < sizeT; tIndex++) 
     2403      for (int zIndex = 0; zIndex < sizeZ; zIndex++) 
     2404        for (int cIndex = 0; cIndex < sizeC; cIndex++) 
     2405        { 
     2406          //testIndexValues(imp,0,iIndex++,zIndex,cIndex,tIndex,indexed); 
     2407          assertEquals(0,sIndex(imp,zIndex,cIndex,tIndex,indexed)); 
     2408          assertEquals(iIndex++,iIndex(imp,zIndex,cIndex,tIndex,indexed)); 
     2409        } 
     2410     
     2411    assertTrue(seriesInCorrectOrder(imp,indexed,0,sizeZ-1,1,0,sizeC-1,1,0,sizeT-1,1)); 
     2412     
     2413    // images from BF look to be in ZCT order 
     2414    // however IJ likes CZT order 
     2415    // seriesInCorrectOrder() is the touchpoint between both ways. See there. 
     2416  } 
     2417 
     2418  /** helper test that verifies the indices of a FakeFile[z,c,t] match passed in values*/ 
     2419  private void testIndexValues(ImagePlus imp, int s, int i, int z, int c, int t, boolean indexed) 
     2420  { 
     2421    String status = "Correct"; 
     2422    if ((z != zIndex(imp, z, c, t, indexed)) || (c != cIndex(imp, z, c, t, indexed))) 
     2423      status = "Wrong"; 
     2424    //  System.out.println("expZ("+z+") expC("+c+")  actZ("+zIndex(imp, z, c, t, indexed)+ 
     2425    //                      ") actC("+cIndex(imp, z, c, t, indexed)+")"); 
     2426    //else 
     2427    //  System.out.println("Z("+z+") C("+c+") correct!"); 
     2428    System.out.println("s("+sIndex(imp,z,c,t,indexed)+") i("+iIndex(imp,z,c,t,indexed)+") z("+zIndex(imp,z,c,t,indexed)+ 
     2429        ") c("+cIndex(imp,z,c,t,indexed)+") t("+tIndex(imp,z,c,t,indexed)+")    expZ("+z+") expC("+c+") "+status); 
     2430    assertEquals(s,sIndex(imp, z, c, t, indexed)); 
     2431    assertEquals(i,iIndex(imp, z, c, t, indexed)); 
     2432    //assertEquals(z,zIndex(imp, z, c, t, indexed)); 
     2433    //assertEquals(c,cIndex(imp, z, c, t, indexed)); 
     2434    assertEquals(t,tIndex(imp, z, c, t, indexed)); 
     2435  } 
     2436   
     2437  private int sIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
     2438  { 
     2439    return getPixelValue(0,0,imp,z,c,t,indexed); 
     2440  } 
     2441   
     2442  private int iIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
     2443  { 
     2444    return getPixelValue(10,0,imp,z,c,t,indexed); 
     2445  } 
     2446   
     2447  private int zIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
     2448  { 
     2449    return getPixelValue(20,0,imp,z,c,t,indexed); 
     2450  } 
     2451   
     2452  private int cIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
     2453  { 
     2454    return getPixelValue(30,0,imp,z,c,t,indexed); 
     2455  } 
     2456   
     2457  private int tIndex(ImagePlus imp, int z, int c, int t, boolean indexed) 
     2458  { 
     2459    return getPixelValue(40,0,imp,z,c,t,indexed); 
     2460  } 
     2461   
     2462  @Test 
     2463  public void testCompositeSubcases() 
     2464  { 
     2465    // TODO - handle more cases with falseColor, rgb, etc. 
     2466    for (boolean indexed : BooleanStates) 
     2467      for (int channels = 2; channels <= 7; channels++) 
     2468        if (!indexed)  // TODO - remove in future; only doing nonindexed right now 
     2469          compositeTester(channels,indexed); 
     2470    fail("unfinished"); 
     2471  } 
    23192472} 
Note: See TracChangeset for help on using the changeset viewer.