コード例 #1
0
def lsmChannelSplitter(imp):
    width = imp.getWidth()
    height = imp.getHeight()
    channels = imp.getNChannels()
    slices = imp.getNSlices()
    frames = imp.getNFrames()
    bitDepth = imp.getBitDepth()
    size = slices * frames
    reducer = HyperStackReducer(imp)
    for ch in range(channels):
        c = ch + 1
        stack2 = ImageStack(width, height, size)
        stack2.setPixels(imp.getProcessor().getPixels(), 1)
        newtitile = "C%d-%s" % (c, imp.getTitle())
        imp2 = ImagePlus(newtitile, stack2)
        #stack2.setPixels(null, 1)
        imp.setPosition(c, 1, 1)
        imp2.setDimensions(1, slices, frames)
        imp2.setCalibration(imp.getCalibration())
        reducer.reduce(imp2)
        if imp2.getNDimensions() > 3:
            imp2.setOpenAsHyperStack(true)
            imp2.show()
    imp.changes = false
    imp.close()
コード例 #2
0
def lsmChannelExtractrer(imp, extch):
    width = imp.getWidth()
    height = imp.getHeight()
    channels = imp.getNChannels()
    slices = imp.getNSlices()
    frames = imp.getNFrames()
    bitDepth = imp.getBitDepth()
    size = slices * frames
    reducer = HyperStackReducer(imp)
    if extch > channels:
        return 0
    else:
        c = extch
        imp.setPosition(c, 1, 1)
        stack2 = ImageStack(width, height, size)
        stack2.setPixels(imp.getProcessor().getPixels(), 1)
        newtitile = "C%d-%s" % (c, imp.getTitle())
        imp2 = ImagePlus(newtitile, stack2)
        #stack2.setPixels(null, 1)
        imp.setPosition(c, 1, 1)
        imp2.setDimensions(1, slices, frames)
        imp2.setCalibration(imp.getCalibration())
        reducer.reduce(imp2)
        if imp2.getNDimensions() > 3:
            imp2.setOpenAsHyperStack(true)
        imp.changes = False
        return imp2