Пример #1
0
def get_parameters(p):
  gd = GenericDialogPlus("Please enter parameters")

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'boolean':
      gd.addCheckbox(k, p[k]['value'])
    elif p[k]['type'] == 'folder':
      gd.addDirectoryField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'file':
      gd.addFileField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addStringField(k, p[k]['value'])	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addNumericField(k, p[k]['value'], 0)	 
    elif p[k]['type'] == 'float':
      gd.addNumericField(k, p[k]['value'], 2)
  
  gd.showDialog()
  if gd.wasCanceled():
    return

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'boolean':
      p[k]['value'] = gd.getNextBoolean()
    elif p[k]['type'] == 'folder' or p[k]['type'] == 'file':
      p[k]['value'] = gd.getNextString()
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        p[k]['value'] = gd.getNextChoice()	
      else:
        p[k]['value'] = gd.getNextString()	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        p[k]['value'] = int(gd.getNextChoice())	
      else:
        p[k]['value'] = int(gd.getNextNumber()) 
    elif p[k]['type'] == 'float':
        p[k]['value'] = gd.getNextNumber()
    
  return p
def get_parameters(p):
  gd = GenericDialogPlus("Please enter parameters")

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'folder':
      gd.addDirectoryField(k, p[k]['value'], 100)	
    if p[k]['type'] == 'file':
      gd.addFileField(k, p[k]['value'], 100)	
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addStringField(k, p[k]['value'], 50)	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        gd.addChoice(k, p[k]['choices'], p[k]['value'])	
      else:
        gd.addNumericField(k, p[k]['value'], 0)	 
    elif p[k]['type'] == 'float':
      gd.addNumericField(k, p[k]['value'], 2)
  
  gd.showDialog()
  if gd.wasCanceled():
    return(0)

  for k in p['expose_to_gui']['value']:
    if p[k]['type'] == 'folder' or p[k]['type'] == 'file':
      p[k]['value'] = gd.getNextString()
    elif p[k]['type'] == 'string':
      if p[k]['choices']:
        p[k]['value'] = gd.getNextChoice()	
      else:
        p[k]['value'] = gd.getNextString()	 
    elif p[k]['type'] == 'int':
      if p[k]['choices']:
        p[k]['value'] = int(gd.getNextChoice())	
      else:
        p[k]['value'] = int(gd.getNextNumber()) 
    elif p[k]['type'] == 'float':
        p[k]['value'] = gd.getNextNumber()
    
  return(p)
def selectionDialog(categories,labelColorBarImp):
	gd = GenericDialogPlus("ROI labeller -image picking")
	imps = WM.getImageTitles()
	nonimages=WM.getNonImageTitles()
	
	gd.addChoice("Image to quantify", imps, imps[0])
	try:
		gd.addChoice("FRETENTATOR results table", nonimages, nonimages[0])
		fail=0
	except:
		gd.addMessage("No results table open")
		fail=1
	gd.addImage(labelColorBarImp)
	for i in range(categories):
		gd.addStringField("Label "+str(i) +" name:", "Label "+str(i))

	gd.addChoice("Quantify an open image or add labels to open results table?", ["Image", "Results table"], "Results table")
	
	#quantImp= IJ.getImage(gd.getNextChoice())
	
	
	gd.setModal(False)
	gd.showDialog()
	while ((not gd.wasCanceled()) and not (gd.wasOKed())):
		Thread.sleep(50)


	names=dict()
	
	for i in range(categories):
		names[i]=str(gd.getNextString())
	imageName=gd.getNextChoice()
	if fail==0:	
		resultsName=gd.getNextChoice()
		imageOrTable=gd.getNextChoice()
	else:
		imageOrTable="Image"
		resultsName=0
	return names, imageName, resultsName, imageOrTable
Пример #4
0
Win.addMessage("""If you use this plugin please cite :
Laurent SV Thomas, Jochen Gehrig
bioRxiv 619338; doi: https://doi.org/10.1101/619338""")
Win.addHelp(
    "https://github.com/multi-template-matching/MultiTemplateMatching-Fiji/wiki"
)

Win.showDialog()

if Win.wasOKed():
    template = Win.getNextImage()
    image = Win.getNextImage()
    flipv = Win.getNextBoolean()
    fliph = Win.getNextBoolean()
    angles = Win.getNextString()
    method = Win.getNextChoice()
    n_hit = int(Win.getNextNumber())
    score_threshold = Win.getNextNumber()
    #tolerance   = Win.getNextNumber()
    tolerance = 0
    max_overlap = Win.getNextNumber()
    add_roi = Win.getNextBoolean()
    show_table = Win.getNextBoolean()

    # Save for persistence
    ImageName = image.getTitle()
    prefs.put("Template", template.getTitle())
    prefs.put("Image", ImageName)
    prefs.put("FlipV", flipv)
    prefs.put("FlipH", fliph)
    prefs.put("Angles", angles)
Пример #5
0
	print("Cleaning up!")
	try:
		shutil.rmtree(td)
	except OSError:
		print("Failed to remove temporary directory: "+td+"\n")
		pass

download_urls=cmtkgui.downloads()
# download_urls=['http://www.nitrc.org/frs/download.php/4814/CMTK-2.2.3-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4812/CMTK-2.2.3-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4820/CMTK-2.2.3-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4822/CMTK-2.2.3-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4824/CMTK-2.2.3-MacOSX-10.6-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4604/CMTK-2.2.1-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4596/CMTK-2.2.1-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4608/CMTK-2.2.1-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4610/CMTK-2.2.1-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4611/CMTK-2.2.1-MacOSX-10.6-x86_64.tar.gz']
download_files=map(os.path.basename,download_urls)
download_dict=dict(zip(download_files,download_urls))
print cmtkgui.install_dir()

gd = GenericDialogPlus('Install CMTK')
gd.addMessage('Currently installed CMTK version: '+cmtkgui.installed_version())
recommended_file=cmtkgui.recommended_file(download_files)
if recommended_file is None:
	recommended_file = download_files[0]
gd.addChoice("Download file",download_files,recommended_file)
gd.addMessage('By downloading this file you agree to the following (if you '+
	'do not agree to this, please press "Cancel" below):')
gd.addMessage('Core CMTK code is licensed under the GPLv3.\nBundled software'+
	' may be licensed under different terms - see licences/ directory for details')
gd.showDialog()
if gd.wasOKed():
	download_file=gd.getNextChoice()
	# nb url has a suffix to indicate that user agreed to license
	download_url=download_dict[download_file]+'/?i_agree=1&download_now=1'
	print "Downloading "+download_file+' from url '+download_url+' to '+cmtkgui.install_dir()
	cmtkgui.download_and_untar_url(download_url,cmtkgui.install_dir(),untar_binaries,download_file)
Пример #6
0
from ij.plugin import ImageCalculator
from ij.process import ImageProcessor
from ij.process import FloatProcessor
from fiji.util.gui import GenericDialogPlus
from mpv2 import MatchingPursuit as MP, JamaMatrix as Matrix, SymmetricMatrix as SM

#Input parameters
gd = GenericDialogPlus("Sparse Approximation, Input Parameters")
gd.addDirectoryOrFileField("Select dictionary", "")
gd.addChoice("Greedy algorithm type", ["MP", "OMP", "ORMP"], "OMP")
gd.addNumericField("Number of non-zero elements", 3, 0)  # show 3 decimals
gd.showDialog()

directory_w = gd.getNextString()
t_w = int(gd.getNextNumber())
Rt = gd.getNextChoice()

imp2 = IJ.getImage()
IJ.run("32-bit")
imp2 = IJ.getImage()

#path to lighting directions
IJ.run("Text Image... ", "open=" + str(directory_w))
imp = IJ.getImage()
imp.setTitle("Dictionary Atoms")

# making a jython nested list for constructing dictionary atom matrix
m = imp.getProcessor().getPixels()
m2 = [val for val in m]
K = imp.width
L = [m2[i:i + K] for i in range(0, len(m2), K)]
	munger_actions+="-w "
if reformat:
	channels=''
	if ch01:
		channels+='01'
	if ch02:
		channels+='02'
	if ch03:
		channels+='03'
	if channels != '':
		munger_actions+="-r "+channels+" "

verbose=gd.getNextBoolean()
corestouse=gd.getNextNumber()
outsuffix=gd.getNextString()
regparams=gd.getNextChoice()
print regparams
regparams=gd.getNextString()
mungeropts=gd.getNextString()
action=gd.getNextChoice()

if action == 'Test': mungeropts+=' -t'
if verbose: mungeropts+=' -v'
mungeropts+=' -T %d' % (int(corestouse))

if not outsuffix == '':
	mungeropts += ' -d .'+outsuffix

cmd='"%s" -b "%s" %s %s %s -s "%s" %s' % (munger,bindir,munger_actions,regparams,mungeropts,refBrain,image)
print cmd
Пример #8
0
gd.addCheckbox("Threshold nuclei by stack?", analyzeNucStack)
gd.addCheckbox("Are the cardiomyocyte images brightfield?", brightfield)
gd.addChoice("Cardiomyocyte thresholding method", methodsList,  cmMethod)
gd.addCheckbox("Threshold cardiomyocyes by stack?", analyzeCmStack)
gd.addNumericField("Rows per well", rowNo, 0)
gd.addNumericField("Columns per well", colNo, 0)
gd.addNumericField("Nuclear minimum size (pixels)", nucMinSize, 0)
gd.addNumericField("Cardiomyocyte minimum size (pixels)", cmMinSize, 0)
gd.showDialog()
folderPath = gd.getNextString() + "/"
formatString = gd.getNextString()
groupBy = re.findall(r"\w+", gd.getNextString())
nucChannel = gd.getNextString()
cmChannel = gd.getNextString()
stitched = gd.getNextBoolean()
nucMethod = gd.getNextChoice()
analyzeNucStack = gd.getNextBoolean()
brightfield = gd.getNextBoolean()
cmMethod = gd.getNextChoice()
analyzeCmStack = gd.getNextBoolean()
rowNo = int(gd.getNextNumber())
colNo = int(gd.getNextNumber())
nucMinSize = int(gd.getNextNumber())
cmMinSize = int(gd.getNextNumber())
allFileNames = os.listdir(folderPath)
jsonStoreDict = {"folderPath": folderPath,
				"formatString":formatString,
				"groupBy": ','.join(groupBy),
				"nucChannel": nucChannel,
				"cmChannel": cmChannel,
				"stitched": stitched,
Пример #9
0

download_urls = cmtkgui.downloads()
# download_urls=['http://www.nitrc.org/frs/download.php/4814/CMTK-2.2.3-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4812/CMTK-2.2.3-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4820/CMTK-2.2.3-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4822/CMTK-2.2.3-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4824/CMTK-2.2.3-MacOSX-10.6-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4604/CMTK-2.2.1-CYGWIN-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4596/CMTK-2.2.1-Linux-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4608/CMTK-2.2.1-MacOSX-10.4-i686.tar.gz', 'http://www.nitrc.org/frs/download.php/4610/CMTK-2.2.1-MacOSX-10.5-x86_64.tar.gz', 'http://www.nitrc.org/frs/download.php/4611/CMTK-2.2.1-MacOSX-10.6-x86_64.tar.gz']
download_files = map(os.path.basename, download_urls)
download_dict = dict(zip(download_files, download_urls))
print cmtkgui.install_dir()

gd = GenericDialogPlus('Install CMTK')
gd.addMessage('Currently installed CMTK version: ' +
              cmtkgui.installed_version())
recommended_file = cmtkgui.recommended_file(download_files)
if recommended_file is None:
    recommended_file = download_files[0]
gd.addChoice("Download file", download_files, recommended_file)
gd.addMessage('By downloading this file you agree to the following (if you ' +
              'do not agree to this, please press "Cancel" below):')
gd.addMessage(
    'Core CMTK code is licensed under the GPLv3.\nBundled software' +
    ' may be licensed under different terms - see licences/ directory for details'
)
gd.showDialog()
if gd.wasOKed():
    download_file = gd.getNextChoice()
    # nb url has a suffix to indicate that user agreed to license
    download_url = download_dict[download_file] + '/?i_agree=1&download_now=1'
    print "Downloading " + download_file + ' from url ' + download_url + ' to ' + cmtkgui.install_dir(
    )
    cmtkgui.download_and_untar_url(download_url, cmtkgui.install_dir(),
                                   untar_binaries, download_file)
gdp.addStringField("x: ", xpos_def, 5)

gdp.addStringField("y: ", ypos_def, 5)
gdp.addMessage("------------------------------------------------------------", italicFont)
progress = images_processed(dest)
gdp.addMessage(str(progress[0])+'% Images Assayed' + ' ' +
               '(' + str(progress[2]) + '/' + str(progress[1]) + ')', italicFont)
gdp.addHelp("https://github.com/JohnSargeant-rgb")
gdp.showDialog()
if gdp.wasOKed():
    dest = gdp.getNextString().strip()
    ProFolder = gdp.getNextString().strip()
    Quant = gdp.getNextString().strip()
    Quant_MM = gdp.getNextString().strip()
    transport_c = gdp.getNextChoice()
    file_type = gdp.getNextString().strip()
    golgi_c = gdp.getNextChoice()
    extension = gdp.getNextString().strip()
    zoom_to = int(gdp.getNextChoice())
    radius = gdp.getNextString().strip()
    color_scale = gdp.getNextChoice()
    always_select = gdp.getNextBoolean()
    always_auto = gdp.getNextBoolean()
    mean_max_det = gdp.getNextBoolean()
    man_bck_det = gdp.getNextBoolean()
    auto_pos_det = gdp.getNextBoolean()
    xpos_det = gdp.getNextString().strip()
    ypos_det = gdp.getNextString().strip()

    new_selected_values = {
Пример #11
0
    "Minimum granule circularity/shape. 1.0 = perfect cirlce, 0.5 = ellipse, 0.0 = rod",
    0.50, 3)
gdp.addNumericField("Maximum granule circularity", 1.00, 3)
gdp.addNumericField(
    "Minimum percent overlap between images (0 = no overlap required, 100 = perfect overlap)",
    25, 0)
gdp.addChoice(
    "Exclude particles on outside perimeter? Recommended for ATP analysis", yn,
    "NO")
gdp.showDialog()
outdir = gdp.getNextString()
path_wt = gdp.getNextString()
path_dic = gdp.getNextString()
path_mut = gdp.getNextString()
path_bg = gdp.getNextString()
analysistype = gdp.getNextChoice()
uThres = gdp.getNextNumber()
uGsize = gdp.getNextNumber()
uGshape = gdp.getNextNumber()
uGshapemax = gdp.getNextNumber()
uOverlap = gdp.getNextNumber()
uExclude = gdp.getNextChoice()

# Files will automatically be output to a new Fiji_Analysis directory. If this directory already exists, files will be overwritten. This checks to make sure the directory does not yet exist.
if path.exists(outdir + File.separatorChar +
               "Fiji_Analysis") and path.isdir(outdir + File.separatorChar +
                                               "Fiji_Analysis"):
    gdchk = GenericDialog("WARNING")
    gdchk.addMessage(
        "Analysis folder already exists. Choose a different directory to avoid overwritng your current data"
    )
Пример #12
0
        munger_actions += "-w "
    if reformat:
        channels = ''
        if ch01:
            channels += '01'
        if ch02:
            channels += '02'
        if ch03:
            channels += '03'
        if channels != '':
            munger_actions += "-r " + channels + " "

    verbose = gd.getNextBoolean()
    corestouse = gd.getNextNumber()
    outsuffix = gd.getNextString()
    regparams = gd.getNextChoice()
    print regparams
    regparams = gd.getNextString()
    mungeropts = gd.getNextString()
    action = gd.getNextChoice()

    if action == 'Test': mungeropts += ' -t'
    if verbose: mungeropts += ' -v'
    mungeropts += ' -T %d' % (int(corestouse))

    if not outsuffix == '':
        mungeropts += ' -d .' + outsuffix

    cmd = '"%s" -b "%s" %s %s %s -s "%s" %s' % (
        munger, bindir, munger_actions, regparams, mungeropts, refBrain, image)
    print cmd