ImageJ base code to get access to all the classes and their methods to test new Plugins. https://imagejdocu.tudor.lu/howto/plugins/the_imagej_eclipse_howto
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.8 KiB

2 years ago
  1. // This macro runs "Measure" on a all the slices in a stack. With a
  2. // hyperstack, it runs "Measure" in a user-selected (c,t,z) order.
  3. // Unchecking "Channels", "Slices" or "Frames" will select the
  4. // current channel, slice or frame while running "Measure".
  5. //
  6. // Ved P. Sharma, March 21, 2012
  7. // Albert Einstein College of Medicine, New York
  8. saveSettings;
  9. setOption("Stack position", true);
  10. if (!Stack.isHyperstack) {
  11. getVoxelSize(width, height, depth, unit);
  12. for (n=1; n<=nSlices; n++) {
  13. setSlice(n);
  14. run("Measure");
  15. }
  16. if (unit!="pixels") {
  17. depths = newArray(Table.size);
  18. for (i=0; i<Table.size; i++)
  19. depths[i] = i*depth;
  20. Table.setColumn(unit, depths);
  21. Table.update;
  22. }
  23. restoreSettings;
  24. exit;
  25. }
  26. Stack.getDimensions(w, h, channels, slices, frames);
  27. Stack.getPosition(ch, sl, fr);
  28. Dialog.create("Measure Hyperstack");
  29. Dialog.addCheckbox("Channels ("+channels+")", true);
  30. Dialog.addCheckbox("Slices ("+slices+")", true);
  31. Dialog.addCheckbox("Frames ("+frames+")", true);
  32. choices = newArray("czt(default)", "ctz", "zct", "ztc", "tcz", "tzc");
  33. Dialog.addChoice("Order:", choices, choices[0]);
  34. Dialog.show();
  35. state1 = Dialog.getCheckbox();
  36. state2 = Dialog.getCheckbox();
  37. state3 = Dialog.getCheckbox();
  38. order = Dialog.getChoice();
  39. if(state1) {startCh = 1; endCh = channels;}
  40. else {startCh = ch; endCh = ch;}
  41. if(state2) {startSl = 1; endSl = slices;}
  42. else {startSl = sl; endSl = sl;}
  43. if(state3) {startFr = 1; endFr = frames;}
  44. else {startFr = fr; endFr = fr;}
  45. if(order == "czt(default)") {
  46. for (u=startFr; u<=endFr; u++) {
  47. Stack.setFrame(u);
  48. for (v=startSl; v<=endSl; v++) {
  49. Stack.setSlice(v);
  50. for (w=startCh; w<=endCh; w++) {
  51. Stack.setChannel(w);
  52. run("Measure");
  53. }
  54. }
  55. }
  56. }
  57. if(order == "ctz") {
  58. for (u=startSl; u<=endSl; u++) {
  59. Stack.setSlice(u);
  60. for (v=startFr; v<=endFr; v++) {
  61. Stack.setFrame(v);
  62. for (w=startCh; w<=endCh; w++) {
  63. Stack.setChannel(w);
  64. run("Measure");
  65. }
  66. }
  67. }
  68. }
  69. if(order == "zct") {
  70. for (u=startFr; u<=endFr; u++) {
  71. Stack.setFrame(u);
  72. for (v=startCh; v<=endCh; v++) {
  73. Stack.setChannel(v);
  74. for (w=startSl; w<=endSl; w++) {
  75. Stack.setSlice(w);
  76. run("Measure");
  77. }
  78. }
  79. }
  80. }
  81. if(order == "ztc") {
  82. for (u=startCh; u<=endCh; u++) {
  83. Stack.setChannel(u);
  84. for (v=startFr; v<=endFr; v++) {
  85. Stack.setFrame(v);
  86. for (w=startSl; w<=endSl; w++) {
  87. Stack.setSlice(w);
  88. run("Measure");
  89. }
  90. }
  91. }
  92. }
  93. if(order == "tcz") {
  94. for (u=startSl; u<=endSl; u++) {
  95. Stack.setSlice(u);
  96. for (v=startCh; v<=endCh; v++) {
  97. Stack.setChannel(v);
  98. for (w=startFr; w<=endFr; w++) {
  99. Stack.setFrame(w);
  100. run("Measure");
  101. }
  102. }
  103. }
  104. }
  105. if(order == "tzc") {
  106. for (u=startCh; u<=endCh; u++) {
  107. Stack.setChannel(u);
  108. for (v=startSl; v<=endSl; v++) {
  109. Stack.setSlice(v);
  110. for (w=startFr; w<=endFr; w++) {
  111. Stack.setFrame(w);
  112. run("Measure");
  113. }
  114. }
  115. }
  116. }
  117. Stack.setPosition(ch, sl, fr);
  118. restoreSettings;