#import sys.path #import sys.modules #from java.lang.System import getProperty #sys.path.append(getProperty('fiji.dir') + '/plugins/Stowers/Jay_Unruh') #sys.modules.clear() import table_tools import ij.plugin.frame.RoiManager as RoiManager import ij.gui.PointRoi as PointRoi from ij import WindowManager import ij.gui.GenericDialog as GenericDialog def getTableName(): #this shows the user a list of open non-images windows and let's them pick a table gd=GenericDialog("Options") frames=WindowManager.getNonImageWindows() titles=[frames[i].title for i in range(len(frames))] gd.addChoice("Table Name",titles,titles[0]) gd.showDialog() if(gd.wasCanceled()): return None tabname=titles[gd.getNextChoiceIndex()] return tabname def getColLabels(headers,nsel,titles=None): #this shows the user a list of selected table column labels and let's them pick some headers2=headers+['None'] nheads=len(headers) titles2=titles if(titles is None): titles2=['col'+(i+1) for i in range(nsel)] gd=GenericDialog('Options') for i in range(nsel): gd.addChoice(titles2[i],headers2,headers2[i%nheads]) gd.showDialog() if(gd.wasCanceled()): return None labels=[] for i in range(nsel): tlabel=headers2[gd.getNextChoiceIndex()] if(tlabel=='None'): labels.append(None) else: labels.append(tlabel) return labels tabname=getTableName() if(tabname is None): tabname='Results' sdata,headers=table_tools.getTableData(tabname) xname,yname,cname,zname,tname=getColLabels(headers,5,['x','y','c','z','t']) fdata=table_tools.transpose(table_tools.getTableValues(sdata)) xdata=fdata[headers.index(xname)] ydata=fdata[headers.index(yname)] npts=len(xdata) zdata,cdata,tdata=[0]*npts,[0]*npts,[0]*npts if(zname is not None): zdata=fdata[headers.index(zname)] if(cname is not None): cdata=fdata[headers.index(cname)] if(tname is not None): tdata=fdata[headers.index(tname)] rman=RoiManager.getInstance() if(rman is None): rman=RoiManager() for i in range(len(xdata)): #print([xdata[i],ydata[i],cdata[i],zdata[i],tdata[i]]) roi=PointRoi(xdata[i],ydata[i]) roi.setPosition(int(cdata[i])+1,int(zdata[i])+1,int(tdata[i])+1) rman.addRoi(roi)