Example #1
0
def test_precision_weight():
    experiments = []
    geomean = {}
    geostder = {}
    for num in range(4):
        name = 'test_{}'.format(num)
        experiments.append(name)
        data1 = {
            'Frame': [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
            'Track_ID': [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
            'X': [x * (num + 1) for x in [5, 6, 7, 8, 9, 2, 4, 6, 8, 10]],
            'Y': [x * (num + 1) for x in [6, 7, 8, 9, 10, 6, 8, 10, 12, 14]],
            'Quality': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
            'SN_Ratio': [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
            'Mean_Intensity': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
        }
        df = pd.DataFrame(data=data1)
        msds = msd.all_msds2(df)
        msds.to_csv('msd_test_{}.csv'.format(num))
        geomean[name], geostder[name] = msd.geomean_msdisp(name,
                                                           umppx=1,
                                                           fps=1,
                                                           upload=False)

    slices, bins, bin_names = msd.binning(experiments, wells=1)
    weights, w_holder = msd.precision_weight(experiments, geostder)
    weights_t = np.array([8.3, 8.3, 8.3, 8.3])
    npt.assert_equal(np.round(weights[weights.mask == False].data, 1),
                     weights_t)
Example #2
0
def test_geomean_msdisp():
    data1 = {
        'Frame': [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
        'Track_ID': [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
        'X': [5, 6, 7, 8, 9, 1, 2, 3, 4, 5],
        'Y': [6, 7, 8, 9, 10, 2, 3, 4, 5, 6],
        'Quality': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        'SN_Ratio': [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
        'Mean_Intensity': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    }

    geomean_t = np.array([2., 8., 18., 32.])
    geostder_t = np.array([])
    df = pd.DataFrame(data=data1)
    msds = msd.all_msds2(df)
    msds.to_csv('msd_test.csv')

    geomean, geostder = msd.geomean_msdisp('test',
                                           umppx=1,
                                           fps=1,
                                           upload=False)
    npt.assert_equal(np.round(np.exp(geomean[geomean.mask == False].data), 1),
                     geomean_t)
    npt.assert_equal(
        np.round(np.exp(geostder[geostder.mask == False].data), 1), geostder_t)

    # test 2
    data1 = {
        'Frame': [1, 2, 1, 2],
        'Track_ID': [1, 1, 2, 2],
        'X': [1, 2, 3, 4],
        'Y': [1, 2, 3, 4],
        'Quality': [10, 10, 10, 10],
        'SN_Ratio': [0.1, 0.1, 0.1, 0.1],
        'Mean_Intensity': [10, 10, 10, 10]
    }
    df = pd.DataFrame(data=data1)
    msds = msd.all_msds2(df)
    msds.to_csv('msd_test.csv')
    geomean, geostder = msd.geomean_msdisp('test',
                                           umppx=1,
                                           fps=1,
                                           upload=False)
    npt.assert_equal(geomean, np.nan * np.ones(651))
    npt.assert_equal(geostder, np.nan * np.ones(651))

    # test 3
    data1 = {
        'Frame': [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
        'Track_ID': [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
        'X': [5, 6, 7, 8, 9, 2, 4, 6, 8, 10],
        'Y': [6, 7, 8, 9, 10, 6, 8, 10, 12, 14],
        'Quality': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
        'SN_Ratio': [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
        'Mean_Intensity': [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    }
    df = pd.DataFrame(data=data1)
    geomean_t = np.array([4., 16., 36., 64.])
    geostder_t = np.array([2., 2., 2., 2])
    msds = msd.all_msds2(df)
    msds.to_csv('msd_test.csv')

    geomean, geostder = msd.geomean_msdisp('test',
                                           umppx=1,
                                           fps=1,
                                           upload=False)
    npt.assert_equal(np.round(np.exp(geomean[geomean.mask == False].data), 1),
                     geomean_t)
    npt.assert_equal(
        np.round(np.exp(geostder[geostder.mask == False].data), 1), geostder_t)
Example #3
0
to_track = []
frames = 651
fps = 100.02
umppx = 0.07

vids = 5
covers = ['10K', '1K', '5K', 'COOH']
slices = [4, 5, 6]
for cover in covers:
    for slic in slices:
        for num in range(1, vids + 1):
            #to_track.append('100x_0_4_1_2_gel_{}_bulk_vid_{}'.format(vis, num))
            to_track.append('{}_tissue_S{}_XY{}'.format(cover, slic, num))

geomean = {}
gSEM = {}
for sample_name in to_track[int(sys.argv[1]):int(sys.argv[2])]:
    # Users can toggle between using pre-calculated geomean files and calculating new values by commenting out the relevant
    # lines of code within the for loop.
    #aws.download_s3('{}/geomean_{}.csv'.format(folder, sample_name), 'geomean_{}.csv'.format(sample_name), bucket_name=bucket)
    #aws.download_s3('{}/geoSEM_{}.csv'.format(folder, sample_name), 'geoSEM_{}.csv'.format(sample_name), bucket_name=bucket)
    #geomean[sample_name] = np.genfromtxt('geomean_{}.csv'.format(sample_name))
    #gSEM[sample_name] = np.genfromtxt('geoSEM_{}.csv'.format(sample_name))

    aws.download_s3('{}/msd_{}.csv'.format(folder, sample_name),
                    'msd_{}.csv'.format(sample_name),
                    bucket_name=bucket)
    geomean[sample_name], gSEM[sample_name] = msd.geomean_msdisp(
        sample_name, umppx=umppx, fps=fps, remote_folder=folder, bucket=bucket)
    print('Done with {}'.format(sample_name))