Before starting, you need to get a data file to be converted to Photon-HDF5. You can use one of our example data files available on figshare.
Specify the input data file in the following cell:
filename = 'data/DNA_FRET_0.5nM.pt3'
import os
try:
with open(filename): pass
print('Data file found, you can proceed.')
except IOError:
print('ATTENTION: Data file not found, please check the filename.\n'
' (current value "%s")' % filename)
%matplotlib inline
import numpy as np
import phconvert as phc
print('phconvert version: ' + phc.__version__)
d, meta = phc.loader.nsalex_pq(filename,
donor = 2,
acceptor = 1,
alex_period_donor = (0, 2000),
alex_period_acceptor = (2000, 3200),
excitation_wavelengths = (470e-9, 635e-9),
detection_wavelengths = (525e-9, 690e-9),
)
meta['hardware_name']
detectors = d['photon_data']['detectors']
print("Detector Counts")
print("-------- --------")
for det, count in zip(*np.unique(detectors, return_counts=True)):
print("%8d %8d" % (det, count))
nanotimes = d['photon_data']['nanotimes']
detectors = d['photon_data']['detectors']
timestamps = d['photon_data']['timestamps']
not_overflow = d['photon_data']['nanotimes'] != 0
detectors = detectors[not_overflow]
timestamps = timestamps[not_overflow]
nanotimes = nanotimes[not_overflow]
print("Detector Counts")
print("-------- --------")
for det, count in zip(*np.unique(detectors, return_counts=True)):
print("%8d %8d" % (det, count))
d['photon_data']['nanotimes'] = nanotimes
d['photon_data']['detectors'] = detectors
d['photon_data']['timestamps'] = timestamps
phc.plotter.alternation_hist(d)
author = 'Biswajit'
author_affiliation = 'Leiden University'
description = 'A demonstrative pt3 data file.'
sample_name = 'Copper Azurin in 1mM Ascorbate'
dye_names = 'ATTO655'
buffer_name = 'HEPES pH7 with 100 mM NaCl'
d['description'] = description
d['sample'] = dict(
sample_name=sample_name,
dye_names=dye_names,
buffer_name=buffer_name,
num_dyes = len(dye_names.split(',')))
d['identity'] = dict(
author=author,
author_affiliation=author_affiliation)
# Remove some empty groups that may cause errors on saving
_ = meta.pop('dispcurve', None)
_ = meta.pop('imghdr', None)
d['user'] = {'picoquant': meta}
phc.hdf5.save_photon_hdf5(d, overwrite=True)
from pprint import pprint
filename = d['_data_file'].filename
h5data = phc.hdf5.load_photon_hdf5(filename)
phc.hdf5.dict_from_group(h5data.identity)
phc.hdf5.dict_from_group(h5data.setup)
pprint(phc.hdf5.dict_from_group(h5data.photon_data))
h5data._v_file.close()