This notebook shows how to create a Photon-HDF5 file from scratch using dummy data and phconvert.
For more info see Writing Photon-HDF5 files.
import phconvert as phc
phc.__version__
import numpy as np
timestamps = np.random.randint(low=0, high=2e8, size=10000).astype('int64')
timestamps.sort()
timestamps_unit = 10e-9 # 10 ns, units are always S.I.
detectors = np.random.randint(low=0, high=1, size=10000).astype('uint8')
description = 'This is a fake dataset which mimics smFRET data.'
author = 'Author Name'
author_affiliation = 'Name of Research Institution'
sample_name = 'describe the sample here'
buffer_name = 'describe the buffer here'
dye_names = 'Cy3B, ATTO647N' # Comma separates names of fluorophores
photon_data = dict(
timestamps=timestamps,
detectors=detectors,
timestamps_specs={'timestamps_unit': timestamps_unit})
setup
group¶The /setup
group contains information about the measurement setup.
setup = dict(
## Mandatory fields
num_pixels = 2, # using 2 detectors
num_spots = 1, # a single confoca excitation
num_spectral_ch = 2, # donor and acceptor detection
num_polarization_ch = 1, # no polarization selection
num_split_ch = 1, # no beam splitter
modulated_excitation = False, # CW excitation, no modulation
excitation_alternated = [False], # CW excitation, no modulation
lifetime = False, # no TCSPC in detection
## Optional fields
excitation_wavelengths = [532e-9], # List of excitation wavelenghts
excitation_cw = [True], # List of booleans, True if wavelength is CW
detection_wavelengths = [580e-9, 640e-9], # Nominal center wavelength
# each for detection ch
)
provenance
group¶Non-mandatory group containing info about the original file prior to Photon-HDF5 conversion. If some information is not available the relative field may be omitted.
provenance = dict(
filename='original_data_file.dat',
software='Acquisition Software Name')
identity
group¶Non-mandatory group containing info about information this specific Photon-HDF5 file.
identity = dict(
author=author,
author_affiliation=author_affiliation)
measurement_specs
group¶The optional /photon_data/measurement_specs group contains additional information allowing unambiguous interpretation of the data for each specific type of measurement.
measurement_specs = dict(
measurement_type = 'smFRET',
detectors_specs = {'spectral_ch1': [0], # list of donor's detector IDs
'spectral_ch2': [1]} # list of acceptor's detector IDs
)
data = dict(
description=description,
photon_data = photon_data,
setup=setup,
)
phc.hdf5.save_photon_hdf5(data, h5_fname='dummy_dataset_barebone.h5', overwrite=True)
NOTE: a user of this file can read the data but does not know what kind of measurement it is (e.g. smFRET with single laser excitation and 2-colors detection).
Create a Photon-HDF5 with non-mandatory fields (including measurement_specs
):
photon_data['measurement_specs'] = measurement_specs
data = dict(
description=description,
photon_data = photon_data,
setup=setup,
identity=identity,
provenance=provenance
)
phc.hdf5.save_photon_hdf5(data, h5_fname='dummy_dataset_complete.h5', overwrite=True)
NOTE: a user of this file can correctly interpret the data reading that the measurement type is 'smFRET' (meaning smFRET with single laser excitation and 2-colors detection) and the IDs of donor and acceptor detectors (from
detectors_specs/spectral_ch1
andspectral_ch2
respectively).