def getOptions(): pixels = zeros('f', 4) # 4 elements # First Dialog Box item = [ "coralline", "tunicate", "red", "macro", "background", "more than one" ] gd = GenericDialog("Options") gd.addRadioButtonGroup("options", item, 3, 2, "coralline") gd.showDialog() button = gd.getNextRadioButton() # Second Dialog Box gd2 = GenericDialog("Multiple Options") items = ["coralline", "tunicate", "red", "macro", "garbage"] defaultVal = [False] * 5 gd2.addCheckboxGroup(2, 3, items, defaultVal) gd2.addNumericField("coralline %", 0, 0) gd2.addNumericField("tunicate %", 0, 0) gd2.addNumericField("red %", 0, 0) gd2.addNumericField("macro %", 0, 0) gd2.addNumericField("background %", 0, 0) if gd.wasCanceled(): return 0 if button == "coralline": pixels[0] = 1 elif button == "tunicate": pixels[1] = 1 elif button == "red": pixels[2] = 1 elif button == "macro": pixels[3] = 1 elif button == "more than one": gd2.showDialog() checklist = gd2.getCheckboxes() pixels[0] = int( checklist[0].state) * (float(gd2.getNextNumber()) / 100) pixels[1] = int( checklist[1].state) * (float(gd2.getNextNumber()) / 100) pixels[2] = int( checklist[2].state) * (float(gd2.getNextNumber()) / 100) pixels[3] = int( checklist[3].state) * (float(gd2.getNextNumber()) / 100) return pixels
def uScopeCalDialog(cal): ''' Pop up a dialog asking user to edit line settings etc. CalIdx, SetGlobalScale, AddScaleBar = uScopeCalDialog(cal) `cal` should be the object containing `names`, `cals`, `units` attributes as set in the "user_settings.py" file. `CalIdx` is the list index to the chosen calibration. Eg., if the options were ['5x', '10x', '20x'] and the user chose '10x', then CalIdx = 1 Returns `None` if the user cancelled the dialog. `SetGlobalScale` is a boolean (True/False) from a checkbox option, if the user wants this calibration set 'globally' to all open images. `AddScaleBar` is also a boolean (True/False), for a checkbox option, if user would like to run "Scale Bar..." afterwards. ''' # The following inspired heavily by Correct_3D_drift.py: #print "uScopeCalDialog():" #print cal.names, [str(x) for x in cal.cals] gd = GenericDialog("Microscope Calibrations") gd.addMessage("Choose the calibration to load:") # generate text to display in list: # Radio Buttons: CalStr = [] CalType_IsFunc = [] for ii, name in enumerate(cal.names): if MC_DEBUG: print("item #%i: name=" % (ii), name, "\n\t type=", type(name)) if isinstance(name, basestring): '''It's just a regular calibration setting''' CalStr.append(name + " (%s" % cal.cals[ii] + " pixels/%s)" % cal.units[ii]) else: ''' Assume we'll be loading a custom function/class ''' CalStr.append( name.name) # get the name from the Class' .name attribute #end if(str) #end for(cal.names) '''if > 20 cals, use dropdown list, otherwise use radio buttons''' if len(cal.names) > 20: Radio = False # Drop-Down list: gd.addChoice(" Calibration:", CalStr, CalStr[0]) # default = 1st (#0) else: Radio = True gd.addRadioButtonGroup(" Calibration:", CalStr, len(CalStr), 1, CalStr[0]) #addRadioButtonGroup(label, [String items], rows, columns, String:defaultItem) #end if(cal>20) gd.addCheckbox("Apply Scale to all open images?", False) gd.addCheckbox("Add Scale Bar to this image?", False) gd.addMessage( "These calibrations can be altered by editing the file: \nFiji.app/plugins/Scripts/Plugins/Analyze/...\n\tMicroscope Measurement Tools/...\n\tMicroscope_Calibrations_user_settings.py" ) gd.showDialog() if gd.wasCanceled(): return None, None, None # return None's if user cancels if Radio: ChosenCal = gd.getNextRadioButton() # Find the index to the chosen radio button w/ [list].index(): CalIdx = CalStr.index(ChosenCal) else: ChosenCal = gd.getNextChoiceIndex() CalIdx = ChosenCal # the index to the choice SetGlobalScale = gd.getNextBoolean() AddScaleBar = gd.getNextBoolean() #if MC_DEBUG: print( ChosenCal,CalIdx, SetGlobalScale ) #if MC_DEBUG: print( "end uScopeCalDialog()." ) return CalIdx, SetGlobalScale, AddScaleBar
import logging outDirChoices = ["New Directory, no subfolders", "New Directory, keep input subfolders", "Within (subfolders of) input directory"] overwriteChoices = ["NO overwrite existing files", "Overwrite existing files"] channelSubfolderChoices = ["yes", "no"] mipChoices = ["yes: tiff", "yes: jpg"] overwriteList = [] startTime = time.time() imageCount = 0 voxel_info = str() gd = GenericDialog("Set ToTiff Options") gd.addStringField("File extension to be processed", ".nd2") gd.addRadioButtonGroup("Output", outDirChoices, 3, 1, outDirChoices[0]) gd.addRadioButtonGroup("Overwrite", overwriteChoices, 2, 1, overwriteChoices[0]) gd.addRadioButtonGroup("Save channels in different subfolders", channelSubfolderChoices, 1, 1, channelSubfolderChoices[0]) gd.addCheckboxGroup(2, 1, mipChoices, [False, False], ["Do you want maximum intensity projections of your images?"]) gd.showDialog() if gd.wasCanceled(): exit() fileExt = gd.getNextString() outDirPref = gd.getNextRadioButton() overwritePref = gd.getNextRadioButton() channelSubfolderPref = gd.getNextRadioButton() mipPrefTIFF = gd.getNextBoolean() mipPrefJPG = gd.getNextBoolean()
import logging outDirChoices = ["New Directory, no subfolders", "New Directory, keep input subfolders", "Within (subfolders of) input directory"] thresholdChoices = ["Otsu, white objects, stack, histogram of each slice", "Otsu, white objects, stack, stack histogram", "Otsu, white objects, try both methods"] overwriteChoices = ["NO overwrite existing files", "Overwrite existing files"] mipChoices = ["yes: tiff", "yes: jpg"] overwriteList = [] startTime = time.time() imageCount = 0 gd = GenericDialog("Set binarization.py Options") gd.addStringField("String to identify your input images", "_deconv") gd.addRadioButtonGroup("Output", outDirChoices, 3, 1, outDirChoices[0]) gd.addRadioButtonGroup("Threshold Settings", thresholdChoices, 3, 1, thresholdChoices[0]) gd.addRadioButtonGroup("Overwrite", overwriteChoices, 2, 1, overwriteChoices[0]) gd.addCheckboxGroup(2, 1, mipChoices, [False, False], ["Do you want maximum intensity projections of your images?"]) gd.showDialog() if gd.wasCanceled(): exit() fileID = gd.getNextString() outDirPref = gd.getNextRadioButton() thresholdPref = gd.getNextRadioButton() overwritePref = gd.getNextRadioButton() mipPrefTIFF = gd.getNextBoolean() mipPrefJPG = gd.getNextBoolean() IJ.redirectErrorMessages(True)
path.append("/Users/sean/Desktop/wormAnalysis") from pharynx_analysis.utils import * ################################################### # SETUP imTitles = WindowManager.getImageTitles() nTitles = len(imTitles) ## DIALOG d = GenericDialog("Measure") d.addChoice("Mask", imTitles, "-") d.addChoice("470 image", imTitles, "-") d.addChoice("410 image", imTitles, "-") d.addRadioButtonGroup("Binning", ["4x4", "2x2"], 1, 2, "4x4") d.showDialog() imgMask = WindowManager.getImage(d.getNextChoice()) img470 = WindowManager.getImage(d.getNextChoice()) img410 = WindowManager.getImage(d.getNextChoice()) binning = d.getNextRadioButton() PARENT_DIR = img410.getOriginalFileInfo().directory # setup data collection object dataTable = ResultsTable() ################################################## # INITIAL MEASUREMENTS
def uScopeCalDialog(cal): ''' Pop up a dialog asking user to choose from the calibration names etc. CalIdx, SetGlobalScale, AddScaleBar = uScopeCalDialog(cal) `cal` should be the object containing `names`, `cals`, `units` attributes as set in the "user_settings.py" file. `CalIdx` is the list index to the chosen calibration. Eg., if the options were ['5x', '10x', '20x'] and the user chose '10x', then CalIdx = 1 Returns `None` if the user cancelled the dialog. `SetGlobalScale` is a boolean (True/False) from a checkbox option, if the user wants this calibration set 'globally' to all open images. `AddScaleBar` is also a boolean (True/False), for a checkbox option, if user would like to run "Scale Bar..." afterwards. ''' # The following inspired heavily by Correct_3D_drift.py: #print "uScopeCalDialog():" #print cal.names, [str(x) for x in cal.cals] gd = GenericDialog("Microscope Calibrations") gd.addMessage("Choose the calibration to load:") # generate text to display in list: # Radio Buttons: CalStr = [] CalType_IsFunc = [] for ii, name in enumerate(cal.names): if mc_DEBUG: print( "item #%i: name=" % (ii), name, "\n\t type=", type(name) ) if isinstance(name, basestring): '''It's just a regular calibration setting''' CalStr.append( name + " (%s"%cal.cals[ii] + " pixels/%s)"%cal.units[ii] ) else: ''' Assume we'll be loading a custom function/class ''' CalStr.append( name.name ) # get the name from the Class' .name attribute #end if(str) #end for(cal.names) '''if > 20 cals, use dropdown list, otherwise use radio buttons''' if len(cal.names) > 20: Radio=False # Drop-Down list: gd.addChoice(" Calibration:", CalStr, CalStr[0] ) # default = 1st (#0) else: Radio=True gd.addRadioButtonGroup(" Calibration:", CalStr, len(CalStr), 1, CalStr[0]) #addRadioButtonGroup(label, [String items], rows, columns, String:defaultItem) #end if(cal>20) gd.addCheckbox("Apply Scale to all open images?", False) gd.addCheckbox("Add Scale Bar to this image?", False) gd.addMessage("These calibrations can be altered by editing the file: \nFiji.app/plugins/Scripts/Plugins/Analyze/...\n\tMicroscope Measurement Tools/...\n\tMicroscope_Calibrations_user_settings.py") gd.showDialog() if gd.wasCanceled(): return None, None, None # return None's if user cancels if Radio: ChosenCal = gd.getNextRadioButton() # Find the index to the chosen radio button w/ [list].index(): CalIdx = CalStr.index( ChosenCal ) else: ChosenCal = gd.getNextChoiceIndex() CalIdx = ChosenCal # the index to the choice SetGlobalScale = gd.getNextBoolean() AddScaleBar = gd.getNextBoolean() #if mc_DEBUG: print( ChosenCal,CalIdx, SetGlobalScale ) #if mc_DEBUG: print( "end uScopeCalDialog()." ) return CalIdx, SetGlobalScale, AddScaleBar