コード例 #1
0
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
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
コード例 #3
0
def getOptions(imp):
  gd = GenericDialog("Correct 2D/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("Correct only x & y (for 3D data):", False)
  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.addNumericField("Only consider pixels with values larger than:", 0, 0)
  gd.addNumericField("Lowest z plane to take into account:", 1, 0)
  gd.addNumericField("Highest z plane to take into account:", imp.getNSlices(), 0)
  gd.addCheckbox("Use virtualstack for saving the results to disk to save RAM?", 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.showDialog()
  if gd.wasCanceled():
    return
  channel = gd.getNextChoiceIndex() + 1  # zero-based
  correct_only_xy = gd.getNextBoolean()
  multi_time_scale = gd.getNextBoolean()
  subpixel = gd.getNextBoolean()
  process = gd.getNextBoolean()
  background = gd.getNextNumber()
  z_min = gd.getNextNumber()
  z_max = gd.getNextNumber()
  virtual = gd.getNextBoolean()
  only_compute = gd.getNextBoolean()
  return channel, virtual, multi_time_scale, subpixel, process, background, z_min, z_max, only_compute, correct_only_xy
コード例 #4
0
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
コード例 #5
0
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
0
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]
コード例 #7
0
ファイル: HelperDialogs.py プロジェクト: m-entrup/EFTEMj
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
0
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
コード例 #9
0
ファイル: Options.py プロジェクト: rejsmont/nuclearP
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
コード例 #10
0
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
0
ファイル: Copy_Properties.py プロジェクト: m-entrup/EFTEMj
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
コード例 #12
0
def getOptions(imp):
  gd = GenericDialog("Correct 2D/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("Correct only x & y (for 3D data):", False)
  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.addNumericField("Only consider pixels with values larger than:", 0, 0)
  gd.addNumericField("Lowest z plane to take into account:", 1, 0)
  gd.addNumericField("Highest z plane to take into account:", imp.getNSlices(), 0)
  gd.addNumericField("Max_shift_x [pixels]:", 10, imp.getWidth())
  gd.addNumericField("Max_shift_y [pixels]:", 10, imp.getHeight())
  gd.addNumericField("Max_shift_z [pixels]:", 10, imp.getNSlices())
  gd.addCheckbox("Use virtualstack for saving the results to disk to save RAM?", 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.showDialog()
  if gd.wasCanceled():
    return
  options = {}
  options['channel'] = gd.getNextChoiceIndex() + 1  # zero-based
  options['correct_only_xy'] = gd.getNextBoolean()
  options['multi_time_scale'] = gd.getNextBoolean()
  options['subpixel'] = gd.getNextBoolean()
  options['process'] = gd.getNextBoolean()
  options['background'] = gd.getNextNumber()
  options['z_min'] = gd.getNextNumber()
  options['z_max'] = gd.getNextNumber()
  max_shifts = [0,0,0]
  max_shifts[0] = gd.getNextNumber()
  max_shifts[1] = gd.getNextNumber()
  max_shifts[2] = gd.getNextNumber()
  options['max_shifts'] = max_shifts
  options['virtual'] = gd.getNextBoolean()
  options['only_compute'] = gd.getNextBoolean()
  return options
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
コード例 #14
0
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
コード例 #15
0
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)
コード例 #16
0
if (wList):
	theImage = IJ.getImage()
	titles = []
	for i in range(len(wList)):
		imp = WindowManager.getImage(wList[i])
		titles.append(imp.getTitle())

	gd = GenericDialog("Pick images")
	gd.addChoice("Main channel:",titles,titles[0])
	gd.addChoice("Subtracted channel:",titles,titles[1])
	gd.showDialog()

	if (gd.wasCanceled()): 
		quit()

	index1 = gd.getNextChoiceIndex()
	index2 = gd.getNextChoiceIndex()
	image1 = WindowManager.getImage(wList[index1])
	image2 = WindowManager.getImage(wList[index2])
	IJ.selectWindow(wList[index1])

	rt = ResultsTable.getResultsTable()
	rt.reset()
	gd = WaitForUserDialog("Pick region with only bleedthrough")
	gd.show()
	al1 = Analyzer(image1)
	theSlice = image1.getSlice()
	al1.measure()
	al1.displayResults()
	theRoi = image1.getRoi()
	al2 = Analyzer(image2)
コード例 #17
0
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)
コード例 #18
0
ファイル: Record_Window.py プロジェクト: Mverp/fiji
def run(title):
    gd = GenericDialog("Record Window")
    gd.addMessage("Maximum number of frames to record.\nZero means infinite, interrupt with ESC key.")
    gd.addNumericField("Max. frames:", 50, 0)
    gd.addNumericField("Milisecond interval:", 300, 0)
    gd.addSlider("Start in (seconds):", 0, 20, 5)
    frames = []
    titles = []
    for f in Frame.getFrames():
        if f.isEnabled() and f.isVisible():
            frames.append(f)
            titles.append(f.getTitle())
    gd.addChoice("Window:", titles, titles[0])
    gd.addCheckbox("To file", False)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    frame = frames[gd.getNextChoiceIndex()]
    delay = int(gd.getNextNumber())
    tofile = gd.getNextBoolean()

    dir = None
    if tofile:
        dc = DirectoryChooser("Directory to store image frames")
        dir = dc.getDirectory()
        if dir is None:
            return  # dialog canceled

    snaps = []
    borders = None
    executors = Executors.newFixedThreadPool(1)
    try:
        while delay > 0:
            IJ.showStatus("Starting in " + str(delay) + "s.")
            time.sleep(1)  # one second
            delay -= 1

        IJ.showStatus("Capturing frame borders...")
        bounds = frame.getBounds()
        robot = Robot()
        frame.toFront()
        time.sleep(0.5)  # half a second
        borders = robot.createScreenCapture(bounds)

        IJ.showStatus("Recording " + frame.getTitle())

        # Set box to the inside borders of the frame
        insets = frame.getInsets()
        box = bounds.clone()
        box.x = insets.left
        box.y = insets.top
        box.width -= insets.left + insets.right
        box.height -= insets.top + insets.bottom

        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        i = 1
        fus = None
        if tofile:
            fus = []

            # 0 n_frames means continuous acquisition
        while 0 == n_frames or (len(snaps) < n_frames and last - start < n_frames * interval):
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                img = snapshot(frame, box)
                if tofile:
                    fus.append(executors.submit(Saver(i, dir, bounds, borders, img, insets)))  # will flush img
                    i += 1
                else:
                    snaps.append(img)
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)
                # interrupt capturing:
            if IJ.escapePressed():
                IJ.showStatus("Recording user-interrupted")
                break

                # debug:
                # print "insets:", insets
                # print "bounds:", bounds
                # print "box:", box
                # print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()

                # Create stack
        stack = None
        if tofile:
            for fu in snaps:
                fu.get()  # wait on all
            stack = VirtualStack(bounds.width, bounds.height, None, dir)
            files = File(dir).list(TifFilter())
            Arrays.sort(files)
            for f in files:
                stack.addSlice(f)
        else:
            stack = ImageStack(bounds.width, bounds.height, None)
            t = 0
            for snap, real_interval in zip(snaps, intervals):
                bi = BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB)
                g = bi.createGraphics()
                g.drawImage(borders, 0, 0, None)
                g.drawImage(snap, insets.left, insets.top, None)
                stack.addSlice(str(IJ.d2s(t, 3)), ImagePlus("", bi).getProcessor())
                t += real_interval
                snap.flush()
                bi.flush()

        borders.flush()

        ImagePlus(frame.getTitle() + " recording", stack).show()
        IJ.showStatus("Done recording " + frame.getTitle())
    except Exception, e:
        print "Some error ocurred:"
        print e.printStackTrace()
        IJ.showStatus("")
        if borders is not None:
            borders.flush()
        for snap in snaps:
            snap.flush()
コード例 #19
0
def run(title):
    gd = GenericDialog('Record Window')
    gd.addMessage(
        "Maximum number of frames to record.\nZero means infinite, interrupt with ESC key."
    )
    gd.addNumericField('Max. frames:', 50, 0)
    gd.addNumericField('Milisecond interval:', 300, 0)
    gd.addSlider('Start in (seconds):', 0, 20, 5)
    frames = []
    titles = []
    for f in Frame.getFrames():
        if f.isEnabled() and f.isVisible():
            frames.append(f)
            titles.append(f.getTitle())
    gd.addChoice('Window:', titles, titles[0])
    gd.addCheckbox("To file", False)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    frame = frames[gd.getNextChoiceIndex()]
    delay = int(gd.getNextNumber())
    tofile = gd.getNextBoolean()

    dir = None
    if tofile:
        dc = DirectoryChooser("Directory to store image frames")
        dir = dc.getDirectory()
        if dir is None:
            return  # dialog canceled

    snaps = []
    borders = None
    executors = Executors.newFixedThreadPool(1)
    try:
        while delay > 0:
            IJ.showStatus('Starting in ' + str(delay) + 's.')
            time.sleep(1)  # one second
            delay -= 1

        IJ.showStatus('Capturing frame borders...')
        bounds = frame.getBounds()
        robot = Robot()
        frame.toFront()
        time.sleep(0.5)  # half a second
        borders = robot.createScreenCapture(bounds)

        IJ.showStatus("Recording " + frame.getTitle())

        # Set box to the inside borders of the frame
        insets = frame.getInsets()
        box = bounds.clone()
        box.x = insets.left
        box.y = insets.top
        box.width -= insets.left + insets.right
        box.height -= insets.top + insets.bottom

        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        i = 1
        fus = None
        if tofile:
            fus = []

        # 0 n_frames means continuous acquisition
        while 0 == n_frames or (len(snaps) < n_frames
                                and last - start < n_frames * interval):
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                img = snapshot(frame, box)
                if tofile:
                    fus.append(
                        executors.submit(
                            Saver(i, dir, bounds, borders, img,
                                  insets)))  # will flush img
                    i += 1
                else:
                    snaps.append(img)
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)
            # interrupt capturing:
            if IJ.escapePressed():
                IJ.showStatus("Recording user-interrupted")
                break

        # debug:
        #print "insets:", insets
        #print "bounds:", bounds
        #print "box:", box
        #print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()

        # Create stack
        stack = None
        if tofile:
            for fu in snaps:
                fu.get()  # wait on all
            stack = VirtualStack(bounds.width, bounds.height, None, dir)
            files = File(dir).list(TifFilter())
            Arrays.sort(files)
            for f in files:
                stack.addSlice(f)
        else:
            stack = ImageStack(bounds.width, bounds.height, None)
            t = 0
            for snap, real_interval in zip(snaps, intervals):
                bi = BufferedImage(bounds.width, bounds.height,
                                   BufferedImage.TYPE_INT_RGB)
                g = bi.createGraphics()
                g.drawImage(borders, 0, 0, None)
                g.drawImage(snap, insets.left, insets.top, None)
                stack.addSlice(str(IJ.d2s(t, 3)),
                               ImagePlus('', bi).getProcessor())
                t += real_interval
                snap.flush()
                bi.flush()

        borders.flush()

        ImagePlus(frame.getTitle() + " recording", stack).show()
        IJ.showStatus('Done recording ' + frame.getTitle())
    except Exception, e:
        print "Some error ocurred:"
        print e.printStackTrace()
        IJ.showStatus('')
        if borders is not None: borders.flush()
        for snap in snaps:
            snap.flush()
コード例 #20
0
from ij.plugin import ChannelSplitter
from ij.plugin import RGBStackMerge
from ij.plugin import ImageCalculator
from ij import WindowManager

theImage = IJ.getImage()
gd = GenericDialog("Options...")
channelText = [("Channel " + str(ch+1)) for ch in range(theImage.getNChannels())]
gd.addChoice("Amplified_channel",channelText,channelText[0])
gd.addChoice("Reference_channel",channelText,channelText[-1])
gd.addNumericField("Amplifying_ratio",1,0)
gd.addCheckbox("Remove_bleedthrough",True)
gd.addCheckbox("Correct_for_refraction",True)
gd.showDialog()
if gd.wasOKed():
	amplifyChannel = gd.getNextChoiceIndex() + 1
	refChannel = gd.getNextChoiceIndex() + 1
	ampFactor = gd.getNextNumber()
	doRemoveBleedthrough = gd.getNextBoolean()
	doCorrectRefraction = gd.getNextBoolean()
	chImages = ChannelSplitter.split(theImage)
	
	## After this step, the image to operate on is "nextStepImage"
	if doRemoveBleedthrough:
		params = ("bleeding_channel=" + str(refChannel) + " bloodied_channel=" + str(amplifyChannel) + " " +
				"allowable_saturation_percent=1.0 rsquare_threshold=0.50")
		IJ.run("Remove Bleedthrough (automatic)", params)
		unbledImage = WindowManager.getImage("Corrected_ch" + str(amplifyChannel))
		mergingImages = [unbledImage,chImages[refChannel-1].duplicate()]
		nextStepImage = RGBStackMerge.mergeChannels(mergingImages,True)
		#nextStepImage.show()
コード例 #21
0
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)
コード例 #22
0
ファイル: settings.py プロジェクト: Sverreg/FRET-analysis
def settings():
    """ Settings """

    # Calls potential config file to set defaults
    # for settings dialog. Sets all defaults to 0
    # if no config file exists.
    con_path = os.path.join(str(Root), "FRET_params.cfg")
    if os.path.exists(con_path):
        dflt = config_read()
        print type(dflt.get("b_sub", "Rolling ball"))
        print (dflt.get("b_sub", "Rolling ball"))
        print type(int(dflt.get("b_sub", "Rolling ball")))
        print (dflt.get("b_sub", "Rolling ball"))
    else:
        dflt = {}

    feat_model_strings = ["Translation", "Rigid", 
                          "Similarity", "Affine
                          ]
    reg_model_strings = ["Translation", "Rigid",
                         "Similarity", "Affine",
                         "Elastic", "Least Squares"
                         ]
    b_sub_strings = ["Rolling Ball", "Manual Selection"]
                         
    # Registration parameters dialog.
    gd = GenericDialog("Advanced Settings")
    gd.addMessage("REGISTRATION PARAMETERS") 
    gd.addNumericField("Steps per scale octave: ", float(dflt.get("steps", 6)), 0, 7, "")
    gd.addNumericField("Max Octave Size: ", float(dflt.get("max_oct", 1024)), 0, 7, "")
    gd.addNumericField("Feature Descriptor Size: ", float(dflt.get("fd_size", 12)), 1, 7, "")
    gd.addNumericField("Initial Sigma: ", float(dflt.get("sigma", 1.2)), 2, 7, "")  
    gd.addNumericField("Max Epsilon: ", float(dflt.get("max_eps", 15)), 1, 7, "")
    gd.addNumericField("Min Inlier Ratio: ", float(dflt.get("min_inlier", 0.05)), 3, 7, "")
    gd.addCheckbox("Use Shrinkage Constraint", ast.literal_eval(dflt.get("shrinkage", "False")))
    gd.addChoice("Feature extraction model", feat_model_strings,
                 feat_model_strings[int(dflt.get("feat_model", 1))]
                 )
    gd.addChoice("Registration model", reg_model_strings,
                 reg_model_strings[int(dflt.get("reg_model", 1))]
                 )
    
    # Background removal parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("BACKGROUND REMOVAL") 
    gd.addChoice("Subtraction method:", b_sub_strings,
                 b_sub_strings[int(dflt.get("b_sub", 0))]
                 )          
    gd.addNumericField("Rolling ball size: ", 
                       float(dflt.get("ballsize", 50)), 1, 7, "px"
                       )
    gd.addCheckbox("Create Background", ast.literal_eval(dflt.get("create_b", "False")))
    gd.addCheckbox("Light Background", ast.literal_eval(dflt.get("light_b", "False")))
    gd.addCheckbox("Use Parabaloid", ast.literal_eval(dflt.get("parab", "False")))
    gd.addCheckbox("Do Pre-smoothing", ast.literal_eval(dflt.get("smooth", "False")))
    gd.addCheckbox("Correct Corners", ast.literal_eval(dflt.get("corners", "False")))

    # Measumrent parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("MEASUREMENT PARAMETERS")
    gd.addNumericField("Max Cell Area", float(dflt.get("cell_max", 2200)), 0, 7, "px")
    gd.addNumericField("Min Cell Area", float(dflt.get("cell_min", 200)), 0, 7, "px")
    gd.addNumericField("Ratio Subtraction", float(dflt.get("subtr_ratio", 0.31)), 3, 7, "")

    # Plot parameters dialog.
    gd.addPanel(Panel())
    gd.addMessage("PLOT PARAMETERS")
    gd.addNumericField("Max y, d and aFRET", float(dflt.get("p_max", 0.65)), 2, 7, "")
    gd.addNumericField("Min y, d and aFRET", float(dflt.get("p_min", 0.0)), 2, 7, "")
    gd.addNumericField("Max y, norm. d and aFRET", float(dflt.get("p_max_n", 1.65)), 2, 7, "")
    gd.addNumericField("Min y, norm. d and aFRET", float(dflt.get("p_min_n", 0.5)), 2, 7, "")
    
    # Set location of dialog on screen.
    #gd.setLocation(0,1000)
    
    gd.showDialog()
    
    # Checks if cancel was pressed, kills script.
    if gd.wasCanceled() is True:
        sys.exit("Cancel was pressed, script terminated.")

    # Parameters dictionary.
    parameters = {"steps" : gd.getNextNumber(), 
                 "max_oct" : gd.getNextNumber(),
                 "fd_size" : gd.getNextNumber(),
                 "sigma" : gd.getNextNumber(),
                 "max_eps" : gd.getNextNumber(),
                 "min_inlier" : gd.getNextNumber(),
                 "shrinkage" : gd.getNextBoolean(),
                 "feat_model" : gd.getNextChoiceIndex(),
                 "reg_model" : gd.getNextChoiceIndex(),
                 "b_sub" : gd.getNextChoiceIndex(),
                 "ballsize" : gd.getNextNumber(),
                 "create_b" : gd.getNextBoolean(),
                 "light_b" : gd.getNextBoolean(),
                 "parab" : gd.getNextBoolean(),
                 "smooth" : gd.getNextBoolean(),
                 "corners" : gd.getNextBoolean(),
                 "cell_max" : gd.getNextNumber(),
                 "cell_min" : gd.getNextNumber(),
                 "subtr_ratio" : gd.getNextNumber(),
                 "p_max" : gd.getNextNumber(),
                 "p_min" : gd.getNextNumber(),
                 "p_max_n" : gd.getNextNumber(),
                 "p_min_n" : gd.getNextNumber()
                 }

    parameters = config_write(parameters)   

    return parameters
コード例 #23
0
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)