def addDefaultOptions(self): ''' Add default GUI items - checkbox runMeasurement - add to Manager, nextSlice, runMeasurement - resource message - help button ''' # Checkbox next slice and run Measure self.addCheckbox("Auto next slice/image file", bool(Prefs.get("annot.doNext", True))) if self.browseMode == "stack": self.addToSameRow() self.addChoice("- dimension (for hyperstack)", hyperstackDim, Prefs.get("annot.dimension", hyperstackDim[0])) elif self.browseMode == "directory": # Add button previous/next self.addButton(BrowseButton.LABEL_PREVIOUS, BrowseButton()) self.addToSameRow() self.addButton(BrowseButton.LABEL_NEXT, BrowseButton()) self.addMessage( "Documentation and generic analysis workflows available on the GitHub repo (click Help)" ) # Add Help button pointing to the github self.addHelp( r"https://github.com/LauLauThom/Fiji-QualiAnnotations#readme") self.hideCancelButton()
def main(*R): """ Main function """ # Show intial progress bar IJ.showProgress(0, 50) IJ.showStatus("Heterogeneous Z Correction") # Retrieve the values R (with default values) from previous attempts Rstr = "[(-0.05977, 83.3, 78.73),(-0.05976, 41.65, 39.36)]" R = eval(Prefs.get("HetZCorr.R", Rstr)) # Load current image and get infos imp = IJ.getImage() stk = imp.getStack() (sx, sy, sz) = stackSize(stk) cal = imp.getCalibration() # Get unique values val = getUniqueValues(stk) # Get R from dialog R = showDialogR(R, val) # Generate optical model correction = generateModel(stk, R, val) imp.setCalibration(cal) #Show model image correction.show() correction.setSlice(sz) IJ.run(correction, "Enhance Contrast", "saturated=0.35") IJ.run(correction, "Fire", "")
def actionPerformed(self, event): """Delete the last row""" # Generate a save dialog dialog = JFileChooser(Prefs.get("roiGroup.importDir", "")) dialog.setSelectedFile(File("roiGroups.txt")) dialog.setFileFilter(FileNameExtensionFilter("Text file", ["txt"])) output = dialog.showOpenDialog( self.groupTable) # could be None argument too if output in [JFileChooser.CANCEL_OPTION, JFileChooser.ERROR_OPTION]: return selectedFile = dialog.getSelectedFile() directory = selectedFile.getParent() Prefs.set("roiGroup.importDir", directory) if not selectedFile.isFile(): return filePath = selectedFile.getPath() # Read comma-separated group from file with open(filePath, "r") as textFile: stringGroup = textFile.readline().rstrip() # Update table with content of file tableModel = self.groupTable.tableModel tableModel.setGroupColumn(stringGroup)
def GetLastMeasureCount(): myCount = Prefs.get("JRM.meas.counter", int(-1)) if myCount < 0: # it was not set, so set it to zero resetLastMeasureCount() return 0 else: myCount = int(myCount) return myCount
def makeCategoryComponent(self, category): """ Generates a checkbox with the new category name, to add to the GUI Overwrite the original method """ stringCat = Prefs.get("annot.listCat", "") newStringCat = stringCat + "," + category if stringCat else category Prefs.set("annot.listCat", newStringCat) # Make a new checkbox with the category name checkbox = Checkbox(category, False) checkbox.setFocusable( False) # important to have the keybard shortcut working return checkbox
def debug_mode(): """Wrapper to check if 'imcf.debugging' is enabled. This is a workaround for a Jython issue in ImageJ with values that are stored in the "IJ_Prefs.txt" file being cast to the wrong types and / or values in Python. Callling Prefs.get() using a (Python) boolean as the second parameter always leads to the return value '0.0' (Python type float), no matter what is actually stored in the preferences. Doing the same in e.g. Groovy behaves correctly. Calling Prefs.get() as below with the second parameter being a string and subsequently checking the string value leads to the expected result. """ debug = Prefs.get("imcf.debugging", "false") return debug == "true"
def actionPerformed(self, event): """Delete the last row""" # Generate a save dialog dialog = JFileChooser(Prefs.get("roiGroup.exportDir", "")) dialog.setSelectedFile(File("roiGroups.txt")) dialog.setFileFilter(FileNameExtensionFilter("Text file", ["txt"])) output = dialog.showSaveDialog( self.groupTable) # could be argument None too if output in [JFileChooser.CANCEL_OPTION, JFileChooser.ERROR_OPTION]: return selectedFile = dialog.getSelectedFile() directory = selectedFile.getParent() Prefs.set("roiGroup.exportDir", directory) filePath = selectedFile.getPath() if not ("." in filePath): filePath += ".txt" # Add extension if missing # Write the groupString to the file groupString = self.groupTable.tableModel.getGroupString() with open(filePath, "w") as textFile: textFile.write(groupString)
# for Ambro 2016-05-16 # gLo = 500 # gHi = 3800 # for Kang LM 2016-05-24 gLo = 730 gHi = 2850 bDoTiltCorrect = False mu = IJ.micronSymbol scaUm = mu + "m" lastPath = Prefs.get("Last.Image.Dir", "None") if os.path.exists(lastPath): os.chdir(lastPath) dc = DirectoryChooser("Choose directory") basePath = dc.getDirectory() print(basePath) Prefs.set("Last.Image.Dir", basePath) names = [] for file in os.listdir(basePath): if file.endswith(".tif"): name = os.path.splitext(file)[0] names.append(name)
def getCategoriesFromPersistence(): """Return categories saved in memory as a list.""" stringCat = Prefs.get( "annot.listCat", "Category1" ) # Retrieve the list of categories as a comma separated list, if not defined default to Category1 return stringCat.split(",") if stringCat else []