Changeset 6259


Ignore:
Timestamp:
05/10/10 16:34:34 (10 years ago)
Author:
bdezonia
Message:

further work: group files, open indiv files

File:
1 edited

Legend:

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

    r6258 r6259  
    1717import java.lang.reflect.Field; 
    1818 
     19import loci.common.Location; 
    1920import loci.common.Region; 
    2021import loci.formats.FormatException; 
     
    2526 
    2627// TODO 
     28//  - figure out what openIndiv is supposed to do and also where it fits in priorities 
    2729//  - flesh out existing tests 
    28 //      get reflection code working 
    29 //      write test for open series code 
    30 //      write tests for split options 
    31 //      write tests for the color options 
     30//      groups files test needs to be written/debugged 
     31//      write test for open indiv files : getting dataset from Melissa. Priority may be wrong. 
     32//      write tests for split options : 3 cases 
     33//      write tests for the color options : 4 cases 
    3234//      concat follows - see my test to see if sufficient 
    3335//      lowest priority - record modifications 
     
    210212    /* 
    211213    assertEquals(z,ip.getNSlices());    // tricky - these last 3 getters have side effects that change their output. 
    212     assertEquals(c,ip.getNChannels());  // TODO - How to test? 
     214    assertEquals(c,ip.getNChannels()); 
    213215    assertEquals(t,ip.getNFrames()); 
    214216    */ 
    215     if (z != getSizeZ(ip)) { new ij.ImageJ(); ip.show(); }//TEMP 
     217    //if (z != getSizeZ(ip)) { new ij.ImageJ(); ip.show(); }//TEMP 
    216218    assertEquals(z,getSizeZ(ip)); 
    217219    assertEquals(t,getSizeT(ip)); 
     
    303305    assertEquals(z*c*t,numSlices); 
    304306 
    305     System.out.println("datasetSwapDimsTest()"); 
    306     System.out.println("  Numslices == " + numSlices); 
    307      
    308307    int maxZ = -1; 
    309308    int maxT = -1; 
     
    322321  } 
    323322 
    324   private void datasetOpenAllSeriesTest() 
    325   { 
    326     // TODO - fill me in 
     323  private void datasetOpenAllSeriesTest(int x, int y, int z, int c, int t, int s) 
     324  { 
     325    String path = constructFakeFilename("XYZCT", FormatTools.UINT32, x, y, z, c, t, s); 
     326     
     327    // try it when false 
     328     
     329    ImagePlus[] imps = null; 
     330    try { 
     331      ImporterOptions options = new ImporterOptions(); 
     332      options.setId(path); 
     333      options.setOpenAllSeries(false); 
     334      imps = BF.openImagePlus(options); 
     335    } 
     336    catch (IOException e) { 
     337      fail(e.getMessage()); 
     338    } 
     339    catch (FormatException e) { 
     340      fail(e.getMessage()); 
     341    } 
     342     
     343    // test results 
     344     
     345    assertEquals(1,imps.length); 
     346    assertEquals(x,imps[0].getWidth()); 
     347    assertEquals(y,imps[0].getHeight()); 
     348    assertEquals(z*c*t, imps[0].getStack().getSize()); 
     349     
     350    // try it when true 
     351     
     352    try { 
     353      ImporterOptions options = new ImporterOptions(); 
     354      options.setId(path); 
     355      options.setOpenAllSeries(true); 
     356      imps = BF.openImagePlus(options); 
     357    } 
     358    catch (IOException e) { 
     359      fail(e.getMessage()); 
     360    } 
     361    catch (FormatException e) { 
     362      fail(e.getMessage()); 
     363    } 
     364 
     365    // test results 
     366     
     367    assertEquals(s,imps.length); 
     368    for (int i = 0; i < s; i++) 
     369    { 
     370      assertEquals(x,imps[i].getWidth()); 
     371      assertEquals(y,imps[i].getHeight()); 
     372      assertEquals(z*c*t, imps[i].getStack().getSize()); 
     373    } 
    327374  } 
    328375   
     
    363410      // printVals(proc); 
    364411      assertEquals(0,sIndex(proc));  // make sure we have one series only 
     412      // TODO - do we need to test something regarding order of images in series 
    365413    } 
    366414  } 
     
    503551  public void testDatasetGroupFiles() 
    504552  { 
    505     String path = constructFakeFilename("group", FormatTools.INT16, 50, 50, 1, 1, 1, -1); 
     553    String[] files = { 
     554        "test_C1_TP1&sizeX=50&sizeY=20&sizeZ=7.fake", 
     555        "test_C2_TP1&sizeX=50&sizeY=20&sizeZ=7.fake", 
     556        "test_C3_TP1&sizeX=50&sizeY=20&sizeZ=7.fake", 
     557        "test_C1_TP2&sizeX=50&sizeY=20&sizeZ=7.fake", 
     558        "test_C2_TP2&sizeX=50&sizeY=20&sizeZ=7.fake", 
     559        "test_C3_TP2&sizeX=50&sizeY=20&sizeZ=7.fake", 
     560        "test_C1_TP3&sizeX=50&sizeY=20&sizeZ=7.fake", 
     561        "test_C2_TP3&sizeX=50&sizeY=20&sizeZ=7.fake", 
     562        "test_C3_TP3&sizeX=50&sizeY=20&sizeZ=7.fake", 
     563        "test_C1_TP4&sizeX=50&sizeY=20&sizeZ=7.fake", 
     564        "test_C2_TP4&sizeX=50&sizeY=20&sizeZ=7.fake", 
     565        "test_C3_TP4&sizeX=50&sizeY=20&sizeZ=7.fake", 
     566        "test_C1_TP5&sizeX=50&sizeY=20&sizeZ=7.fake", 
     567        "test_C2_TP5&sizeX=50&sizeY=20&sizeZ=7.fake", 
     568        "test_C3_TP5&sizeX=50&sizeY=20&sizeZ=7.fake", 
     569        "outlier.txt" 
     570      }; 
     571     
     572    for (String file : files) 
     573      Location.mapId(file, "iThinkI'mImportantButI'mNot"); 
     574 
     575    String path = "test_C1_TP1&sizeX=50&sizeY=20&sizeZ=7.fake"; 
     576 
    506577    ImagePlus[] imps = null; 
    507578    try { 
     
    510581      options.setId(path); 
    511582      imps = BF.openImagePlus(options); 
     583      // TODO - assertEquals("test_C<1-3>_TP<1-5>&sizeX=50&sizeY=20&sizeZ=7.fake",options.getId()); 
    512584    } 
    513585    catch (IOException e) { 
     
    518590      } 
    519591     
    520     // TODO - flesh this out and add asserts 
     592    assertEquals(1,imps.length); 
     593    assertEquals(105,imps[0].getStack().getSize()); 
    521594  } 
    522595 
     
    524597  public void testDatasetOpenFilesIndividually() 
    525598  { 
    526     // TODO - do something. Did Curtis say this did not need testing. I didn't have it. 
    527     //   May have been an oversight but maybe not. 
     599    // TODO - try to remove file dependency 
     600     
     601    String path = "2channel_stack_raw01.pic"; 
     602     
     603    // try ungrouped 
     604     
     605    ImagePlus[] imps = null; 
     606    try { 
     607      ImporterOptions options = new ImporterOptions(); 
     608      options.setUngroupFiles(true); 
     609      options.setId(path); 
     610      imps = BF.openImagePlus(options); 
     611    } 
     612    catch (IOException e) { 
     613      fail(e.getMessage()); 
     614    } 
     615    catch (FormatException e) { 
     616      fail(e.getMessage()); 
     617    } 
     618     
     619    // test results 
     620     
     621    assertEquals(1,imps.length); 
     622    assertEquals(16,imps[0].getStack().getSize()); 
     623     
     624    // try grouped 
     625     
     626    try { 
     627      ImporterOptions options = new ImporterOptions(); 
     628      options.setUngroupFiles(false); 
     629      options.setId(path); 
     630      imps = BF.openImagePlus(options); 
     631    } 
     632    catch (IOException e) { 
     633      fail(e.getMessage()); 
     634    } 
     635    catch (FormatException e) { 
     636      fail(e.getMessage()); 
     637    } 
     638 
     639    // test results 
     640     
     641    assertEquals(1,imps.length); 
     642    assertEquals(32,imps[0].getStack().getSize()); 
    528643  } 
    529644   
     
    547662  public void testDatasetOpenAllSeries() 
    548663  { 
    549     // TODO - add cases 
    550     datasetOpenAllSeriesTest(); 
     664    datasetOpenAllSeriesTest(73,107,1,1,1,1);  // one series 
     665    datasetOpenAllSeriesTest(73,107,1,1,1,2);  // two series 
     666    datasetOpenAllSeriesTest(73,107,5,3,4,4);  // multiple series with Z,C,T larger than 1 
    551667  } 
    552668   
     
    597713  public void testMemoryRecordModifications() 
    598714  { 
    599     // TODO - how to test this? 
     715    // TODO - how to test this? lowest priority 
    600716  } 
    601717   
     
    9141030 } 
    9151031That's how you synthesize a virtual directory on disk, essentially, for the file grouping logic to use. 
    916 The key is to register each fake filename with "Location.mapId(filename, dummy)" where "dummy" doesn't matter. As long as it's not null. 
    917  
    918 Then below, I call "getUsedFiles" to get a list of the constituent filenames, which you can compare against your expectations. 
     1032The key is to register each fake filename with "Location.mapId(filename, dummy)" where "dummy" doesn't matter. 
     1033As long as it's not null. 
     1034 
     1035Then below, I call "getUsedFiles" to get a list of the constituent filenames, which you can compare against 
     1036your expectations. 
     1037 
     1038Oh, forget about what I said about getUsedFilesÑyou don't have access to the API at that level. 
    9191039 
    9201040 */ 
Note: See TracChangeset for help on using the changeset viewer.