コード例 #1
0
ファイル: i3togrid.py プロジェクト: CMSpeer/storm-analysis
 def gridFn():
     mask = (self.i3data['c'] == channel)
     self.i3data = i3dtype.maskData(self.i3data, mask)
     return self.i3To2DGridAllChannelsMerged(zmin = zmin,
                                             zmax = zmax,
                                             uncorrected = uncorrected,
                                             verbose = verbose)
コード例 #2
0
 def gridFn():
     mask = (self.i3data['c'] == channel)
     self.i3data = i3dtype.maskData(self.i3data, mask)
     return self.i3To2DGridAllChannelsMerged(zmin=zmin,
                                             zmax=zmax,
                                             uncorrected=uncorrected,
                                             verbose=verbose)
 def getMoleculesInFrameRange(self, start, stop, good_only = True):
     start_mol_num = self.findFrame(start)
     stop_mol_num = self.findFrame(stop)
     if (type(self.localizations) == type(numpy.array([]))):
         data = self.localizations[start_mol_num:stop_mol_num]
     else:
         cur = self.fp.tell()
         self.fp.seek(16 + start_mol_num*self.record_size)
         size = stop_mol_num - start_mol_num
         data = numpy.fromfile(self.fp,
                               dtype=i3dtype.i3DataType(),
                               count=size)
         self.fp.seek(cur)  
     if good_only:
         return i3dtype.maskData(data, (data['c'] != 9))
     else:
         return data
コード例 #4
0
 def getMoleculesInFrameRange(self, start, stop, good_only = True):
     start_mol_num = self.findFrame(start)
     stop_mol_num = self.findFrame(stop)
     if (type(self.localizations) == type(numpy.array([]))):
         data = self.localizations[start_mol_num:stop_mol_num]
     else:
         cur = self.fp.tell()
         self.fp.seek(16 + start_mol_num*self.record_size)
         size = stop_mol_num - start_mol_num
         data = numpy.fromfile(self.fp,
                               dtype=i3dtype.i3DataType(),
                               count=size)
         self.fp.seek(cur)  
     if good_only:
         return i3dtype.maskData(data, (data['c'] != 9))
     else:
         return data
コード例 #5
0
    def nextBlock(self, block_size=400000, good_only=True):

        # check if we have read all the molecules.
        if (self.cur_molecule >= self.molecules):
            return False

        size = block_size

        # adjust size if we'll read past the end of the file.
        if ((self.cur_molecule + size) > self.molecules):
            size = self.molecules - self.cur_molecule

        self.cur_molecule += size

        # read the data
        data = numpy.fromfile(self.fp, dtype=i3dtype.i3DataType(), count=size)

        if good_only:
            return i3dtype.maskData(data, (data['c'] != 9))
        else:
            return data
コード例 #6
0
    def nextBlock(self, block_size = 400000, good_only = True):

        # check if we have read all the molecules.
        if(self.cur_molecule>=self.molecules):
            return False

        size = block_size
        
        # adjust size if we'll read past the end of the file.
        if((self.cur_molecule+size)>self.molecules):
            size = self.molecules - self.cur_molecule

        self.cur_molecule += size

        # read the data
        data = numpy.fromfile(self.fp,
                              dtype=i3dtype.i3DataType(),
                              count=size)

        if good_only:
            return i3dtype.maskData(data, (data['c'] != 9))
        else:
            return data
def loadI3NumpyGoodOnly(filename, verbose = 1):
    data = loadI3FileNumpy(filename, verbose = verbose)
    return i3dtype.maskData(data, (data['c'] != 9))
コード例 #8
0
def loadI3NumpyGoodOnly(filename, verbose = 1):
    data = loadI3FileNumpy(filename, verbose = verbose)
    return i3dtype.maskData(data, (data['c'] != 9))
コード例 #9
0
    def demodulate_individual_localizations(self,
                                            chunk_size=1000,
                                            f_type='single',
                                            block_size=None,
                                            lasers=None):
        daxIn = DAX.DAX()
        daxIn.open(self.nobg_DAX_name)
        _num_frames = daxIn.numFrames
        _im_size = daxIn.height
        if block_size == None:
            block_size = self.block_size
        if lasers == None:
            lasers = self.lasers
        _chunk_size = chunk_size*block_size
        _num_chunks = _num_frames//(_chunk_size)
        _extra_frames = _num_frames%(_chunk_size)
        print(_chunk_size,_num_chunks,_extra_frames,_chunk_size*_num_chunks+_extra_frames)

        i3in = readinsight3.I3Reader(self.i3TypeIndivBinNames[f_type])
        locs = i3in.getMoleculesInFrameRange(0,_num_frames+1)
        demod_locs = np.zeros([locs.shape[0],4+np.sum(lasers)])
        idx_dm = 0
        data = np.zeros([_chunk_size+block_size, _im_size, _im_size]).astype(np.uint16)
        for i in range(_num_chunks):
            t_locs = i3dtype.maskData(locs,locs['fr']>=_chunk_size*i+1)
            i_locs = i3dtype.maskData(t_locs,t_locs['fr']<_chunk_size*(i+1)+1)
            start_time = timer()
            for j in range(_chunk_size+block_size):
                data[j] = daxIn.read(_chunk_size*i+j)
            curr_locs = idx_dm
            for frame in range(_chunk_size):
                _f = frame+_chunk_size*i
                l_locs = i3dtype.maskData(i_locs,i_locs['fr']==_f+1)
                l_data = data[frame:frame+block_size]
                temp_locs = local_dft.calc_indiv_demods_new(l_locs,l_data,lasers,_im_size)
                demod_locs[idx_dm:idx_dm+temp_locs.shape[0]] = temp_locs
                idx_dm += temp_locs.shape[0]
            stop_time = timer()
            new_locs = idx_dm - curr_locs
            print('Chunk %d of %d complete in %d seconds (%d localizations added).' % (i+1, _num_chunks, stop_time-start_time, new_locs))
        start_time = timer()
        for j in range(_extra_frames):
            data[j] = daxIn.read(_chunk_size*_num_chunks+j)
        curr_locs = idx_dm
        i_locs = i3dtype.maskData(locs,locs['fr']>=_chunk_size*_num_chunks+1)
        for frame in range(_extra_frames-block_size):
            _f = frame+_num_chunks*_chunk_size
            l_locs = i3dtype.maskData(i_locs,i_locs['fr']==_f+1)
            l_data = data[frame:frame+block_size]
            temp_locs = local_dft.calc_indiv_demods_new(l_locs,l_data,lasers,_im_size)
            demod_locs[idx_dm:idx_dm+temp_locs.shape[0]] = temp_locs
            idx_dm += temp_locs.shape[0]
        stop_time = timer()
        new_locs = idx_dm - curr_locs
        print('Extra frames complete in %d seconds (%d localizations added).' % (stop_time-start_time, new_locs))
        i3in.close()
        daxIn.close()
        i3out = writeinsight3.I3Writer(self.i3CatIndivBinNames[f_type],_num_frames-1)
        i3out.addMoleculesWithXYZF(demod_locs[:,0],demod_locs[:,1],demod_locs[:,2],demod_locs[:,3])
        i3out.close()
        self.write_to_indiv_ints(demod_locs, f_type)
        return True