Skip to content

Instantly share code, notes, and snippets.

@mutterer
Last active April 3, 2019 21:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutterer/7758228 to your computer and use it in GitHub Desktop.
Save mutterer/7758228 to your computer and use it in GitHub Desktop.
A sample image menu macro that allows manually assigning classes to ROIs
var tags = newArray("nucleus-1","nucleus-2","cyto-1", "cyto-2");
var colors = newArray("red", "green", "blue", "magenta");
var commands = newArray("Select by tag...");
var menu = Array.concat(commands, tags);
var pmCmds = newMenu("Popup Menu", menu);
macro "Popup Menu" {
cmd = getArgument();
if (cmd=="Select by tag...") {
Dialog.create("Title");
Dialog.addChoice("select tag", tags);
Dialog.show();
tag = Dialog.getChoice();
array =selectROIS(tag);
roiManager ('select', array);
} else {
Roi.setProperty(cmd);
color = getMatchingColor(cmd);
Roi.setStrokeColor(color);
Roi.setStrokeWidth(2);
roiManager('add');
}
}
function selectROIS (keyword) {
ids=newArray(0);
for (i=0;i<roiManager('count');i++) {
roiManager('select',i);
if (Roi.getProperty(keyword)==true) {
ids=Array.concat(ids,i);
}
}
return ids;
}
function getMatchingColor(s) {
index=-1;
for (i=0;i<tags.length;i++) {
if (tags[i]==s) index=i;
}
return colors[index];
}
@leec13
Copy link

leec13 commented Dec 3, 2013

La "classe" !!!
;-)
leon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment