Exemplo n.º 1
0
def MultiFileDialog(title):
  #hide/show debug prints
  verbose = 0
  # Choose image file(s) to open
  fc = JFileChooser()
  fc.setMultiSelectionEnabled(True)
  fc.setDialogTitle(title)

  sdir = OpenDialog.getDefaultDirectory()
  if sdir!=None:
    fdir = File(sdir)
  if fdir!=None:
    fc.setCurrentDirectory(fdir)
  
  returnVal = fc.showOpenDialog(IJ.getInstance())
  if returnVal!=JFileChooser.APPROVE_OPTION:
    return
  files = fc.getSelectedFiles()

  paths = []
  for i in range(len(files)):
      paths.append(os.path.join(files[i].getParent(), files[i].getName()))
      
  if verbose > 0:
    for i in range(len(files)):
      path = os.path.join(files[i].getParent(), files[i].getName())
      print "Path: " + path
  
  return paths
Exemplo n.º 2
0
def MultiFileDialog(title):
    #hide/show debug prints
    verbose = 0
    # Choose image file(s) to open
    fc = JFileChooser()
    fc.setMultiSelectionEnabled(True)
    fc.setDialogTitle(title)

    sdir = OpenDialog.getDefaultDirectory()
    if sdir != None:
        fdir = File(sdir)
    if fdir != None:
        fc.setCurrentDirectory(fdir)

    returnVal = fc.showOpenDialog(IJ.getInstance())
    if returnVal != JFileChooser.APPROVE_OPTION:
        return
    files = fc.getSelectedFiles()

    paths = []
    for i in range(len(files)):
        paths.append(os.path.join(files[i].getParent(), files[i].getName()))

    if verbose > 0:
        for i in range(len(files)):
            path = os.path.join(files[i].getParent(), files[i].getName())
            print "Path: " + path

    return paths
Exemplo n.º 3
0
def FolderDialog(title, folder):
  fc = JFileChooser()
  fc.setMultiSelectionEnabled(False)
  fc.setDialogTitle(title)
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setAcceptAllFileFilterUsed(False);
  if folder ==None:
    sdir = OpenDialog.getDefaultDirectory()
  else:
    sdir = folder
  if sdir!=None:
    fdir = File(sdir)
  if fdir!=None:
    fc.setCurrentDirectory(fdir)
  returnVal = fc.showOpenDialog(IJ.getInstance())
  if returnVal!=JFileChooser.APPROVE_OPTION:
    return
  folder = fc.getSelectedFile();
  path = os.path.join(folder.getParent(), folder.getName())
  return path
def getImgRoiDir():

    gui = GenericDialogPlus(
        "Select directories to process images and ROI sets to apply")

    default_dir = OpenDialog.getDefaultDirectory()
    gui.addDirectoryField("Choose a iamge folder to be processed", default_dir)
    gui.addDirectoryField("Choose a ROI set folder to apply", default_dir)

    gui.showDialog()

    if gui.wasOKed():

        img_dir = gui.getNextString()
        if not img_dir.endswith(os.sep):
            img_dir = img_dir + os.sep

        roi_dir = gui.getNextString()
        if not roi_dir.endswith(os.sep):
            roi_dir = roi_dir + os.sep

        return img_dir, roi_dir
from fiji.util.gui import GenericDialogPlus
from ij.io import OpenDialog
import os
import glob
import re
from ij import IJ
from ij.plugin.frame import RoiManager
from ij.process import ImageStatistics
from ij.measure import Calibration, Measurements
from org.python.core import codecs
from ij.io import DirectoryChooser

DirectoryChooser("").setDefaultDirectory(OpenDialog.getDefaultDirectory())
codecs.setDefaultEncoding('utf-8')


def getImgRoiDir():

    gui = GenericDialogPlus(
        "Select directories to process images and ROI sets to apply")

    default_dir = OpenDialog.getDefaultDirectory()
    gui.addDirectoryField("Choose a iamge folder to be processed", default_dir)
    gui.addDirectoryField("Choose a ROI set folder to apply", default_dir)

    gui.showDialog()

    if gui.wasOKed():

        img_dir = gui.getNextString()
        if not img_dir.endswith(os.sep):