This notebook converts the us-ALEX
.smdata file into Photon-HDF5 file format.
In [1]:
%matplotlib inline
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
from glob import glob
In [2]:
import phconvert as phc
phc.__version__
Out[2]:
Paste here the folder containing the .sm files to convert:
In [3]:
data_dir = r'C:\Data\Antonio\data/8-spot 5samples data/2012-11-26/'
This is the list of the files that will be converted:
In [4]:
file_list = glob(data_dir + '*.sm')
file_list
Out[4]:
In [5]:
author = 'Francesco Panzeri/Antonino Ingargiola'
author_affiliation = 'UCLA'
creator = 'Antonino Ingargiola'
creator_affiliation = 'UCLA'
In [6]:
description = 'dsDNA with D-A separation of %d base-pairs. %s.'
sample_name = 'Doubly-labeled 40-bp dsDNA, D-A separation %d base-pairs.'
dye_names = 'ATTO550, ATTO647N'
buffer_name = 'TE50'
In [7]:
import re
In [8]:
bp_pattern = '.+_([0-9]{1,2})d_.+'
In [9]:
filename = file_list[0]
spad_name = 'MPD SPAD (donor), MPD RE-SPAD (acceptor)'
sample_bp = int(re.match(bp_pattern, filename).group(1))
spad_name, sample_bp
Out[9]:
In [10]:
d = phc.loader.usalex_sm(filename,
donor = 0,
acceptor = 1,
alex_period = 4000,
alex_offset = 700,
alex_period_donor = (2150, 3900),
alex_period_acceptor = (200, 1900),
excitation_wavelengths = (532e-9, 635e-9),
detection_wavelengths = (580e-9, 680e-9))
In [11]:
ph_data = d['photon_data']
det = ph_data['detectors']
timestamps = ph_data['timestamps']
In [12]:
np.unique(det)
Out[12]:
In [13]:
phc.plotter.alternation_hist(d)
In [14]:
d['description'] = description % (sample_bp, spad_name)
d['sample'] = dict(
sample_name=sample_name % sample_bp,
dye_names=dye_names,
buffer_name=buffer_name,
num_dyes = len(dye_names.split(',')))
d['identity'] = dict(
author=author,
author_affiliation=author_affiliation,
creator=creator,
creator_affiliation=creator_affiliation)
In [15]:
d['description']
Out[15]:
In [16]:
#phc.hdf5.save_photon_hdf5(d)
In [17]:
for filename in file_list:
spad_name = 'MPD SPAD (donor), MPD RE-SPAD (acceptor)'
sample_bp = int(re.match(bp_pattern, filename).group(1))
print(spad_name, sample_bp, '\t', filename)
d = phc.loader.usalex_sm(filename,
donor = 0,
acceptor = 1,
alex_period = 4000,
alex_offset = 700,
alex_period_donor = (2150, 3900),
alex_period_acceptor = (200, 1900),
excitation_wavelengths = (532e-9, 635e-9),
detection_wavelengths = (580e-9, 680e-9))
d['description'] = description % (sample_bp, spad_name)
d['sample'] = dict(
sample_name=sample_name % sample_bp,
dye_names=dye_names,
buffer_name=buffer_name,
num_dyes = len(dye_names.split(',')))
d['identity'] = dict(
author=author,
author_affiliation=author_affiliation,
creator=creator,
creator_affiliation=creator_affiliation)
phc.hdf5.save_photon_hdf5(d, overwrite=True)
In [18]:
from fretbursts import *
In [19]:
from IPython.display import display
In [20]:
for fname in file_list:
fname = fname[:-2] + 'hdf5'
print(fname)
d = loader.photon_hdf5(fname)
loader.alex_apply_period(d)
d.calc_bg(fun=bg.exp_fit)
d.burst_search()
ds = d.select_bursts(select_bursts.size, th1=20)
alex_jointplot(ds)
fig = plt.gcf()
plt.close(fig)
display(fig)
In [ ]:
In [ ]: