本文整理汇总了Python中ij.WindowManager.getWindow方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.getWindow方法的具体用法?Python WindowManager.getWindow怎么用?Python WindowManager.getWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.WindowManager
的用法示例。
在下文中一共展示了WindowManager.getWindow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: myrun
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
def myrun(self):
imp = IJ.openImage(self.path) #open imp
if imp is None:
print 'ERROR opening file:', self.path
return 0
numSlices = imp.getNSlices()
if numSlices<2:
return 0
middleSlice = int(math.floor(imp.getNSlices() / 2)) #int() is necc., python is fucking picky
imp.show()
imp.setSlice(middleSlice)
impTitle = imp.getTitle()
impWin = WindowManager.getWindow(impTitle) #returns java.awt.Window
transformationFile = os.path.basename(self.path)
transformationFile = os.path.splitext(transformationFile)[0] + '.txt'
transformationFile = '/Users/cudmore/Desktop/out/' + transformationFile
stackRegParams = 'stack_1=[%s] action_1=Align file_1=[%s] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body] save' %(impWin,transformationFile)
IJ.run('MultiStackReg', stackRegParams)
imp.close()
'''
#20150723, we just aligned on a cropped copy, apply alignment to original imp
origImpTitle = imp.getTitle()
stackRegParams = 'stack_1=[%s] action_1=[Load Transformation File] file_1=[%s] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body]' %(origImpTitle,transformationFile)
IJ.run('MultiStackReg', stackRegParams)
'''
'''
示例2: loadVideoSegment
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
def loadVideoSegment(fwin, start, reduction, label):
'''
Load a video segment, optionally trim the unused frames
in the beginning (usually the 1st segment)
- fwin: name of the window of the video file (already opened)
- start: starting frame number, default = 1
- reduction: sampling rate (i.e. frame reduction factor)
- label: label of the loaded substack
'''
WM.setCurrentWindow(WM.getWindow(fwin))
im1 = IJ.getImage()
nSlices = im1.getStack().getSize()
IJ.run(im1, 'Make Substack...',
' slices=' + str(start) + '-' + str(nSlices) + '-' + str(reduction))
im2 = IJ.getImage()
im2.setTitle('Substack ' + label)
im1.close()
return im2
示例3: ImagePlus
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
# we create a new image from that stack and display it
ImagePlus("stack", red_stack).show()
# then we close the original image
image.close()
# from now on, "image" refers to the channel 3 only stack
image = IJ.getImage()
# before thresholding, we need to invert it
IJ.run("Invert", "stack")
# then, we create a binary image using MaxEntropy thresholding
IJ.run("Make Binary", "method=MaxEntropy background=Dark");
# now we use the 3D Objects Counter to do 3D particle analysis
IJ.run("3D Objects Counter", "threshold=128 slice=32 min.=10 max.=16777216 exclude_objects_on_edges statistics")
# The results window is called "Statistics for stack". We assign that to rt
rt = WindowManager.getWindow("Statistics for stack").getTextPanel().getOrCreateResultsTable()
# create a new "dist" column in the results table
rt.addValue("dist", 0)
for row in range(rt.size()):
# for each result, we get XYZ coordinates and then calculate their
# "real" value given pixel size
x = rt.getValue("X", row)
x = x * size_x
y = rt.getValue("Y", row)
y = y * size_y
z = rt.getValue("Z", row)
z = z * size_z
# now, we calculate the "real" distance between this particle
示例4: str
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
#average all frames
IJ.run("Z Project...", "projection=[Average Intensity]")
# plot the diagonal profile
imp = IJ.getImage()
IJ.run("Line Width...", "line=3")
IJ.makeLine(0, 0, imp.width, imp.height)
IJ.run("Plot Profile")
# bring back the projection, run Measure to get max and min
WM.putBehind()
IJ.run("Measure") #this method reports the actual max and min, not averaged across 3 px...
rt = ResultsTable.getResultsTable()
max = rt.getValue("Max", 0)
min = rt.getValue("Min", 0)
rolloff = (min*1.0/max)*100
IJ.run("Fire")
IJ.log("Percent illumination roll-off: " + str(rolloff))
# close the annoying results window
resultswin = WM.getWindow("Results")
resultswin.removeNotify()
# tile windows so you can see all the beautiful output better
IJ.run("Tile")
示例5: runOneFile
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
def runOneFile(fullFilePath):
global gFileType
global gNumChannels
global gAlignBatchVersion
if not os.path.isfile(fullFilePath):
bPrintLog('\nERROR: runOneFile() did not find file: ' + fullFilePath + '\n',0)
return 0
bPrintLog(time.strftime("%H:%M:%S") + ' starting runOneFile(): ' + fullFilePath, 1)
enclosingPath = os.path.dirname(fullFilePath)
head, tail = os.path.split(enclosingPath)
enclosingPath += '/'
#make output folders
destFolder = enclosingPath + tail + '_channels/'
if not os.path.isdir(destFolder):
os.makedirs(destFolder)
destMaxFolder = destFolder + 'max/'
if not os.path.isdir(destMaxFolder):
os.makedirs(destMaxFolder)
if gDoAlign:
destAlignmentFolder = destFolder + 'alignment/'
if not os.path.isdir(destAlignmentFolder):
os.makedirs(destAlignmentFolder)
if gSave8bit:
eightBitFolder = destFolder + 'channels8/'
if not os.path.isdir(eightBitFolder):
os.makedirs(eightBitFolder)
eightBitMaxFolder = eightBitFolder + 'max/'
if not os.path.isdir(eightBitMaxFolder):
os.makedirs(eightBitMaxFolder)
if gFileType=='tif':
# open .tif image
imp = Opener().openImage(fullFilePath)
else:
# open .lsm
cmdStr = 'open=%s autoscale color_mode=Default view=Hyperstack stack_order=XYCZT' % (fullFilePath,)
IJ.run('Bio-Formats Importer', cmdStr)
lsmpath, lsmfilename = os.path.split(fullFilePath)
lsWindow = lsmfilename
imp = WindowManager.getImage(lsWindow)
# get parameters of image
(width, height, nChannels, nSlices, nFrames) = imp.getDimensions()
bitDepth = imp.getBitDepth()
infoStr = imp.getProperty("Info") #get all .tif tags
if not infoStr:
infoStr = ''
infoStr += 'bAlignBatch_Version=' + str(gAlignBatchVersion) + '\n'
infoStr += 'bAlignBatch_Time=' + time.strftime("%Y%m%d") + '_' + time.strftime("%H%M%S") + '\n'
msgStr = 'w:' + str(width) + ' h:' + str(height) + ' slices:' + str(nSlices) \
+ ' channels:' + str(nChannels) + ' frames:' + str(nFrames) + ' bitDepth:' + str(bitDepth)
bPrintLog(msgStr, 1)
path, filename = os.path.split(fullFilePath)
shortName, fileExtension = os.path.splitext(filename)
#
# look for num channels in ScanImage infoStr
if gGetNumChanFromScanImage:
for line in infoStr.split('\n'):
#scanimage.SI4.channelsSave = [1;2]
scanimage4 = find(line, 'scanimage.SI4.channelsSave =') == 0
#state.acq.numberOfChannelsSave=2
scanimage3 = find(line, 'state.acq.numberOfChannelsSave=') == 0
if scanimage3:
#print 'line:', line
equalIdx = find(line, '=')
line2 = line[equalIdx+1:]
if gGetNumChanFromScanImage:
gNumChannels = int(line2)
bPrintLog('over-riding gNumChannels with: ' + str(gNumChannels), 2)
if scanimage4:
#print ' we have a scanimage 4 file ... now i need to exptract the number of channel'
#print 'line:', line
equalIdx = find(line, '=')
line2 = line[equalIdx+1:]
for delim in ';[]':
line2 = line2.replace(delim, ' ')
if gGetNumChanFromScanImage:
gNumChannels = len(line2.split())
bPrintLog('over-riding gNumChannels with: ' + str(gNumChannels), 2)
# show
imp.show()
# split channels if necc. and grab the original window names
if gNumChannels == 1:
origImpWinStr = imp.getTitle() #use this when only one channel
origImpWin = WindowManager.getWindow(origImpWinStr) #returns java.awt.Window
if gNumChannels == 2:
winTitle = imp.getTitle()
bPrintLog('Deinterleaving 2 channels...', 1)
IJ.run('Deinterleave', 'how=2 keep') #makes ' #1' and ' #2', with ' #2' frontmost
#.........这里部分代码省略.........
示例6: range
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
from ij import IJ
from ij.gui import WaitForUserDialog
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 import WindowManager
from ij import ImageStack
# Python imports
import socket
import os
# Close results window if it already exists
if WindowManager.getWindow('Results') is not None:
IJ.selectWindow('Results')
IJ.run('Close')
image = IJ.getImage()
# If there are multiple slices to the image, take the last one
# as that will be the original. That is our plan here to quickly
# deal with problems!
numSlices = image.getStackSize()
stack = image.getStack()
if numSlices > 1:
for i in range(numSlices - 1):
stack.deleteSlice(1)
image.setStack(stack)
示例7: float
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
from ij.text import TextWindow
bClose = True
IJ.run("Blobs (25K)")
imp = IJ.getImage()
IJ.setAutoThreshold(imp, "Default")
IJ.run(imp, "Convert to Mask", "")
IJ.run(imp, "Set Measurements...", "area center redirect=None decimal=3")
IJ.run(imp, "Analyze Particles...", "display exclude clear include summarize")
tw = WindowManager.getFrame("Summary")
if tw != None:
st = tw.getTextPanel().getResultsTable()
IJ.log("1st row of Summary:\n"+ st.getRowAsString(0))
v = st.getCounter()
w = st.getLastColumn()
s = st.size()
z = st.getValueAsDouble(w, 0)
af = float(z)
af /= 100.
print("Area Fraction: %.3f" % af)
else:
IJ.log("Summary window not found")
if bClose:
tw.close()
imp.changes = False
imp.close()
tw = WindowManager.getWindow("Results")
tw.dispose()
示例8: run
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
#.........这里部分代码省略.........
status.showStatus("Analyzing skeleton...")
skel_result = skel.run()
status.showStatus("Computing graph based parameters...")
branch_lengths = []
summed_lengths = []
graphs = skel_result.getGraph()
for graph in graphs:
summed_length = 0.0
edges = graph.getEdges()
for edge in edges:
length = edge.getLength()
branch_lengths.append(length)
summed_length += length
summed_lengths.append(summed_length)
output_parameters["branch length mean"] = eztables.statistical.average(branch_lengths)
output_parameters["branch length median"] = eztables.statistical.median(branch_lengths)
output_parameters["branch length stdevp"] = eztables.statistical.stdevp(branch_lengths)
output_parameters["summed branch lengths mean"] = eztables.statistical.average(summed_lengths)
output_parameters["summed branch lengths median"] = eztables.statistical.median(summed_lengths)
output_parameters["summed branch lengths stdevp"] = eztables.statistical.stdevp(summed_lengths)
branches = list(skel_result.getBranches())
output_parameters["network branches mean"] = eztables.statistical.average(branches)
output_parameters["network branches median"] = eztables.statistical.median(branches)
output_parameters["network branches stdevp"] = eztables.statistical.stdevp(branches)
# Create/append results to a ResultsTable...
status.showStatus("Display results...")
if "Mito Morphology" in list(WindowManager.getNonImageTitles()):
rt = WindowManager.getWindow("Mito Morphology").getTextPanel().getOrCreateResultsTable()
else:
rt = ResultsTable()
rt.incrementCounter()
for key in output_order:
rt.addValue(key, str(output_parameters[key]))
# Add user comments intelligently
if user_comment != None and user_comment != "":
if "=" in user_comment:
comments = user_comment.split(",")
for comment in comments:
rt.addValue(comment.split("=")[0], comment.split("=")[1])
else:
rt.addValue("Comment", user_comment)
rt.show("Mito Morphology")
# Create overlays on the original ImagePlus and display them if 2D...
if imp.getNSlices() == 1:
status.showStatus("Generate overlays...")
IJ.run(skeleton, "Green", "")
IJ.run(binary, "Magenta", "")
skeleton_ROI = ImageRoi(0,0,skeleton.getProcessor())
skeleton_ROI.setZeroTransparent(True)
skeleton_ROI.setOpacity(1.0)
binary_ROI = ImageRoi(0,0,binary.getProcessor())
binary_ROI.setZeroTransparent(True)
binary_ROI.setOpacity(0.25)
overlay = Overlay()
示例9: runOneFile
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
#.........这里部分代码省略.........
subArgVal = 'value=%s stack' % (origMin,)
IJ.run('Subtract...', subArgVal)
# 20150701, set any pixel <0 to 0
if 0:
ip = imp.getProcessor() # returns a reference
pixels = ip.getPixels() # returns a reference
msgStr = '\tSet all pixels <0 to 0. This was added 20150701 ...'
bPrintLog(msgStr, 2)
pixels = map(lambda x: 0 if x<0 else x, pixels)
bPrintLog('\t\t... done', 2)
#get and print out min/max
newMin = StackStatistics(imp).min
newMax = StackStatistics(imp).max
msgStr = '\tnew min=' + str(newMin) + ' max=' + str(newMax)
bPrintLog(msgStr, 2)
#without these, 8-bit conversion goes to all 0 !!! what the fuck !!!
#bPrintLog('calling imp.resetStack() and imp.resetDisplayRange()', 2)
imp.resetStack()
imp.resetDisplayRange()
#append calibration to info string
infoStr += 'calibCoeff_a = ' + str(calCoeff[0]) + '\n'
infoStr += 'calibCoeff_b = ' + str(calCoeff[1]) + '\n'
infoStr += 'origMin = ' + str(origMin) + '\n'
infoStr += 'origMax = ' + str(origMax) + '\n'
#
# set up
if gNumChannels == 1:
impWinStr = imp.getTitle() #use this when only one channel
impWin = WindowManager.getWindow(impWinStr) #returns java.awt.Window
if gNumChannels == 2:
winTitle = imp.getTitle()
bPrintLog('Deinterleaving 2 channels...', 1)
IJ.run('Deinterleave', 'how=2 keep') #makes ' #1' and ' #2', with ' #2' frontmost
ch1WinStr = winTitle + ' #1'
ch2WinStr = winTitle + ' #2'
ch1Imp = WindowManager.getImage(ch1WinStr)
ch2Imp = WindowManager.getImage(ch2WinStr)
ch1File = destFolder + shortName + '_ch1.tif'
ch2File = destFolder + shortName + '_ch2.tif'
#
# alignment
if gDoAlign and gNumChannels == 1 and imp.getNSlices()>1:
infoStr += 'AlignOnChannel=1' + '\n'
#snap to middle slice
if gAlignOnMiddleSlice:
middleSlice = int(math.floor(imp.getNSlices() / 2)) #int() is necc., python is fucking picky
else:
middleSlice = gAlignOnThisSlice
imp.setSlice(middleSlice)
transformationFile = destAlignmentFolder + shortName + '.txt'
bPrintLog('MultiStackReg aligning:' + impWinStr, 1)
stackRegParams = 'stack_1=[%s] action_1=Align file_1=[%s] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body] save' %(impWin,transformationFile)
IJ.run('MultiStackReg', stackRegParams)
infoStr += 'AlignOnSlice=' + str(middleSlice) + '\n'
if gDoAlign and gNumChannels == 2 and ch1Imp.getNSlices()>1 and ch2Imp.getNSlices()>1:
#apply to gAlignThisChannel
alignThisWindow = ''
示例10: BasicDialog
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
- 2 slices
'''
# should first par be width?
w = imp.getWidth()
h = imp.getHeight()
imagesize = jarray.array([w, h], 'i')
color = imp.getType() == ImagePlus.COLOR_RGB
dl = BasicDialog(imagesize, color, False)
# "quality='1' topology='0' show-view='on' show-topology='off'"
delta = 0
quality = 1
topology = 0
showview = True
showtopology= False
dl.parameters.setQualitySettings(quality)
dl.parameters.setTopologySettings(topology)
dl.parameters.show3dView = showview
dl.parameters.showTopology = showtopology
dl.process()
while (WindowManager.getWindow("Output") is None ):
time.sleep(1)
impEDF = WindowManager.getCurrentImage()
impEDF.show()
imp.close()
imp.flush()
strImg = imgDir + relImg + "/out/bez-50X-1-ij-edf.tif"
print(strImg)
IJ.saveAs("Tiff", strImg)
示例11:
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getWindow [as 别名]
import os
from ij import IJ
from ij import WindowManager
bCleanup = True
gitDir = os.environ['GIT_HOME']
relImg = "/OSImageAnalysis/images"
strImg = gitDir + relImg + "/George.tif"
strTxt = gitDir + relImg + "/George.txt"
# 1. Open an image
impRaw = IJ.openImage(strImg)
impRaw.show()
IJ.run("Find Edges")
IJ.run("Skeletonize (2D/3D)")
IJ.run("Find Connected Regions", "allow_diagonal display_one_image display_results regions_for_values_over=100 minimum_number_of_points=1 stop_after=-1")
strSaveCoord = "background=0 save=%s" % strTxt
IJ.run("Save XY Coordinates...", strSaveCoord)
# Get the final map
impCon = WindowManager.getCurrentImage()
impRaw.changes=False
impRaw.close()
resWin = WindowManager.getWindow("Results")
resWin.dispose()
logWin = WindowManager.getWindow("Log")
logWin.dispose()
if bCleanup:
impCon.changes=False
impCon.close()