本文整理汇总了Python中window.Window.volume方法的典型用法代码示例。如果您正苦于以下问题:Python Window.volume方法的具体用法?Python Window.volume怎么用?Python Window.volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类window.Window
的用法示例。
在下文中一共展示了Window.volume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import volume [as 别名]
def __call__(self, nSteps, shift_factor, keepSourceWindow=False):
g.settings['light_sheet_analyzer']['nSteps']=nSteps
g.settings['light_sheet_analyzer']['shift_factor']=shift_factor
g.m.statusBar().showMessage("Generating 4D movie ...")
t = time()
self.start(keepSourceWindow)
A = self.tif
# A = A[1:] # Ian Parker said to hard code removal of the first frame.
'''
A=g.m.currentWindow.image
nSteps=250
shift_factor=1
'''
mt, mx, my = A.shape
mv = int(np.floor(mt / nSteps)) # number of volumes
A = A[:mv * nSteps]
B = np.reshape(A, (mv, nSteps, mx, my))
B = B.swapaxes(1, 3) # the direction we step is going to be the new y axis, whereas the old y axis will eventually become the z axis
B = np.repeat(B, shift_factor, axis=3) # We need to stretch the y axis pixels (which were the step size) so that one new y pixel is the same as a pixel in the x direction. Hopefully before this transformation, the step size (ums) is an integer multiple of the x pixel size (um).
# Now our matrix is in terms of (mv, mz, mx, my).
mv, mz, mx, my = B.shape
mz_new, _ = zoom(B[0, :, 0, :], (1 / np.sqrt(2), 1)).shape
C = np.zeros((mv, mz_new, mx, my), dtype=B.dtype)
for v in np.arange(mv):
for x in np.arange(mx):
C[v, :, x, :] = zoom(B[v, :, x, :], (1 / np.sqrt(2), 1), order=0) # squash the z axis pixel size by sqrt(2)
mv, mz, mx, my = C.shape
newy = my + mz # because we will be shifting each x-y plane in the y direction by one pixel, the resulting size will be my plus the number of x-y planes (mz)
D = np.zeros((mv, mz, mx, newy), dtype=A.dtype)
shifted = 0
for z in np.arange(mz):
minus_z = mz - z
shifted = minus_z
D[:, z, :, shifted:shifted + my] = C[:, z, :, :]
D = D[:, ::-1, :, :] # (mv, mz, mx, my)
g.m.statusBar().showMessage("Successfully generated movie ({} s)".format(time() - t))
w = Window(np.squeeze(D[:,0,:,:]), name=self.oldname)
w.volume=D
Volume_Viewer(w)
return