示例#1
0
    def saveStack(self, event=None):
        fdialog = wx.FileDialog(
            None,
            'Save Data Stack as ...',
            defaultDir=self.filedir,
            wildcard='KDF (*.kdf)|*.kdf|TIFF (*.tif)|*.tif',
            style=wx.FD_SAVE | wx.HIDE_READONLY)
        succ = fdialog.ShowModal()
        if (succ == wx.ID_OK):
            fpath = fdialog.GetPath()
            if os.path.splitext(fpath)[1] == '.kdf':
                self.ds.SaveToFile(fdialog.GetPath())
            else:
                #save using PIL
                if self.ds.getNumChannels() == 1:
                    #im = Image.fromarray(cSMI.CDataStack_AsArray(self.ds, 0), 'I;16')
                    #im.save(fpath)
                    im = cSMI.CDataStack_AsArray(self.ds, 0).squeeze()
                    saveTiffStack.writeTiff(im, fpath)
                else:
                    fst, ext = os.path.splitext(fpath)
                    for i in range(self.ds.getNumChannels()):
                        #im = Image.fromarray(cSMI.CDataStack_AsArray(self.ds, i), 'I;16')
                        #im.save(fst + '_%d'%i + ext)

                        im = cSMI.CDataStack_AsArray(self.ds, i).squeeze()
                        saveTiffStack.writeTiff(im, fst + '_%d' % i + ext)

            if not (self.log is None):
                lw = logparser.logwriter()
                s = lw.write(self.log)
                log_f = open('%s.log' % fdialog.GetPath().split('.')[0], 'w')
                log_f.write(s)
                log_f.close()

            self.SetTitle(fdialog.GetFilename())
            self.saved = True
示例#2
0
def generateThumbnail(inputFile, thumbSize):
    global size
    im = cSMI.CDataStack_AsArray(cSMI.CDataStack(inputFile.encode()),
                                 0).mean(2).squeeze()

    xsize = im.shape[0]
    ysize = im.shape[1]

    if xsize > ysize:
        zoom = float(thumbSize) / xsize
    else:
        zoom = float(thumbSize) / ysize

    size = (int(xsize * zoom), int(ysize * zoom))

    im = im - im.min()

    im = maximum(minimum(1 * (255 * im) / im.max(), 255), 0)

    return im.astype('uint8')
示例#3
0
    def LoadKdf(self, filename):
        '''load khorus formatted data - pretty much deprecated by now'''
        import PYME.cSMI as cSMI
        self.data = cSMI.CDataStack_AsArray(cSMI.CDataStack(filename),
                                            0).squeeze()
        self.mdh = MetaData.TIRFDefault

        try:  #try and get metadata from the .log file
            lf = open(os.path.splitext(filename)[0] + '.log')
            from PYME.DSView import logparser
            lp = logparser.logparser()
            log = lp.parse(lf.read())
            lf.close()

            self.mdh.setEntry('voxelsize.z', log['PIEZOS']['Stepsize'])
        except:
            pass

        from PYME.ParallelTasks.relativeFiles import getRelFilename
        self.seriesName = getRelFilename(filename)

        self.mode = 'psf'
示例#4
0
def calcSum(caller):
    Is.append(cSMI.CDataStack_AsArray(caller.ds, 0).sum())