-
Notifications
You must be signed in to change notification settings - Fork 0
/
loc_ramp_analysis.py
2337 lines (1926 loc) · 112 KB
/
loc_ramp_analysis.py
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
from matplotlib.patches import Patch
import itertools
import scipy
from scipy import stats
from scipy.stats import kde
from sklearn.linear_model import LinearRegression
import warnings
warnings.filterwarnings('ignore')
from matplotlib.pyplot import cm
from astropy.convolution import convolve, Gaussian1DKernel, Box1DKernel
def split_data_by_recording_day(data):
#split them into early and late sessions
sorted_days = np.sort(np.asarray(data.recording_day))
mid_point_day = sorted_days[int(len(sorted_days)/2)]
early_data = data[(data["recording_day"] < mid_point_day)]
late_data = data[(data["recording_day"] >= mid_point_day)]
return early_data, late_data
def get_tidy_title(collumn):
if collumn == "speed_score":
return "Speed Score"
elif collumn == "grid_score":
return "Grid Score"
elif collumn == "border_score":
return "Border Score"
elif collumn == "corner_score":
return "Corner Score"
elif collumn == "hd_score":
return "HD Score"
elif collumn == "ramp_score_out":
return "Ramp Score Outbound"
elif collumn == "ramp_score_home":
return "Ramp Score Homebound"
elif collumn == "ramp_score":
return "Ramp Score"
elif collumn == "abs_ramp_score":
return "Abs Ramp Score"
elif collumn == "max_ramp_score":
return "Max Ramp Score"
elif collumn == 'rayleigh_score':
return 'Rayleigh Score'
elif collumn == "rate_map_correlation_first_vs_second_half":
return "Spatial Stability"
elif collumn == "lm_result_b_outbound":
return "LM Outbound fit"
elif collumn == "lm_result_b_homebound":
return "LM Homebound fit"
elif collumn == "lmer_result_b_outbound":
return "LMER Outbound fit"
elif collumn == "lmer_result_b_homebound":
return "LMER Homebound fit"
elif collumn == "beaconed":
return "Beaconed"
elif collumn == "non-beaconed":
return "Non Beaconed"
elif collumn == "probe":
return "Probe"
elif collumn == "all":
return "All Trial Types"
elif collumn == "spike_ratio":
return "Spike Ratio"
elif collumn == "_cohort5":
return "C5"
elif collumn == "_cohort4":
return "C4"
elif collumn == "_cohort3":
return "C3"
elif collumn == "_cohort2":
return "C2"
elif collumn == "ThetaIndex_vr":
return "Theta Index VR"
elif collumn == "ThetaPower_vr":
return "Theta Power VR"
elif collumn == "ThetaIndex":
return "Theta Index"
elif collumn == "ThetaPower":
return "Theta Power"
elif collumn == 'best_theta_idx_vr':
return "Max Theta Index VR"
elif collumn == 'best_theta_idx_of':
return "Max Theta Index OF"
elif collumn == 'best_theta_idx_combined':
return "Max Theta Index VR+OF"
elif collumn == 'best_theta_pwr_vr':
return "Max Theta Power VR"
elif collumn == 'best_theta_pwr_of':
return "Max Theta Power OF"
elif collumn == 'best_theta_pwr_combined':
return "Max Theta Power VR+OF"
else:
print("collumn title not found!")
return collumn
def get_score_threshold(collumn):
if collumn == "speed_score":
return 0.18
elif collumn == "grid_score":
return 0.4
elif collumn == "border_score":
return 0.5
elif collumn == "corner_score":
return 0.5
elif collumn == "hd_score":
return 0.5
elif collumn == "rate_map_correlation_first_vs_second_half":
return None
def absolute_ramp_score(data):
absolute_ramp_scores = []
for index, row in data.iterrows():
row = row.to_frame().T.reset_index(drop=True)
ramp_score = row["ramp_score"].iloc[0]
absolute_ramp_scores.append(np.abs(ramp_score))
data["abs_ramp_score"] = absolute_ramp_scores
return data
def analyse_ramp_driver(data, trialtypes_linear_model):
ramp_driver=[]
for index, row in data.iterrows():
label= "None"
row = row.to_frame().T.reset_index(drop=True)
session_id = row.session_id.iloc[0]
cluster_id = row.cluster_id.iloc[0]
lm_cluster = trialtypes_linear_model[(trialtypes_linear_model.cluster_id == cluster_id) &
(trialtypes_linear_model.session_id == session_id)]
if len(lm_cluster) > 0:
if (lm_cluster.lm_result_b_outbound.iloc[0] == "Negative") or (lm_cluster.lm_result_b_outbound.iloc[0] == "Positive"): # significant on beaconed
if (lm_cluster.lm_result_nb_outbound.iloc[0] == "Negative") or (lm_cluster.lm_result_nb_outbound.iloc[0] == "Positive"): # significant on non_beaconed
label="PI"
elif (lm_cluster.lm_result_nb_outbound.iloc[0] == "None") : # not significant on non beaconed
label="Cue"
else:
print("if this prints then something is wrong")
else:
label="None"
else:
label=np.nan
ramp_driver.append(label)
data["ramp_driver"] = ramp_driver
return data
def get_p_text(p, ns=False):
if p is not None:
if p<0.0001:
return "****"
elif p<0.001:
return "***"
elif p<0.01:
return "**"
elif p<0.05:
return "*"
elif ns:
return "ns"
else:
return " "
else:
return " "
def lmer_result_color(lmer_result):
if lmer_result=="PA":
return ((211.0/255,118.0/255,255.0/255))
elif lmer_result=="PS":
return ((255.0/255,176.0/255,100.0/255))
elif lmer_result=="A":
return ((111.0/255, 172.0/255, 243.0/255))
elif lmer_result=="S":
return ((255.0/255,226.0/255,101.0/255))
elif lmer_result=="P":
return ((255.0/255,115.0/255,121.0/255))
elif lmer_result=="PSA":
return ((120.0/255,138.0/255,138.0/255))
elif lmer_result=="SA":
return ((153.0/255,220.0/255,97.0/255))
elif lmer_result=="None":
return ((216.0/255,216.0/255,216.0/255))
def lm_result_color(lm_result):
if lm_result=="None":
return "grey"
elif lm_result=="Negative":
return "red"
elif lm_result=="Positive":
return "blue"
def ramp_driver_color(ramp_driver):
if ramp_driver == "PI":
return "yellow"
elif ramp_driver == "Cue":
return "green"
elif ramp_driver == "None":
return "grey"
def max_ramp_score_label_color(max_ramp_score_label):
if max_ramp_score_label == "outbound":
return "cyan"
elif max_ramp_score_label == "homebound":
return "blue"
elif max_ramp_score_label == "full_track":
return "black"
else:
print("label color not found")
def cohort_mouse_label_color(cohort_mouse_label):
if cohort_mouse_label == "C2_1124":
return "C0"
elif cohort_mouse_label == "C2_245":
return "C1"
elif cohort_mouse_label == "C3_M1":
return "C2"
elif cohort_mouse_label == "C3_M6":
return "C3"
elif cohort_mouse_label == "C4_M2":
return "C4"
elif cohort_mouse_label == "C4_M3":
return "C5"
elif cohort_mouse_label == "C5_M1":
return "C6"
elif cohort_mouse_label == "C5_M2":
return "C7"
def label_collumn2color(data, label_collumn):
colors=[]
if (label_collumn == "lmer_result_homebound") or (label_collumn == "lmer_result_outbound"):
for i in range(len(data[label_collumn])):
colors.append(lmer_result_color(data[label_collumn].iloc[i]))
elif (label_collumn == "lm_result_b_homebound") or (label_collumn == "lm_result_b_outbound") or \
(label_collumn == "lm_result_p_homebound") or (label_collumn == "lm_result_p_outbound") or \
(label_collumn == "lm_result_nb_homebound") or (label_collumn == "lm_result_nb_outbound"):
for i in range(len(data[label_collumn])):
colors.append(lm_result_color(data[label_collumn].iloc[i]))
elif (label_collumn == "ramp_driver"):
for i in range(len(data[label_collumn])):
colors.append(ramp_driver_color(data[label_collumn].iloc[i]))
elif (label_collumn == "max_ramp_score_label"):
for i in range(len(data[label_collumn])):
colors.append(max_ramp_score_label_color(data[label_collumn].iloc[i]))
elif (label_collumn == "cohort_mouse"):
for i in range(len(data[label_collumn])):
colors.append(cohort_mouse_label_color(data[label_collumn].iloc[i]))
return colors
def simple_histogram(data, collumn, save_path=None, ramp_region=None, filter_by_slope=False):
fig, ax = plt.subplots(figsize=(6,6))
if ramp_region == "outbound":
collumn = 'ramp_score_o'
elif ramp_region == "homebound":
collumn = 'ramp_score_h'
PS = data[data.tetrode_location == "PS"]
MEC = data[data.tetrode_location == "MEC"]
PS_neg = PS[PS[collumn] < 0]
MEC_neg = MEC[MEC[collumn] < 0]
PS_pos = PS[PS[collumn] > 0]
MEC_pos = MEC[MEC[collumn] > 0]
p = stats.ks_2samp(np.asarray(PS_neg[collumn]), np.asarray(MEC_neg[collumn]))[1]
print("p =",p, "for negative slopes, ", get_p_text(p))
p = stats.ks_2samp(np.asarray(PS_pos[collumn]), np.asarray(MEC_pos[collumn]))[1]
print("p =",p, "for positive slopes, ", get_p_text(p))
p = stats.ks_2samp(np.asarray(PS[collumn]), np.asarray(MEC[collumn]))[1]
p_str = get_p_text(p, ns=True)
#print("p=", p)
ax.hist(np.asarray(PS_neg[collumn]), range=(-1, 1), bins=25, alpha=0.3, color="b", label="MEC", histtype="bar", density=True, cumulative=False, linewidth=4)
#density_PS_neg = kde.gaussian_kde(np.asarray(PS_neg[collumn]).astype(float)); x = np.linspace(-1,1,300); y=density_PS_neg(x); ax.plot(x,y, color="b");
ax.hist(np.asarray(MEC_neg[collumn]), range=(-1, 1), bins=25, alpha=0.3, color="r", label="MEC", histtype="bar", density=True, cumulative=False, linewidth=4)
#density_MEC_neg = kde.gaussian_kde(np.asarray(MEC_neg[collumn]).astype(float)); x = np.linspace(-1,1,300); y=density_MEC_neg(x); ax.plot(x,y, color="r");
ax.hist(np.asarray(PS_pos[collumn]), range=(-1, 1), bins=25, alpha=0.3, color="b", label="PS", histtype="bar", density=True, cumulative=False, linewidth=4)
#density_PS_pos = kde.gaussian_kde(np.asarray(PS_pos[collumn]).astype(float)); x = np.linspace(-1,1,300); y=density_PS_pos(x); ax.plot(x,y, color="b");
ax.hist(np.asarray(MEC_pos[collumn]), range=(-1, 1), bins=25, alpha=0.3, color="r", label="MEC", histtype="bar", density=True, cumulative=False, linewidth=4)
#density_MEC_pos = kde.gaussian_kde(np.asarray(MEC_pos[collumn]).astype(float)); x = np.linspace(-1,1,300); y=density_MEC_pos(x); ax.plot(x,y, color="r");
ax.set_ylabel("Density", fontsize=25)
collumn = "ramp_score"
ax.set_xlabel(get_tidy_title(collumn), fontsize=25)
if collumn == "ramp_score":
ax.set_xlim(left=-0.75, right=0.75)
ax.xaxis.set_major_locator(plt.MaxNLocator(3))
ax.tick_params(axis='both', which='major', labelsize=25)
ax.set_xlim(left=-1, right=1)
ax.set_xticks([-1, -0.5, 0, 0.5, 1])
plt.locator_params(axis='x', nbins=5)
plt.locator_params(axis='y', nbins=4)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
plt.subplots_adjust(left=0.2)
#ax.legend(loc="upper right")
ax.set_xlim(left=-1, right=1)
#plt.subplots_adjust(top=0.8)
ax.text(0.1, 0.9, p_str, ha='center', va='center', transform=ax.transAxes, fontsize=12)
if save_path is not None:
if filter_by_slope:
plt.savefig(save_path+"/FBS_location_histo_"+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
else:
plt.savefig(save_path+"/location_histo_"+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
return
def simple_boxplot(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, filter_by_slope=False):
fig, ax = plt.subplots(figsize=(6,3))
PS = data[data.tetrode_location == "PS"]
MEC = data[data.tetrode_location == "MEC"]
UN = data[data.tetrode_location == "UN"]
p = stats.ks_2samp(np.asarray(PS[collumn]), np.asarray(MEC[collumn]))[1]
p_str = get_p_text(p, ns=True)
#ax.text(0.1, 0.9, p_str, ha='center', va='center', transform=ax.transAxes, fontsize=12)
ax.set_title("rr= "+ramp_region+", tt= "+trial_type +", p="+p_str, fontsize=12)
ax.set_title(p_str, fontsize=20)
objects = ("PS", "MEC", "UN")
objects = ("PS", "MEC")
y_pos = np.arange(len(objects))
boxprops = dict(linewidth=3, color='k')
medianprops = dict(linewidth=3, color='k')
capprops = dict(linewidth=3, color='k')
whiskerprops = dict(linewidth=3, color='k')
bplot1 = ax.boxplot(np.asarray(PS[collumn]), positions = [0], widths=0.9,
boxprops=boxprops, medianprops=medianprops,
whiskerprops=whiskerprops, capprops=capprops, patch_artist=True, vert=False)
bplot2 = ax.boxplot(np.asarray(MEC[collumn]), positions = [1], widths=0.9,
boxprops=boxprops, medianprops=medianprops,
whiskerprops=whiskerprops, capprops=capprops, patch_artist=True, vert=False)
#bplot3 = ax.boxplot(np.asarray(UN[collumn]), positions = [2], widths=0.9,
# boxprops=boxprops, medianprops=medianprops,
# whiskerprops=whiskerprops, capprops=capprops, patch_artist=True)
# fill with colors
colors = ['b', 'r', 'grey']
colors = ['b', 'r']
i=0
#for bplot in (bplot1, bplot2, bplot3):
for bplot in (bplot1, bplot2):
for patch, color in zip(bplot['boxes'], colors):
patch.set_facecolor(colors[i])
i+=1
#ax.text(0.95, 1.25, "p= "+str(np.round(p, decimals=4)), ha='right', va='top', transform=ax.transAxes, fontsize=20)
plt.yticks(y_pos, objects, fontsize=25)
plt.xlabel(get_tidy_title(collumn), fontsize=25)
plt.ylim((-1,3))
plt.ylim((-0.75,1.5))
if collumn == "ramp_score":
ax.set_xlim(left=-1, right=1)
#plt.axvline(x=-1, ymax=1, ymin=0, linewidth=3, color="k")
#plt.axhline(y=0, xmin=-1, xmax=2, linewidth=3, color="k")
#plt.title('Programming language usage')
#ax.legend()
ax.tick_params(axis='both', which='major', labelsize=25)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
if filter_by_slope:
plt.savefig(save_path+"/FBS_location_boxplot_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
else:
plt.savefig(save_path+"/location_boxplot_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def simple_bar_mouse(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False, filter_by_slope=False):
fig, ax = plt.subplots(figsize=(5, 4.2))
p_str = get_p_text(p, ns=True)
objects = np.unique(data["cohort_mouse"])
x_pos = np.arange(len(objects))
use_color_cycle=True
cycle_colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
for i in range(len(objects)):
y = data[(data["cohort_mouse"] == objects[i])]
if use_color_cycle:
ax.errorbar(x_pos[i], np.mean(np.asarray(y[collumn])), yerr=stats.sem(np.asarray(y[collumn])), ecolor=cycle_colors[i], capsize=10, fmt="o", color=cycle_colors[i])
ax.scatter(x_pos[i]*np.ones(len(np.asarray(y[collumn]))), np.asarray(y[collumn]), edgecolor=cycle_colors[i], marker="o", facecolors='none')
else:
ax.errorbar(x_pos[i], np.mean(np.asarray(y[collumn])), yerr=stats.sem(np.asarray(y[collumn])), ecolor='black', capsize=10, fmt="o", color="black")
ax.scatter(x_pos[i]*np.ones(len(np.asarray(y[collumn]))), np.asarray(y[collumn]), edgecolor="black", marker="o", facecolors='none')
plt.xticks(x_pos, objects, fontsize=8)
plt.xticks(rotation=-45)
plt.locator_params(axis='y', nbins=4)
plt.ylabel(get_tidy_title(collumn), fontsize=20)
plt.xlim((-0.5, len(objects)-0.5))
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
if filter_by_slope:
plt.savefig(save_path+"/FBS_mouse_bar_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
else:
plt.savefig(save_path+"/mouse_bar_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def simple_bar_location(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False, filter_by_slope=False):
fig, ax = plt.subplots(figsize=(3,6.5))
p_str = get_p_text(p, ns=True)
#ax.set_title("rr= "+ramp_region+", tt= "+trial_type +", p="+p_str, fontsize=12)
objects = np.unique(data["tetrode_location"])
x_pos = np.arange(len(objects))
for i in range(len(objects)):
y = data[(data["tetrode_location"] == objects[i])]
ax.errorbar(x_pos[i], np.mean(np.asarray(y[collumn])), yerr=stats.sem(np.asarray(y[collumn])), ecolor='black', capsize=10, fmt="o", color="black")
ax.scatter(x_pos[i]*np.ones(len(np.asarray(y[collumn]))), np.asarray(y[collumn]), edgecolor="black", marker="o", facecolors='none')
#ax.bar(x_pos[i], np.mean(np.asarray(y[collumn])), yerr=stats.sem(np.asarray(y[collumn])), align='center', alpha=0.5, ecolor='black', capsize=10)
#ax.text(0.95, 1, p_str, ha='left', va='top', transform=ax.transAxes, fontsize=20)
plt.xticks(x_pos, objects, fontsize=8)
plt.xticks(rotation=-45)
plt.ylabel(get_tidy_title(collumn), fontsize=20)
plt.locator_params(axis='y', nbins=4)
plt.xlim((-0.5, len(objects)-0.5))
#if collumn == "ramp_score":
# plt.ylim(-0.6, 0.6)
#elif collumn == "abs_ramp_score":
# plt.ylim(0, 0.6)
#plt.axvline(x=-1, ymax=1, ymin=0, linewidth=3, color="k")
#plt.axhline(y=0, xmin=-1, xmax=2, linewidth=3, color="k")
#plt.title('Programming language usage')
#ax.legend()
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
if filter_by_slope:
plt.savefig(save_path+"/FBS_location_bar_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
else:
plt.savefig(save_path+"/location_bar_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def simple_lm_stack_mouse(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False):
fig, ax = plt.subplots(figsize=(3,6))
#p_str = get_p_text(p, ns=True)
#ax.set_title("rr= "+ramp_region+", tt= "+trial_type +", p="+p_str, fontsize=12)
aggregated = data.groupby([collumn, "cohort_mouse"]).count().reset_index()
if (collumn == "lm_result_hb") or (collumn == "lm_result_ob"):
colors_lm = [((238.0/255,58.0/255,140.0/255)), ((102.0/255,205.0/255,0.0/255)), "black", "grey"]
groups = ["Negative", "Positive", "None", "NoSlope"]
elif (collumn == "ramp_driver"):
colors_lm = ["grey", "green", "yellow"]
groups = [ "None", "PI", "Cue"]
else:
colors_lm = ["lightgrey", "lightslategray", "limegreen", "violet", "orange",
"cornflowerblue", "yellow", "lightcoral"]
groups = ["P", "S", "A", "PS", "PA", "SA", "PSA", "None"]
groups = ["None", "PSA", "SA", "PA", "PS", "A", "S", "P"]
objects = np.unique(aggregated["cohort_mouse"])
x_pos = np.arange(len(objects))
for object, x in zip(objects, x_pos):
tetrode_location = aggregated[aggregated["cohort_mouse"] == object]
bottom=0
for color, group in zip(colors_lm, groups):
count = tetrode_location[(tetrode_location[collumn] == group)]["Unnamed: 0"]
if len(count)==0:
count = 0
else:
count = int(count)
percent = (count/np.sum(tetrode_location["Unnamed: 0"]))*100
ax.bar(x, percent, bottom=bottom, color=color, edgecolor=color)
bottom = bottom+percent
#ax.text(0.95, 1, p_str, ha='left', va='top', transform=ax.transAxes, fontsize=20)
plt.xticks(x_pos, objects, fontsize=8)
plt.xticks(rotation=-45)
plt.ylabel("Percent of neurons", fontsize=20)
plt.xlim((-0.5, len(objects)-0.5))
#plt.axvline(x=-1, ymax=1, ymin=0, linewidth=3, color="k")
#plt.axhline(y=0, xmin=-1, xmax=2, linewidth=3, color="k")
#plt.title('Programming language usage')
#ax.legend()
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
plt.savefig(save_path+"/mouse_slope_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def simple_lm_stack(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False):
fig, ax = plt.subplots(figsize=(3,6))
data = data[(data["tetrode_location"] != "V1")]
#p_str = get_p_text(p, ns=True)
#ax.set_title("rr= "+ramp_region+", tt= "+trial_type +", p="+p_str, fontsize=12)
aggregated = data.groupby([collumn, "tetrode_location"]).count().reset_index()
if (collumn == "lm_result_hb") or (collumn == "lm_result_ob"):
colors_lm = [((238.0/255,58.0/255,140.0/255)), ((102.0/255,205.0/255,0.0/255)), "black"]
groups = ["Negative", "Positive", "Unclassified"]
elif (collumn == "ramp_driver"):
colors_lm = ["grey", "green", "yellow"]
groups = [ "None", "PI", "Cue"]
else:
colors_lm = ["lightgrey", "lightslategray", "limegreen", "violet", "orange",
"cornflowerblue", "yellow", "lightcoral"]
groups = ["P", "S", "A", "PS", "PA", "SA", "PSA", "None"]
groups = ["None", "PSA", "SA", "PA", "PS", "A", "S", "P"]
colors_lm = [lmer_result_color(c) for c in groups]
objects = np.unique(aggregated["tetrode_location"])
x_pos = np.arange(len(objects))
for object, x in zip(objects, x_pos):
tetrode_location = aggregated[aggregated["tetrode_location"] == object]
bottom=0
for color, group in zip(colors_lm, groups):
count = tetrode_location[(tetrode_location[collumn] == group)]["Unnamed: 0"]
if len(count)==0:
count = 0
else:
count = int(count)
percent = (count/np.sum(tetrode_location["Unnamed: 0"]))*100
ax.bar(x, percent, bottom=bottom, color=color, edgecolor=color)
bottom = bottom+percent
#ax.text(0.95, 1, p_str, ha='left', va='top', transform=ax.transAxes, fontsize=20)
plt.xticks(x_pos, objects, fontsize=8)
plt.xticks(rotation=-45)
plt.ylabel("Percent of neurons", fontsize=25)
plt.xlim((-0.5, len(objects)-0.5))
plt.ylim((0,100))
#plt.axvline(x=-1, ymax=1, ymin=0, linewidth=3, color="k")
#plt.axhline(y=0, xmin=-1, xmax=2, linewidth=3, color="k")
#plt.title('Programming language usage')
#ax.legend()
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
plt.savefig(save_path+"/location_slope_"+"_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def add_theta_modulated_marker(data, threshold=0.07):
ThetaIndexLabel = []
for index, row in data.iterrows():
row = row.to_frame().T.reset_index(drop=True)
ThetaIndex = row["ThetaIndex"].iloc[0]
if ThetaIndex> threshold:
binary = "TR"
else:
binary = "NR"
ThetaIndexLabel.append(binary)
data["ThetaIndexLabel"] = ThetaIndexLabel
return data
def simple_lm_stack_theta(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False):
# were only interested in the postive and negative sloping neurons when looking at the proportions of lmer neurons
if (collumn == "lmer_result_ob"):
data = data[(data["lm_result_ob"] == "Positive") | (data["lm_result_ob"] == "Negative")]
elif (collumn == "lmer_result_hb"):
data = data[(data["lm_result_hb"] == "Positive") | (data["lm_result_hb"] == "Negative")]
fig, ax = plt.subplots(figsize=(3,6))
data = add_theta_modulated_marker(data)
aggregated = data.groupby([collumn, "ThetaIndexLabel"]).count().reset_index()
if (collumn == "lm_result_hb") or (collumn == "lm_result_ob"):
colors_lm = [((238.0/255,58.0/255,140.0/255)), ((102.0/255,205.0/255,0.0/255)), "black"]
groups = ["Negative", "Positive", "Unclassified"]
elif (collumn == "ramp_driver"):
colors_lm = ["grey", "green", "yellow"]
groups = [ "None", "PI", "Cue"]
else:
groups = ["None", "PSA", "SA", "PA", "PS", "A", "S", "P"]
colors_lm = [lmer_result_color(c) for c in groups]
objects = np.unique(aggregated["ThetaIndexLabel"])
x_pos = np.arange(len(objects))
for object, x in zip(objects, x_pos):
ThetaIndexLabel = aggregated[aggregated["ThetaIndexLabel"] == object]
bottom=0
for color, group in zip(colors_lm, groups):
count = ThetaIndexLabel[(ThetaIndexLabel[collumn] == group)]["ThetaIndex"]
if len(count)==0:
count = 0
else:
count = int(count)
print("stack_theta, ramp_region=", ramp_region, " , group=", group, ", theta=", object, "count=", count)
percent = (count/np.sum(ThetaIndexLabel["ThetaIndex"]))*100
ax.bar(x, percent, bottom=bottom, color=color, edgecolor=color)
bottom = bottom+percent
#ax.text(0.95, 1, p_str, ha='left', va='top', transform=ax.transAxes, fontsize=20)
plt.xticks(x_pos, objects, fontsize=15)
#plt.xticks(rotation=-45)
plt.ylabel("Percent of neurons", fontsize=25)
plt.xlim((-0.5, len(objects)-0.5))
plt.ylim((0,100))
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=25)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
plt.savefig(save_path+"/ThetaIndexLabel_stack_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def simple_lm_stack_negpos(data, collumn, save_path=None, ramp_region=None, trial_type=None, p=None, print_p=False):
# were only interested in the postive and negative sloping neurons when looking at the proportions of lmer neurons
if (collumn == "lmer_result_ob"):
data = data[(data["lm_result_ob"] == "Positive") | (data["lm_result_ob"] == "Negative")]
lm_collumn = "lm_result_ob"
elif (collumn == "lmer_result_hb"):
data = data[(data["lm_result_hb"] == "Positive") | (data["lm_result_hb"] == "Negative")]
lm_collumn = "lm_result_hb"
fig, ax = plt.subplots(figsize=(3,6))
aggregated = data.groupby([collumn, lm_collumn]).count().reset_index()
if (collumn == "lm_result_hb") or (collumn == "lm_result_ob"):
colors_lm = [((238.0/255,58.0/255,140.0/255)), ((102.0/255,205.0/255,0.0/255)), "black"]
groups = ["Negative", "Positive", "Unclassified"]
elif (collumn == "ramp_driver"):
colors_lm = ["grey", "green", "yellow"]
groups = [ "None", "PI", "Cue"]
else:
groups = ["None", "PSA", "SA", "PA", "PS", "A", "S", "P"]
colors_lm = [lmer_result_color(c) for c in groups]
objects = np.unique(aggregated[lm_collumn])
x_pos = np.arange(len(objects))
for object, x in zip(objects, x_pos):
ThetaIndexLabel = aggregated[aggregated[lm_collumn] == object]
bottom=0
for color, group in zip(colors_lm, groups):
count = ThetaIndexLabel[(ThetaIndexLabel[collumn] == group)]["ThetaIndex"]
if len(count)==0:
count = 0
else:
count = int(count)
print("stack_theta, ramp_region=", ramp_region, " , group=", group, ", theta=", object, "count=", count)
percent = (count/np.sum(ThetaIndexLabel["ThetaIndex"]))*100
ax.bar(x, percent, bottom=bottom, color=color, edgecolor=color)
ax.text(x,bottom, str(count), color="k", fontsize=10)
bottom = bottom+percent
#ax.text(0.95, 1, p_str, ha='left', va='top', transform=ax.transAxes, fontsize=20)
plt.xticks(x_pos, objects, fontsize=15)
#plt.xticks(rotation=-45)
plt.ylabel("Percent of neurons", fontsize=25)
plt.xlim((-0.5, len(objects)-0.5))
plt.ylim((0,100))
if print_p:
print(p)
ax.tick_params(axis='both', which='major', labelsize=25)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
if save_path is not None:
plt.savefig(save_path+"/negpos_stack_tt_"+trial_type+"_rr_"+ramp_region+"_"+collumn+".png", dpi=300)
plt.show()
plt.close()
def add_locations(df, tetrode_locations_df):
data = pd.DataFrame()
for index, df_row in df.iterrows():
df_row = df_row.to_frame().T.reset_index(drop=True)
session_id_datetime = df_row.session_id_datetime.iloc[0]
print("processing, ", session_id_datetime)
session_tetrode_info = tetrode_locations_df[(tetrode_locations_df.session_id == session_id_datetime)]
df_row["tetrode_location"] = session_tetrode_info.estimated_location.iloc[0]
data = pd.concat([data, df_row], ignore_index=True)
return data
def add_short_session_id(df):
data = pd.DataFrame()
for index, row in df.iterrows():
row = row.to_frame().T.reset_index(drop=True)
session_id_datetime = row.session_id.iloc[0]
session_id_date = "_".join(session_id_datetime.split("_")[0:3])
row["session_id_date"] = session_id_date
row["session_id_datetime"] = session_id_datetime
data = pd.concat([data, row], ignore_index=True)
return data
def add_theta(data, theta_df):
data_new = pd.DataFrame()
for index, row in data.iterrows():
row = row.to_frame().T.reset_index(drop=True)
session_id = row.session_id.iloc[0]
cluster_id = row.cluster_id.iloc[0]
thetaIdx = theta_df[(theta_df.session_id == session_id) & (theta_df.cluster_id == cluster_id)].iloc[0].ThetaIndex
thetaPwr = theta_df[(theta_df.session_id == session_id) & (theta_df.cluster_id == cluster_id)].iloc[0].ThetaPower
Boccara_theta_class = theta_df[(theta_df.session_id == session_id) & (theta_df.cluster_id == cluster_id)].iloc[0].Boccara_theta_class
row["ThetaIndex"] = thetaIdx
row["ThetaPower"] = thetaPwr
row["Boccara_theta_class"] = Boccara_theta_class
data_new = pd.concat([data_new, row], ignore_index=True)
print("I matched ", len(data_new)/len(data)*100, "% of cells with a theta index")
return data_new
def add_lm(data, linear_model_df):
data_new = pd.DataFrame()
outbound_specific_data = linear_model_df.iloc[0::3, :]
homebound_specific_data = linear_model_df.iloc[1::3, :]
for index, row in data.iterrows():
row = row.to_frame().T.reset_index(drop=True)
session_id = row.session_id.iloc[0]
cluster_id = row.cluster_id.iloc[0]
if len(linear_model_df[(linear_model_df.session_id == session_id) & (linear_model_df.cluster_id == cluster_id)])>0:
lm_result_ob = linear_model_df[(linear_model_df.session_id == session_id) & (linear_model_df.cluster_id == cluster_id)].iloc[0].lm_group_b
lm_result_hb = linear_model_df[(linear_model_df.session_id == session_id) & (linear_model_df.cluster_id == cluster_id)].iloc[0].lm_group_b_h
lmer_result_ob = linear_model_df[(linear_model_df.session_id == session_id) & (linear_model_df.cluster_id == cluster_id)].iloc[0].final_model_o_b
lmer_result_hb = linear_model_df[(linear_model_df.session_id == session_id) & (linear_model_df.cluster_id == cluster_id)].iloc[0].final_model_h_b
ramp_score_ob = outbound_specific_data[(outbound_specific_data.session_id == session_id) & (outbound_specific_data.cluster_id == cluster_id)].iloc[0].ramp_score
ramp_score_hb = homebound_specific_data[(homebound_specific_data.session_id == session_id) & (homebound_specific_data.cluster_id == cluster_id)].iloc[0].ramp_score
ramp_score_ob = float(ramp_score_ob.replace(',', '.'))
ramp_score_hb = float(ramp_score_hb.replace(',', '.'))
else:
lm_result_hb = np.nan
lm_result_ob = np.nan
lmer_result_ob = np.nan
lmer_result_hb = np.nan
ramp_score_ob = np.nan
ramp_score_hb = np.nan
row["lm_result_hb"] = lm_result_hb
row["lm_result_ob"] = lm_result_ob
row["lmer_result_ob"] = lmer_result_ob
row["lmer_result_hb"] = lmer_result_hb
row["ramp_score_o"] = ramp_score_ob
row["ramp_score_h"]= ramp_score_hb
data_new = pd.concat([data_new, row], ignore_index=True)
# drop the collumns without a classifications, these were dropped for not passing behavioural criteria
data_new = data_new.dropna(subset =["lm_result_hb"])
return data_new
def mouse_ramp(data, collumn, save_path, ramp_region="outbound", trial_type="beaconed", print_p=False, filter_by_slope=False):
if filter_by_slope:
if ramp_region == "outbound":
data = data[(data.lm_result_ob == "Positive") | (data.lm_result_ob == "Negative")]
elif ramp_region == "homebound":
data = data[(data.lm_result_hb == "Positive") | (data.lm_result_hb == "Negative")]
elif ramp_region == "all":
data = data[(data.lm_result_ob == "Positive") | (data.lm_result_ob == "Negative") |
(data.lm_result_hb == "Positive") | (data.lm_result_hb == "Negative")]
# only look at beacoend and outbound
data = data[(data.trial_type == trial_type) &
(data.ramp_region == ramp_region)]
simple_histogram(data, collumn, save_path, ramp_region=ramp_region, trial_type=trial_type, p=None, filter_by_slope=filter_by_slope)
#simple_boxplot(data, collumn, save_path, ramp_region=ramp_region, trial_type=trial_type, p=None, filter_by_slope=filter_by_slope)
simple_bar_mouse(data, collumn, save_path, ramp_region=ramp_region, trial_type=trial_type, p=None, print_p=print_p, filter_by_slope=filter_by_slope)
return
def location_ramp(data, collumn, save_path, ramp_region="outbound", filter_by_slope=True):
if filter_by_slope:
if ramp_region == "outbound":
data = data[(data.lm_result_ob == "Positive") | (data.lm_result_ob == "Negative")]
elif ramp_region == "homebound":
data = data[(data.lm_result_hb == "Positive") | (data.lm_result_hb == "Negative")]
simple_histogram(data, collumn, save_path, ramp_region=ramp_region, filter_by_slope=filter_by_slope)
return
def mouse_slope(data, collumn, save_path, ramp_region="outbound", trial_type="beaconed", print_p=False):
data = data[(data[collumn] != np.nan)]
# only look at beacoend and outbound
data = data[(data.trial_type == trial_type) &
(data.ramp_region == ramp_region)]
simple_lm_stack_mouse(data, collumn, save_path, ramp_region=ramp_region, trial_type=trial_type, p=None)
def location_slope(data, collumn, save_path, ramp_region="outbound", trial_type="beaconed", print_p=False):
data = data[(data[collumn] != np.nan)]
# were only interested in the postive and negative sloping neurons when looking at the proportions of lmer neurons
if (collumn == "lmer_result_ob"):
data = data[(data["lm_result_ob"] == "Positive") | (data["lm_result_ob"] == "Negative")]
elif (collumn == "lmer_result_hb"):
data = data[(data["lm_result_hb"] == "Positive") | (data["lm_result_hb"] == "Negative")]
# only look at beacoend and outbound
data = data[(data.trial_type == trial_type) &
(data.ramp_region == ramp_region)]
simple_lm_stack(data, collumn, save_path, ramp_region=ramp_region, trial_type=trial_type, p=None)
def cue_theta_location_hist(data, save_path):
data = data[(data.trial_type == "all") & (data.ramp_region == "outbound")]
PS_cue_d = data[(data.tetrode_location == "PS") & (data.ramp_driver == "Cue")]
PS_cue_i = data[(data.tetrode_location == "PS") & (data.ramp_driver == "PI")]
MEC_d = data[(data.tetrode_location == "MEC") & (data.ramp_driver == "Cue")]
MEC_i = data[(data.tetrode_location == "MEC") & (data.ramp_driver == "PI")]
fig, ax = plt.subplots(figsize=(6,6))
ax.hist(np.asarray(PS_cue_d["ThetaIndex"]), bins=1000, alpha=0.5, color="y", label="MEC", histtype="step", density=True, cumulative=True, linewidth=2)
ax.hist(np.asarray(PS_cue_i["ThetaIndex"]), bins=1000, alpha=0.5, color="g", label="PS", histtype="step", density=True, cumulative=True, linewidth=2)
ax.set_ylabel("Cumulative Density", fontsize=15)
ax.set_xlabel("Theta Index", fontsize=15)
ax.set_xlim(left=-0.1, right=0.4)
#ax.xaxis.set_major_locator(plt.MaxNLocator(3))
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
#plt.subplots_adjust(left=0.2, right=0.6, top=0.8, bottom=0.2)
#ax.legend(loc="upper right")
plt.savefig(save_path+"/cue_theta_location_hist_PS.png", dpi=300)
plt.show()
plt.close()
print("PS p= ", stats.ks_2samp(np.asarray(PS_cue_d["ThetaIndex"]), np.asarray(PS_cue_i["ThetaIndex"]))[1])
fig, ax = plt.subplots(figsize=(6,6))
ax.hist(np.asarray(MEC_d["ThetaIndex"]), bins=1000, alpha=0.5, color="y", label="MEC", histtype="step", density=True, cumulative=True, linewidth=2)
ax.hist(np.asarray(MEC_i["ThetaIndex"]), bins=1000, alpha=0.5, color="g", label="PS", histtype="step", density=True, cumulative=True, linewidth=2)
ax.set_ylabel("Cumulative Density", fontsize=15)
ax.set_xlabel("Theta Index", fontsize=15)
ax.set_xlim(left=-0.1, right=0.4)
#ax.xaxis.set_major_locator(plt.MaxNLocator(3))
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
#plt.subplots_adjust(left=0.2, right=0.6, top=0.8, bottom=0.2)
#ax.legend(loc="upper right")
plt.savefig(save_path+"/cue_theta_location_hist_MEC.png", dpi=300)
plt.show()
plt.close()
print("MEC, p= ", stats.ks_2samp(np.asarray(MEC_d["ThetaIndex"]), np.asarray(MEC_i["ThetaIndex"]))[1])
return
def cue_theta_location_bar(data, save_path):
fig, ax = plt.subplots(figsize=(6,6))
PS_cue_d = data[(data.tetrode_location == "PS") & (data.ramp_driver == "Cue")]
PS_cue_i = data[(data.tetrode_location == "PS") & (data.ramp_driver == "PI")]
MEC_d = data[(data.tetrode_location == "MEC") & (data.ramp_driver == "Cue")]
MEC_i = data[(data.tetrode_location == "MEC") & (data.ramp_driver == "PI")]
objects = ("PS|CD", "PS|CI", "MEC|CD", "MEC|CI")
x_pos = [0, 2, 4, 6]
ax.bar(x_pos, [np.mean(np.asarray(PS_cue_d["ThetaIndex"])),
np.mean(np.asarray(PS_cue_i["ThetaIndex"])),
np.mean(np.asarray(MEC_d["ThetaIndex"])),
np.mean(np.asarray(MEC_i["ThetaIndex"]))],
yerr= [stats.sem(np.asarray(PS_cue_d["ThetaIndex"])),
stats.sem(np.asarray(PS_cue_i["ThetaIndex"])),
stats.sem(np.asarray(MEC_d["ThetaIndex"])),
stats.sem(np.asarray(MEC_i["ThetaIndex"]))],
align='center',
alpha=0.5,
ecolor='black',
capsize=10,
color =['b', 'r', 'b', 'r'])
print("p = ", stats.ttest_ind(np.asarray(MEC_d["ThetaIndex"]),
np.asarray(MEC_i["ThetaIndex"]))[1])
plt.xticks(x_pos, objects, fontsize=15)
plt.ylabel("Theta Index", fontsize=20)
plt.xlim((-1,7))
#plt.axvline(x=-1, ymax=1, ymin=0, linewidth=3, color="k")
#plt.axhline(y=0, xmin=-1, xmax=2, linewidth=3, color="k")
ax.tick_params(axis='both', which='major', labelsize=20)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.tight_layout()
plt.savefig(save_path+"/theta_cue_location.png", dpi=300)
plt.show()
plt.close()
def get_day(full_session_id):
session_id = full_session_id.split("/")[-1]
training_day = session_id.split("_")[1]
training_day = training_day.split("D")[1]
training_day = ''.join(filter(str.isdigit, training_day))
return int(training_day)
def get_year(session_id):
for i in range(11, 30):
if "20"+str(i) in session_id:
return "20"+str(i)
def get_suedo_day(full_session_id):
session_id = full_session_id.split("/")[-1]
year = get_year(session_id)
tmp = session_id.split(year)
month = tmp[1].split("-")[1]
day = tmp[1].split("-")[2].split("_")[0]
return(int(year+month+day)) # this ruturns a useful number in terms of the order of recordings
def get_cohort(full_session_id):
if "Cohort7_october2020" in full_session_id:
return "C7"
elements = full_session_id.split("/")
for i in range(len(elements)):
if "cohort" in elements[i]:
return elements[i]
def get_mouse(session_id):
return session_id.split("_")[0]
def get_cohort_mouse(full_session_id):
session_id = full_session_id.split("/")[-1]
mouse = get_mouse(session_id)
cohort_tmp = get_cohort(full_session_id)
cohort = get_tidy_title(cohort_tmp)
return cohort+"_"+mouse