Skip to content

Instantly share code, notes, and snippets.

@mutterer
Last active February 27, 2016 10:52
Show Gist options
  • Select an option

  • Save mutterer/8fc04d0bdcc72a56072c to your computer and use it in GitHub Desktop.

Select an option

Save mutterer/8fc04d0bdcc72a56072c to your computer and use it in GitHub Desktop.
// written at the request of S.Mingle.
// https://gist.github.com/mutterer/8fc04d0bdcc72a56072c
var baselineIndex=0;
macro "Help Action Tool - C00cT0f18?" {
help = setup();
}
macro "Define BaseLine Action Tool - C00cT0f18BTaf18l" {
run("Set Measurements...", "centroid fit display redirect=None decimal=3");
if (selectionType()!=5) {
setTool("line");
exit("Draw pelvic baseline first");
}
getLine(x1, y1, x2, y2, lineWidth);
if (x1>x2) makeLine(x2, y2,x1,y1);
run ("Measure");
baselineIndex = nResults-1;
setResult("ROIType",baselineIndex,"baseline");
updateResults();
setTool("ellipse");
}
macro "Measure Implant Action Tool - C00cT0f18IT5f10mTef10p" {
run("Set Measurements...", "centroid fit display redirect=None decimal=3");
if (selectionType()!=3) {
setTool("ellipse");
exit("Draw ellipse over cup opening first");
}
run ("Measure");
ellipseIndex=nResults-1;
ellipse_angle=getResult("Angle",ellipseIndex);
minor = getResult("Minor",ellipseIndex);
major = getResult("Major",ellipseIndex);
pelvic_base_angle=getResult("Angle",baselineIndex);
side = "Left";
if (getResult("X",ellipseIndex)<getResult("X",baselineIndex))
side="Right";
if (side == "Left"){
inclination = ellipse_angle-pelvic_base_angle;
} else {
inclination = 180-(ellipse_angle-pelvic_base_angle);
}
setResult("ROIType",ellipseIndex,"ellipse");
setResult("Side",ellipseIndex,side);
setResult("Inclination",ellipseIndex,d2s(inclination,1));
setResult("Version",ellipseIndex,d2s((180/PI)*asin(minor/major),1));
}
function setup() {
m = "Hip Implant Toolset\n"
+ "---------------------\n"
+ "For each new image do the following:\n"
+ "\n"
+ "1-Draw pelvic baseline first\n"
+ "2-Press the 'Bl' button to measure it\n"
+ "3-Draw ellipse over cup opening\n"
+ "4-Press the 'Imp' button to measure it\n"
+ "5-Optional: repeat steps 3&4 for opposite implant\n"
+ "6-Start over with new image\n";
showMessage (m);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment