/*run("3D Project...", "projection='Brightest Point' axis=Y-Axis slice=4 initial=290 total=140 rotation=10 lower=1 upper=255 opacity=0 surface=100 interior=50 interpolate"); run("Rotate 90 Degrees Right"); run("3D Project...", "projection='Brightest Point' axis=Y-Axis slice=4 initial=290 total=140 rotation=10 lower=1 upper=255 opacity=0 surface=100 interior=50 interpolate"); run("Rotate 90 Degrees Left"); run("Stack Combiner", "stack='Projections of big.tif' stack='Projections of big.tif' "); */ //Get crop dimensions x = 0; y = 0; width = 0; height = 0; getSelectionBounds(x, y, width, height); myImageTitle = getTitle(); //Get projection parameters title = "temp"; initialAngle = 0;totalAngle = 360;angleInc = 10; transparencyLower=1; transparencyUpper=255;opacity=0; depthCueSurf=100;depthCueInt=50;sliceSpacing = 1.0; interpolate=false;interpolateString = ""; stereo=false;stereoAngle=7; slicesPerStack = nSlices; Dialog.create("3d Projection"); Dialog.addString("Title:", title); Dialog.addChoice("Projection Method:", newArray("Nearest Point", "Brightest Point", "Mean Value")); Dialog.addChoice("Axis of Rotation:", newArray("X-Axis", "Y-Axis", "Both")); Dialog.addNumber("Slice spacing (pixels):", sliceSpacing); Dialog.addNumber("Initial Angle (0-360 deg):", initialAngle); Dialog.addNumber("Total Rotation (0-360 deg):", totalAngle); Dialog.addNumber("Rotation Angle Increment:", angleInc); Dialog.addNumber("Lower Transparency Bound:", transparencyLower); Dialog.addNumber("Upper Transparency Bound:", transparencyUpper); Dialog.addNumber("Opacity (0-100%):", opacity); Dialog.addNumber("Surface Depth-Cueing (0-100%):", depthCueSurf); Dialog.addNumber("Interior Depth-Cueing (0-100%):", depthCueInt); Dialog.addCheckbox("Interpolate When Slice Spacing > 1.0", interpolate); Dialog.addCheckbox("Generate Stereo Pairs",stereo); Dialog.addChoice("Stereo Type:", newArray("Stereo Pair", "Red-Green", "Red-Cyan")); Dialog.addNumber("Stereo Angle:",stereoAngle); Dialog.addNumber("Top focal plane:",1); Dialog.addNumber("Bottom focal plane:",slicesPerStack); Dialog.show(); //Populate the parameters for the rotations title = Dialog.getString(); projectionMethod = Dialog.getChoice(); axisOfRotation = Dialog.getChoice(); sliceSpacing = Dialog.getNumber(); initialAngle = Dialog.getNumber(); totalAngle = Dialog.getNumber(); angleInc = Dialog.getNumber(); transparencyLower = Dialog.getNumber(); transparencyUpper = Dialog.getNumber(); opacity = Dialog.getNumber(); depthCueSurf = Dialog.getNumber(); depthCueInt = Dialog.getNumber(); interpolate = Dialog.getCheckbox(); if (interpolate) {interpolateString = " interpolate";} stereo = Dialog.getCheckbox(); stereoType = Dialog.getChoice(); stereoAngle = Dialog.getNumber(); topFocalPlane = Dialog.getNumber(); bottomFocalPlane = Dialog.getNumber(); if ((stereo) && (stereoType == "Stereo Pair") && (axisOfRotation == "Both")) { //beep(); showMessage("Stereo pairs can only be generated with single axis rotations."); exit(); } //Duplicate so we can perform cropping operations. Uses more memory! selectImage(myImageTitle); run("Duplicate...", "title=temp duplicate"); selectImage("temp"); //delete slices out of the range specified in the original dialog if (topFocalPlane > 1) { setSlice(1); for (j=0; j<(topFocalPlane -1); j++) { run("Delete Slice"); } } if (bottomFocalPlane < slicesPerStack) { setSlice(nSlices); for (j=0; j<( slicesPerStack - bottomFocalPlane); j++) { run("Delete Slice"); } } makeRectangle(x, y, width, height); if (axisOfRotation == "Y-Axis") { run("Crop"); //if no stereo option selected, don't do it! if (!stereo) { run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + initialAngle + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("temp");close(); } else { run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle - (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Left"); selectImage("temp"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle + (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Right"); selectImage("temp");close(); if (stereoType == "Stereo Pair") { run("Stack Combiner", "stack1=Left stack2=Right"); } if (stereoType == "Red-Green") { run("RGB Merge...", "red=Left green=Right blue=*None*"); } else if (stereoType == "Red-Cyan") { run("RGB Merge...", "red=Left green=Right blue=Right"); } } } else if (axisOfRotation == "X-Axis") { if (!stereo){ run("Crop"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + initialAngle + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("temp");close(); } else { if (stereoType == "Stereo Pair"){ run("Crop"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle - (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Left"); selectImage("temp"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle + (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Right"); selectImage("temp");close(); run("Stack Combiner", "stack1=Left stack2=Right"); } else { run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle - (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Left"); selectImage("temp"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + axisOfRotation + " slice=" + sliceSpacing + " initial=" + (initialAngle + (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Right"); selectImage("temp");close(); if (stereoType == "Red-Green") { run("RGB Merge...", "red=Left green=Right blue=*None*"); } else if (stereoType == "Red-Cyan") { run("RGB Merge...", "red=Left green=Right blue=Right"); } } } } else { run("Crop"); //Do Y-axis projection if (!stereo){ run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "Y-Axis" + " slice=" + sliceSpacing + " initial=" + initialAngle + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("Projections of temp"); rename("Y-Axis"); } else { run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "Y-Axis" + " slice=" + sliceSpacing + " initial=" + (initialAngle - (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Left"); selectImage("temp"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "Y-Axis" + " slice=" + sliceSpacing + " initial=" + (initialAngle + (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); rename("Right"); if (stereoType == "Red-Green") { run("RGB Merge...", "red=Left green=Right blue=*None*"); rename("Y-Axis"); } else if (stereoType == "Red-Cyan") { run("RGB Merge...", "red=Left green=Right blue=Right"); rename("Y-Axis"); } } //Now do X-axis projection selectImage("temp"); if (!stereo){ run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "X-Axis" + " slice=" + sliceSpacing + " initial=" + initialAngle + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("Projections of temp"); rename("X-Axis"); selectImage("temp"); close(); } else { run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "X-Axis" + " slice=" + sliceSpacing + " initial=" + (initialAngle - (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("Projections of temp"); rename("Left"); selectImage("temp"); run("3D Project...", "projection=[" + projectionMethod + "] axis=" + "X-Axis" + " slice=" + sliceSpacing + " initial=" + (initialAngle + (stereoAngle/2)) + " total=" + totalAngle + " rotation=" + angleInc + " lower=" + transparencyLower + " upper=" + transparencyUpper + " opacity=" + opacity + " surface=" + depthCueSurf + " interior=" + depthCueInt + interpolateString); selectImage("Projections of temp"); rename("Right"); selectImage("temp");close(); if (stereoType == "Red-Green") { run("RGB Merge...", "red=Left green=Right blue=*None*"); rename("X-Axis"); } else if (stereoType == "Red-Cyan") { run("RGB Merge...", "red=Left green=Right blue=Right"); rename("X-Axis"); } } run("Stack Combiner", "stack1=X-Axis stack2=Y-Axis"); }