本文整理汇总了Python中ij.io.DirectoryChooser.getDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python DirectoryChooser.getDirectory方法的具体用法?Python DirectoryChooser.getDirectory怎么用?Python DirectoryChooser.getDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.io.DirectoryChooser
的用法示例。
在下文中一共展示了DirectoryChooser.getDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ijGUI
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def ijGUI():
from ij.io import DirectoryChooser
dc = DirectoryChooser("Choose directory with Stratec files to scrub")
dir_in = dc.getDirectory()
dc = DirectoryChooser("Choose directory to write scrubbed files")
dir_out = dc.getDirectory()
idle_task_ij (process_files (dir_in, dir_out))
示例2: run
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def run():
imp = IJ.getImage()
if imp is None:
return
if not imp.isHyperStack():
print "Not a hyper stack!"
return
if 1 == imp.getNFrames():
print "There is only one time frame!"
return
if 1 == imp.getNSlices():
print "To register slices of a stack, use 'Register Virtual Stack Slices'"
return
dc = DirectoryChooser("Choose target folder")
target_folder = dc.getDirectory()
if target_folder is None:
return # user canceled the dialog
if not validate(target_folder):
return
gd = GenericDialog("Options")
channels = []
for ch in range(1, imp.getNChannels()+1 ):
channels.append(str(ch))
gd.addChoice("channel:", channels, channels[0])
gd.showDialog()
if gd.wasCanceled():
return
channel = gd.getNextChoiceIndex() + 1 # zero-based
vs_imp = create_registered_hyperstack(imp, target_folder, channel)
vs_imp.show()
示例3: main
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def main():
#filename = sys.argv[1]
#exportDir = sys.argv[2]
inputDir = "/mnt/med-groups-lmu/ls1/users/l/lsalomie/"
defaultName = "lif.lif"
outputDir = "/home/hajaalin/tmp/lifexporttest"
filename = OpenDialog("Choose LIF",inputDir,defaultName).getPath()
if not filename:
# user canceled dialog
return
chooser = DirectoryChooser("Choose export directory")
chooser.setDefaultDirectory(outputDir)
exportDir = chooser.getDirectory()
if not exportDir:
# user canceled dialog
return
# EDF parameters
params = Parameters()
params.setQualitySettings(params.QUALITY_HIGH)
params.nScales = 10
worker = EdfWorker(exportDir,params)
iterateLif(filename,worker)
示例4: actionPerformed
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def actionPerformed(self, event):
dlg = DirectoryChooser("Choose an output directory for the classifier")
if os.path.exists(self.path):
dlg.setDefaultDirectory(self.path)
self.path = dlg.getDirectory()
IJ.log("Added path: "+self.path)
示例5: run
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def run():
imp = IJ.getImage()
if imp is None:
return
if not imp.isHyperStack():
print "Not a hyper stack!"
return
if 1 == imp.getNFrames():
print "There is only one time frame!"
return
if 1 == imp.getNSlices():
print "To register slices of a stack, use 'Register Virtual Stack Slices'"
return
options = getOptions(imp)
if options is not None:
channel, virtual = options
print "channel="+str(channel)+" virtual="+str(virtual)
if virtual is True:
dc = DirectoryChooser("Choose target folder to save image sequence")
target_folder = dc.getDirectory()
if target_folder is None:
return # user canceled the dialog
if not validate(target_folder):
return
else:
target_folder = None
registered_imp= create_registered_hyperstack(imp, channel, target_folder, virtual)
if virtual is True:
if 1 == imp.getNChannels():
ip=imp.getProcessor()
ip2=registered_imp.getProcessor()
ip2.setColorModel(ip.getCurrentColorModel())
registered_imp.show()
else:
registered_imp.copyLuts(imp)
registered_imp.show()
else:
if 1 ==imp.getNChannels():
registered_imp.show()
else:
registered_imp.copyLuts(imp)
registered_imp.show()
registered_imp.show()
示例6: selectInputDir
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def selectInputDir(self):
inputDialog = DirectoryChooser("Please select a directory contaning your images")
inputDir = inputDialog.getDirectory()
for imageFile in os.listdir(inputDir):
self.files.append(inputDir + imageFile)
示例7: run
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def run():
IJ.log("Correct_3D_Drift")
imp = IJ.getImage()
if imp is None:
return
if 1 == imp.getNFrames():
print "There is only one time frame!"
return
options = getOptions(imp)
if options is not None:
channel, virtual, multi_time_scale, subpixel, process, only_compute = options
if virtual is True:
dc = DirectoryChooser("Choose target folder to save image sequence")
target_folder = dc.getDirectory()
if target_folder is None:
return # user canceled the dialog
if not validate(target_folder):
return
else:
target_folder = None
# compute shifts
IJ.log(" computing drifts..."); print("\nCOMPUTING SHIFTS:")
IJ.log(" at frame shifts of 1");
dt = 1; shifts = compute_and_update_frame_translations_dt(imp, channel, dt, process)
# multi-time-scale computation
if multi_time_scale is True:
dt_max = imp.getNFrames()-1
# computing drifts on exponentially increasing time scales 3^i up to 3^6
# ..one could also do this with 2^i or 4^i
# ..maybe make this a user choice? did not do this to keep it simple.
dts = [3,9,27,81,243,729,dt_max]
for dt in dts:
if dt < dt_max:
IJ.log(" at frame shifts of "+str(dt))
shifts = compute_and_update_frame_translations_dt(imp, channel, dt, process, shifts)
else:
IJ.log(" at frame shifts of "+str(dt_max));
shifts = compute_and_update_frame_translations_dt(imp, channel, dt_max, process, shifts)
break
# invert measured shifts to make them the correction
shifts = invert_shifts(shifts)
print(shifts)
# apply shifts
if not only_compute:
IJ.log(" applying shifts..."); print("\nAPPLYING SHIFTS:")
if subpixel:
registered_imp = register_hyperstack_subpixel(imp, channel, shifts, target_folder, virtual)
else:
shifts = convert_shifts_to_integer(shifts)
registered_imp = register_hyperstack(imp, channel, shifts, target_folder, virtual)
if virtual is True:
if 1 == imp.getNChannels():
ip=imp.getProcessor()
ip2=registered_imp.getProcessor()
ip2.setColorModel(ip.getCurrentColorModel())
registered_imp.show()
else:
registered_imp.copyLuts(imp)
registered_imp.show()
else:
if 1 ==imp.getNChannels():
registered_imp.show()
else:
registered_imp.copyLuts(imp)
registered_imp.show()
registered_imp.show()
else:
if imp.getRoi():
xmin = imp.getRoi().getBounds().x
ymin = imp.getRoi().getBounds().y
zmin = 0
xmax = xmin + imp.getRoi().getBounds().width - 1
ymax = ymin + imp.getRoi().getBounds().height - 1
zmax = imp.getNSlices()-1
else:
xmin = 0
ymin = 0
zmin = 0
xmax = imp.getWidth() - 1
ymax = imp.getHeight() - 1
zmax = imp.getNSlices() - 1
save_shifts(shifts, [xmin, ymin, zmin, xmax, ymax, zmax])
#.........这里部分代码省略.........
示例8: DirectoryChooser
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
from ij.io import DirectoryChooser
import ij.ImageStack
from ij import IJ, ImagePlus
import os
import time
# Choose a directory containing the data
dc = DirectoryChooser("Choose directory containing embryo folders...")
srcDir = dc.getDirectory()
print(srcDir)
IJ.log('Root directory: ' + srcDir)
# Prepare output directories...
nowStr = time.strftime('%Y-%m-%d %H%M%S')
outputDir = os.path.join(srcDir, nowStr+ " results")
if not os.path.exists(outputDir):
os.makedirs(outputDir)
# Loop through embryo sample directories, taking note of date and embryo number
folders=[f for f in os.listdir(srcDir)
if os.path.isdir(os.path.join(srcDir,f)) and not (f.endswith('results'))]
for folder in folders:
print(folder)
IJ.log('Working on data in sample folder: ' + folder)
(date, embryoNumber) = folder.split('_E')
# Identify the indices of the files where cuts occur
textFiles=[f for f in os.listdir(os.path.join(srcDir, folder))
if (f.endswith('.txt')) and not (f.endswith('para.txt'))]
示例9: get_files_and_analyze
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
def get_files_and_analyze(folder):
count = 0
timeseries = []
for root, directories, filenames in os.walk(folder):
#print directories
for directory in sorted(directories):
#print directory
if not (("field" in directory)): # "field is specific to the folder where the image files are"
continue
else:
print os.path.join(root, directory)
analyze(os.path.join(root, directory), 3, 7, 1)
if __name__ == '__main__':
dc = DirectoryChooser("Choose top directory containing all Matrix Screener images")
foldername = dc.getDirectory()
#od = OpenDialog("Click on one of the image files in the folder to be analysed", None )
#filename = od.getFileName()
#foldername = od.getDirectory()
#print foldername
print "\n\n\n\n\n\n"
#foldername = "/g/almf/software/scripts/imagej/Data_MatrixScreenerImport"
if None != foldername:
print "foldername = "+foldername
get_files_and_analyze(foldername)
示例10: DirectoryChooser
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
from ij.io import FileSaver, DirectoryChooser
from ij import ImagePlus
from ij.io import FileSaver
import jmFijiGen as jmg
tic = time.time()
sFac = 0.0
barW = 5 # bar width, microns
barH = 6 # bar height, pts
barF = 24 # bar font, pts
barC = "White" # bar color
barL= "Lower Right" # bar location
dc = DirectoryChooser("Choose directory")
basePath = dc.getDirectory()
sPngPath = basePath + os.sep + "png" + os.sep
jmg.ensureDir(sPngPath)
names = []
for file in os.listdir(basePath):
if file.endswith(".tif"):
name = os.path.splitext(file)[0]
names.append(name)
names.sort()
sSat = "saturated=%.2f" % sFac
示例11: DirectoryChooser
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
import glob
import os.path
from ij import IJ, ImagePlus, ImageStack, WindowManager
from ij.io import DirectoryChooser
from edfgui import ExtendedDepthOfField, Parameters
dc = DirectoryChooser("Set input directory")
files = glob.glob(dc.getDirectory() + "/*.tiff")
dc = DirectoryChooser("Set output directory")
outputDir = dc.getDirectory()
# EDF parameters
params = Parameters()
params.setQualitySettings(params.QUALITY_HIGH)
for f in files:
imp = ImagePlus(f)
# output name
head,tail = os.path.split(f)
base,ext = os.path.splitext(tail)
output = os.path.join(outputDir,base + "_edf.tif")
print output
# make all-in-focus image
edf = ExtendedDepthOfField(imp,params)
edf.process()
示例12: run
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
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:
#.........这里部分代码省略.........
示例13: calculate_memory_recs
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
sumSize = sumSize + theSize
return sumSize
def calculate_memory_recs(dirsize,maxmem):
values = []
maxchannel = maxmem / 10
maxtot = long(maxmem * 0.3)
for i in range(1,6):
if (maxtot/i > maxchannel):
values.append((maxchannel*i)/1048576)
else:
values.append(maxtot/1048576)
return values
dc = DirectoryChooser("Choose directory with OME.TIF files...")
sourceDir = dc.getDirectory()
if not(sourceDir is None):
if not os.path.exists(sourceDir + "resized"):
os.mkdir(sourceDir + "resized")
dirSize = get_directory_size(sourceDir)
dirSizeMB = dirSize / 1048576
memoryObj = Memory()
memFiji = memoryObj.maxMemory()
memFijiMB = memFiji / 1048576
gd = GenericDialog("Set Parameters...")
gd.addNumericField("Sizing_ratio (Final disk space / Initial disk space):",0.25,2)
gd.addMessage("Directory size: " + str(dirSizeMB) + "MB")
gd.addMessage("Maximum memory: " + str(memFijiMB) + "MB")
示例14: find_index_greater_zero
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
arr2 = [x - ma for x in arr]
start = find_index_greater_zero(arr1)
end = find_index_greater_zero(arr2)
length = end-start+1
return [start,end,length]
def make_tile_series(xs,ys,xlen,ylen):
arr = []
for y in range(ys[0],ys[1]+1):
arr.extend(range(xlen*y+xs[0],xlen*y+xs[1]+1))
arr = [m+1 for m in arr]
return arr
##### Sets directory of full-res tiles and gets metadata ######
dc = DirectoryChooser("Choose directory where full-res tiles are stored...")
imgDir = dc.getDirectory()
metadata = IJ.openAsString(imgDir+"tile_info.txt")
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:
ytiles = 0
else:
ytiles = int(m.group(1))
if not os.path.exists(imgDir + "temp"):
os.mkdir(imgDir + "temp")
示例15: DirectoryChooser
# 需要导入模块: from ij.io import DirectoryChooser [as 别名]
# 或者: from ij.io.DirectoryChooser import getDirectory [as 别名]
from ij.plugin.frame import RoiManager
from ij.measure import Calibration
from loci.plugins import BF
from ij.io import FileSaver
from ij.measure import Measurements
from ij.process import ImageStatistics as IS
from java.awt import Color
from ij.io import DirectoryChooser
# Python imports
import os
import math
import sys
# Choose a folder that you want the images resized to the same scale
input_dc = DirectoryChooser("Choose a folder with images to be rescaled.")
inputDir = input_dc.getDirectory()
output_dc = DirectoryChooser("Choose output folder.")
outputDir = output_dc.getDirectory()
# What we need to do is crop EQUAL AREAS. First find the smallest
# image area.
# Find the minimum area per pixel
minArea = 999999
for filename in os.listdir(inputDir):
if '.tif' in filename:
print 'Opening ' , filename , '...'
image = IJ.openImage(inputDir + '/' + filename)
ip = image.getProcessor()