If it's the first time you are using a Jupyter notebook please click on Help -> User Interface Tour for a quick tour of the interface.
In this notebook there are text cells, like this paragraph, and code cells, containing the code to be executed. To execute a selected code cell hit SHIFT+ENTER. To edit a code cell it must be selected and with a green frame around it.
If you are reading this notebook online, please refer to this quick-start guide for instructions on how to install the required software and run a Jupyter notebook on your machine.
Your can run this notebook using example data files available on figshare. If you use these example files, please unzip them and put them in a folder named "data" (lower case) inside the folder containing this notebook.
Alternatively, you can use on your own SM file. In this case you need to paste
the full path of your SM file in the following cell, replacing value between single quotes
filename = r'data\022rde11_T_minus15_acc__NT_plus10_don_1.sm'
The next cell will check if the
filename location is correct:
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)
In case of file not found, please double check that you put the example
data files in the "data" folder, or that the path you put in
is correct. Please re-execute the last two cells until the file is found.
Here we specify the additional metadata that will be stored in the Photon-HDF5 file. If you are using the example file you don't need to edit any of these. If using your own file, please modify these description accordingly.
author = 'Eitan Lerner' author_affiliation = 'UCLA' creator = 'Antonino Ingargiola' creator_affiliation = 'UCLA'
description = 'A demostrative smFRET-usALEX measurement.' sample_name = '022rde11_T_minus15_acc__NT_plus10_don_1' dye_names = ['ATTO550', 'ATTO647N'] buffer_name = 'Transcription buffer.'
Please edit the previous cells and execute them (SHIFT+ENTER) to make sure there are no errors. Then proceed to the next section.
%matplotlib inline import matplotlib.pyplot as plt import numpy as np import phconvert as phc print('phconvert version: ' + phc.__version__)
Next, we can load the input file and assign the measurement parameters (measurement_specs), necessary to create a complete Photon-HDF5 file.
If using your own file, please review all the parameters in the next cell.
d = phc.loader.usalex_sm(filename, donor = 0, acceptor = 1, alex_period = 4000, alex_offset = 700, alex_period_donor = (2180, 3900), alex_period_acceptor = (200, 1800), excitation_wavelengths = (532e-9, 635e-9), detection_wavelengths = (580e-9, 680e-9))
The next cell plots a
nanotimes histogram for the donor and acceptor channel separately.
The shaded areas marks the donor (green) and acceptor (red) excitation periods.
If the histogram looks wrong in some aspects (no photons, wrong detectors assignment, wrong period selection) please go back to the previous cell and tweak the relevant parameters until the histogram looks correct.
You may also find useful to see how many different detectors are present and their number of photons. This information is shown in the next cell.
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))
Once you finished editing the the previous sections you can proceed with the actual conversion. It is suggested to execute the notebook in one step by clicking on the menu Cells -> Run All.
After that, you should find a new
.hdf5 file in the same folder of the input
file. You can check it's content by using HDFView.
The cells below contain the code to convert the input file to Photon-HDF5.
d['description'] = description d['sample'] = dict( sample_name=sample_name, dye_names=[n.encode() for n in dye_names], buffer_name=buffer_name, num_dyes = len(dye_names)) d['identity'] = dict( author=author, author_affiliation=author_affiliation, creator=creator, creator_affiliation=creator_affiliation)
Before writing to disk, we assure the file structure follows the Photon-HDF5 format:
from pprint import pprint
filename = d['_data_file'].filename
h5data = phc.hdf5.load_photon_hdf5(filename)
If the next cell output shows "OK" then the execution is terminated.