Changeset 6620
 Timestamp:
 07/01/10 11:36:51 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/components/lociplugins/test/loci/plugins/in/ImporterTest.java
r6594 r6620 37 37 38 38 // left off 39 // datasetSwapDims has ugly workaround to handle bad signed data / virtual flag interaction. Need BF fix. 40 // note  I made getPixelValue() use czt order. this allowed compositeTester() to pass for some simple cases. Notice it broke 41 // memorySpecifyRange(). Also notice that 3/1 gives weird sizct values in stackInCztOrder(). 42 // remember to test the 25 limitation in the CompositeTester that it still is required 39 43 // expand testing to use virtual stacks everywhere  partially done 40 44 // expand compositeTestSubcases() to handle more pixTypes and indexed data … … 121 125 122 126 private static final int FakePlaneCount = 7; 127 private static final int FakeChannelCount = 3; 128 private static final int FakeTimepointCount = 5; 123 129 124 130 static { … … 428 434 // else a regular ImagePlus 429 435 430 System.out.println(" getting color table from a regular ImagePlus.");436 //System.out.println(" getting color table from a regular ImagePlus."); 431 437 432 438 IndexColorModel icm = (IndexColorModel)imp.getProcessor().getColorModel(); … … 444 450 private int getPixelValue(int x,int y, ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor) 445 451 { 446 setZctPosition(imp,z,c,t); 452 //TODO  restore  changed for compositeTest debugging setZctPosition(imp,z,c,t); 453 setCztPosition(imp,z,c,t); 447 454 448 455 int rawValue = (int) (imp.getProcessor().getPixelValue(x, y)); … … 457 464 // OR Use red in case lut len < 3 and zero fills other channels 458 465 459 System.out.println(" did a lut lookup in getPixelValue("+z+","+c+","+t+") = "+value+" (rawValue = "+rawValue+")");466 //System.out.println(" did a lut lookup in getPixelValue("+z+","+c+","+t+") = "+value+" (rawValue = "+rawValue+")"); 460 467 461 468 return value; … … 559 566 560 567 /** tests that the indices of a FakeFile[z,c,t] match passed in values*/ 561 private void indexValuesTest(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor, 562 int es, int ei, int ez, int ec, int et) 563 { 564 assertEquals(es,sIndex(imp, z, c, t, indexed,falseColor)); 565 assertEquals(ei,iIndex(imp, z, c, t, indexed,falseColor)); 566 assertEquals(ez,zIndex(imp, z, c, t, indexed,falseColor)); 567 assertEquals(ec,cIndex(imp, z, c, t, indexed,falseColor)); 568 assertEquals(et,tIndex(imp, z, c, t, indexed,falseColor)); 568 private boolean indexValuesTest(ImagePlus imp, int z, int c, int t, boolean indexed, boolean falseColor, 569 int expS, int expI, int expZ, int expC, int expT) 570 { 571 int tempS = sIndex(imp, z, c, t, indexed, falseColor); 572 int tempI = iIndex(imp, z, c, t, indexed, falseColor); 573 int tempZ = zIndex(imp, z, c, t, indexed, falseColor); 574 int tempC = cIndex(imp, z, c, t, indexed, falseColor); 575 int tempT = tIndex(imp, z, c, t, indexed, falseColor); 576 577 System.out.println("actual CZT "+tempC+" "+tempZ+" "+tempT); 578 579 //System.out.println(" indices test"); 580 //System.out.println(" expected (sizct): "+expS+" "+expI+" "+expZ+" "+expC+" "+expT); 581 //System.out.println(" actual (sizct): "+tempS+" "+tempI+" "+tempZ+" "+tempC+" "+tempT); 582 583 //TODO  remove this debugging code 584 if ((expS != tempS)  /*(expI != tempI) */ (expZ != tempZ)  (expC != tempC)  (expT != tempT)) 585 { 586 //System.out.println(" indices test"); 587 //System.out.println(" expected (sizct): "+expS+" "+expI+" "+expZ+" "+expC+" "+expT); 588 //System.out.println(" actual (sizct): "+tempS+" "+tempI+" "+tempZ+" "+tempC+" "+tempT); 589 590 return false; 591 } 592 else 593 { 594 assertEquals(expS,tempS); 595 //assertEquals(expI,tempI); 596 assertEquals(expZ,tempZ); 597 assertEquals(expC,tempC); 598 assertEquals(expT,tempT); 599 return true; 600 } 569 601 } 570 602 … … 572 604 private void stackInZctOrderTest(ImagePlus imp, int maxZ, int maxC, int maxT, boolean indexed, boolean falseColor) 573 605 { 606 System.out.println("stackInZctOrderTest()"); 607 608 boolean success = true; 609 574 610 stackTest(imp,(maxZ * maxC * maxT)); 575 611 576 612 int iIndex = 0; 577 for (int t = 0; t < maxT; t++) 578 for (int c = 0; c < maxC; c++) 579 for (int z = 0; z < maxZ; z++) 580 { 613 for (int t = 0; t < maxT; t++) { 614 for (int c = 0; c < maxC; c++) { 615 for (int z = 0; z < maxZ; z++) { 616 581 617 int expectedS = 0; 582 618 int expectedI = iIndex; … … 587 623 iIndex++; 588 624 589 indexValuesTest(imp,z,c,t,indexed,falseColor,expectedS,expectedI,expectedZ,expectedC,expectedT);625 success &= indexValuesTest(imp,z,c,t,indexed,falseColor,expectedS,expectedI,expectedZ,expectedC,expectedT); 590 626 } 591 } 592 593 /** tests that a FakeFile dataset has index values in ZCT order repeated once per series */ 594 private void multipleSeriesInZtcOrderTest(ImagePlus imp, int numSeries, int maxZ, int maxC, int maxT) 627 } 628 } 629 630 if (!success) 631 fail("indexValuesTest() failed for some values"); 632 } 633 634 /** tests that a FakeFile dataset has index values in CZT order */ 635 private void stackInCztOrderTest(ImagePlus imp, int maxZ, int maxC, int maxT, boolean indexed, boolean falseColor,int inputChan, int inputChanPerPlane) 636 { 637 System.out.println("stackInCztOrderTest()"); 638 639 boolean success = true; 640 641 stackTest(imp,(maxZ * maxC * maxT)); 642 643 int iIndex = 0; 644 for (int t = 0; t < maxT; t++) { 645 for (int z = 0; z < maxZ; z++) { 646 for (int c = 0; c < maxC; c++) { 647 648 int expectedS = 0; 649 int expectedI = 0; // won't test anymore : some tricky cases arise 650 // TODO hack #1 651 //if (inputChan == 3 && inputChanPerPlane == 1) 652 // expectedI = iIndex; // works for nonindexed 3/1 uint8. fails for indexed 3/1 uint8 653 // does not work for 6/3/nonindexed : there it looks like iIndex/maxC again 654 //else if (inputChan == inputChanPerPlane) 655 // expectedI = iIndex/maxC; // works for nonindexed 1/1 2/2 7/7 8/8 uint8s. 656 //else 657 // expectedI = iIndex/inputChanPerPlane; 658 659 int expectedZ = z; 660 int expectedC = c; 661 // TODO : BIG hack #2  temporary! required to get 3/1/nonindexed passing. Will break 6/3/nonindexed. 662 //if (inputChan != inputChanPerPlane) 663 //{ 664 // expectedZ = c; // why are they out of order in this case????? 665 // expectedC = z; 666 //} 667 int expectedT = t; 668 669 iIndex++; 670 671 success &= indexValuesTest(imp,z,c,t,indexed,falseColor,expectedS,expectedI,expectedZ,expectedC,expectedT); 672 } 673 } 674 } 675 676 if (!success) 677 fail("indexValuesTest() failed for some values"); 678 } 679 680 /** tests that a FakeFile dataset has index values in CZT order repeated once per series */ 681 private void multipleSeriesInCztOrderTest(ImagePlus imp, int numSeries, int maxZ, int maxC, int maxT) 595 682 { 596 683 // make sure the number of slices in stack is a sum of all series … … 602 689 for (int sIndex = 0; sIndex < numSeries; sIndex++) { 603 690 for (int tIndex = 0; tIndex < maxT; tIndex++) { 604 for (int cIndex = 0; cIndex < maxC; cIndex++) {605 for (int zIndex = 0; zIndex < maxZ; zIndex++) {691 for (int zIndex = 0; zIndex < maxZ; zIndex++) { 692 for (int cIndex = 0; cIndex < maxC; cIndex++) { 606 693 ImageProcessor proc = st.getProcessor(++slice); 607 694 assertEquals(sIndex, sIndex(proc)); … … 635 722 636 723 int slice = 0; 637 for (int i = 0; i < maxI; i++) 638 for (int j = 0; j < maxJ; j++) 639 for (int k = 0; k < maxK; k++) 640 { 724 for (int i = 0; i < maxI; i++) { 725 for (int j = 0; j < maxJ; j++) { 726 for (int k = 0; k < maxK; k++) { 727 641 728 ImageProcessor proc = st.getProcessor(++slice); 642 729 //printVals(proc); … … 649 736 assertEquals(k,index(fastest,proc)); 650 737 } 738 } 739 } 651 740 } 652 741 … … 684 773 ImageStack st = imp.getStack(); 685 774 775 System.out.println("groupedFilesTest"); 686 776 int slice = 0; 687 for (int fnum = 0; fnum < FAKE_FILES.length; fnum++) 688 { 689 for (int plane = 0; plane < FakePlaneCount; plane++) 690 { 691 ImageProcessor proc = st.getProcessor(++slice); 692 //printVals(proc); 693 assertEquals(0,sIndex(proc)); 694 assertEquals(plane,iIndex(proc)); // TODO: is this correct. it passes but looks wrong. 695 assertEquals(plane,zIndex(proc)); 696 assertEquals(0,cIndex(proc)); 697 assertEquals(0,tIndex(proc)); 777 for (int t = 0; t < FakeTimepointCount; t++) { 778 for (int z = 0; z < FakePlaneCount; z++) { 779 for (int c = 0; c < FakeChannelCount; c++) { 780 781 ImageProcessor proc = st.getProcessor(++slice); 782 printVals(proc); 783 assertEquals(0,sIndex(proc)); 784 assertEquals(z,iIndex(proc)); // TODO: is this correct. it passes but looks wrong. 785 assertEquals(z,zIndex(proc)); 786 assertEquals(0,cIndex(proc)); 787 assertEquals(0,tIndex(proc)); 788 } 698 789 } 699 790 } … … 701 792 702 793 /** tests that a dataset has had its Z & T dimensions swapped */ 703 private void swappedZtTest(ImagePlus imp, int originalZ, int originalC, int originalT) 704 { 794 private void swappedZtTest(ImagePlus imp, int pixType, boolean virtual, int originalZ, int originalC, int originalT) 795 { 796 System.out.println("swappedZtTest() : virtual "+virtual+" pixType "+FormatTools.getPixelTypeString(pixType)); 797 705 798 stackTest(imp,(originalZ*originalC*originalT)); 706 799 707 800 ImageStack st = imp.getStack(); 708 801 802 long offset = minPixelValue(pixType); 803 if (pixType == FormatTools.INT32) // note  since INT32 represented internally as float the signedness is ignored by IJ 804 offset = 0; 805 709 806 // verify that the dimensional extents were swapped 710 807 final int actualSizeZ = imp.getNSlices(); … … 717 814 // verify that every plane appears in the swapped order 718 815 int slice = 0; 719 for (int tIndex = 0; tIndex < actualSizeT; tIndex++) 720 for (int cIndex = 0; cIndex < actualSizeC; cIndex++) 721 for (int zIndex = 0; zIndex < actualSizeZ; zIndex++) 722 { 816 for (int tIndex = 0; tIndex < actualSizeT; tIndex++) { 817 for (int zIndex = 0; zIndex < actualSizeZ; zIndex++) { 818 for (int cIndex = 0; cIndex < actualSizeC; cIndex++) { 819 820 int actualZ, actualC, actualT; 723 821 ImageProcessor proc = st.getProcessor(++slice); 724 final int actualZ = tIndex(proc); // Z<>T swapped 725 final int actualC = cIndex(proc); 726 final int actualT = zIndex(proc); // Z<>T swapped 822 823 // TODO  hack in place to clarify an underlying BF bug. Remove when bug fixed. 824 if (virtual) 825 { 826 actualZ = (int)(offset + tIndex(proc)); // Z<>T swapped 827 actualC = (int)(offset + cIndex(proc)); 828 actualT = (int)(offset + zIndex(proc)); // Z<>T swapped 829 } 830 else 831 { 832 actualZ = tIndex(proc); // Z<>T swapped 833 actualC = cIndex(proc); 834 actualT = zIndex(proc); // Z<>T swapped 835 } 836 //System.out.println("\nexp CZT "+cIndex+" "+zIndex+" "+tIndex); 837 //System.out.println("act CZT "+actualC+" "+actualZ+" "+actualT); 838 // TODO  put back in post debug 727 839 assertEquals(zIndex, actualZ); 728 840 assertEquals(cIndex, actualC); 729 841 assertEquals(tIndex, actualT); 730 842 } 843 } 844 } 731 845 } 732 846 … … 743 857 stackTest(imp,(zs * cs * ts)); 744 858 745 for (int t = 0; t < ts; t++) 746 for (int c = 0; c < cs; c++) 747 for (int z = 0; z < zs; z++) 748 { 859 for (int t = 0; t < ts; t++) { 860 for (int c = 0; c < cs; c++) { 861 for (int z = 0; z < zs; z++) { 862 749 863 int zIndex = zIndex(imp,z,c,t,indexed,falseColor); 750 864 int cIndex = cIndex(imp,z,c,t,indexed,falseColor); … … 759 873 assertEquals(tVal,tIndex); 760 874 } 875 } 876 } 761 877 } 762 878 … … 764 880 private void calibrationTest(ImagePlus imp, int pixType) 765 881 { 766 // IJ handles BF INT32 as float. So th istest is invalid in that case882 // IJ handles BF INT32 as float. So the test is invalid in that case 767 883 if (pixType == FormatTools.INT32) 768 884 return; … … 793 909 794 910 /** tests if images split on Z are ordered correctly */ 795 private void images InZctOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)911 private void imagesZInCtOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 796 912 { 797 913 // unwind CZT loop : Z pulled outside, CT in order … … 815 931 816 932 /** tests if images split on C are ordered correctly */ 817 private void images InCztOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)933 private void imagesCInZtOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 818 934 { 819 935 // unwind CZT loop : C pulled outside, ZT in order … … 837 953 838 954 /** tests if images split on T are ordered correctly */ 839 private void images InTczOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)955 private void imagesTInCzOrderTest(ImagePlus[] imps, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 840 956 { 841 957 // unwind CZT loop : T pulled outside, CZ in order … … 859 975 860 976 /** tests that a set of images is ordered via Z first  used by concatSplit tests */ 861 private void imageSeries InZctOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)977 private void imageSeriesZInCtOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 862 978 { 863 979 // from CZT order: Z pulled out, CT in order 864 for (int z = 0; z < sizeZ; z++) 865 { 980 for (int z = 0; z < sizeZ; z++) { 866 981 ImagePlus imp = imps[z]; 867 982 xyzctTest(imp,sizeX,sizeY,1,sizeC,sizeT*numSeries); … … 890 1005 891 1006 /** tests that a set of images is ordered via C first  used by concatSplit tests */ 892 private void imageSeries InCztOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)1007 private void imageSeriesCInZtOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 893 1008 { 894 1009 // from CZT order: C pulled out, ZT in order 895 for (int c = 0; c < sizeC; c++) 896 { 1010 for (int c = 0; c < sizeC; c++) { 897 1011 ImagePlus imp = imps[c]; 898 1012 xyzctTest(imp,sizeX,sizeY,sizeZ,1,sizeT*numSeries); … … 921 1035 // Then we're splitting on T. Logic will need to be different from others. 922 1036 /** tests that a set of images is ordered via T first  used by concatSplit tests */ 923 private void imageSeries InTczOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)1037 private void imageSeriesTInCzOrderTest(ImagePlus[] imps, int numSeries, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT) 924 1038 { 925 1039 int imageNum = 0; 926 for (int s = 0; s < numSeries; s++) 927 { 1040 for (int s = 0; s < numSeries; s++) { 928 1041 // from CZT order: T pulled out, CZ in order 929 1042 for (int t = 0; t < sizeT; t++) … … 965 1078 int newT = numC; 966 1079 967 for (int zIndex = 0; zIndex < newZ; zIndex++) 968 {1080 for (int zIndex = 0; zIndex < newZ; zIndex++) { 1081 969 1082 ImagePlus imp = imps[zIndex]; 970 1083 … … 976 1089 977 1090 int slice = 0; 978 for (int tIndex = start; tIndex < newMaxT; tIndex += stepBy) 1091 for (int tIndex = start; tIndex < newMaxT; tIndex += stepBy) { 979 1092 for (int cIndex = 0; cIndex < newC; cIndex++) 980 1093 { … … 992 1105 assertEquals(tIndex, actualT); 993 1106 } 1107 } 994 1108 } 995 1109 } … … 1097 1211 try { 1098 1212 ImporterOptions options = new ImporterOptions(); 1213 options.setVirtual(virtual); 1099 1214 options.setUngroupFiles(true); 1100 1215 options.setId(path); … … 1118 1233 try { 1119 1234 ImporterOptions options = new ImporterOptions(); 1235 options.setVirtual(virtual); 1120 1236 options.setUngroupFiles(false); 1121 1237 options.setId(path); … … 1139 1255 private void datasetSwapDimsTester(boolean virtual, int pixType, int x, int y, int z, int t) 1140 1256 { 1257 System.out.println("datsetSwapDimsTester() virtual = "+virtual+" pixType = "+FormatTools.getPixelTypeString(pixType)); 1141 1258 int c = 3; 1142 1259 ChannelOrder swappedOrder = ChannelOrder.TCZ; // original order is ZCT … … 1167 1284 xyzctTest(imp,x,y,t,c,z); // Z<>T swapped 1168 1285 1169 swappedZtTest(imp, z,c,t);1286 swappedZtTest(imp,pixType,virtual,z,c,t); 1170 1287 } 1171 1288 … … 1222 1339 try { 1223 1340 ImporterOptions options = new ImporterOptions(); 1224 //options.setVirtual(virtual); // NOTE  do not allow this combo1225 1341 options.setId(path); 1226 1342 options.setOpenAllSeries(true); … … 1244 1360 xyzctTest(imp,x,y,z,c,t*s); 1245 1361 1246 multipleSeriesIn ZtcOrderTest(imp,s,z,c,t);1362 multipleSeriesInCztOrderTest(imp,s,z,c,t); 1247 1363 } 1248 1364 … … 1287 1403 } 1288 1404 1405 private void ascendingValuesTest(byte[] data, int expectedLength) 1406 { 1407 assertEquals(expectedLength,data.length); 1408 for (int i = 0; i < expectedLength; i++) 1409 assertEquals(i,data[i]&0xff); 1410 } 1411 1412 private void imagePlusLutTest(ImagePlus imp, boolean indexed, boolean falseColor) 1413 { 1414 // When numCh < 2 or numCh > 7 the setColorMode() code for Composite and Colorize cannot create a CompositeImage. 1415 // Therefore it creates a one channel ImagePlus with a LUT that only ramps the red channel. Test this to be 1416 // the case. 1417 1418 assertFalse(imp instanceof CompositeImage); 1419 1420 LUT lut = getColorTable(imp,0); 1421 1422 byte[] data = new byte[256]; 1423 1424 lut.getReds(data); 1425 1426 if (indexed && falseColor) 1427 { 1428 System.out.println("imagePlusLutTest()  indexed and falseColor  1st 10 lut entries"); 1429 for (int i = 0; i < 10; i++) 1430 System.out.print(" "+data[i]); 1431 System.out.println(); 1432 } 1433 else 1434 ascendingValuesTest(data,256); 1435 } 1436 1289 1437 /** tests BF's options.setColorMode(composite) */ 1290 1438 private void colorCompositeTester(int pixType, boolean indexed, int channels, int chanPerPlane, boolean falseColor, int numSeries) … … 1294 1442 int sizeX = 55, sizeY = 71, sizeZ = 3, sizeT = 4; 1295 1443 1296 // reportedly works in BF for 2<=sizeC<=7 and also numSeries*sizeC*3 <= 25 1297 1298 assertTrue(channels >= 2); 1299 assertTrue(channels <= 7); 1300 assertTrue(numSeries*channels*3 <= 25); // slider limit in IJ 1444 // reportedly works in BF as long as numSeries*sizeC*3 <= 25 1301 1445 1302 1446 String path = constructFakeFilename("colorComposite", pixType, sizeX, sizeY, sizeZ, channels, sizeT, numSeries, … … 1318 1462 } 1319 1463 1320 // TODO  notice I pass in numSeries but don't test it below : no for loop for it. 1464 // TODO  notice I pass in numSeries but don't test it below : no for loop for it. We're only opening the first series. 1465 // Not sure why I'm enforcing the 25 slider rule then. 1321 1466 1322 1467 impsCountTest(imps,1); … … 1330 1475 xyzctTest(imp,sizeX,sizeY,sizeZ,expectedSizeC,sizeT); 1331 1476 1332 assertTrue(imp.isComposite()); 1333 1334 CompositeImage ci = (CompositeImage)imp; 1335 1336 assertFalse(ci.hasCustomLuts()); 1337 1338 assertEquals(CompositeImage.COMPOSITE, ci.getMode()); 1339 1340 colorTests(ci,expectedSizeC,DefaultColorOrder); 1341 1342 ci.reset(); // force the channel processors to get initialized, otherwise nullptr  TODO : does this point out a IJ bug? 1343 1344 /* 1345 int maxZ = ci.getNSlices(); 1346 int maxC = ci.getNChannels(); 1347 int maxT = ci.getNFrames(); 1348 1349 //System.out.println("Checking index vals"); 1350 //System.out.println("maxes z c t = "+maxZ+" "+maxC+" "+maxT); 1351 1352 // check that each image in the overall series has the correct iIndex value 1353 int index = 0; 1354 for (int t = 0; t < maxT; t++) 1355 for (int c = 0; c < maxC; c++) 1356 for (int z = 0; z < maxZ; z++) 1357 assertEquals(index++, getIndexValue(ci,z,c,t,indexed)); // expected value from CZT order 1358 //indexValuesTest(ci, z, c, t, indexed, 0, index++, z, c, t); 1359 */ 1360 stackInZctOrderTest(imp,sizeZ,expectedSizeC,sizeT,indexed,falseColor); 1477 if ((expectedSizeC >= 2) && (expectedSizeC <= 7)) 1478 { 1479 assertTrue(imp.isComposite()); 1480 1481 CompositeImage ci = (CompositeImage)imp; 1482 1483 assertFalse(ci.hasCustomLuts()); 1484 1485 assertEquals(CompositeImage.COMPOSITE, ci.getMode()); 1486 1487 colorTests(ci,expectedSizeC,DefaultColorOrder); 1488 1489 // TODO  may need to reenable if commented code below reactivated 1490 //ci.reset(); // force the channel processors to get initialized, otherwise nullptr  TODO : does this point out a IJ bug? 1491 1492 /* 1493 int maxZ = ci.getNSlices(); 1494 int maxC = ci.getNChannels(); 1495 int maxT = ci.getNFrames(); 1496 1497 //System.out.println("Checking index vals"); 1498 //System.out.println("maxes z c t = "+maxZ+" "+maxC+" "+maxT); 1499 1500 // check that each image in the overall series has the correct iIndex value 1501 int index = 0; 1502 for (int t = 0; t < maxT; t++) 1503 for (int c = 0; c < maxC; c++) 1504 for (int z = 0; z < maxZ; z++) 1505 assertEquals(index++, getIndexValue(ci,z,c,t,indexed)); // expected value from CZT order 1506 //indexValuesTest(ci, z, c, t, indexed, 0, index++, z, c, t); 1507 */ 1508 } 1509 else // expectedSizeC < 2 or > 7  we should have gotten back a regular ImagePlus 1510 { 1511 assertFalse(imp.isComposite()); 1512 1513 imagePlusLutTest(imp,indexed,falseColor); 1514 } 1515 1516 stackInCztOrderTest(imp,sizeZ,expectedSizeC,sizeT,indexed,falseColor,channels,chanPerPlane); 1361 1517 } 1362 1518 … … 1707 1863 impsCountTest(imps,sizeC); 1708 1864 1709 images InCztOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT);1865 imagesCInZtOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT); 1710 1866 } 1711 1867 … … 1737 1893 impsCountTest(imps,sizeZ); 1738 1894 1739 images InZctOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT);1895 imagesZInCtOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT); 1740 1896 } 1741 1897 … … 1767 1923 impsCountTest(imps,sizeT); 1768 1924 1769 images InTczOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT);1925 imagesTInCzOrderTest(imps,sizeX,sizeY,sizeZ,sizeC,sizeT); 1770 1926 } 1771 1927 … … 1819 1975 } 1820 1976 1821 minMaxTest(imp,expectedMin,expectedMax); 1977 // NOTE  the minMaxTest can't work for INT32 as it has more precision than can be represented by IJ's GRAY32 float 1978 if (pixType != FormatTools.INT32) 1979 minMaxTest(imp,expectedMin,expectedMax); 1822 1980 } 1823 1981 … … 1854 2012 impsCountTest(imps,sizeZ); 1855 2013 1856 imageSeries InZctOrderTest(imps,series,sizeX,sizeY,sizeZ,sizeC,sizeT);2014 imageSeriesZInCtOrderTest(imps,series,sizeX,sizeY,sizeZ,sizeC,sizeT); 1857 2015 } 1858 2016 … … 1889 2047 impsCountTest(imps,sizeC); 1890 2048 1891 imageSeries InCztOrderTest(imps,series,sizeX,sizeY,sizeZ,sizeC,sizeT);2049 imageSeriesCInZtOrderTest(imps,series,sizeX,sizeY,sizeZ,sizeC,sizeT); 1892 2050 } 1893 2051 … … 1924 2082 impsCountTest(imps,sizeT*numSeries); 1925 2083 1926 imageSeries InTczOrderTest(imps,numSeries,sizeX,sizeY,sizeZ,sizeC,sizeT);2084 imageSeriesTInCzOrderTest(imps,numSeries,sizeX,sizeY,sizeZ,sizeC,sizeT); 1927 2085 } 1928 2086 1929 2087 /** tests BF's options.setColormode(composite)  alternate, later definition */ 1930 private void composite Tester(int sizeC, boolean indexed)2088 private void compositeSubcaseTester(int sizeC, boolean indexed) 1931 2089 { 1932 2090 int pixType = FormatTools.UINT8, sizeX = 60, sizeY = 30, sizeZ = 2, sizeT = 3, numSeries = 1, rgb = 1, lutLen = 1; … … 2021 2179 datasetSwapDimsTester(virtual,FormatTools.UINT16, 82, 47, 5, 2); 2022 2180 datasetSwapDimsTester(virtual,FormatTools.UINT32, 82, 47, 5, 2); 2181 datasetSwapDimsTester(virtual,FormatTools.FLOAT, 67, 109, 4, 3); 2182 datasetSwapDimsTester(virtual,FormatTools.DOUBLE, 67, 100, 3, 2); 2023 2183 datasetSwapDimsTester(virtual,FormatTools.INT8, 44, 108, 1, 4); 2024 2184 datasetSwapDimsTester(virtual,FormatTools.INT16, 44, 108, 2, 1); 2025 2185 datasetSwapDimsTester(virtual,FormatTools.INT32, 44, 108, 4, 3); 2026 datasetSwapDimsTester(virtual,FormatTools.FLOAT, 67, 109, 4, 3);2027 datasetSwapDimsTester(virtual,FormatTools.DOUBLE, 67, 100, 3, 2);2028 2186 } 2029 2187 } … … 2032 2190 public void testDatasetOpenAllSeries() 2033 2191 { 2034 for (boolean virtual : BooleanStates) 2035 for (boolean openAll : BooleanStates) 2036 { 2192 for (boolean virtual : BooleanStates) { 2193 for (boolean openAll : BooleanStates) { 2037 2194 datasetOpenAllSeriesTester(virtual,openAll); 2038 2195 datasetOpenAllSeriesTester(virtual,openAll); 2039 2196 } 2197 } 2040 2198 } 2041 2199 … … 2089 2247 2090 2248 // TODO  make a virtual case when working 2091 // TODO  older unfinished implementation : set aside for now and working on testCompositeSubcases() 2249 // TODO  older unfinished implementation. More work in testCompositeSubcases(). Currently working on 2250 // this version. 2092 2251 @Test 2093 2252 public void testColorComposite() 2094 2253 { 2095 // BF only supporting C from 2 to 7 and due to IJ's slider limitation (C*numSeries*3) <= 25 2254 final boolean NotIndexed = false; 2255 final boolean Indexed = true; 2256 2257 final boolean FalseColor = true; 2258 final boolean RealColor = false; 2259 2260 final int OneSeries = 1; 2096 2261 2097 2262 // these here to simplify debugging 2098 2099 colorCompositeTester(FormatTools.UINT8,false,3,1,false,1); 2100 colorCompositeTester(FormatTools.UINT8,true,3,1,false,1); 2101 2263 2264 // edge cases in number of channels nonindexed in one series 2265 colorCompositeTester(FormatTools.UINT8,NotIndexed,1,1,RealColor,OneSeries); 2266 colorCompositeTester(FormatTools.UINT8,NotIndexed,2,2,RealColor,OneSeries); 2267 colorCompositeTester(FormatTools.UINT8,NotIndexed,7,7,RealColor,OneSeries); 2268 colorCompositeTester(FormatTools.UINT8,NotIndexed,8,8,RealColor,OneSeries); 2269 2270 // edge cases in number of channels nonindexed in one series 2271 colorCompositeTester(FormatTools.UINT8,NotIndexed,4,4,RealColor,OneSeries); 2272 colorCompositeTester(FormatTools.UINT8,NotIndexed,6,3,RealColor,OneSeries); 2273 colorCompositeTester(FormatTools.UINT8,NotIndexed,12,3,RealColor,OneSeries); 2274 2275 // TODO  fails right now : was swapping c's and z's before Curtis's fixes to Fake and ChannSep 63010 2276 colorCompositeTester(FormatTools.UINT8,NotIndexed,3,1,RealColor,OneSeries); 2277 2278 // edge cases of indexing with planar layout 2279 colorCompositeTester(FormatTools.UINT8,NotIndexed,3,1,RealColor,OneSeries); 2280 // TODO  this next one returns all 0's for actual sizct values 2281 colorCompositeTester(FormatTools.UINT8,Indexed,1,1,RealColor,OneSeries); 2282 // TODO  this next test not necessary? its rare to have 3 indices in a image 2283 // but note that it swaps z and c unexpectedly 2284 colorCompositeTester(FormatTools.UINT8,Indexed,3,1,RealColor,OneSeries); 2285 2286 // general test loop 2102 2287 int[] pixTypes = new int[] {FormatTools.UINT8}; 2103 int[] channels = new int[] { 2,3,4,5,6,7}; // all that BF/IJ supports right now2288 int[] channels = new int[] {1,2,3,4,5,6,7,8}; 2104 2289 int[] series = new int[] {1,2,3,4}; 2105 2290 int[] channelsPerPlaneVals = new int[]{1,2,3}; 2106 2291 2107 for (int pixFormat : pixTypes) 2108 for (int chanCount : channels) 2109 for (int numSeries : series) 2110 if ((chanCount*numSeries*3) <= 25) // IJ slider limitation 2111 for (int channelsPerPlane : channelsPerPlaneVals) 2112 for (boolean indexed : BooleanStates) 2113 for (boolean falseColor : BooleanStates) 2114 { 2115 //System.out.println(" format "+pixFormat+"indexed "+indexed+" rgb "+rgb+" fasleColor "+falseColor+" c "+c+" s "+s); 2116 colorCompositeTester(pixFormat,indexed,chanCount,channelsPerPlane,falseColor,numSeries); 2117 } 2292 for (int pixFormat : pixTypes) { 2293 for (int chanCount : channels) { 2294 for (int numSeries : series) { 2295 for (int channelsPerPlane : channelsPerPlaneVals) { 2296 for (boolean indexed : BooleanStates) { 2297 for (boolean falseColor : BooleanStates) { 2298 2299 //System.out.println(" format "+pixFormat+"indexed "+indexed+" rgb "+rgb+" fasleColor "+falseColor+" c "+c+" s "+s); 2300 2301 // TODO see what happens when we remove this 2302 if ((chanCount*numSeries*3) > 25) // IJ slider limitation 2303 continue; 2304 2305 if (!indexed && falseColor) // invalid combo  skip 2306 continue; 2307 2308 if ((chanCount % channelsPerPlane) != 0) // invalid combo  skip 2309 continue; 2310 2311 colorCompositeTester(pixFormat,indexed,chanCount,channelsPerPlane,falseColor,numSeries); 2312 } 2313 } 2314 } 2315 } 2316 } 2317 } 2118 2318 } 2119 2319 … … 2168 2368 // note  can't autoscale a virtualStack. No need to test it. 2169 2369 2170 for (int pixType : PixelTypes) 2171 { 2172 for (boolean autoscale : BooleanStates) 2173 { 2370 for (int pixType : PixelTypes) { 2371 for (boolean autoscale : BooleanStates) { 2174 2372 //System.out.println("testColorAutoscale(): pixType = "+FormatTools.getPixelTypeString(pixType)+" autoscale = "+autoscale); 2175 2373 autoscaleTester(pixType,autoscale); … … 2431 2629 } 2432 2630 2631 /* 2433 2632 @Test 2434 2633 public void testComboConcatColorize() … … 2438 2637 fail("unimplemented"); 2439 2638 } 2440 2639 */ 2640 2441 2641 @Test 2442 2642 public void testComboConcatSplitFocalPlanes() … … 2463 2663 } 2464 2664 2665 /* 2465 2666 @Test 2466 2667 public void testComboColorizeSplit() … … 2470 2671 fail("unimplemented"); 2471 2672 } 2472 2673 */ 2674 2675 /* 2473 2676 @Test 2474 2677 public void testComboConcatColorizeSplit() … … 2478 2681 fail("unimplemented"); 2479 2682 } 2683 */ 2480 2684 2481 2685 @Test … … 2557 2761 2558 2762 System.out.println(" Returned imp: Z = " +imp.getNSlices()+ " C = " +imp.getNChannels()+" T = "+imp.getNFrames()); 2559 for (int tIndex = 0; tIndex < imp.getNFrames(); tIndex++) 2560 for (int cIndex = 0; cIndex < imp.getNChannels(); cIndex++) 2561 for (int zIndex = 0; zIndex < imp.getNSlices(); zIndex++) 2562 { 2763 for (int tIndex = 0; tIndex < imp.getNFrames(); tIndex++) { 2764 for (int cIndex = 0; cIndex < imp.getNChannels(); cIndex++) { 2765 for (int zIndex = 0; zIndex < imp.getNSlices(); zIndex++) { 2563 2766 setZctPosition(imp,zIndex,cIndex,tIndex); 2564 2767 ImageProcessor proc = imp.getProcessor(); 2565 2768 printVals(proc); 2566 2769 } 2770 } 2771 } 2567 2772 2568 2773 if (lutLen == 1) … … 2646 2851 2647 2852 // sizeC == 1 : don't test yet 2853 // TODO  is this limitation now fixed in BF? Do we need to test here? 2648 2854 2649 2855 // sizeC = 4 and rgb = 4 : interleaved including alpha … … 2690 2896 for (int channels = 2; channels <= 7; channels++) 2691 2897 if (!indexed) // TODO  remove this limitation when BF updated 2692 composite Tester(channels,indexed);2898 compositeSubcaseTester(channels,indexed); 2693 2899 fail("unfinished but 2<=sizeC<=7 nonindexed working"); 2694 2900 }
Note: See TracChangeset
for help on using the changeset viewer.