def addMoleculesWithXYCatF(self, x, y, cat,f): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.setI3Field(i3data, 'c', cat) i3dtype.setI3Field(i3data, 'fr', f) self.addMolecules(i3data)
def addMoleculesWithXYZCat(self, x, y, z, cat): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.posSet(i3data, 'z', z) i3dtype.setI3Field(i3data, 'c', cat) self.addMolecules(i3data)
def addMoleculesWithXYAFrame(self, x, y, pa, frame): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.setI3Field(i3data, 'a', pa) i3dtype.setI3Field(i3data, 'fr', frame) self.addMolecules(i3data)
def addMoleculesWithXYCatF(self, x, y, cat, f): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.setI3Field(i3data, 'c', cat) i3dtype.setI3Field(i3data, 'fr', f) self.addMolecules(i3data)
def addMoleculesWithXYZIFrame(self, x, y, z, pi, f): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.posSet(i3data, 'z', z) i3dtype.setI3Field(i3data, 'i', pi) i3dtype.setI3Field(i3data, 'fr', f) self.addMolecules(i3data)
def addMoleculesWithXYIWFrame(self, x, y, pi, width, frame): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.setI3Field(i3data, 'i', pi) i3dtype.setI3Field(i3data, 'w', width) i3dtype.setI3Field(i3data, 'fr', frame) self.addMolecules(i3data)
def addDAOSTORMMolecules(self, frame, xc, yc, br, be, msky, niter, sharp, chi, err): # # DAOSTORM -> Insight3 format mapping. # # xc - xcenter # yc - ycenter # br - brightness -> peak height # be - brightness error (?) -> peak area # msky - background -> peak background # niter - fit iterations # sharp - sharpness (?) -> peak angle # chi - fit quality -> peak width # err - error flag -> link # i3data = i3dtype.createDefaultI3Data(xc.size) i3dtype.posSet(i3data, 'x', xc) i3dtype.posSet(i3data, 'y', yc) i3dtype.setI3Field(i3data, 'h', br) i3dtype.setI3Field(i3data, 'a', be) i3dtype.setI3Field(i3data, 'bg', msky) i3dtype.setI3Field(i3data, 'fi', niter) i3dtype.setI3Field(i3data, 'phi', sharp) i3dtype.setI3Field(i3data, 'w', chi) i3dtype.setI3Field(i3data, 'lk', err) self.addMolecules(i3data)
def addMultiFitMolecules(self, molecules, x_size, y_size, frame, nm_per_pixel, inverted=False): n_molecules = molecules.shape[0] h = molecules[:, 0] if inverted: xc = y_size - molecules[:, 1] yc = x_size - molecules[:, 3] wx = 2.0 * molecules[:, 2] * nm_per_pixel wy = 2.0 * molecules[:, 4] * nm_per_pixel else: xc = molecules[:, 3] + 1 yc = molecules[:, 1] + 1 wx = 2.0 * molecules[:, 4] * nm_per_pixel wy = 2.0 * molecules[:, 2] * nm_per_pixel bg = molecules[:, 5] zc = molecules[:, 6] * 1000.0 # fitting is done in um, insight works in nm st = numpy.round(molecules[:, 7]) err = molecules[:, 8] # calculate peak area, which is saved in the "a" field. parea = 2.0 * 3.14159 * h * molecules[:, 2] * molecules[:, 4] ax = wy / wx ww = numpy.sqrt(wx * wy) i3data = i3dtype.createDefaultI3Data(xc.size) i3dtype.posSet(i3data, 'x', xc) i3dtype.posSet(i3data, 'y', yc) i3dtype.posSet(i3data, 'z', zc) i3dtype.setI3Field(i3data, 'h', h) i3dtype.setI3Field(i3data, 'bg', bg) i3dtype.setI3Field(i3data, 'fi', st) i3dtype.setI3Field(i3data, 'a', parea) i3dtype.setI3Field(i3data, 'w', ww) i3dtype.setI3Field(i3data, 'ax', ax) i3dtype.setI3Field(i3data, 'fr', frame) i3dtype.setI3Field(i3data, 'i', err) self.addMolecules(i3data)
def addMoleculesWithXYI(self, x, y, pi): i3data = i3dtype.createDefaultI3Data(x.size) i3dtype.posSet(i3data, 'x', x) i3dtype.posSet(i3data, 'y', y) i3dtype.setI3Field(i3data, 'i', pi) self.addMolecules(i3data)
def addMultiFitMolecules(self, molecules, x_size, y_size, frame, nm_per_pixel, inverted=False): n_molecules = molecules.shape[0] h = molecules[:,0] if inverted: xc = y_size - molecules[:,1] yc = x_size - molecules[:,3] wx = 2.0*molecules[:,2]*nm_per_pixel wy = 2.0*molecules[:,4]*nm_per_pixel else: xc = molecules[:,3] + 1 yc = molecules[:,1] + 1 wx = 2.0*molecules[:,4]*nm_per_pixel wy = 2.0*molecules[:,2]*nm_per_pixel bg = molecules[:,5] zc = molecules[:,6] * 1000.0 # fitting is done in um, insight works in nm st = np.round(molecules[:,7]) err = molecules[:,8] # calculate peak area, which is saved in the "a" field. sum = 2.0*3.14159*h*molecules[:,2]*molecules[:,4] ax = wy/wx ww = np.sqrt(wx*wy) i3data = i3dtype.createDefaultI3Data(xc.size) i3dtype.posSet(i3data, 'x', xc) i3dtype.posSet(i3data, 'y', yc) i3dtype.posSet(i3data, 'z', zc) i3dtype.setI3Field(i3data, 'h', h) i3dtype.setI3Field(i3data, 'bg', bg) i3dtype.setI3Field(i3data, 'fi', st) i3dtype.setI3Field(i3data, 'a', sum) i3dtype.setI3Field(i3data, 'w', ww) i3dtype.setI3Field(i3data, 'ax', ax) i3dtype.setI3Field(i3data, 'fr', frame) i3dtype.setI3Field(i3data, 'i', err) self.addMolecules(i3data)
c = 1 # default to 1 channelName = field[0] if (channelName == 'Z Rejected'): c = 0 else: for ch, name in enumerate(channelNames): if channelName == name: c = ch + 1 break fi = int(field[15]) #"valid" for iteration fr = int(field[12]) tl = int(field[13]) lk = int(field[14]) z = float(field[16]) zc = float(field[17]) i3dtype.setI3Field(data, 'x', x) i3dtype.setI3Field(data, 'y', y) i3dtype.setI3Field(data, 'xc', xc) i3dtype.setI3Field(data, 'yc', yc) i3dtype.setI3Field(data, 'h', h) i3dtype.setI3Field(data, 'a', a) i3dtype.setI3Field(data, 'w', w) i3dtype.setI3Field(data, 'phi', phi) i3dtype.setI3Field(data, 'ax', ax) i3dtype.setI3Field(data, 'bg', bg) i3dtype.setI3Field(data, 'i', i) i3dtype.setI3Field(data, 'c', c) i3dtype.setI3Field(data, 'fi', fi) i3dtype.setI3Field(data, 'fr', fr) i3dtype.setI3Field(data, 'tl', tl) i3dtype.setI3Field(data, 'lk', lk)