本文整理匯總了Python中ij.gui.GenericDialog.addChoice方法的典型用法代碼示例。如果您正苦於以下問題:Python GenericDialog.addChoice方法的具體用法?Python GenericDialog.addChoice怎麽用?Python GenericDialog.addChoice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ij.gui.GenericDialog
的用法示例。
在下文中一共展示了GenericDialog.addChoice方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getOptions
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getOptions(imp):
gd = GenericDialog("Correct 3D Drift Options")
channels = []
for ch in range(1, imp.getNChannels()+1 ):
channels.append(str(ch))
methods = ["phase_correlation","center_of_mass"]
gd.addChoice("Channel for registration:", channels, channels[0])
gd.addChoice("Method for registration:", methods, methods[1])
gd.addNumericField("Background value:", 0, 0)
gd.addCheckbox("Multi_time_scale computation for enhanced detection of slow drifts?", False)
gd.addCheckbox("Sub_pixel drift correction (possibly needed for slow drifts)?", False)
gd.addCheckbox("Edge_enhance images for possibly improved drift detection?", False)
gd.addCheckbox("Use virtualstack for saving the results to disk to save RAM?", False)
gd.addCheckbox("Drift correct only data inside ROI?", False)
gd.addCheckbox("Only compute drift vectors?", False)
gd.addMessage("If you put a ROI, drift will only be computed in this region;\n the ROI will be moved along with the drift to follow your structure of interest.")
gd.addSlider("z_min of ROI", 1, imp.getNSlices(), 1)
gd.addSlider("z_max of ROI", 1, imp.getNSlices(), imp.getNSlices())
gd.showDialog()
if gd.wasCanceled():
return
channel = gd.getNextChoiceIndex() + 1 # zero-based
method = gd.getNextChoiceIndex() + 1 # zero-based
bg_value = gd.getNextNumber()
multi_time_scale = gd.getNextBoolean()
subpixel = gd.getNextBoolean()
process = gd.getNextBoolean()
virtual = gd.getNextBoolean()
only_roi = gd.getNextBoolean()
only_compute = gd.getNextBoolean()
roi_z_min = int(gd.getNextNumber())
roi_z_max = int(gd.getNextNumber())
return channel, method, bg_value, virtual, multi_time_scale, subpixel, process, only_roi, only_compute, roi_z_min, roi_z_max
示例2: main
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def main():
properties = ImageProperties(imp)
# Create a GenericDialog to configure renaming:
gd = GenericDialog('Gatan Reamer')
gd.addMessage('Modifying: %s' % (imp.getTitle(),))
gd.addMessage('Recorded: %s' % (properties.date.toString(),))
gd.addNumericField('Exposure time', properties.exposure, 4, field_width, 's')
gd.addNumericField('Magnification:', properties.magnification, 0, field_width, 'x')
mag_units = ('kx', 'x')
gd.addChoice('Magnification unit:', mag_units, mag_units[0])
gd.addMessage('The actual magnification is %.2f times larger.' % (properties.mag_factor,))
gd.addCheckbox('Use actual magnification:', False)
gd.addMessage('')
gd.addNumericField('Energy loss:', properties.energyloss, 1, field_width, 'eV')
gd.addStringField('Date:', properties.date_string, field_width)
gd.addStringField('original name:', properties.name, field_width_long)
gd.addStringField('Filename format', default_format_str, field_width_long)
gd.showDialog()
if not gd.wasCanceled():
# Edit the properties to consiter user choices:
properties.exposure = gd.getNextNumber()
mag = gd.getNextNumber()
properties.mag_unit = gd.getNextChoice()
if gd.getNextBoolean():
properties.calc_mag(mag)
properties.energyloss = gd.getNextNumber()
properties.date_string = gd.getNextString()
properties.name = gd.getNextString()
format_str = gd.getNextString()
# Chenge the title:
imp.setTitle(format_str % properties.to_dict())
示例3: Resize
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def Resize(imp):
gd = GenericDialog("Image size")
scales = ["1024","2048","4096"]
gd.addChoice("Choose image size",scales,scales[1])
gd.showDialog()
scale_choice = gd.getNextChoice()
IJ.run(imp,"Scale...", "x=- y=- z=1.0 width="+scale_choice+" height="+scale_choice+" interpolation=Bilinear average process create title=Scaled")
scaled_imp = WindowManager.getImage("Scaled")
return scaled_imp
示例4: getChannels
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getChannels():
gd = GenericDialog( "Select stack's channels" )
# print gd.getModalityType()
# gd.setModal( False )
# print gd.getModalityType()
color = ["red", "green", "blue"]
gd.addChoice("Channel for mask", color, color[2])
gd.addChoice("Channel for particles", color, color[1])
gd.showDialog()
maskChannel = gd.getNextChoice()
partChannel = gd.getNextChoice()
if gd.wasCanceled():
sys.exit()
return maskChannel, partChannel
示例5: create_selection_dialog
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def create_selection_dialog(image_titles, defaults, title='Select images for processing'):
gd = GenericDialog(title)
# The build in function enumerate() returns two values:
# The index and the value stored in the tuple/list.
for index, default in enumerate(defaults):
# for each loop we add a new choice element to the dialog.
gd.addChoice('Image_'+ str(index + 1), image_titles, image_titles[default])
gd.showDialog()
if gd.wasCanceled():
return None
# This function returns a list.
# _ is used as a placeholder for values we don't use.
# The for loop is used to call gd.getNextChoiceIndex() len(defaults) times.
return [gd.getNextChoiceIndex() for _ in defaults]
示例6: getOptions
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getOptions(imp):
gd = GenericDialog("Correct 3D Drift Options")
channels = []
for ch in range(1, imp.getNChannels()+1 ):
channels.append(str(ch))
gd.addMessage("Select a channel to be used for the registration.")
gd.addChoice(" channel:", channels, channels[0])
gd.addCheckbox("Use virtualstack?", False)
gd.addMessage("This will store the registered hyperstack as an image sequence and\nshould be used if free RAM is less than 2X the size of the hyperstack. ")
gd.showDialog()
if gd.wasCanceled():
return
channel = gd.getNextChoiceIndex() + 1 # zero-based
virtual = gd.getNextBoolean()
return channel, virtual
示例7: create_selection_dialog
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def create_selection_dialog(image_titles, defaults, title='Select images for processing'):
"""
Show a dialog to select the images to process and return a list of the selected ones (index).
:param image_titles: A list of image titles presented for selection.
:param defaults: The titles to be selected by default.
The length of this list defines the number of selectable images.
:param title: the title of the dialog (default 'Select images for processing').
"""
dialog = GenericDialog(title)
for index, default in enumerate(defaults):
dialog.addChoice('Image_'+ str(index + 1), image_titles, image_titles[default])
dialog.showDialog()
if dialog.wasCanceled():
return None
return [dialog.getNextChoiceIndex() for _ in defaults]
示例8: getOptions
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getOptions(options, image):
if 'channel' not in options:
channels = []
for ch in range(1, image.getNChannels() + 1):
channels.append("Channel " + "%i" % ch)
dialog = GenericDialog("Select deconvolution parameters")
dialog.addChoice("Channel to process", channels, None)
dialog.addNumericField("Regularization parameter", 0.01, 2)
dialog.addNumericField("Number of iterations", 50, 0)
dialog.showDialog()
if dialog.wasCanceled():
sys.exit(1)
options['channel'] = dialog.getNextChoiceIndex()
options['regparam'] = dialog.getNextNumber()
options['iterations'] = dialog.getNextNumber()
return options
示例9: getOptionsDialog
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getOptionsDialog(self, imp):
thr_methods = ["None", "Default", "Huang", "Intermodes", "IsoData", "Li", "MaxEntropy","Mean", "MinError(I)", "Minimum", "Moments", "Otsu", "Percentile", "RenyiEntropy", "Shanbhag" , "Triangle", "Yen"]
gd = GenericDialog("Please select channels to collocalize")
for i in range(1, imp.getNChannels() + 1):
gd.addChoice("Threshold method for channel %i" % i, thr_methods, "None")
gd.showDialog()
if gd.wasCanceled():
self.exit()
channels = []
for i in range(1, imp.getNChannels() + 1):
method = gd.getNextChoice()
self.methods.append(method)
if method != "None":
channels.append(i)
for x in channels:
for y in channels:
if x < y:
self.pairs.append((x, y))
示例10: getOptions
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def getOptions(imp):
gd = GenericDialog("Correct 3D Drift Options")
channels = []
for ch in range(1, imp.getNChannels()+1 ):
channels.append(str(ch))
gd.addChoice("Channel for registration:", channels, channels[0])
gd.addCheckbox("Multi_time_scale computation for enhanced detection of slow drifts?", False)
gd.addCheckbox("Sub_pixel drift correction (possibly needed for slow drifts)?", False)
gd.addCheckbox("Edge_enhance images for possibly improved drift detection?", False)
gd.addCheckbox("Use virtualstack for saving the results to disk to save RAM?", False)
gd.addMessage("If you put a ROI, drift will only be computed in this region;\n the ROI will be moved along with the drift to follow your structure of interest.")
gd.showDialog()
if gd.wasCanceled():
return
channel = gd.getNextChoiceIndex() + 1 # zero-based
multi_time_scale = gd.getNextBoolean()
subpixel = gd.getNextBoolean()
process = gd.getNextBoolean()
virtual = gd.getNextBoolean()
dt = gd.getNextNumber()
return channel, virtual, multi_time_scale, subpixel, process
示例11: get_setup
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def get_setup():
''' Returns the drift correction mode and three image.
The order of return values is drift detection mode, pre-edge 1, pre-edge 2, post-edge.
'''
options = drift.get_options()
modes = drift.get_modes()
dialog = GenericDialog('3-window-method setup')
dialog.addMessage('Select the mode for drift correction\n' +
'and the images to process.')
dialog.addChoice('Mode:', options, options[0])
image_ids = WindowManager.getIDList()
if not image_ids or len(image_ids) < 2:
return [None]*4
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
dialog.addMessage('Post-edge is divided by the pre-edge.')
dialog.addChoice('Pre-edge 1', image_titles, image_titles[0])
dialog.addChoice('Pre-edge 2', image_titles, image_titles[1])
dialog.addChoice('Post-edge', image_titles, image_titles[2])
dialog.showDialog()
if dialog.wasCanceled():
return [None]*4
mode = modes[dialog.getNextChoiceIndex()]
img1 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
img2 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
img3 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
return mode, img1, img2, img3
示例12: get_setup
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def get_setup():
'''Returns two ImagePlus objects and a dictionary of properties to copy.'''
dialog = GenericDialog('Copy Properties setup')
dialog.addMessage('Select the source and target image and the properties to copy.')
image_ids = WindowManager.getIDList()
if not image_ids or len(image_ids) < 2:
IJ.showMessage('Two or more images are necessary to use this plugin.')
return [None]*3
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
dialog.addChoice('Source', image_titles, image_titles[0])
dialog.addChoice('Target', image_titles, image_titles[1])
dialog.addCheckbox('Copy Calibration', True)
dialog.addCheckbox('Copy Slice Labels', False)
dialog.showDialog()
if dialog.wasCanceled():
return [None]*3
source = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
target = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
choices = {'cal': dialog.getNextBoolean(),
'labels': dialog.getNextBoolean()
}
return source, target, choices
示例13: make_directory
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def make_directory(imgDir):
""" Makes the necessary output directories or overwrites current ones. """
if not path.exists(imgDir) or not path.isdir(imgDir):
print "Not a valid directory"
exit(0)
if not path.exists(imgDir+"/binary"):
mkdir(imgDir+"/binary")
else:
gd = GenericDialog("Confirm Overwrite")
choices = ["Yes", "No"]
gd.addChoice("Overwrite \"binary\" folder?", choices, choices[0])
gd.showDialog()
if gd.wasCanceled():
exit(0)
choice = gd.getNextChoice()
if choice == "No":
exit(0)
shutil.rmtree(imgDir+"/binary")
mkdir(imgDir+"/binary")
if not path.exists(imgDir+"/greyscale"):
mkdir(imgDir+"/greyscale")
else:
gd = GenericDialog("Confirm Overwrite")
choices = ["Yes", "No"]
gd.addChoice("Overwrite \"greyscale\" folder?", choices, choices[0])
gd.showDialog()
if gd.wasCanceled():
exit(0)
choice = gd.getNextChoice()
if choice == "No":
exit(0)
shutil.rmtree(imgDir+"/greyscale")
mkdir(imgDir+"/greyscale")
示例14: get_setup
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def get_setup():
''' Returns the drift correction mode and two image.'''
options = drift.get_options()
modes = drift.get_modes()
dialog = GenericDialog('Jump-ratio setup')
dialog.addMessage('Select the mode for drift correction\n' +
'and the images to process.')
dialog.addChoice('Mode:', options, options[0])
image_ids = WindowManager.getIDList()
if not image_ids or len(image_ids) < 2:
return [None]*3
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
dialog.addMessage('Post-edge is divided by the pre-edge.')
dialog.addChoice('Pre-edge', image_titles, image_titles[0])
dialog.addChoice('Post-edge', image_titles, image_titles[1])
dialog.showDialog()
if dialog.wasCanceled():
return [None]*3
mode = modes[dialog.getNextChoiceIndex()]
img1 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
img2 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
return mode, img1, img2
示例15: Options
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import addChoice [as 別名]
def Options(sourceFolder):
#globals
global gFileType
global gGetNumChanFromScanImage
global gNumChannels
global gDoAlign
global gAlignThisChannel
global gDoCrop
global gCropLeft
global gCropTop
global gCropWidth
global gCropHeight
global gAlignOnMiddleSlice
global gAlignOnThisSlice
global gRemoveCalibration
global gLinearShift
global gSave8bit
tifNames = [file.name for file in File(sourceFolder).listFiles(Filter())]
lsmNames = [file.name for file in File(sourceFolder).listFiles(Filter_LSM())]
numTifs = len(tifNames)
numLSM = len(lsmNames)
gd = GenericDialog('Align Batch 7 Options')
#gd.addStringField('Command: ', '')
gd.addMessage('Source Folder: ' + sourceFolder)
gd.addMessage('Number of .tif files: ' + str(numTifs))
gd.addMessage('Number of .lsm files: ' + str(numLSM))
gd.addChoice('File Type', ['tif','lsm'], gFileType)
#gd.setInsets(5,0,3)
#0
gd.addCheckboxGroup(1, 1, ['Get Number Of Channels From ScanImage 3.x or 4.x header'], [gGetNumChanFromScanImage], ['Channels'])
gd.addNumericField('Otherwise, Assume All Stacks Have This Number Of Channels: ', gNumChannels, 0)
print gLinearShift
#1
gd.addCheckboxGroup(1, 1, ['Remove Linear Calibration From ScanImage 4.x'], [gRemoveCalibration], ['ScanImage4'])
gd.addNumericField('And offset (subtract) by this amount: ', gLinearShift, 0)
gd.addMessage('20151110, this number = 2^15-512 = 32768-512 = 32256')
#2
gd.addCheckboxGroup(1, 1, ['Crop All Images (pixels)'], [gDoCrop], ['Crop'])
gd.addNumericField('Left', gCropLeft, 0)
gd.addNumericField('Top', gCropTop, 0)
gd.addNumericField('Width', gCropWidth, 0)
gd.addNumericField('Height', gCropHeight, 0)
#gd.setInsets(5,0,3)
#3
gd.addCheckboxGroup(1, 1, ['Run MultiStackReg'], [gDoAlign], ['MultStackReg'])
gd.addNumericField('If 2 Channels Then Align On This Channel', gAlignThisChannel, 0)
#4
gd.addCheckboxGroup(1, 1, ['Start Alignment On Middle Slice'], [gAlignOnMiddleSlice], ['Align On Middle Slice'])
gd.addNumericField('Otherwise, Start Alignment On This Slice', gAlignOnThisSlice, 0)
#5
gd.addCheckboxGroup(1, 1, ['Save 8-bit'], [gSave8bit], ['Save 8-bit (at end)'])
#gd.addCheckbox('Save 8-bit', gSave8bit)
gd.showDialog()
if gd.wasCanceled():
print 'Options Was Cancelled by user'
return 0
else:
print 'Reading values'
gFileType = gd.getNextChoice()
gNumChannels = int(gd.getNextNumber())
gLinearShift = int(gd.getNextNumber())
gCropLeft = int(gd.getNextNumber())
gCropTop = int(gd.getNextNumber())
gCropWidth = int(gd.getNextNumber())
gCropHeight = int(gd.getNextNumber())
gAlignThisChannel = int(gd.getNextNumber())
gAlignOnThisSlice = int(gd.getNextNumber())
checks = gd.getCheckboxes()
checkIdx = 0
for check in checks:
#print check.getState()
if checkIdx==0:
gGetNumChanFromScanImage = check.getState()
if checkIdx==1:
gRemoveCalibration = check.getState()
if checkIdx==2:
gDoCrop = check.getState()
if checkIdx==3:
#.........這裏部分代碼省略.........