def makeMovie(filename, xsize=512): apDisplay.printMsg('Making movie', 'blue') mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] apDisplay.printMsg('Reading 3D recon %s' % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize, shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg('Calculating stats...') slice = numpy.sum(array[:, :, :], axis=0) / shape[0] stats['std'] = slice.std() stats['mean'] = slice.mean() if shape[0] > shape[1]: renders = { 'a': { 'axis': 0, 'axisname': 'z' }, 'b': { 'axis': 1, 'axisname': 'y' } } else: renders = { 'a': { 'axis': 1, 'axisname': 'y' }, 'b': { 'axis': 0, 'axisname': 'z' } } keys = renders.keys() keys.sort() for key in keys: axis = renders[key]['axis'] dimz = shape[axis] #generate a sequence of jpg images, each is an average of 5 slices apDisplay.printMsg('Making smoothed slices...') for i in range(0, dimz): pictpath = rootpath + '_avg%05d' % i ll = max(0, i - 2) hh = min(dimz, i + 3) if axis == 0: slice = numpy.sum(array[ll:hh, :, :], axis=axis) / (hh - ll) else: slice = numpy.sum(array[:, ll:hh, :], axis=axis) / (hh - ll) # adjust and shrink each image array2jpg(pictpath, slice, stats['mean'] - 8 * stats['std'], stats['mean'] + 8 * stats['std'], xsize) apDisplay.printMsg('Putting the jpg files together to flash video...') moviepath = dirpath + '/minitomo%s' % key + '.flv' framepath = rootpath + '_avg*.jpg' apMovie.makeflv('jpg', framepath, moviepath)
def makeAlignStackMovie(filename, xsize=2**16): ''' Make movie based on align stack. Default size is the size of the align stack ''' if not os.path.exists(filename): apDisplay.printWarning('align stack does not exist. No movie making.') return apDisplay.printMsg('Making movie', 'blue') mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] alignsplit = rootpath.split('-') if len(alignsplit) > 1: key = alignsplit[-1] else: key = '' apDisplay.printMsg('Reading align stack %s' % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize, shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg('Calculating stats...') slice = numpy.sum(array[:, :, :], axis=0) / shape[0] stats['std'] = slice.std() stats['mean'] = slice.mean() axis = 0 dimz = shape[0] #generate a sequence of jpg images apDisplay.printMsg('Making slices...') for i in range(0, dimz): pictpath1 = rootpath + '_slice%05d' % i pictpath2 = rootpath + '_slice%05d' % (2 * dimz - i) slice = array[i, :, :] stats['mean'] = slice.mean() # adjust and shrink each image array2jpg(pictpath1, slice, stats['mean'] - 6 * stats['std'], stats['mean'] + 6 * stats['std'], xsize) array2jpg(pictpath2, slice, stats['mean'] - 6 * stats['std'], stats['mean'] + 6 * stats['std'], xsize) apDisplay.printMsg('Putting the jpg files together to flash video...') moviepath = dirpath + '/minialign' + key framepath = rootpath + '_slice%05d.jpg' apMovie.makemp4('jpg', framepath, moviepath, False) apMovie.makeflv('jpg', framepath, moviepath)
def makeAlignStackMovie(filename,xsize=2**16): ''' Make movie based on align stack. Default size is the size of the align stack ''' if not os.path.exists(filename): apDisplay.printWarning('align stack does not exist. No movie making.') return apDisplay.printMsg('Making movie','blue') mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] alignsplit = rootpath.split('-') if len(alignsplit) > 1: key = alignsplit[-1] else: key = '' apDisplay.printMsg('Reading align stack %s' % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize,shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg('Calculating stats...') slice = numpy.sum(array[:,:,:],axis=0)/shape[0] stats['std'] = slice.std() stats['mean'] = slice.mean() axis = 0 dimz = shape[0] #generate a sequence of jpg images apDisplay.printMsg('Making slices...') for i in range(0, dimz): pictpath1 = rootpath+'_slice%05d' % i pictpath2 = rootpath+'_slice%05d' % (2*dimz-i) slice = array[i,:,:] stats['mean'] = slice.mean() # adjust and shrink each image array2jpg(pictpath1,slice,stats['mean']-6*stats['std'],stats['mean']+6*stats['std'],xsize) array2jpg(pictpath2,slice,stats['mean']-6*stats['std'],stats['mean']+6*stats['std'],xsize) apDisplay.printMsg('Putting the jpg files together to flash video...') moviepath = dirpath+'/minialign'+key framepath = rootpath+'_slice%05d.jpg' apMovie.makemp4('jpg',framepath,moviepath,False) apMovie.makeflv('jpg',framepath,moviepath)
def makeAlignStackMovie(filename, xsize=2 ** 16): """ Make movie based on align stack. Default size is the size of the align stack """ if not os.path.exists(filename): apDisplay.printWarning("align stack does not exist. No movie making.") return apDisplay.printMsg("Making movie", "blue") mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] alignsplit = rootpath.split("-") if len(alignsplit) > 1: key = alignsplit[-1] else: key = "" apDisplay.printMsg("Reading align stack %s" % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize, shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg("Calculating stats...") slice = numpy.sum(array[:, :, :], axis=0) / shape[0] stats["std"] = slice.std() stats["mean"] = slice.mean() axis = 0 dimz = shape[0] # generate a sequence of jpg images apDisplay.printMsg("Making slices...") for i in range(0, dimz): pictpath1 = rootpath + "_slice%05d" % i pictpath2 = rootpath + "_slice%05d" % (2 * dimz - i) slice = array[i, :, :] stats["mean"] = slice.mean() # adjust and shrink each image array2jpg(pictpath1, slice, stats["mean"] - 6 * stats["std"], stats["mean"] + 6 * stats["std"], xsize) array2jpg(pictpath2, slice, stats["mean"] - 6 * stats["std"], stats["mean"] + 6 * stats["std"], xsize) apDisplay.printMsg("Putting the jpg files together to flash video...") moviepath = dirpath + "/minialign" + key framepath = rootpath + "_slice%05d.jpg" apMovie.makemp4("jpg", framepath, moviepath, False) apMovie.makeflv("jpg", framepath, moviepath)
def makeMovie(filename,xsize=512): apDisplay.printMsg('Making movie','blue') mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] apDisplay.printMsg('Reading 3D recon %s' % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize,shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg('Calculating stats...') slice = numpy.sum(array[:,:,:],axis=0)/shape[0] stats['std'] = slice.std() stats['mean'] = slice.mean() if shape[0] > shape[1]: renders = {'a':{'axis':0,'axisname':'z'},'b':{'axis':1,'axisname':'y'}} else: renders = {'a':{'axis':1,'axisname':'y'},'b':{'axis':0,'axisname':'z'}} keys = renders.keys() keys.sort() for key in keys: axis = renders[key]['axis'] dimz = shape[axis] #generate a sequence of jpg images, each is an average of 5 slices apDisplay.printMsg('Making smoothed slices...') for i in range(0, dimz): pictpath = rootpath+'_avg%05d' % i ll = max(0,i - 2) hh = min(dimz,i + 3) if axis == 0: slice = numpy.sum(array[ll:hh,:,:],axis=axis)/(hh-ll) else: slice = numpy.sum(array[:,ll:hh,:],axis=axis)/(hh-ll) # adjust and shrink each image array2jpg(pictpath,slice,stats['mean']-8*stats['std'],stats['mean']+8*stats['std'],xsize) apDisplay.printMsg('Putting the jpg files together to flash video...') moviepath = dirpath+'/minitomo%s'%key+'.flv' framepath = rootpath+'_avg*.jpg' apMovie.makeflv('jpg',framepath,moviepath)
def makeMovie(filename, xsize=512): apDisplay.printMsg("Making movie", "blue") mrcpath = filename dirpath = os.path.dirname(mrcpath) splitnames = os.path.splitext(mrcpath) rootpath = splitnames[0] apDisplay.printMsg("Reading 3D recon %s" % mrcpath) array = mrc.read(mrcpath) shape = array.shape xsize = min(xsize, shape[2]) stats = {} # speed up stats calculation by projecting to axis 0 to reduce array dimension apDisplay.printMsg("Calculating stats...") slice = numpy.sum(array[:, :, :], axis=0) / shape[0] stats["std"] = slice.std() stats["mean"] = slice.mean() if shape[0] > shape[1]: renders = {"a": {"axis": 0, "axisname": "z"}, "b": {"axis": 1, "axisname": "y"}} else: renders = {"a": {"axis": 1, "axisname": "y"}, "b": {"axis": 0, "axisname": "z"}} keys = renders.keys() keys.sort() for key in keys: axis = renders[key]["axis"] dimz = shape[axis] # generate a sequence of jpg images, each is an average of 5 slices apDisplay.printMsg("Making smoothed slices...") for i in range(0, dimz): pictpath = rootpath + "_avg%05d" % i ll = max(0, i - 2) hh = min(dimz, i + 3) if axis == 0: slice = numpy.sum(array[ll:hh, :, :], axis=axis) / (hh - ll) else: slice = numpy.sum(array[:, ll:hh, :], axis=axis) / (hh - ll) # adjust and shrink each image array2jpg(pictpath, slice, stats["mean"] - 8 * stats["std"], stats["mean"] + 8 * stats["std"], xsize) apDisplay.printMsg("Putting the jpg files together to flash video...") moviepath = dirpath + "/minitomo%s" % key + ".flv" framepath = rootpath + "_avg*.jpg" apMovie.makeflv("jpg", framepath, moviepath)
def makeMovie(self,framepaths_wild,moviepath): apMovie.makeflv('jpg',framepaths_wild,moviepath)
def makeMovie(self,framepaths_wild,moviepath): apMovie.makeflv('jpg',framepaths_wild,moviepath)