本文整理汇总了Python中ij.gui.GenericDialog.getNextString方法的典型用法代码示例。如果您正苦于以下问题:Python GenericDialog.getNextString方法的具体用法?Python GenericDialog.getNextString怎么用?Python GenericDialog.getNextString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.gui.GenericDialog
的用法示例。
在下文中一共展示了GenericDialog.getNextString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [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())
示例2: get_results_filename
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def get_results_filename():
'''Prompt the user to suggest name of the output file.'''
dialog = GenericDialog('Output results file')
dialog.addStringField('Choose name without extension:', 'results')
dialog.showDialog()
name = dialog.getNextString()
if dialog.wasCanceled():
return None
#TODO Check if file exists before and try again?
return name + '.csv'
示例3: get_parameters
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def get_parameters(p, num_data_sets):
gd = GenericDialog("Correct 3D Drift Options")
gd.addMessage("Found "+str(num_data_sets)+" data sets")
gd.addStringField("analyse", "all");
gd.addMessage("Image analysis parameters:")
for k in p.keys():
gd.addNumericField(k, p[k], 2);
gd.showDialog()
if gd.wasCanceled():
return
to_be_analyzed = gd.getNextString()
for k in p.keys():
p[k] = gd.getNextNumber()
return to_be_analyzed, p
示例4: get_parameters
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
#
def get_parameters(p, keys, num_data_sets):
gd = GenericDialog("Please enter parameters")
gd.addMessage("Found "+str(num_data_sets)+" data sets")
gd.addStringField("analyse", "all");
gd.addMessage("Image analysis parameters:")
gd.addMessage("Please note: the threshold values are inclusive!\nThus, to exlude pixels with value 255 the upper threshold needs to be 254")
for k in keys:
gd.addNumericField(k, p[k], 2);
gd.showDialog()
if gd.wasCanceled():
return
to_be_analyzed = gd.getNextString()
for k in keys:
p[k] = gd.getNextNumber()
示例5: run
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def run():
types = ['oneDay','oneMouse','oneFile','oneMonth','OneFolder','mapManager']
gd = GenericDialog('Define Source Options')
#gd.addMessage('Choose the Source type:')
gd.addChoice('Source Type:',types,types[0])
gd.showDialog()
if gd.wasCanceled():
bPrintLog('user cancel the plugin',1)
return 0
else:
srcType = gd.getNextChoiceIndex()
#run one day
if srcType == 0:
dayFolder = DirectoryChooser('Please Choose A Directory Of .tif Files').getDirectory()
if not os.path.isdir(dayFolder):
bPrintLog('\nERROR: runOneDay() did not find folder: ' + dayFolder + '\n',0)
return 0
overWriteDate(dayFolder)
#run one mouse
if srcType == 1:
mouseFolder = DirectoryChooser('Please Choose A Mouse Directory Of .tif Files').getDirectory()
if not mouseFolder:
exit(1)
overWriteMouse(mouseFolder)
#run one file
if srcType == 2:
od = OpenDialog("Choose a convoluted tif file to overwrite", None)
srcDirectory = od.getDirectory()
srcFile = od.getFileName()
if srcFile != None:
fileFullPath = os.path.join(srcDirectory,srcFile)
convert32to16(fileFullPath)
#run one month
if srcType == 3:
monthFolder = DirectoryChooser('Please Choose A MONTH Directory Of .tif Files').getDirectory()
if not os.path.isdir(monthFolder):
bPrintLog('\nERROR: runOneMonth() did not find folder: ' + monthFolder + '\n',0)
return 0
runOneMonth(monthFolder)
#run one Folder
if srcType == 4:
srcFolder = DirectoryChooser('Please Choose A folder Of .tif Files').getDirectory()
if not os.path.isdir(srcFolder):
bPrintLog('\nERROR: runOneFolder() did not find folder: ' + srcFolder + '\n',0)
return 0
runOneFolder(srcFolder)
if srcType == 5: #align centain map's raw folder
mapPath = 'G:/ZY/MapManager3'
#mapNames = raw_input('type maps initials seperated with ,: ').split(',') #raw_input does not work here
#mapNames = tuple(mapNames)
mapNames = "F58,F59" #preset
#get map names
gd = GenericDialog('Choose maps for alignment')
gd.addStringField("maps root path",mapPath,50)
gd.addStringField("maps name initials sep = ','(empty for all)",mapNames,50)
gd.showDialog()
if gd.wasCanceled():
bPrintLog('user cancel the plugin',0)
return 0
mapPath = gd.getNextString()
mapNames = tuple(gd.getNextString().split(','))
mapFolders = [f for f in os.listdir(mapPath) if f.startswith(mapNames) and os.path.isdir(os.path.join(mapPath,f))]
if len(mapFolders) == 0:
bPrintLog('\nERROR: no map folder found',0)
return 0
bPrintLog('Map Folder number: ' + str(len(mapFolders)),0)
#put option here so we do not have to click for each folder
sourceFolders= [mapPath + '/' + mapFolder + '/raw/raw_userRaw' for mapFolder in mapFolders]
for srcFolder in sourceFolders:
runOneFolder(srcFolder)
示例6: open_Octopus_file
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def open_Octopus_file():
# set up a file info structure
fi = FileInfo()
fi.fileFormat = fi.RAW
fi.fileType=FileInfo.GRAY16_UNSIGNED
fi.intelByteOrder = True
fi.nImages = 1
op = OpenDialog("Choose Octopus .dth file...", "")
if not op.getDirectory(): return False
# get the file extension
file_extension = re.search('(\.[a-z][a-z][a-z])', op.getFileName()).group(1)
if file_extension != ".dth":
dlg = GenericDialog("Warning")
dlg.addMessage("Please select an octopus .dth file")
dlg.showDialog()
return False
# now strip the filename into a stem and index
file_parse = re.match('([a-zA-z0-9_]*_)([0-9]+)\.dth', op.getFileName())
file_stem = file_parse.group(1)
file_index = int( file_parse.group(2) )
# ok now we need to parse the header info
header = get_Octopus_header(op.getDirectory(), file_stem, file_index)
fi.nImages = len(header['N'])
# check to see whether we have a bit depth, if not, assume 16-bit
if 'Bit_Depth' in header:
print header['Bit_Depth']
bit_depth = int(header['Bit_Depth'][0])
if bit_depth == 8: fi.fileType = FileInfo.GRAY8
else:
bit_depth = 16
# will assume that all files have the same size
fi.width = int( header['W'][0] )
fi.height = int( header['H'][0] )
file_timestamp = strftime("%a, %d %b %Y %H:%M:%S", gmtime(float(header['Time'][0])) )
# make a new imagestack to store the data
stack = ImageStack(fi.width, fi.height)
# finally, we need to make a list of files to import as sometimes we have
# non contiguous file numbers
try:
files = os.listdir(op.getDirectory())
except IOError:
raise IOError( "No files exist in directory: " + op.getDirectory())
filenums = []
for f in files:
# strip off the stem, and get the number
targetfile = re.match(file_stem+'([0-9]+)\.dth', f)
# only take thosefiles which match the formatting requirements
if targetfile:
filenums.append( int(targetfile.group(1)) )
# sort the file numbers
sorted_filenums = sorted(filenums)
# make a file stats string
file_stats_str = file_stem + '\n' + str(fi.width) +'x' + str(fi.height) + 'x' + \
str(len(sorted_filenums)) +' ('+str(bit_depth)+'-bit)\n' + file_timestamp
# now open a dialog to let the user set options
dlg = GenericDialog("Load Octopus Stream (v"+__version__+")")
dlg.addMessage(file_stats_str)
dlg.addStringField("Title: ", file_stem)
dlg.addNumericField("Start: ", 1, 0);
dlg.addNumericField("End: ", len(sorted_filenums), 0)
dlg.addCheckbox("Open headers", True)
dlg.addCheckbox("Contiguous stream?", False)
dlg.addCheckbox("8-bit unsigned", bit_depth==8)
dlg.showDialog()
# if we cancel the dialog, exit here
if dlg.wasCanceled():
return
# set some params
file_title = dlg.getNextString()
file_start = dlg.getNextNumber()
file_end = dlg.getNextNumber()
DISPLAY_HEADER = bool( dlg.getNextBoolean() )
# check the ranges
if file_start > file_end:
file_start, file_end = file_end, file_start
if file_start < 1:
file_start = 1
if file_end > len(sorted_filenums):
file_end = len(sorted_filenums)
# now set these to the actual file numbers in the stream
#.........这里部分代码省略.........
示例7: DirectoryChooser
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
from ij.io import DirectoryChooser
from ij.io import OpenDialog
from ij.gui import GenericDialog
from ij import IJ
dc = DirectoryChooser("Choose directory with image tiles you want to stitch...")
sourceDir = dc.getDirectory()
opener = OpenDialog("Select DMI metadata file...",sourceDir,"tile_info.txt")
metadata_file = opener.getPath()
gd = GenericDialog("Input image name...")
gd.addStringField("Image_prefix:","IMGid")
gd.addMessage("Input directory: " + sourceDir)
gd.showDialog()
img_name = gd.getNextString()
outputPath = sourceDir + img_name + "_seq"
if sourceDir is not None and metadata_file is not None:
## computes tiling information from DMI metadata
metadata = IJ.openAsString(metadata_file)
p = re.compile(r'X Tiles: (\d+)')
m = p.search(metadata)
if m is None:
xtiles = 0
else:
xtiles = int(m.group(1))
p = re.compile(r'Y Tiles: (\d+)')
m = p.search(metadata)
if m is None:
示例8: run
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def run():
types = ['oneDay','oneFolder','oneFile','mapmaneger','test']
gd = GenericDialog('Define Source Options')
#gd.addMessage('Choose the Source type:')
gd.addChoice('Source Type:',types,types[0])
gd.showDialog()
if gd.wasCanceled():
print 'user cancel the plugin'
return 0
else:
srcType = gd.getNextChoiceIndex()
#run one day
if srcType == 0:
dayFolder = DirectoryChooser('Please Choose A Directory Of .tif Files').getDirectory()
if not os.path.isdir(dayFolder):
bab.bPrintLog('\nERROR: runOneDay() did not find folder: ' + dayFolder + '\n',0)
return 0
dirNames = [file for file in os.listdir(dayFolder) if os.path.isdir(os.path.join(dayFolder,file))]
numDirs = len(dirNames)
bab.bPrintLog('dayFolder is:' + dayFolder,0)
bab.bPrintLog('Number of subFolders: ' + str(numDirs),1)
#put option here so we do not have to click for each folder
if bab.Options(dayFolder + dirNames[0] + '/'):
for dirName in dirNames:
#sourceFolder = os.path.join(dayFolder, dirName) # did not add '/' to the end
sourceFolder = dayFolder + '/' + dirName + '/'
bab.runOneFolder(sourceFolder)
#run one folder
if srcType == 1:
sourceFolder = DirectoryChooser('Please Choose A Directory Of .tif Files').getDirectory()
if not sourceFolder:
exit(1)
if bab.Options(sourceFolder):
bab.runOneFolder(sourceFolder)
#run one file
if srcType == 2:
od = OpenDialog("Choose image file", None)
srcDirectory = od.getDirectory()
srcFile = od.getFileName()
if srcFile != None and bab.Options(srcDirectory):
bab.runOneFile(srcDirectory + srcFile)
if srcType == 3: #align centain map's raw folder
mapPath = 'G:/ZY/MapManager3'
#mapNames = raw_input('type maps initials seperated with ,: ').split(',') #raw_input does not work here
#mapNames = tuple(mapNames)
mapNames = "F58,F59" #preset
#get map names
gd = GenericDialog('Choose maps for alignment')
gd.addStringField("maps root path",mapPath,50)
gd.addStringField("maps name initials sep = ','",mapNames,50)
gd.showDialog()
if gd.wasCanceled():
bab.bPrintLog('user cancel the plugin',0)
return 0
mapPath = gd.getNextString()
mapNames = tuple(gd.getNextString().split(','))
mapFolders = [f for f in os.listdir(mapPath) if f.startswith(mapNames) and os.path.isdir(os.path.join(mapPath,f))]
if len(mapFolders) == 0:
bab.bPrintLog('\nERROR: no map folder found',0)
return 0
bab.bPrintLog('Map Folder number: ' + str(len(mapFolders)),0)
#put option here so we do not have to click for each folder
sourceFolders= [mapPath + '/' + mapFolder + '/raw/' for mapFolder in mapFolders]
if bab.Options(sourceFolders[0]):
for sourceFolder in sourceFolders:
bab.runOneFolder(sourceFolder)
if srcType == 4: #for test
gd = GenericDialog('Choose maps')
gd.addStringField('maps name initials','F58,F59')
gd.showDialog()
maps = gd.getNextString().split(',')
maps = tuple(maps)
bab.bPrintLog(maps[0],0)
示例9: DirectoryChooser
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
returnVal = 1
else:
IJ.log("skipped")
returnVal = 2
return returnVal
dc = DirectoryChooser("Choose root directory")
rootPath = dc.getDirectory()
if rootPath is not None:
gd = GenericDialog("Batch mode options...")
gd.addStringField("Filename extension","lsm",6)
gd.showDialog()
if (gd.wasOKed()):
extension = gd.getNextString()
for root, dirs, files in os.walk(rootPath):
LSMfiles = filter(lambda x: check_if_filetype(x,extension),files)
if len(LSMfiles)>0:
LSMpaths = map(lambda x: generate_path(x,root),LSMfiles)
explodeStatuses = map(run_explode,LSMpaths)
resizePaths = map(get_first_in_tuple,filter(filter_by_return_status,map(lambda x,y:(x,y),LSMpaths,explodeStatuses)))
if len(resizePaths)>0:
resizeStatuses = map(run_resize,resizePaths)
stitchPaths = map(get_first_in_tuple,filter(filter_by_return_status,map(lambda x,y:(x,y),resizePaths,resizeStatuses)))
if len(stitchPaths)>0:
stitchStatuses = map(run_stitch,stitchPaths)
combinePaths = map(get_first_in_tuple,filter(filter_by_return_status,map(lambda x,y:(x,y),stitchPaths,stitchStatuses)))
if len(combinePaths)>0:
combineStatuses = map(run_combine,combinePaths)
示例10: GenericDialog
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
dialog = GenericDialog( "Overlapping thickness estimation" )
dialog.addStringField( "Root directory for storing results", root )
dialog.addCheckbox( "Render matrix to image at each iteration.", False )
dialog.addNumericField( "Start.", 0, 0 )
dialog.addNumericField( "Stop.", height, 0 )
dialog.addNumericField( "Interval size.", 1000, 0 )
dialog.addNumericField( "Overlap.", imgSource.getWidth()/2, 0 )
dialog.addNumericField( "Range.", c, 0 )
dialog.showDialog()
if dialog.wasCanceled():
raise Exception( "dialog was canceled" )
root = dialog.getNextString()
doRender = dialog.getNextBoolean()
start = dialog.getNextNumber()
stop = dialog.getNextNumber()
interval = dialog.getNextNumber()
overlap = dialog.getNextNumber()
c = dialog.getNextNumber()
step = interval - overlap
ImageConverter( imgSource ).convertToGray32()
stat = FloatStatistics( imgSource.getProcessor() )
normalizeBy = stat.max
imgSource.getProcessor().multiply( 1.0 / normalizeBy )
开发者ID:hanslovsky,项目名称:em-thickness-estimation,代码行数:32,代码来源:estimate_from_correlation_strip_intervals.py
示例11: GenericDialog
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
#commands = [c for c in ij.Menus.getCommands().keySet()]
# Above, equivalent list as below:
commands = Menus.getCommands().keySet().toArray()
gd = GenericDialog('Command Launcher')
gd.addStringField('Command: ', '');
prompt = gd.getStringFields().get(0)
prompt.setForeground(Color.red)
class TypeListener(TextListener):
def textValueChanged(self, tvc):
if prompt.getText() in commands:
prompt.setForeground(Color.black)
return
prompt.setForeground(Color.red)
# or loop:
#for c in commands:
# if c == text:
# prompt.setForeground(Color.black)
# return
#
#prompt.setForeground(Color.red)
prompt.addTextListener(TypeListener())
gd.showDialog()
if not gd.wasCanceled(): IJ.doCommand(gd.getNextString())
# This python version does not encapsulate the values of the variables, so they are all global when defined outside the class definition.
# In contrast, the lisp 'let' definitions encapsulates them in full
# As an advantage, each python script executes within its own namespace, whereas clojure scripts run all within a unique static interpreter.
示例12: dialog
# 需要导入模块: from ij.gui import GenericDialog [as 别名]
# 或者: from ij.gui.GenericDialog import getNextString [as 别名]
def dialog(self):
"""
Open the classifier dialog window and return the paramters
chosen.
"""
# determine how many images are currently open
image_count = WindowManager.getImageCount()
image_titles = list(WindowManager.getImageTitles())
image_titles.append("None")
# now open a dialog to let the user set options
path_listener = SetPathListener(self.path)
path_button = TrimmedButton("Output directory",0)
path_button.addActionListener(path_listener)
dlg = GenericDialog("Create classifier data (v"+__version__+")")
dlg.addMessage("Session ID: "+ str(self.session_id))
dlg.addMessage("")
dlg.addMessage("Select the ROI you want to save")
dlg.addNumericField("Window size (pixels): ", self.window_size, 0)
dlg.addChoice("Class label: ", DEFAULT_CLASSES+['Other...'], DEFAULT_CLASSES[0])
dlg.addStringField("Class label (if other): ", "")
dlg.addChoice("Image file #1 (BF):",image_titles,"None")
dlg.addChoice("Image file #2 (GFP):",image_titles,"None")
dlg.addChoice("Image file #3 (RFP):",image_titles,"None")
dlg.addChoice("Mask file:",image_titles,"None")
dlg.addCheckbox("Rename ROIs", True)
dlg.addCheckbox("Exclude edges", True)
dlg.addCheckbox("Save ROI zip", True)
dlg.addCheckbox("Save classifier details", True)
dlg.add(path_button)
dlg.showDialog()
# handle the cancelled dialog box
if dlg.wasCanceled():
return None
label_option = dlg.getNextChoice()
if label_option == 'Other...':
label = dlg.getNextString()
else:
label = label_option
# get the root path from the path listener
root_path = path_listener.path
if not os.path.isdir(root_path):
w_dlg = GenericDialog("Warning")
w_dlg.addMessage("Root path does not exist!!")
w_dlg.showDialog()
return None
# try to make the directory for the label if it does not exist
label_path = os.path.join(root_path, label)
check_and_makedir(label_path)
# get the options
dialog_options = {'window_size': dlg.getNextNumber(),
'label': label,
'BF': dlg.getNextChoice(),
'GFP': dlg.getNextChoice(),
'RFP': dlg.getNextChoice(),
'mask': dlg.getNextChoice(),
'rename': dlg.getNextBoolean(),
'edges': dlg.getNextBoolean(),
'zip': dlg.getNextBoolean(),
'save': dlg.getNextBoolean(),
'path': label_path}
# check that we actually selected an image file
if all([dialog_options[d] == "None" for d in ['BF','GFP','RFP']]):
w_dlg = GenericDialog("Warning")
w_dlg.addMessage("You must select an image stream.")
w_dlg.showDialog()
return None
# grab the contents and return these as a dictionary
return dialog_options