Last active
April 3, 2019 21:57
-
-
Save mutterer/7758228 to your computer and use it in GitHub Desktop.
A sample image menu macro that allows manually assigning classes to ROIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
La "classe" !!!
;-)
leon