Esempio n. 1
0
# In[1]:


import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit

from lumicks import pylake


# ## Load FD curve

# In[ ]:


file = pylake.File("20190709-153836 pFM008 in NTM FD Curve 78.h5")
print("Kymo I.D. = " + str(list(file.fdcurves)))

# Loading the I.D. as a variable so there is no need to type it manually every time in other windows
curve_number = (list(file.fdcurves))   

# Inspecting the content of the .h5 file
#print(file)


# ## WLC - 7 parameter model
# This function returns the forces computed from a 7 parameter model of the WLC using the model by Bouchiat et al. Biophys J 76:409 (1999)
# 
# 

# In[ ]:
import PIL
from PIL import Image

get_ipython().run_line_magic('matplotlib', 'inline')

# # Loading the .h5 file and inspecting its content
#
# 1. Make sure that this notebook is in the same folder as the file that is about to be analyzed.
# 2. Copy the entire name of the file below.
#
# The .H5 file exported from Bluelake should contain at least one kymograph that has an assigned number (Kymo I.D). The script will further automatically call the kymograph by this number.

# In[2]:

file = pylake.File("20190123-195538 Kymograph 11.h5")
print("Kymo I.D. = " + str(list(file.kymos)))

# Loading the Kymo I.D. as a variable so there is no need to type it manually every time in other windows
kymo_number = (list(file.kymos))

# Inspecting the content of the .h5 file
print(file)

# In[ ]:

# # Plotting and saving the kymograph together with the force measurement
#
# Kymograph is loaded as .png by default. The image's brightness is improved (vmax=N) to visualize the green signal. Next, force detection is downscaled and co-plotted with the kymograph.
#
# 1. Change "green" to "red" or "blue" depending on which dye was used in the experiment !!
Esempio n. 3
0
filenames = os.listdir(folder)  # all files in the chosen folder
Filenames = []

for filename in filenames:  # selection of .H5 files only
    if filename[-3:] == '.h5':
        Filenames.append(filename)
"""
 # Extract kymograph from all files in one folder and save them as TIFF
"""

for i in range(len(Filenames)):
    print(Filenames[i])

    #Load Marker File containing both kymograph and force extension data
    name = str(Filenames[i])
    file = pylake.File(name)
    #file = pylake.File("20190517-192654 ATP Kymograph 22.h5")
    print("Kymo I.D. = " + str(list(file.kymos)))
    print("FD Curve I.D. = " + str(list(file.fdcurves)))
    #print(file) #textual representation of the contents of a file

    kymo_names = list(file.kymos)  #reference to Kymo I.D
    kymo = file.kymos[kymo_names[0]]
    plt.figure(figsize=(40, 10))  #changes plot size
    #kymo.plot_rgb()
    kymo2 = kymo.plot_green()
    #print("Start timestamp = " + str(kymo.start) + " ns")
    #print("End timestamp = " + str(kymo.stop) + " ns")
    time = round((kymo.stop - kymo.start) / 1000000000, 2)
    #round(number[, ndigits])
    print("Imaging time = " + str(time) + " s")
Esempio n. 4
0
# This is a test for git
# Pylake package that LUMICKS provides
import lumicks.pylake as pylake

# standard python toolkit for more elaborate mathematical operations
import numpy as np

# plotting library
import matplotlib.pyplot as plt

#############################################################################################
file= pylake.File('file directory/filename.h5')
# access the channel(s) we need

#point scan - photon counts in green and red channel
blue_data = file.blue_photon_count[:].data
green_data = file.green_photon_count[:].data   
red_data = file.red_photon_count[:].data

# time points
time_counts = file.green_photon_count[:].timestamps
time_counts = (time_counts - time_counts[0]) *1e-9   # times counts in seconds


# save the data as txt file: [time, blue counts, green counts, red counts]
all_photon_counts= np.vstack((time_counts,blue_data,green_data,red_data)).T
np.savetxt('file directory/filename.txt',all_photon_counts, 
           delimiter=',',header='time blue green red' )
Esempio n. 5
0
def test_h5_export(tmpdir_factory, h5_file, save_h5):
    f = pylake.File.from_h5py(h5_file)
    tmpdir = tmpdir_factory.mktemp("pylake")

    new_file = f"{tmpdir}/copy.h5"
    save_h5(f, new_file, 5)
    g = pylake.File(new_file)
    assert str(g) == str(f)

    # Verify that all attributes are there and correct
    test_file_items.test_scans(g.h5)
    test_file_items.test_kymos(g.h5)
    test_attributes(g.h5)
    test_file_items.test_channels(g.h5)
    test_file_items.test_calibration(g.h5)
    test_file_items.test_marker(g.h5)
    test_properties(g.h5)

    new_file = f"{tmpdir}/omit_LF1y.h5"
    save_h5(f, new_file, 5, omit_data={"Force LF/Force 1y"})
    omit_lf1y = pylake.File(new_file)

    np.testing.assert_allclose(omit_lf1y["Force LF"]["Force 1x"].data,
                               f["Force LF"]["Force 1x"].data)
    np.testing.assert_allclose(omit_lf1y["Force HF"]["Force 1x"].data,
                               f["Force HF"]["Force 1x"].data)
    np.testing.assert_allclose(omit_lf1y["Force HF"]["Force 1y"].data,
                               f["Force HF"]["Force 1y"].data)
    with pytest.raises(KeyError):
        assert np.any(omit_lf1y["Force LF"]["Force 1y"].data)

    new_file = f"{tmpdir}/omit_1y.h5"
    save_h5(f, new_file, 5, omit_data={"*/Force 1y"})
    omit_1y = pylake.File(new_file)

    np.testing.assert_allclose(omit_1y["Force LF"]["Force 1x"].data,
                               f["Force LF"]["Force 1x"].data)
    np.testing.assert_allclose(omit_1y["Force HF"]["Force 1x"].data,
                               f["Force HF"]["Force 1x"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_1y["Force HF"]["Force 1y"].data,
                                   f["Force HF"]["Force 1y"].data)
    with pytest.raises(KeyError):
        assert np.any(omit_1y["Force LF"]["Force 1y"].data)

    new_file = f"{tmpdir}/omit_hf.h5"
    save_h5(f, new_file, 5, omit_data={"Force HF/*"})
    omit_hf = pylake.File(new_file)

    np.testing.assert_allclose(omit_hf["Force LF"]["Force 1x"].data,
                               f["Force LF"]["Force 1x"].data)
    np.testing.assert_allclose(omit_hf["Force LF"]["Force 1y"].data,
                               f["Force LF"]["Force 1y"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_hf["Force HF"]["Force 1x"].data,
                                   f["Force HF"]["Force 1x"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_hf["Force HF"]["Force 1y"].data,
                                   f["Force HF"]["Force 1y"].data)

    new_file = f"{tmpdir}/omit_two.h5"
    save_h5(f, new_file, 5, omit_data={"Force HF/*", "*/Force 1y"})
    omit_two = pylake.File(new_file)

    np.testing.assert_allclose(omit_two["Force LF"]["Force 1x"].data,
                               f["Force LF"]["Force 1x"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_two["Force LF"]["Force 1y"].data,
                                   f["Force LF"]["Force 1y"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_two["Force HF"]["Force 1x"].data,
                                   f["Force HF"]["Force 1x"].data)
    with pytest.raises(KeyError):
        np.testing.assert_allclose(omit_two["Force HF"]["Force 1y"].data,
                                   f["Force HF"]["Force 1y"].data)