In [1]:
import os
import csv
import sys
import scipy.optimize as opt
import scipy.stats as stat
from operator import itemgetter
import random
import numpy as np
import numpy.ma as ma
import numpy.linalg as la

pi = np.pi
sin = np.sin
cos = np.cos

In [2]:
from basic_utils import fillin2, MSD_iteration, vectorized_MMSD_calcs

Inputs

folder folder where trajectory csv file is located.

path path (including folder name) where trajectory csv file is located.

frames number of frames associated with the video being analyzed.

conversion list containing the resolution (microns per pixel), frame rate (frames per second), and stack height (microns)

to_frame don't worry about it right now. Used to limit analysis to this number of frames.

dimension no longer has 3d capabilities, but used to be able to toggle between 2d and 3d

time_to_calculate used to be used to indicated where to calculate diffusion coefficients in seconds.

cut exludes trajectories that have less than specified number of frames. Leave at 1 for now.

totvids total number of videos to be analyzed. Only used if using a for loop.

frame_m redundant for the time being. Make sure it matches the frames variable


In [3]:
folder = "./"
path = "./geoM2xy_{sample_name}.csv"
frames = 401
#SD_frames = [10, 20, 50, 80]
conversion = (1, 1, 1)  # (0.3, 3.95, 1)
to_frame = 60
dimension = "2D"
time_to_calculate = 1

# name = 'RED_KO_PEG_P1_S1_cortex'
cut = 1
totvids = 1
frame_m = 401  # atm I can't go lower than the actual value.

parameters = {}
parameters["channels"] = ["RED"]
parameters["surface functionalities"] = ["nPEG"]
parameters["slices"] = ["S1", "S2"]
parameters["videos"] = [1, 2]
parameters["replicates"] = [1, 2, 3]


channels = parameters["channels"]
surface_functionalities = parameters["surface functionalities"]
slices = parameters["slices"]
videos = parameters["videos"]
replicates = parameters["replicates"]

geoM2xy = {}
gSEM = {}
SM1x = {}
SM1y = {}
SM2xy = {}

In [ ]:
#sample_name = "{}_{}_{}_{}_{}".format(channel, surface_functionality, '37C_72pH', slic, video)
sample_name = "specify" #Fill sample name in here
DIR = folder

total1, xs, ys, x, y = MSD_iteration(DIR, sample_name, cut, totvids, conversion, frame_m)

geoM2xy[sample_name], gSEM[sample_name], SM1x[sample_name], SM1y[sample_name],\
    SM2xy[sample_name] = vectorized_MMSD_calcs(frames, total1, xs, ys, x, y, frame_m)
np.savetxt(DIR+'geoM2xy_{}.csv'.format(sample_name), geoM2xy[sample_name], delimiter=',')
np.savetxt(DIR+'gSEM_{}.csv'.format(sample_name), gSEM[sample_name], delimiter=',')
np.savetxt(DIR+'SM2xy_{}.csv'.format(sample_name), SM2xy[sample_name], delimiter=',')

#geoM2xy[sample_name] = np.genfromtxt(DIR + 'geoM2xy_{}.csv'.format(sample_name), delimiter=",");
#SM2xy[sample_name] = np.genfromtxt(DIR + "SM2xy_{}.csv".format(sample_name), delimiter=",");