@@ -36,7 +36,6 @@ def get_all_sess_with_ME():
3636 return eids
3737
3838
39-
4039def get_repeated_sites ():
4140 one = ONE ()
4241 STR_QUERY = 'probe_insertion__session__project__name__icontains,ibl_neuropixel_brainwide_01,' \
@@ -512,7 +511,7 @@ def get_licks(XYs):
512511 return sorted (list (set .union (* licks )))
513512
514513
515- def plot_licks (eid , combine = False ):
514+ def plot_licks (eid , combine = True ):
516515
517516 '''
518517 lick PSTH
@@ -550,6 +549,9 @@ def plot_licks(eid, combine=False):
550549 start_idx = find_nearest (t ,d [i ][0 ])
551550 end_idx = start_idx + int (d [i ][1 ]/ T_BIN )
552551
552+ if end_idx > len (D ):
553+ break
554+
553555 # split by feedback type)
554556 if d [i ][5 ] == 1 :
555557 licks_pos .append (D [start_idx :end_idx ])
@@ -576,19 +578,30 @@ def plot_licks(eid, combine=False):
576578
577579
578580
579- def lick_raster (eid ):
581+ def lick_raster (eid , combine = True ):
580582
581583 #plt.figure(figsize=(4,4))
582584
583585 T_BIN = 0.02
584586 rt = 2
585587 st = - 0.5
586- times , XYs = get_dlc_XYs (eid , 'left' )
587- lick_times = times [get_licks (XYs )]
588588
589+ if combine :
590+ # combine licking events from left and right cam
591+ lick_times = []
592+ for video_type in ['right' ,'left' ]:
593+ times , XYs = get_dlc_XYs (eid , video_type )
594+ lick_times .append (times [get_licks (XYs )])
595+
596+ lick_times = sorted (np .concatenate (lick_times ))
597+
598+ else :
599+ times , XYs = get_dlc_XYs (eid , 'left' )
600+ lick_times = times [get_licks (XYs )]
601+
589602 R , t , _ = bincount2D (lick_times , np .ones (len (lick_times )), T_BIN )
590- D = R [0 ]
591-
603+ D = R [0 ]
604+
592605 # that's centered at feedback time
593606 d = constant_reaction_time (eid , rt , st ,stype = 'feedback' )
594607
@@ -599,7 +612,10 @@ def lick_raster(eid):
599612
600613 start_idx = find_nearest (t ,d [i ][0 ])
601614 end_idx = start_idx + int (d [i ][1 ]/ T_BIN )
602-
615+
616+ if end_idx > len (D ):
617+ break
618+
603619 # split by feedback type)
604620 if d [i ][5 ] == 1 :
605621 licks_pos .append (D [start_idx :end_idx ])
@@ -707,7 +723,7 @@ def get_sniffs(XYs):
707723 return sniffs
708724
709725
710- def plot_sniffPSTH (eid ,combine = False ):
726+ def plot_sniffPSTH (eid , combine = False ):
711727
712728 '''
713729 sniff PSTH
@@ -1124,7 +1140,7 @@ def plot_all(eid):
11241140 nrows = 2
11251141 ncols = 4
11261142
1127- plt .ioff ()
1143+ # plt.ioff()
11281144
11291145 plt .figure (figsize = (15 ,10 ))
11301146
@@ -1134,6 +1150,7 @@ def plot_all(eid):
11341150 add_panel_letter (k )
11351151 try :
11361152 panels [panel ](eid )
1153+ #continue
11371154 except :
11381155 ax = plt .gca ()
11391156 plt .text (.5 , .5 ,f'error in \n { panel } ' ,color = 'r' ,fontweight = 'bold' ,
@@ -1152,38 +1169,43 @@ def plot_all(eid):
11521169 p = one .path_from_eid (eid )
11531170 s1 = ' ' .join ([str (p ).split ('/' )[i ] for i in [4 ,6 ,7 ,8 ]])
11541171
1155- qcs = ['task' ,'videoLeft' ,'videoRight' ,'videoBody' ,
1156- 'dlcLeft' ,'dlcRight' ,'dlcBody' ,'behavior' ]
1172+ dlc_qcs = [ 'time_trace_length_match' ,
1173+ 'trace_all_nan' ,
1174+ 'mean_in_bbox' ,
1175+ 'pupil_blocked' ,
1176+ 'lick_detection' ]
1177+
1178+
1179+ qcs = ['task' ,'behavior' ,'videoLeft' ,'videoRight' ,'videoBody' ,
1180+ 'dlcLeft' ,'dlcRight' ,'dlcBody' ]
11571181
11581182 l = []
11591183 for q in qcs :
11601184 try :
1161- l .append (q + ':' + str (det [q ]))
1185+ if det [q ] == 'FAIL' :
1186+
1187+ if 'dlc' in q :
1188+ l .append ('\n ' )
1189+ l .append (q + ':' + str (det [q ])+ '-->' )
1190+ video_type = q [3 :]
1191+ for dlc_qc in dlc_qcs :
1192+ w = f'_dlc{ video_type } _{ dlc_qc } '
1193+ if not det [w ]:
1194+ l .append (w + ':' + str (det [w ])+ ',' )
1195+ else :
1196+ l .append (q + ':' + str (det [q ])+ ',' )
11621197 except :
11631198 continue
11641199
11651200 s2 = ' ' .join (l )
11661201
11671202
1168- plt .suptitle (s1 + ' QC ' + s2 + ' ' + ' DLC version: '+ str (task ['version' ]),
1169- backgroundcolor = 'white' )
1170- plt .tight_layout ()
1171- plt .tight_layout ()
1203+ plt .suptitle (s1 + ', DLC version: ' + str (task ['version' ])+ ' \n ' + s2 ,
1204+ backgroundcolor = 'white' , fontsize = 6 )
1205+ plt .tight_layout (rect = [ 0 , 0.03 , 1 , 0.95 ] )
1206+ # plt.tight_layout()
11721207 plt .savefig (f'/home/mic/reproducible_dlc/overviewJune/{ eid } .png' )
11731208 plt .close ()
11741209
1175-
1176- #BWM sessions that errored out when plotting
1177- #['7b26ce84-07f9-43d1-957f-bc72aeb730a3',
1178- # '4b7fbad4-f6de-43b4-9b15-c7c7ef44db4b',
1179- # 'ecb5520d-1358-434c-95ec-93687ecd1396',
1180- # 'a52f5a1b-7f45-4f2c-89a9-fb199d2a0d63',
1181- # '17602713-0ac6-49c1-b134-ee580de84729',
1182- # 'b03fbc44-3d8e-4a6c-8a50-5ea3498568e0',
1183- # '064a7252-8e10-4ad6-b3fd-7a88a2db5463',
1184- # '71e55bfe-5a3a-4cba-bdc7-f085140d798e',
1185- # '15763234-d21e-491f-a01b-1238eb96d389',
1186- # 'd9f0c293-df4c-410a-846d-842e47c6b502',
1187- # 'ebe090af-5922-4fcd-8fc6-17b8ba7bad6d',
1188- # '7f6b86f9-879a-4ea2-8531-294a221af5d0']
1210+
11891211
0 commit comments