本文整理汇总了Python中ij.WindowManager.getIDList方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.getIDList方法的具体用法?Python WindowManager.getIDList怎么用?Python WindowManager.getIDList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.WindowManager
的用法示例。
在下文中一共展示了WindowManager.getIDList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def select_images():
"""
Returns two ImagePlus objects that can be used by the drift correction.
If more than two images are available a dialog is used for selection.
"""
if WindowManager.getImageCount() > 0:
imp = WindowManager.getCurrentImage()
if imp.getImageStackSize() == 2:
dup = Duplicator()
img1 = dup.run(imp, 1, 1)
img1.setTitle("Slice1")
img2 = dup.run(imp, 2, 2)
img2.setTitle("Slice2")
elif WindowManager.getImageCount() == 2:
img1, img2 = [WindowManager.getImage(id) for id in WindowManager.getIDList()]
elif WindowManager.getImageCount() > 2:
image_ids = WindowManager.getIDList()
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
try:
sel1, sel2 = dialogs.create_selection_dialog(image_titles, range(2))
except TypeError:
return(None, None)
img1 = WindowManager.getImage(image_ids[sel1])
img2 = WindowManager.getImage(image_ids[sel2])
else:
IJ.error("You need two images to run the script.")
return(None, None)
else:
IJ.error("You need two images to run the script.")
return(None, None)
return (img1, img2)
示例2: get_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def get_images(ids):
"""
Returns a list of ImagePlus objects.
:param ids: The ids of the ImagePlus objects to return.
"""
image_ids = WindowManager.getIDList()
return [WindowManager.getImage(image_ids[id]) for id in ids]
示例3: get_image_titles
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def get_image_titles():
"""
Returns the titles of all open image windows as a list.
"""
image_ids = WindowManager.getIDList()
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
return image_titles
示例4: get_setup
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
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
示例5: get_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def get_images(minimum=0, maximum=None, exact=None):
''' Returns a list of ImagePlus objects or None if it failed.
Passing None as parameter will trigger a dialog to show up to enter the exact number of images.
:param minimum: The minimum number of images to select (default: 0).
:param maximum: The maximum number of images to select (default: None).
:param exact: Set this to get an exact number of images (default: None).
'''
if not (minimum or maximum or exact):
exact = int(IJ.getNumber("How many images do you want to process?", 3))
def check_count(count):
'''Returns True if the count of images is as required.'''
# print count, exact, minimum, maximum
if exact:
if not count == exact:
return False
else:
if minimum:
if count < minimum:
return False
if maximum:
if count > maximum:
return False
return True
# Option 1: The selected image is a stack and has the demanded size.
if check_count(WindowManager.getCurrentImage().getStackSize()):
return stack_to_list_of_imp(WindowManager.getCurrentImage())
# Option 2: The count of open images matches the demanded number.
image_ids = WindowManager.getIDList()
if exact:
if len(image_ids) < exact:
return None
if len(image_ids) == exact:
return [WindowManager.getImage(img_id) for img_id in image_ids]
# Option 3: The user can select the images from a list.
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
img_count = len(image_ids)
if exact:
img_count = exact
elif maximum:
img_count = maximum
image_titles.append('None')
images_selected = dialogs.create_selection_dialog(image_titles,
range(img_count),
'Select images for drift correction'
)
# dialogs.create_selection_dialog() returns None if canceled
if not images_selected:
return None
# This is only true if 'None has been appended to image_titles and the user selected it.
if len(image_ids) in images_selected:
images_selected.remove(len(image_ids))
if not check_count(len(images_selected)):
return None
image_list = [WindowManager.getImage(image_ids[selection]) for selection in images_selected]
return image_list
示例6: run_script
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def run_script():
while WindowManager.getImageCount() < 10:
create_test_image()
image_titles = [WindowManager.getImage(id).getTitle() for id in WindowManager.getIDList()]
# range(3) will create the list [0, 1, 2].
selected_indices = create_selection_dialog(image_titles, range(3))
# The script stops if the dialog has ben canceld (None was returned from create_selection_dialog).
if selected_indices is None:
print('Script was canceld.')
return
# We have to get the corresponding IMagePlus objects.
selected_imps = [WindowManager.getImage(id) for id in [WindowManager.getIDList()[index] for index in selected_indices]]
# The previous line can be split into 2 lines:
# selected_ids = [WindowManager.getIDList()[index] for index in selected_indices]
# selected_imps = [WindowManager.getImage(id) for id in selected_ids]
for imp in selected_imps:
# Strings can be formated using the % operator:
# http://www.learnpython.org/en/String_Formatting
IJ.log('The image \'%s\' has been selected.' % imp.getTitle())
示例7: ShowRoi
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def ShowRoi(self,imp,point, name):
for indices in self.__gridrectangle.keys() :
if self.__gridrectangle[indices].contains(point) :
roitemp=self.__dictCells[name][self.__listcellname[indices[0]-1]].getRoi(indices[1]-1)
if isinstance(roitemp,Roi) :
idimages=WindowManager.getIDList()
for i in range(len(idimages)) :
if idimages[i]==self.__img.getID() :
IJ.selectWindow(self.__img.getID())
rm = RoiManager.getInstance()
for i in range(rm.getCount()) :
if rm.getName(str(i))==roitemp.getName() :
rm.select(i)
selectroi=self.__img.getRoi()
#col=rm.getSelectedRoisAsArray().getStrokeColor()
selectroi.setStrokeColor(Color.red)
selectroi.setStrokeWidth(3)
self.__img.updateAndDraw()
break
示例8: __selectMeasureStack
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def __selectMeasureStack(self) :
# We allow the user to choose what to measure in the stack, and on which stack.
gd1=NonBlockingGenericDialog("Stack Choice for measures")
idimages=WindowManager.getIDList()
images=[WindowManager.getImage(imgID) for imgID in idimages if WindowManager.getImage(imgID).getImageStackSize()>1 ]
imagesnames=[img.getTitle() for img in images]
activindex=0
for i in range(len(imagesnames)) :
if imagesnames[i] == self.__activeTitle :
activindex=i
gd1.addChoice("Select a stack in the list : ",imagesnames,imagesnames[activindex])
gd1.showDialog()
chosenstack=gd1.getNextChoice()
self.__img=WindowManager.getImage(chosenstack)
IJ.selectWindow(self.__img.getID())
if gd1.wasOKed() : return True
else : return False
示例9: get_setup
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
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
示例10: get_setup
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
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
示例11: __selectTrackStack
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def __selectTrackStack(self) :
gd0=NonBlockingGenericDialog("Stack Choice")
idimages=WindowManager.getIDList()
#images=[WindowManager.getImage(imgID) for imgID in idimages if WindowManager.getImage(imgID).getImageStackSize()>1 ]
images=[WindowManager.getImage(imgID) for imgID in idimages]
imagesnames=[img.getTitle() for img in images]
for i in range(len(imagesnames)) :
if imagesnames[i] == self.__activeTitle : activindex=i
gd0.addChoice("Select a stack in the list : ",imagesnames,imagesnames[activindex])
gd0.showDialog()
chosenstack=gd0.getNextChoice()
self.__img = WindowManager.getImage(chosenstack)
self.__maxLife = self.__img.getImageStackSize()
IJ.selectWindow(self.__img.getID())
self.__activeTitle=self.__img.getTitle()
self.__imagesnames[:]=[]
#self.__imagesnames.append("image1")
self.__imagesnames.append(self.__activeTitle)
if gd0.wasOKed() : return True
else : return False
示例12: range
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
# Performs scaling
if (gd.wasOKed()):
anchorTiles = range(startTile,finishTile+1,stepSize)
print anchorTiles
for i in anchorTiles:
if (i+stepSize-1 > finishTile):
lastAnchorTile = finishTile
else:
lastAnchorTile = i+stepSize-1
iterTiles = range(i,lastAnchorTile+1)
params = "open=[" + theFilePath + "] color_mode=Default view=Hyperstack stack_order=XYCZT series_list=" + str(i) + "-" + str(lastAnchorTile)
print params
IJ.run("Bio-Formats Importer", params)
imageIDList = WindowManager.getIDList()
if (len(imageIDList) == len(iterTiles)):
count = 0
for j in imageIDList:
theImage = WindowManager.getImage(j)
print theImage.getTitle()
params2 = "x=" + str(ratio) + " y=" + str(ratio) + " z=1.0 interpolation=Bilinear average create title=doggie"
IJ.run(theImage,"Scale...",params2)
theImage.close()
saveImage = WindowManager.getImage("doggie")
IJ.saveAsTiff(saveImage,theDirectory+baseName+"_resized/tile_"+str(iterTiles[count])+".tif")
saveImage.close()
count = count + 1
else:
print "Open image count does not match tile count!"
示例13: run_combine
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def run_combine(filePath):
basePath,baseName = os.path.split(filePath)
imagePrefix = os.path.splitext(baseName)[0]
resizeName = basePath + "/" + baseName + "_tiles/resized/"
checkName = basePath + "/" + baseName + "_tiles/resized/" + imagePrefix + "_seq/"
activeName = basePath + "/" + baseName + "_tiles"
outputName = basePath + "/stitched/" + imagePrefix + "/"
IJ.log("Combining " + filePath + "...")
if (not os.path.isdir(outputName)):
try:
os.makedirs(outputName)
if (not os.path.isdir(checkName)):
raise ValueError("Stitched image directory not found")
for dirpath, dirnames, files in os.walk(checkName):
if not files:
raise ValueError("Stitched image directory is empty")
IJ.run("Bio-Formats Importer", "open=["+ activeName +"/tile_1.ome.tif] color_mode=Default view=Hyperstack stack_order=XYCZT");
tileImage = WindowManager.getImage("tile_1.ome.tif")
nChannels = tileImage.getNChannels()
tileImage.close()
options = "open=[" + checkName + "] starting=1 increment=1 scale=100 file=[] sort"
IJ.run("Image Sequence...", options)
theImage = IJ.getImage()
for i in range(1,nChannels+1):
params = "slices=" + str(i) + "-" + str(theImage.getNSlices()) + "-" + str(nChannels)
IJ.run(theImage,"Make Substack...",params)
theImage.close()
wList = WindowManager.getIDList()
for i in range(len(wList)):
currImage = WindowManager.getImage(wList[i])
currImage.setTitle("image"+str(i+1))
IJ.save(currImage,outputName+imagePrefix+"_ch"+str(i+1)+".tif")
if nChannels > 1 and not os.path.isfile(outputName+imagePrefix+"_composite.tif"):
if nChannels == 2:
params = ("c1=" + WindowManager.getImage(wList[0]).getTitle() +
" c4=" + WindowManager.getImage(wList[1]).getTitle() + " create ignore")
elif nChannels == 3:
params = ("c1=" + WindowManager.getImage(wList[1]).getTitle() +
" c2=" + WindowManager.getImage(wList[0]).getTitle() +
" c4=" + WindowManager.getImage(wList[2]).getTitle() + " create ignore")
elif nChannels == 4:
params = ("c1=" + WindowManager.getImage(wList[1]).getTitle() +
" c2=" + WindowManager.getImage(wList[2]).getTitle() +
" c3=" + WindowManager.getImage(wList[0]).getTitle() +
" c4=" + WindowManager.getImage(wList[3]).getTitle() + " create ignore")
elif nChannels == 5:
params = ("c1=" + WindowManager.getImage(wList[1]).getTitle() +
" c2=" + WindowManager.getImage(wList[2]).getTitle() +
" c3=" + WindowManager.getImage(wList[0]).getTitle() +
" c4=" + WindowManager.getImage(wList[4]).getTitle() +
" c7=" + WindowManager.getImage(wList[3]).getTitle() +
" create ignore")
else:
IJ.log("No composite image created due to excess channels (>4)")
IJ.run("Merge Channels...", params)
compositeImage = IJ.getImage()
IJ.save(compositeImage,outputName+imagePrefix+"_composite.tif")
wList = WindowManager.getIDList()
for i in range(len(wList)):
currImage = WindowManager.getImage(wList[i])
currImage.close()
IJ.log("succeeded")
returnVal = 0
except:
IJ.log("failed")
os.rmdir(outputName)
wList = WindowManager.getIDList()
for i in range(len(wList)):
currImage = WindowManager.getImage(wList[i])
currImage.close()
returnVal = 1
else:
IJ.log("skipped")
returnVal = 2
return returnVal
示例14: check_existence
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def check_existence(title):
if WindowManager.getIDList() is None:
return False
image_titles = (WindowManager.getImage(id).getTitle() for id in WindowManager.getIDList())
return title in image_titles
示例15: diagrambuttonPressed
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getIDList [as 别名]
def diagrambuttonPressed(event) :
IJ.showMessage("Push 'Auto' button each time you want to see the diagram")
x1=10
y1=20
x2=100
y2=50
x3=60
y3=30
xr=10
yr=20
wr=20
hr=20
rect=Rectangle(xr,yr,wr,hr)
#img=IJ.getImage()
#nbslices=self.__img.getImageStackSize()
nbslices=self.__maxLife
IJ.run("Hyperstack...", "title=Diagram type=32-bit display=Color width="+str(x2+(nbslices+1)*x3)+" height="+str(y2+y3*len(dico))+" channels=1 slices="+str(len(self.__measures))+" frames=1")
im=IJ.getImage()
ip=im.getProcessor()
for i in range(len(self.__measures)) :
indiceligne=0
maxvalue=0
minvalue=1000000
im.setPosition(1,i+1,1)
for cellname in self.__listcellname :
indiceligne+=1
for indicecolonne in range(1,nbslices+1):
rect.setLocation(x2+indicecolonne*x3+int(x3/6),(y1+indiceligne*y3-int(y3/2)))
# we create at the first iteration a dictionary with the rectangles (for a future use)
if i==0 :
self.__gridrectangle[(indiceligne,indicecolonne)]=Rectangle(rect)
im.setRoi(rect)
ipr=im.getProcessor()
# we find the min and max values of the datas for a measure given.
if self.__dictMeasures[dico[cellname]][self.__measures[i]][indicecolonne-1]>maxvalue :
maxvalue=self.__dictMeasures[dico[cellname]][self.__measures[i]][indicecolonne-1]
if self.__dictMeasures[dico[cellname]][self.__measures[i]][indicecolonne-1]<minvalue :
minvalue=self.__dictMeasures[dico[cellname]][self.__measures[i]][indicecolonne-1]
# we fill the rectangle with the value of the measure
ipr.setValue(self.__dictMeasures[dico[cellname]][self.__measures[i]][indicecolonne-1])
ipr.fill()
# we write the names and the n of slices on the image with the maxvalue.
ip.setValue(maxvalue)
ip.moveTo(x1,y1)
ip.drawString(self.__measures[i])
for j in range(1,nbslices+1) :
ip.moveTo(x2+j*x3,y1)
ip.drawString("Slice "+str(j))
j=0
for cellname in self.__listcellname :
ip.moveTo(x1,y2+j*y3)
ip.drawString(cellname)
j+=1
im.killRoi()
im=IJ.run(im,"Fire","")
IJ.run("Brightness/Contrast...", "")
#im.setMinAndMax(minvalue,maxvalue)
#im.updateImage()
#we add a mouse listener in order to be able to show the roi corresponding to a rectangle when the user clicks on it.
listener = ML()
listener.name=imgName
for imp in map(WindowManager.getImage, WindowManager.getIDList()):
if imp.getTitle().startswith("Diagram") :
win = imp.getWindow()
if win is None:
continue
win.getCanvas().addMouseListener(listener)