{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "filename = r'data\\022rde11_T_minus15_acc__NT_plus10_don_1.sm'" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import phconvert as phc\n", "phc.__version__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Author" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "author = 'Eitan Lerner'\n", "author_affiliation = 'UCLA'\n", "creator = 'Antonino Ingargiola'\n", "creator_affiliation = 'UCLA'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Sample" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "comment = 'A demostrative smFRET-usALEX measurement.'\n", "sample_name = '022rde11_T_minus15_acc__NT_plus10_don_1'\n", "dye_names = ['ATTO550', 'ATTO647N']\n", "buffer_name = 'Transcription buffer.'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Prepare data\n", "\n", "## Read the data" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "d = phc.loader.usalex_sm(filename,\n", " donor = 0,\n", " acceptor = 1,\n", " alex_period = 4000,\n", " alex_offset = 700,\n", " alex_period_donor = (2180, 3900),\n", " alex_period_acceptor = (200, 1800),\n", " excitation_wavelengths = (532e-9, 635e-9),\n", " detection_wavelengths = (580e-9, 680e-9))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc.plotter.alternation_hist(d)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add author and sample info" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "d['comment'] = comment\n", "\n", "d['sample'] = dict(\n", " sample_name=sample_name,\n", " dye_names=[n.encode() for n in dye_names],\n", " buffer_name=buffer_name,\n", " num_dyes = len(dye_names))\n", "\n", "d['identity'] = dict(\n", " author=author,\n", " author_affiliation=author_affiliation,\n", " creator=creator,\n", " creator_affiliation=creator_affiliation)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Validate the Photon-HDF5 structure\n", "\n", "Before writing to disk, we assure the file structure follows the Photon-HDF5 format:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc.hdf5.assert_valid_photon_hdf5(d)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Save to Photon-HDF5" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc.hdf5.save_photon_hdf5(d)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "d['_data_file'].close()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Load Photon-HDF5" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from pprint import pprint" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "filename = d['_data_file'].filename" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "h5data = phc.hdf5.load_photon_hdf5(filename)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc.hdf5.dict_from_group(h5data.identity)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phc.hdf5.dict_from_group(h5data.setup)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "pprint(phc.hdf5.dict_from_group(h5data.photon_data))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }