/* * Toolset for quickly rename and save ROIs * It was thought for brain autoradiograms (in situ hybridization/receptor binding experiments) * where typically measurements need to be performed manually in multiple regions. * * For a faster workflow create first all ROIs (press [t] to add them to the ROI Manager), * and then use the 'Group Labeling' tools to rename them. * Default labels can be modified below... * * Tiago Ferreira ferreira embl.de - 10.2007 */ // --------------- These are the default settings: ------------------- // Regions: var l1 ="CA1"; var l2 ="CA3"; var l3 ="DG"; var l4 ="Cortex"; var l5 ="Striatum"; var l6 ="Amigdala"; var l7 ="Raphe"; var l8 ="Ce"; var l9 ="-"; var l10 ="-"; // Groups: var g1 ="WT"; var g2 ="Het"; var g3 ="KO"; // --------------- QuicklyRename&SaveRoiSets Macro: --------------- var labels =getLabelList(); var groups =getGroupList(); var i =roiManager("index"); var aCmds =newMenu("Group 1 labeling Menu Tool", labels); var bCmds =newMenu("Group 2 labeling Menu Tool", labels); var cCmds =newMenu("Group 3 labeling Menu Tool", labels); var xx = requires138b(); // check version at install function requires138b() {requires("1.38b"); return 0; } } macro "Unused Tool - " { } macro "Group 1 labeling Menu Tool - C000T0b121" { cmd = getArgument(); if (roiManager("count")==0) exit("Before renaming a region\n you need to create it!"); else roiManager('Rename',i+" "+cmd+" "+groups[0]); MoveToNext(); } macro "Group 2 labeling Menu Tool - C000T0b122" { cmd = getArgument(); if (roiManager("count")==0) exit("Before renaming a region\n you need to create it!"); else roiManager('Rename',i+" "+cmd+" "+groups[1]); MoveToNext(); } macro "Group 3 labeling Menu Tool - C000T0b123" { cmd = getArgument(); if (roiManager("count")==0) exit("Before renaming a region\n you need to create it!"); else roiManager('Rename',i+" "+cmd+" "+groups[2]); MoveToNext(); } macro "Previous Region Action Tool - C000D57D58D67D68D76D77D78D79D86D87D88D89D95D96D97D98D99D9aDa5Da6Da7Da8Da9DaaC000C111C222C333C444C555C666C777C888C999CaaaCbbbCcccCdddCeeeCfff" { if (roiManager("count")==0) exit ("ROI Manager is empty.\nCannot cycle through."); else MoveToPrevious(); } macro "Next Region Action Tool - C000D55D56D57D58D59D5aD65D66D67D68D69D6aD76D77D78D79D86D87D88D89D97D98Da7Da8C000C111C222C333C444C555C666C777C888C999CaaaCbbbCcccCdddCeeeCfff" { if (roiManager("count")==0) exit ("ROI Manager is empty.\nCannot cycle through."); else MoveToNext(); } macro "Save All Regions Action Tool - C000D00D01D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD10D14D15D16D17D18D19D1aD1bD1cD1dD1eD1fD20D24D25D26D27D28D29D2aD2bD2cD2dD2eD2fD30D34D35D36D37D38D39D3aD3bD3cD3dD3eD3fD40D44D45D46D47D48D49D4aD4bD4cD4dD4eD4fD50D54D55D5aD5bD5cD5dD5eD5fD60D64D6bD6cD6dD6eD6fD70D74D7bD80D81D82D83D84D8bD90D91D92D93D94D9bD9cD9dD9eD9fDa0Da1Da2Da3Da4Da5DaaDabDacDadDaeDafDb0Db1Db2Db3Db4Db5Db6Db7Db8Db9DbaDbbDbcDbdDbeDbfDc0Dc1Dc2Dc3Dc4Dc5Dc6Dc8Dc9DcaDcbDccDcdDceDcfDd0Dd1Dd2Dd3Dd4Dd5Dd6Dd7Dd8Dd9DdaDdbDdcDddDdeDdfDe0De1De2De3De4De5De6De7De8De9DeaDebDecDedDeeDefDf0Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDffC000D0fC000D02C000C111C222C333C444C555C666C777C888C999CaaaCbbbCcccCdddCeeeCfff"{ options=newArray('Same folder as Image', "Another location"); if (roiManager("count")==0) exit ("ROI Manager is empty.\n No ROIs to save."); else if (nImages==0 && roiManager("count")!=0) exit ("This tool requires an open image"); else if (getDirectory("image")==""){ options=newArray("Another location"); foot =getTitle+' is either on a remote server'+'\n'+'or it has not been saved yet...';} else if (File.exists(getDirectory("image")+getTitle+'-RoiSet.zip')==1) foot ="Attention!\nA similar .zip file already exists at\n"+getDirectory("image")+"\nIf you don't want to overwritte it choose 'Another location'"; else foot ='Current image location:'+'\n'+getDirectory("image"); roiManager('Deselect'); setOption("Show All", true); Dialog.create("Save Session"); Dialog.addChoice('Save '+getTitle()+'-RoiSet.zip'+' in:',options); Dialog.addMessage(foot); Dialog.show(); target = Dialog.getChoice(); if (target=="Same folder as Image") roiManager('save',getDirectory("image")+getTitle()+'-RoiSet.zip'); else roiManager('save', getDirectory("Select a Directory")+getTitle()+'-RoiSet.zip'); setOption("Show All", false); } function getLabelList() { if (nImages>0) a=bitDepth; else a=24; Dialog.create("Settings (I)"); Dialog.addMessage('Labels Definition:') Dialog.addString("Label 01", l1, 10); Dialog.addString("Label 02", l2, 10); Dialog.addString("Label 03", l3, 10); Dialog.addString("Label 04", l4, 10); Dialog.addString("Label 05", l5, 10); Dialog.addString("Label 06", l6, 10); Dialog.addString("Label 07", l7, 10); Dialog.addString("Label 08", l8, 10); Dialog.addString("Label 09", l9, 10); Dialog.addString("Label 10", l10, 10); Dialog.addMessage("Labels defined by '-'\n will be ignored"); Dialog.addCheckbox("Invert gray values", false); Dialog.show(); l1 =Dialog.getString(); l2 =Dialog.getString(); l3 =Dialog.getString(); l4 =Dialog.getString(); l5 =Dialog.getString(); l6 =Dialog.getString(); l7 =Dialog.getString(); l8 =Dialog.getString(); l9 =Dialog.getString(); l10 =Dialog.getString(); inv =Dialog.getCheckbox(); if(inv==true && nImages>0 && a!=24) {run("Invert");run("Invert LUT");} tags =newArray(""+l1,""+l2,""+l3,""+l4,""+l5,""+l6,""+l7,""+l8,""+l9,""+l10,"-","Background"); return tags; } function getGroupList() { Dialog.create("Settings (II)"); Dialog.addMessage('Groups definition:') Dialog.addString("Group 1", g1, 7); Dialog.addString("Group 2", g2, 7); Dialog.addString("Group 3", g3, 7); Dialog.show(); g1 =Dialog.getString(); g2 =Dialog.getString(); g3 =Dialog.getString(); groups =newArray(""+g1,""+g2,""+g3); return groups; } function MoveToNext() { n =roiManager("count"); i =roiManager("index"); if(n==i+1) roiManager('select', 0); else roiManager('select', i+1); } function MoveToPrevious() { n =roiManager("count"); i =roiManager("index"); if (i<=0) roiManager('select', n-1); else roiManager('select', i-1); }