Changeset 6274


Ignore:
Timestamp:
05/11/10 14:48:13 (10 years ago)
Author:
bdezonia
Message:

various impls and improvements. updated swapDimsTest to check order of planes.

File:
1 edited

Legend:

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

    r6273 r6274  
    2828//  - flesh out existing tests 
    2929//      splits - see if for loops are in correct order by comparing to actual data 
    30 //      write tests for the color options : 4 cases - some mention that indexcolor an issue 
     30//      write tests for the color options : 4 cases - some mention was made that indexcolor is an issue in testing 
    3131//      open individual files: try to come up with a way to test without a disk file as source 
    3232//      concatenate - test order of images in stack? 
     
    4848    //String template = "test_C%s_TP%s&sizeX=50&sizeY=20&sizeZ=7.fake"; 
    4949    String template = constructFakeFilename("test_C%s_TP%s", FormatTools.UINT8, 50, 20, 7, 1, 1, -1); 
     50                                                                        // BDZ - INT32 is desirable for the color tests 
    5051     
    5152    FAKE_FILES = new String[] { 
     
    221222  private int getSizeT(ImagePlus imp) { return getField(imp, "nFrames"); } 
    222223  private int getEffectiveSizeC(ImagePlus imp) { return getField(imp, "nChannels"); } 
     224 
     225  // used by the color merge code. calcs a pixel value in our ramped data for a 3 channel merged image 
     226  private int mergedPixel(int i) 
     227  { 
     228    if ((i < 0) || (i > 15)) 
     229      throw new IllegalArgumentException("mergedPixel() can only handle 1st 16 cases. Wants 0<=i<=15 but i = " + i); 
     230     
     231    return i*65536 + i*256 + i; 
     232  } 
    223233   
    224234  // ****** helper tests **************************************************************************************** 
     
    241251    assertNotNull(imps); 
    242252    assertEquals(1,imps.length); 
    243     ImagePlus ip = imps[0]; 
    244     assertNotNull(ip); 
    245     assertEquals(x,ip.getWidth()); 
    246     assertEquals(y,ip.getHeight()); 
     253    ImagePlus imp = imps[0]; 
     254    assertNotNull(imp); 
     255    assertEquals(x,imp.getWidth()); 
     256    assertEquals(y,imp.getHeight()); 
    247257    /* 
    248258    assertEquals(z,ip.getNSlices());    // tricky - these last 3 getters have side effects that change their output. 
     
    251261    */ 
    252262    //if (z != getSizeZ(ip)) { new ij.ImageJ(); ip.show(); }//TEMP 
    253     assertEquals(z,getSizeZ(ip)); 
    254     assertEquals(t,getSizeT(ip)); 
    255     assertEquals(c,getEffectiveSizeC(ip)); 
     263    assertEquals(z,getSizeZ(imp)); 
     264    assertEquals(t,getSizeT(imp)); 
     265    assertEquals(c,getEffectiveSizeC(imp)); 
    256266  } 
    257267   
     
    277287    assertEquals(1,imps.length); 
    278288     
    279     ImagePlus ip = imps[0]; 
    280      
    281     ImageStack st = ip.getStack(); 
     289    ImagePlus imp = imps[0]; 
     290     
     291    ImageStack st = imp.getStack(); 
    282292    int numSlices = st.getSize(); 
    283293 
     
    345355    assertEquals(t,actualZ); 
    346356 
    347     // TODO - Verify that actual order is correct, rather than just lengths. 
    348     // Can use zIndex and tIndex methods for this. 
     357    // make sure the dimensions were swapped correctly 
     358    // notice I'm testing from inside out in ZCT order but using input z for T and the input t for Z 
     359    int p = 1; 
     360    for (int k = 0; k < z; k++) 
     361      for (int j = 0; j < c; j++) 
     362        for (int i = 0; i < t; i++) 
     363        { 
     364          ImageProcessor proc = st.getProcessor(p); 
     365          assertEquals(i,zIndex(proc)); 
     366          assertEquals(j,cIndex(proc)); 
     367          assertEquals(k,tIndex(proc)); 
     368          p++; 
     369        } 
    349370  } 
    350371 
     
    462483      assertNotNull(imps); 
    463484      assertEquals(1,imps.length); 
    464       ImagePlus ip = imps[0]; 
    465       assertNotNull(ip); 
    466       assertEquals(x,ip.getWidth()); 
    467       assertEquals(y,ip.getHeight()); 
    468    
    469       assertEquals(desireVirtual,ip.getStack().isVirtual()); 
     485      ImagePlus imp = imps[0]; 
     486      assertNotNull(imp); 
     487      assertEquals(x,imp.getWidth()); 
     488      assertEquals(y,imp.getHeight()); 
     489   
     490      assertEquals(desireVirtual,imp.getStack().isVirtual()); 
    470491  } 
    471492 
     
    520541    assertNotNull(imps); 
    521542    assertEquals(1,imps.length); 
    522     ImagePlus ip = imps[0]; 
    523     assertNotNull(ip); 
    524     assertEquals(x,ip.getWidth()); 
    525     assertEquals(y,ip.getHeight()); 
    526     ImageStack st = ip.getStack(); 
     543    ImagePlus imp = imps[0]; 
     544    assertNotNull(imp); 
     545    assertEquals(x,imp.getWidth()); 
     546    assertEquals(y,imp.getHeight()); 
     547    ImageStack st = imp.getStack(); 
    527548     
    528549    //System.out.println("SpecifyCRangeTest: slices below"); 
     
    666687    datasetSwapDimsTest(FormatTools.INT16, 44, 109, 2, 1); 
    667688    datasetSwapDimsTest(FormatTools.INT32, 44, 109, 4, 3); 
     689    datasetSwapDimsTest(FormatTools.UINT8, 82, 47, 3, 2); 
    668690  } 
    669691 
     
    688710  public void testColorMerge() 
    689711  { 
     712     
     713    String path = FAKE_FILES[0]; 
     714     
     715    ImagePlus[] imps = null; 
     716    ImagePlus imp = null; 
     717     
     718    // test when color merge false 
     719 
     720    try { 
     721      ImporterOptions options = new ImporterOptions(); 
     722      options.setMergeChannels(false); 
     723      options.setId(path); 
     724      imps = BF.openImagePlus(options); 
     725    } 
     726    catch (IOException e) { 
     727      fail(e.getMessage()); 
     728    } 
     729    catch (FormatException e) { 
     730      fail(e.getMessage()); 
     731    } 
     732     
     733    assertEquals(1,imps.length); 
     734    imp = imps[0]; 
     735    assertEquals(3,getEffectiveSizeC(imp)); 
     736    assertEquals(7,getSizeZ(imp)); 
     737    assertEquals(5,getSizeT(imp)); 
     738     
     739    // test when color merge true 
     740     
     741    try { 
     742      ImporterOptions options = new ImporterOptions(); 
     743      options.setMergeChannels(true); 
     744      options.setId(path); 
     745      imps = BF.openImagePlus(options); 
     746    } 
     747    catch (IOException e) { 
     748      fail(e.getMessage()); 
     749    } 
     750    catch (FormatException e) { 
     751      fail(e.getMessage()); 
     752    } 
     753     
     754    assertEquals(1,imps.length); 
     755    imp = imps[0]; 
     756    assertEquals(1,getEffectiveSizeC(imp)); 
     757    assertEquals(7,getSizeZ(imp)); 
     758    assertEquals(5,getSizeT(imp)); 
     759    assertTrue(imp.getHeight() > 10);  // required for this test to work 
     760    for (int i = 0; i < 10; i++) 
     761      assertEquals(mergedPixel(i),imp.getProcessor().get(i,10)); 
     762     
     763    // TODO - also test mergeOptions when chans > 3. it will be an int == chans per plane. extra blank images are 
     764    //   added as needed to make multiple images each with same number of channels 
     765    //   i.e. 6 channels can -> 123/456 or 12/34/56 or 1/2/3/4/5/6 (last one not merged ???) 
     766    //        5 channels can -> 123/45b or 12/34/5b or 1/2/3/4/5 (last one not merged ???) 
     767  } 
     768 
     769  @Test 
     770  public void testColorRgbColorize() 
     771  { 
    690772    // TODO - Curtis says impl broken right now - will test later 
    691773    fail("to be implemented"); 
     
    693775 
    694776  @Test 
    695   public void testColorRgbColorize() 
     777  public void testColorCustomColorize() 
    696778  { 
    697779    // TODO - Curtis says impl broken right now - will test later 
     
    700782 
    701783  @Test 
    702   public void testColorCustomColorize() 
     784  public void testColorAutoscale() 
    703785  { 
    704786    // TODO - Curtis says impl broken right now - will test later 
     
    707789 
    708790  @Test 
    709   public void testColorAutoscale() 
    710   { 
    711     // TODO - Curtis says impl broken right now - will test later 
    712     fail("to be implemented"); 
    713   } 
    714  
    715   @Test 
    716791  public void testMemoryVirtualStack() 
    717792  { 
     
    727802    // outline 
    728803    //   open as virt stack 
    729     //   run plugin or macro that changes pixels in currently loaded frame (frame 0) 
     804    //   run plugin (invert) or macro that changes pixels in currently loaded frame (frame 0) 
    730805    //   change curr frame to 1 and test that pixels are different from what we set 
    731806    //   change curr frame back to 0 and see if pixel changes remembered 
     
    787862    memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    788863     
     864    // test edge case combo with an invalid by 
     865    z=2; c=2; t=2; zFrom=0; zTo=0; zBy=2; cFrom=1; cTo=1; cBy=1; tFrom=0; tTo=1; tBy=1; 
     866    memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
     867 
    789868    // test a combination of zct's 
    790869    z=5; c=4; t=6; zFrom=1; zTo=4; zBy=2; cFrom=1; cTo=3; cBy=1; tFrom=2; tTo=6; tBy=2; 
    791870    memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    792871     
    793     // TODO 
    794     //  1) more combos 
    795     //  2) noticed I am always setting from/to/by at the same time. test setting only one at a time (pass -1 to ignore) 
     872    // test another combination of zct's 
     873    z=7; c=7; t=7; zFrom=3; zTo=7; zBy=4; cFrom=1; cTo=6; cBy=3; tFrom=0; tTo=2; tBy=2; 
     874    memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 
    796875  } 
    797876   
Note: See TracChangeset for help on using the changeset viewer.