Changeset 6331
- Timestamp:
- 05/18/10 09:47:32 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/loci-plugins/test/loci/plugins/in/ImporterTest.java
r6322 r6331 6 6 7 7 import static org.junit.Assert.assertEquals; 8 import static org.junit.Assert.assertArrayEquals; 8 9 import static org.junit.Assert.assertNotNull; 9 10 import static org.junit.Assert.assertTrue; 11 import static org.junit.Assert.assertFalse; 10 12 import static org.junit.Assert.fail; 11 13 14 import ij.CompositeImage; 12 15 import ij.ImagePlus; 13 16 import ij.ImageStack; 14 17 import ij.process.ImageProcessor; 15 18 19 import java.awt.Color; 16 20 import java.io.IOException; 17 21 import java.lang.reflect.Field; … … 32 36 // mergeOptions BF api for finishing merge tests 33 37 // custom color BF api for doing that test 38 // coboCropAutoscale() - autoscale of a cropped image returning min of whole image 34 39 // - flesh out existing tests 35 40 // write tests for the color options : 4 cases - some mention was made that indexcolor is an issue in testing … … 37 42 // rgb colorize - need to do actual tests. see BF gui to get idea of how it works 38 43 // custom colorize - waiting for creation of API for setting r,g,b info 39 // autoscale - code written but failing44 // autoscale - working 40 45 // open individual files: try to come up with a way to test without a disk file as source 41 46 // swapped dims test needs to test cases other than from default swapping Z & T … … 145 150 } 146 151 152 private char axisChar(String order, int d) 153 { 154 if ((d < 0) || (d > 2)) 155 throw new IllegalArgumentException("axisChar() - index out of bounds [0..2]: "+d); 156 157 return order.charAt(2+d); 158 } 159 147 160 private Axis axis(String order, int d) 148 161 { 149 if ((d < 0) || (d > 2)) 150 throw new IllegalArgumentException("axis() - index out of bounds [0..2]: "+d); 151 152 char dim = order.charAt(2+d); 153 154 if (dim == 'Z') return Axis.Z; 155 if (dim == 'C') return Axis.C; 156 if (dim == 'T') return Axis.T; 157 158 throw new IllegalArgumentException("axis() - invalid image order specified: "+order); 162 char dimChar = axisChar(order,d); 163 164 if (dimChar == 'Z') return Axis.Z; 165 if (dimChar == 'C') return Axis.C; 166 if (dimChar == 'T') return Axis.T; 167 168 throw new IllegalArgumentException("axis() - unknown dimension specified: ("+dimChar+")"); 159 169 } 160 170 … … 184 194 count++; 185 195 return count; 186 187 /* calc'ed version : less clear188 int spread = to - from + 1;189 190 if (spread % by == 0)191 return (spread / by);192 else193 return (spread / by) + 1;194 */195 196 } 196 197 … … 300 301 } 301 302 302 303 303 private long minPixelValue(int pixType) 304 304 { … … 333 333 */ 334 334 } 335 336 // ****** helper tests **************************************************************************************** 337 338 private void defaultBehaviorTest(int pixType, int x, int y, int z, int c, int t) 339 { 340 String path = constructFakeFilename("default", pixType, x, y, z, c, t, -1); 341 ImagePlus[] imps = null; 342 343 try { 344 imps = BF.openImagePlus(path); 345 } 346 catch (IOException e) { 347 fail(e.getMessage()); 348 } 349 catch (FormatException e) { 350 fail(e.getMessage()); 351 } 352 353 assertNotNull(imps); 354 assertEquals(1,imps.length); 355 ImagePlus imp = imps[0]; 335 336 private void xyzctTest(ImagePlus imp, int x, int y, int z, int c, int t) 337 { 356 338 assertNotNull(imp); 357 339 assertEquals(x,imp.getWidth()); 358 340 assertEquals(y,imp.getHeight()); 359 /*360 assertEquals(z,ip.getNSlices()); // tricky - these last 3 getters have side effects that change their output.361 assertEquals(c,ip.getNChannels());362 assertEquals(t,ip.getNFrames());363 */364 //if (z != getSizeZ(ip)) { new ij.ImageJ(); ip.show(); }//TEMP365 341 assertEquals(z,getSizeZ(imp)); 342 assertEquals(c,getEffectiveSizeC(imp)); 366 343 assertEquals(t,getSizeT(imp)); 367 assertEquals(c,getEffectiveSizeC(imp)); 344 } 345 346 // ****** helper tests **************************************************************************************** 347 348 private void defaultBehaviorTest(int pixType, int x, int y, int z, int c, int t) 349 { 350 String path = constructFakeFilename("default", pixType, x, y, z, c, t, -1); 351 ImagePlus[] imps = null; 352 353 try { 354 imps = BF.openImagePlus(path); 355 } 356 catch (IOException e) { 357 fail(e.getMessage()); 358 } 359 catch (FormatException e) { 360 fail(e.getMessage()); 361 } 362 363 assertNotNull(imps); 364 assertEquals(1,imps.length); 365 ImagePlus imp = imps[0]; 366 367 xyzctTest(imp,x,y,z,c,t); 368 368 } 369 369 … … 391 391 ImagePlus imp = imps[0]; 392 392 393 xyzctTest(imp,x,y,z,c,t); 394 393 395 ImageStack st = imp.getStack(); 394 396 int numSlices = st.getSize(); … … 414 416 assertEquals(y,proc.getHeight()); 415 417 assertEquals(0,sIndex(proc)); 416 //TODO - test iIndex too? : assertEquals(count,somethingOrOther(iIndex(proc)));417 //System.out.println("iIndex " + iIndex(proc) + " calc " +418 // pre loop reorder ((maxJ*maxI*k) + (maxI*j) + i)419 //((maxJ*maxK*i) + (maxK*j) + k)420 //((value(middle,maxI,maxJ,maxK)*value(fastest,maxI,maxJ,maxK)*i) + (value(fastest,maxI,maxJ,maxK)*j) + (k))421 //((value(middle,maxK,maxJ,maxI)*value(fastest,maxK,maxJ,maxI)*i) + (value(fastest,maxK,maxJ,maxI)*j) + (k))422 //);423 //System.out.println("maxI "+maxI+" maxJ "+maxJ+" maxK "+maxK+" number "+count+" (i"+i+" "+j+"j "+k+"k) = "+iIndex(proc));424 418 assertEquals(i,index(slowest,proc)); 425 419 assertEquals(j,index(middle,proc)); … … 432 426 { 433 427 int c = 3; String origOrder = "XYZCT", swappedOrder = "XYTCZ"; 434 String path = constructFakeFilename( origOrder, pixType, x, y, z, c, t, -1);428 String path = constructFakeFilename("swapDims", pixType, x, y, z, c, t, -1); 435 429 ImagePlus[] imps = null; 436 430 try { … … 452 446 453 447 ImagePlus imp = imps[0]; 448 449 xyzctTest(imp,x,y,t,c,z); // Z<->T swapped 450 454 451 ImageStack st = imp.getStack(); 455 452 int numSlices = st.getSize(); 456 453 assertEquals(z*c*t,numSlices); 457 458 int actualZ = getSizeZ(imp);459 int actualT = getSizeT(imp);460 assertEquals(z,actualT); // Z<->T swapped461 assertEquals(t,actualZ); // Z<->T swapped462 454 463 455 // make sure the dimensions were swapped correctly … … 497 489 498 490 assertEquals(1,imps.length); 499 assertEquals(x,imps[0].getWidth()); 500 assertEquals(y,imps[0].getHeight()); 491 xyzctTest(imps[0],x,y,z,c,t); 501 492 assertEquals(z*c*t, imps[0].getStack().getSize()); 502 493 … … 597 588 598 589 assertEquals(1,imps.length); 590 599 591 imp = imps[0]; 600 assertEquals(sizeX,imp.getWidth()); 601 assertEquals(sizeY,imp.getHeight()); 602 assertEquals(sizeZ,getSizeZ(imp)); 603 assertEquals(sizeC,getEffectiveSizeC(imp)); 604 assertEquals(sizeT,getSizeT(imp)); 592 593 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 605 594 606 595 ImageStack st = imp.getStack(); … … 611 600 if (wantAutoscale) 612 601 { 613 expectedMax = Math.max( minPixelValue(pixType)+sizeX-1, sizeZ*sizeC*sizeT - 1 ); 602 expectedMax = Math.max( minPixelValue(pixType)+sizeX-1, sizeZ*sizeC*sizeT - 1 ); // series size always 1 so ignore 614 603 expectedMin = minPixelValue(pixType); 615 604 } … … 620 609 } 621 610 622 // TODO : verify each slice? or just imp.getDisplayRangeMax/Min()?623 624 for (int i = 0; i < numSlices; i++)625 {626 ImageProcessor proc = st.getProcessor(i+1);627 //if ((int)expectedMax != (int)proc.getMax())628 // System.out.println(FormatTools.getPixelTypeString(pixType) + " failed for proc #"+i+" exp "+expectedMax+" act "+(int)proc.getMax());629 assertEquals(expectedMax,proc.getMax(),0.1);630 assertEquals(expectedMin,proc.getMin(),0.1);631 }632 }633 634 // note - this test needs to rely on crop() to get predictable nonzero minimums635 636 private void cropAndAutoscaleTest(int pixType)637 {638 //TODO - this code set aside until crop/minMax stuff changed in BF. May be in a partially correct state639 640 //TODO: test more stringently final int sizeZ = 5, sizeC = 3, sizeT = 7, sizeX = 123, sizeY = 74;641 final int sizeZ = 1, sizeC = 1, sizeT = 1, sizeX = 123, sizeY = 74;642 final int cOriginX = 55, cOriginY = 15, cropSize = 24;643 final String path = constructFakeFilename("autoscale",pixType, sizeX, sizeY, sizeZ, sizeC, sizeT, -1);644 645 // needed for this test646 assertTrue(cOriginX >= 50);647 assertTrue(cOriginY >= 10);648 assertTrue(cOriginX + cropSize < sizeX);649 assertTrue(cOriginY + cropSize < sizeY);650 assertTrue(cOriginX + cropSize < 255);651 652 ImagePlus[] imps = null;653 ImagePlus imp = null;654 655 try {656 ImporterOptions options = new ImporterOptions();657 options.setAutoscale(true);658 options.setCrop(true);659 options.setCropRegion(0,new Region(cOriginX,cOriginY,cropSize,cropSize));660 options.setId(path);661 imps = BF.openImagePlus(options);662 }663 catch (IOException e) {664 fail(e.getMessage());665 }666 catch (FormatException e) {667 fail(e.getMessage());668 }669 670 assertEquals(1,imps.length);671 imp = imps[0];672 assertEquals(cropSize,imp.getWidth());673 assertEquals(cropSize,imp.getHeight());674 assertEquals(sizeZ,getSizeZ(imp));675 assertEquals(sizeC,getEffectiveSizeC(imp));676 assertEquals(sizeT,getSizeT(imp));677 678 ImageStack st = imp.getStack();679 int numSlices = st.getSize();680 681 long expectedMax = cOriginX+cropSize-1;682 long expectedMin = cOriginX;683 684 // TODO : verify each slice? or just imp.getDisplayRangeMax/Min()?685 686 611 for (int i = 0; i < numSlices; i++) 687 612 { … … 692 617 } 693 618 619 // note - this test needs to rely on crop() to get predictable nonzero minimums 620 621 private void cropAndAutoscaleTest(int pixType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int numSeries, 622 int originCropX, int originCropY, int sizeCrop) 623 { 624 final String path = constructFakeFilename("cropAutoscale",pixType, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 625 626 // needed for this test 627 assertTrue(originCropX >= 50); 628 assertTrue(originCropY >= 10); 629 assertTrue(sizeCrop > 0); 630 assertTrue(originCropX + sizeCrop < sizeX); 631 assertTrue(originCropY + sizeCrop < sizeY); 632 assertTrue(originCropX + sizeCrop < 255); 633 634 ImagePlus[] imps = null; 635 ImagePlus imp = null; 636 637 try { 638 ImporterOptions options = new ImporterOptions(); 639 options.setAutoscale(true); 640 options.setCrop(true); 641 options.setCropRegion(0,new Region(originCropX,originCropY,sizeCrop,sizeCrop)); 642 options.setId(path); 643 imps = BF.openImagePlus(options); 644 } 645 catch (IOException e) { 646 fail(e.getMessage()); 647 } 648 catch (FormatException e) { 649 fail(e.getMessage()); 650 } 651 652 assertEquals(1,imps.length); 653 imp = imps[0]; 654 xyzctTest(imps[0],sizeCrop,sizeCrop,sizeZ,sizeC,sizeT); 655 656 ImageStack st = imp.getStack(); 657 int numSlices = st.getSize(); 658 659 long expectedMax = originCropX+sizeCrop-1; 660 long expectedMin = originCropX; 661 662 for (int i = 0; i < numSlices; i++) 663 { 664 ImageProcessor proc = st.getProcessor(i+1); 665 assertEquals(expectedMax,proc.getMax(),0.1); 666 assertEquals(expectedMin,proc.getMin(),0.1); 667 } 668 } 669 694 670 private void memoryVirtualStackTest(boolean desireVirtual) 695 671 { 696 int x = 604, y = 531 ;672 int x = 604, y = 531, z = 7, c = 1, t = 1; 697 673 698 String path = constructFakeFilename("vstack", FormatTools.UINT16, x, y, 7, 1, 1, -1);674 String path = constructFakeFilename("vstack", FormatTools.UINT16, x, y, z, c, t, -1); 699 675 700 676 // open stack … … 718 694 ImagePlus imp = imps[0]; 719 695 assertNotNull(imp); 720 assertEquals(x,imp.getWidth()); 721 assertEquals(y,imp.getHeight()); 696 xyzctTest(imp,x,y,z,c,t); 722 697 723 698 assertEquals(desireVirtual,imp.getStack().isVirtual()); … … 726 701 private void memoryRecordModificationsTest(boolean wantToRemember) 727 702 { 728 int x = 444, y = 387 ;729 String path = constructFakeFilename("memRec", FormatTools.UINT8, x, y, 7, 1, 1, -1);703 int x = 444, y = 387, z = 7, c = 1, t = 1; 704 String path = constructFakeFilename("memRec", FormatTools.UINT8, x, y, z, c, t, -1); 730 705 ImagePlus[] imps = null; 731 706 ImagePlus imp = null; … … 753 728 imp = imps[0]; 754 729 assertNotNull(imp); 755 assertEquals(x,imp.getWidth()); 756 assertEquals(y,imp.getHeight()); 730 xyzctTest(imp,x,y,z,c,t); 757 731 758 732 // change data in slice 1, swap to slice 2, swap back, see whether data reverts … … 835 809 assertEquals(1,imps.length); 836 810 ImagePlus imp = imps[0]; 837 assertNotNull(imp); 838 assertEquals(x,imp.getWidth()); 839 assertEquals(y,imp.getHeight()); 811 xyzctTest(imp,x,y,numInSeries(zFrom,zTo,zBy),numInSeries(cFrom,cTo,cBy),numInSeries(tFrom,tTo,tBy)); 840 812 ImageStack st = imp.getStack(); 841 813 … … 867 839 assertNotNull(imps); 868 840 assertEquals(1,imps.length); 869 assertNotNull(imps[0]); 870 assertEquals(cx,imps[0].getWidth()); // here is where we make sure we get back a cropped image 871 assertEquals(cy,imps[0].getHeight()); 841 xyzctTest(imps[0],cx,cy,1,1,1); 872 842 } 873 843 … … 1001 971 } 1002 972 973 @Test 974 public void testColorDefault() 975 { 976 int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4, numSeries = 3; 977 978 String path = constructFakeFilename("colorized", FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 979 980 ImagePlus[] imps = null; 981 ImagePlus imp = null; 982 983 try { 984 ImporterOptions options = new ImporterOptions(); 985 options.setColorMode(ImporterOptions.COLOR_MODE_DEFAULT); 986 options.setId(path); 987 imps = BF.openImagePlus(options); 988 } 989 catch (IOException e) { 990 fail(e.getMessage()); 991 } 992 catch (FormatException e) { 993 fail(e.getMessage()); 994 } 995 996 assertEquals(1,imps.length); 997 998 imp = imps[0]; 999 1000 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 1001 1002 assertFalse(imp.isComposite()); 1003 1004 fail("unfinished"); 1005 } 1006 1007 @Test 1008 public void testColorComposite() 1009 { 1010 int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4, numSeries = 3; 1011 1012 String path = constructFakeFilename("colorized", FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 1013 1014 ImagePlus[] imps = null; 1015 ImagePlus imp = null; 1016 CompositeImage ci = null; 1017 1018 try { 1019 ImporterOptions options = new ImporterOptions(); 1020 options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE); 1021 options.setId(path); 1022 imps = BF.openImagePlus(options); 1023 } 1024 catch (IOException e) { 1025 fail(e.getMessage()); 1026 } 1027 catch (FormatException e) { 1028 fail(e.getMessage()); 1029 } 1030 1031 assertEquals(1,imps.length); 1032 1033 imp = imps[0]; 1034 1035 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 1036 1037 assertTrue(imp.isComposite()); 1038 1039 ci = (CompositeImage)imp; 1040 1041 assertFalse(ci.hasCustomLuts()); 1042 assertArrayEquals(new int[]{0,0,0,0}, ci.getPixel(55,22)); 1043 fail("unfinished"); 1044 } 1045 1046 @Test 1047 public void testColorColorized() 1048 { 1049 int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4, numSeries = 3; 1050 1051 String path = constructFakeFilename("colorized", FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 1052 1053 ImagePlus[] imps = null; 1054 ImagePlus imp = null; 1055 CompositeImage ci = null; 1056 1057 try { 1058 ImporterOptions options = new ImporterOptions(); 1059 options.setColorMode(ImporterOptions.COLOR_MODE_COLORIZED); 1060 options.setId(path); 1061 imps = BF.openImagePlus(options); 1062 } 1063 catch (IOException e) { 1064 fail(e.getMessage()); 1065 } 1066 catch (FormatException e) { 1067 fail(e.getMessage()); 1068 } 1069 1070 assertEquals(1,imps.length); 1071 1072 imp = imps[0]; 1073 1074 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 1075 1076 assertTrue(imp.isComposite()); 1077 1078 ci = (CompositeImage)imp; 1079 1080 assertFalse(ci.hasCustomLuts()); 1081 assertArrayEquals(new int[]{0,0,0,0}, ci.getPixel(55,22)); 1082 fail("unfinished"); 1083 } 1084 1085 @Test 1086 public void testColorGrayscale() 1087 { 1088 int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4, numSeries = 3; 1089 1090 String path = constructFakeFilename("colorized", FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 1091 1092 ImagePlus[] imps = null; 1093 ImagePlus imp = null; 1094 CompositeImage ci = null; 1095 1096 try { 1097 ImporterOptions options = new ImporterOptions(); 1098 options.setColorMode(ImporterOptions.COLOR_MODE_GRAYSCALE); 1099 options.setId(path); 1100 imps = BF.openImagePlus(options); 1101 } 1102 catch (IOException e) { 1103 fail(e.getMessage()); 1104 } 1105 catch (FormatException e) { 1106 fail(e.getMessage()); 1107 } 1108 1109 assertEquals(1,imps.length); 1110 1111 imp = imps[0]; 1112 1113 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 1114 1115 assertTrue(imp.isComposite()); 1116 1117 ci = (CompositeImage)imp; 1118 1119 assertFalse(ci.hasCustomLuts()); 1120 assertArrayEquals(new int[]{0,0,0,0}, ci.getPixel(55,22)); 1121 fail("unfinished"); 1122 } 1123 1124 @Test 1125 public void testColorCustom() 1126 { 1127 int sizeX = 100, sizeY = 120, sizeZ = 2, sizeC = 7, sizeT = 4, numSeries = 3; 1128 1129 String path = constructFakeFilename("colorized", FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, numSeries); 1130 1131 ImagePlus[] imps = null; 1132 ImagePlus imp = null; 1133 CompositeImage ci = null; 1134 1135 try { 1136 ImporterOptions options = new ImporterOptions(); 1137 options.setColorMode(ImporterOptions.COLOR_MODE_CUSTOM); 1138 int series = 0; int channel = 0; 1139 options.setCustomColor(series, channel, Color.BLUE); 1140 options.setId(path); 1141 imps = BF.openImagePlus(options); 1142 } 1143 catch (IOException e) { 1144 fail(e.getMessage()); 1145 } 1146 catch (FormatException e) { 1147 fail(e.getMessage()); 1148 } 1149 1150 assertEquals(1,imps.length); 1151 1152 imp = imps[0]; 1153 1154 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,sizeT); 1155 1156 assertTrue(imp.isComposite()); 1157 1158 ci = (CompositeImage)imp; 1159 1160 assertFalse(ci.hasCustomLuts()); 1161 assertArrayEquals(new int[]{0,0,0,0}, ci.getPixel(55,22)); 1162 fail("unfinished"); 1163 } 1164 1003 1165 /* 1004 1166 @Test … … 1269 1431 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1270 1432 1271 /* TODO - enable when step by 0 code fixed and remove extra tests above and below 1433 // test bad combination of zct's - choosing beyond ends of ranges 1434 1435 // z index before 0 begin 1436 try { 1437 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; 1438 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1439 fail(); 1440 } catch (IllegalArgumentException e) { 1441 assertTrue(true); 1442 } 1443 1444 // z index after z-1 end 1445 try { 1446 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; 1447 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1448 fail(); 1449 } catch (IllegalArgumentException e) { 1450 assertTrue(true); 1451 } 1452 1453 // z by < 1 1454 try { 1455 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; 1456 // TODO - enable post fix 1457 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1458 //fail(); 1459 } catch (IllegalArgumentException e) { 1460 assertTrue(true); 1461 } 1462 1463 // c index before 0 begin 1464 try { 1465 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; 1466 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1467 fail(); 1468 } catch (IllegalArgumentException e) { 1469 assertTrue(true); 1470 } 1471 1472 // c index after c-1 end 1473 try { 1474 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; 1475 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1476 fail(); 1477 } catch (IllegalArgumentException e) { 1478 assertTrue(true); 1479 } 1480 1481 // c by < 1 1482 try { 1483 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; 1484 // TODO - enable post fix 1485 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1486 //fail(); 1487 } catch (IllegalArgumentException e) { 1488 assertTrue(true); 1489 } 1490 1491 // t index before 0 begin 1492 try { 1493 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; 1494 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1495 fail(); 1496 } catch (IllegalArgumentException e) { 1497 assertTrue(true); 1498 } 1499 1500 // t index after t-1 end 1501 try { 1502 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; 1503 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1504 fail(); 1505 } catch (IllegalArgumentException e) { 1506 assertTrue(true); 1507 } 1508 1509 // t by < 1 1510 try { 1511 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; 1512 // TODO - enable post fix 1513 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy); 1514 //fail(); 1515 } catch (IllegalArgumentException e) { 1516 assertTrue(true); 1517 } 1518 1519 /* TODO - enable when step by 0 code fixed and remove extra tests above 1272 1520 // uber combo test 1273 1521 z = 6; c = 5; t = 4; … … 1306 1554 */ 1307 1555 1308 // test bad combination of zct's - choosing beyond ends of ranges1309 1310 // z index before 0 begin1311 try {1312 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;1313 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1314 fail();1315 } catch (IllegalArgumentException e) {1316 assertTrue(true);1317 }1318 1319 // z index after z-1 end1320 try {1321 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;1322 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1323 fail();1324 } catch (IllegalArgumentException e) {1325 assertTrue(true);1326 }1327 1328 // z by < 11329 try {1330 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;1331 // TODO - enable post fix1332 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1333 //fail();1334 } catch (IllegalArgumentException e) {1335 assertTrue(true);1336 }1337 1338 // c index before 0 begin1339 try {1340 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;1341 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1342 fail();1343 } catch (IllegalArgumentException e) {1344 assertTrue(true);1345 }1346 1347 // c index after c-1 end1348 try {1349 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;1350 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1351 fail();1352 } catch (IllegalArgumentException e) {1353 assertTrue(true);1354 }1355 1356 // c by < 11357 try {1358 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;1359 // TODO - enable post fix1360 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1361 //fail();1362 } catch (IllegalArgumentException e) {1363 assertTrue(true);1364 }1365 1366 // t index before 0 begin1367 try {1368 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;1369 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1370 fail();1371 } catch (IllegalArgumentException e) {1372 assertTrue(true);1373 }1374 1375 // t index after t-1 end1376 try {1377 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;1378 memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1379 fail();1380 } catch (IllegalArgumentException e) {1381 assertTrue(true);1382 }1383 1384 // t by < 11385 try {1386 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;1387 // TODO - enable post fix1388 //memorySpecifyRangeTest(z,c,t,zFrom,zTo,zBy,cFrom,cTo,cBy,tFrom,tTo,tBy);1389 //fail();1390 } catch (IllegalArgumentException e) {1391 assertTrue(true);1392 }1393 1556 } 1394 1557 … … 1405 1568 public void testSplitChannels() 1406 1569 { 1407 final int size Z = 5, sizeC = 3, sizeT = 7;1570 final int sizeX = 50, sizeY = 20, sizeZ = 5, sizeC = 3, sizeT = 7; 1408 1571 final String path = constructFakeFilename("splitC", 1409 FormatTools.UINT8, 50, 20, sizeZ, sizeC, sizeT, -1);1572 FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, -1); 1410 1573 1411 1574 // open image … … 1427 1590 assertEquals(sizeC,imps.length); 1428 1591 1429 // unwind ZCT loop : C pulled to front, ZT in order1592 // unwind ZCT loop : C pulled outside, ZT in order 1430 1593 for (int c = 0; c < sizeC; c++) { 1431 ImageStack st = imps[c].getStack(); 1594 ImagePlus imp = imps[c]; 1595 xyzctTest(imp,sizeX,sizeY,sizeZ,1,sizeT); 1596 ImageStack st = imp.getStack(); 1432 1597 assertEquals(sizeZ * sizeT,st.getSize()); 1433 1598 int index = 0; … … 1447 1612 public void testSplitFocalPlanes() 1448 1613 { 1449 final int size Z = 5, sizeC = 3, sizeT = 7;1614 final int sizeX = 50, sizeY = 20, sizeZ = 5, sizeC = 3, sizeT = 7; 1450 1615 final String path = constructFakeFilename("splitZ", 1451 FormatTools.UINT8, 50, 20, sizeZ, sizeC, sizeT, -1);1616 FormatTools.UINT8, sizeX, sizeY, sizeZ, sizeC, sizeT, -1); 1452 1617 1453 1618 // open image … … 1469 1634 assertEquals(sizeZ,imps.length); 1470 1635 1471 // unwind ZCT loop : Z pulled to front, CT in order1636 // unwind ZCT loop : Z pulled outside, CT in order 1472 1637 for (int z = 0; z < sizeZ; z++) { 1473 ImageStack st = imps[z].getStack(); 1638 ImagePlus imp = imps[z]; 1639 xyzctTest(imp,sizeX,sizeY,1,sizeC,sizeT); 1640 ImageStack st = imp.getStack(); 1474 1641 assertEquals(sizeC * sizeT,st.getSize()); 1475 1642 int index = 0; … … 1489 1656 public void testSplitTimepoints() 1490 1657 { 1491 final int size Z = 5, sizeC = 3, sizeT = 7;1658 final int sizeX = 50, sizeY = 20, sizeZ = 5, sizeC = 3, sizeT = 7; 1492 1659 final String path = constructFakeFilename("splitT", 1493 1660 FormatTools.UINT8, 50, 20, sizeZ, sizeC, sizeT, -1); … … 1511 1678 assertEquals(sizeT,imps.length); 1512 1679 1513 // unwind ZTC loop : T pulled to front, ZC in order1680 // unwind ZTC loop : T pulled outside, ZC in order 1514 1681 for (int t = 0; t < sizeT; t++) { 1515 ImageStack st = imps[t].getStack(); 1682 ImagePlus imp = imps[t]; 1683 xyzctTest(imp,sizeX,sizeY,sizeZ,sizeC,1); 1684 ImageStack st = imp.getStack(); 1516 1685 assertEquals(sizeZ * sizeC,st.getSize()); 1517 1686 int index = 0; … … 1531 1700 public void testComboCropAutoscale() 1532 1701 { 1533 cropAndAutoscaleTest(FormatTools.UINT8); 1534 1535 cropAndAutoscaleTest(FormatTools.UINT8); 1536 cropAndAutoscaleTest(FormatTools.UINT16); 1537 //TODO: UINT32 failing - bug in BF? 1538 cropAndAutoscaleTest(FormatTools.UINT32); 1539 //TODO: exp 127 act 255 1540 cropAndAutoscaleTest(FormatTools.INT8); 1541 //TODO: exp 32767 act 65535 1542 cropAndAutoscaleTest(FormatTools.INT16); 1543 //TODO: signed max broken here too 1544 cropAndAutoscaleTest(FormatTools.INT32); 1545 1546 cropAndAutoscaleTest(FormatTools.UINT8); 1547 cropAndAutoscaleTest(FormatTools.UINT16); 1548 cropAndAutoscaleTest(FormatTools.UINT32); 1549 cropAndAutoscaleTest(FormatTools.INT8); 1550 cropAndAutoscaleTest(FormatTools.INT16); 1551 cropAndAutoscaleTest(FormatTools.INT32); 1702 // try a simple test: single small byte type image 1703 cropAndAutoscaleTest(FormatTools.UINT8,100,80,1,1,1,1,70,40,25); 1704 1705 // try multiple dimensions 1706 cropAndAutoscaleTest(FormatTools.UINT8,84,63,4,3,2,5,51,8,13); 1707 1708 // try various pixTypes 1709 for (int pixType : PixelTypes) 1710 cropAndAutoscaleTest(pixType,96,96,2,2,2,2,70,60,10); 1552 1711 } 1553 1712
Note: See TracChangeset
for help on using the changeset viewer.