/* 04.12.2024, 00:44 N.Vischer Transforming "ObjectJ objects" to ImageJ overlays. - Create images with Overlay: With an .ojj ObjectJ project open, run this macro. It creates images with overlay that can be displayed in ImageJ without the need of plugin ObjectJ. They are stored as zipped tif files in a special "_ZIPs" folder inside the project folder - you may rename it afterwards. Old zip files with same name will be overwritten. - Observe Overlay: Drag a zipped image file directly into the ImageJ main window. This avoids the creation of an unpacked duplicate. In ImageJ, choose Image>Overlay>List Elements: the names of the rois are double-clickable. To see the selected ROI isolated, optionally choose Image>Overlay>Hide Overlay. The name of a ROI start with ObjectJ's object number plus underscore. */ macro "Create folder with ZIPs + Overlay"{ withImages = true; //set false to save rois only strokeWidth = 2;//set 0 for non-zooming-width=1 path = ojGetProjectPath(); if (withImages) destDir = path + "_ZIPs" + "/"; else destDir = path + "_RoiOnlyZIPs" + "/"; File.makeDirectory(destDir); itemNames = split(ojGetItemNames(), " "); itemColors = split(ojGetItemColors(), " "); List.fromArrays(itemNames, itemColors); for(img = 1; img <= ojNImages(); img++){ close("*"); ojShowImage(img); showProgress(img/ojNImages()); showStatus("" + img + "/" + ojNImages()); if(img == 10) setBatchMode(true);//faster Overlay.clear; for(obj = ojFirstObject(img); obj <= ojLastObject(img); obj++){ ojShowObject(obj); for(itm = 1; itm <= ojNItems("*"); itm++){ ojSelectItem("*", itm); setSlice(ojZPos(1)); name = ojGetItemName(); color = List.get(name); ojItemToRoi(); Roi.setName("" + obj + "_" + name); Roi.setStrokeColor(color); Roi.setStrokeWidth(strokeWidth); Overlay.addSelection; Stack.getPosition(channel, slice, frame); Overlay.setPosition(channel, slice, frame); } } run("Select None"); zipTitle = File.getNameWithoutExtension(getTitle) + ".zip"; run("Duplicate...", "title=tmp duplicate"); path = destDir + zipTitle; if (withImages) saveAs("ZIP", path); else{ run("To ROI Manager"); roiManager("Save", path); } close("*"); } }