-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMice_callibration_plotter.py
More file actions
79 lines (65 loc) · 2.57 KB
/
Mice_callibration_plotter.py
File metadata and controls
79 lines (65 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 5 10:48:35 2019
@author: Administrator
Scrip to read any txt file organized in columns
"""
import math
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#%% Load the dataset
# The user choose the txt file
# Quality control passed data in TPM (Transcripts per Million)
#data_file = r'C:\MATLAB_FOLDER\Light Display\Exp_data\161207mk_calibration20.txt'
data_file = r'U:\fromNeel\28_05_2021_neel_TestManualBallRotation_turns_during_40s_1min_recording_acw_21.txt'
dataset = pd.read_csv(data_file,sep='\t',header=0, index_col =None)
#%% Fixed Parameters
ball_radius = 3 # (in mm)
ball_circumference = 2 * math.pi * ball_radius
#%% User Parameters
variable = dataset.firstposy
#variable = dataset.secondposy
derivative = np.gradient(variable)
number_of_rotations = 22 # Change this number accordingly
turning_time = 60 #in seconds
#%% Variable Parameters
maximum_distance = np.amax(variable)
distance_per_rotation = maximum_distance/(number_of_rotations)
convertion_factor = ball_circumference/distance_per_rotation
first_data_point = variable[1000:].loc[variable[1000:] != 0].index[0]
last_data_point = variable.loc[variable == maximum_distance].index[0]
duration_turnings = last_data_point - first_data_point
sampling_rate = duration_turnings/turning_time
print('FIRST data point at frame number: ', first_data_point)
print('LAST data point at frame number: ', last_data_point)
print('DURATION of recording in frames: ', duration_turnings)
print('SAMPLING RATE was: ', sampling_rate)
print('Maximum distance: ', maximum_distance)
print('Conversion factor: ', convertion_factor)
#%% Plotting
plt.figure()
plt.plot(derivative,label='slope of the turns')
plt.plot(variable, label='ball turning')
plt.legend()
plt.show()
#%% Variability calculation for triades
# a = 0.2466
# b = 0.2953
# c = 0.2553
# my_list = [a,b,c]
# #d = 0.2523
# #e = 0.2470
# #f = 0.2314
# #g = 0.2257
# #h = 0.2261
# #i = 0.2559
# #my_list = [a,b,c,d,e,f,g,h,i]
# np.mean(my_list)
# np.std(my_list)
# percentatge_of_variation_to_max = ((np.amax(my_list)-np.mean(my_list)) * 100) /np.mean(my_list)
# percentatge_of_variation_to_min = (((np.amin(my_list)-np.mean(my_list)) * 100) /np.mean(my_list))*-1
# print('----------------------------------------------------------------------------------------------')
# print('The mean+- std is: ',np.mean(my_list), '+/-',np.std(my_list))
# print('The % to the max: ',percentatge_of_variation_to_max)
# print('The % to the min: ',percentatge_of_variation_to_min)