@@ -788,6 +788,7 @@ def __init__(self, hdf5_path, electrode_num, params_dict):
788
788
hf5 .close ()
789
789
790
790
def filter_electrode (self ):
791
+ # Raw units get multiplied by 0.195 to get MICROVOLTS
791
792
self .filt_el = clust .get_filtered_electrode (
792
793
self .raw_el ,
793
794
freq = [self .params_dict ['bandpass_lower_cutoff' ],
@@ -846,16 +847,33 @@ def make_cutoff_plot(self):
846
847
recording_cutoff: int
847
848
"""
848
849
fig = plt .figure ()
850
+ # filt_el is in microvolts
849
851
second_data = np .reshape (
850
852
self .filt_el ,
851
853
(- 1 , self .params_dict ['sampling_rate' ]))
852
- plt .plot (np .mean (second_data , axis = 1 ))
854
+ mean_data = np .mean (second_data , axis = 1 )
855
+ std_data = np .std (second_data , axis = 1 )
856
+ plt .plot (mean_data , label = 'Mean' )
857
+ plt .fill_between (
858
+ x = np .arange (len (mean_data )),
859
+ y1 = mean_data + std_data ,
860
+ y2 = mean_data - std_data ,
861
+ label = 'STD' ,
862
+ )
853
863
plt .axvline (self .recording_cutoff ,
854
- color = 'k' , linewidth = 4.0 , linestyle = '--' )
864
+ color = 'k' , linewidth = 2 , linestyle = '--' ,
865
+ label = 'Recording cutoff' )
866
+ plt .axhline (self .params_dict ['voltage_cutoff' ],
867
+ color = 'r' , linewidth = 2.0 , linestyle = '--' ,
868
+ label = 'Voltage cutoff' )
869
+ plt .axhline (- self .params_dict ['voltage_cutoff' ],
870
+ color = 'r' , linewidth = 2.0 , linestyle = '--' )
855
871
plt .xlabel ('Recording time (secs)' )
856
872
plt .ylabel ('Average voltage recorded per sec (microvolts)' )
857
873
plt .title (f'Recording length : { len (second_data )} s' + '\n ' +
858
874
f'Cutoff time : { self .recording_cutoff } s' )
875
+ plt .legend ()
876
+ plt .yscale ('symlog' )
859
877
fig .savefig (
860
878
f'./Plots/{ self .electrode_num :02} /cutoff_time.png' ,
861
879
bbox_inches = 'tight' )
@@ -996,6 +1014,24 @@ def return_cutoff_values(
996
1014
max_secs_above_cutoff ,
997
1015
max_mean_breach_rate_persec
998
1016
):
1017
+ """
1018
+ Return the cutoff values for the electrode recording
1019
+
1020
+ Inputs:
1021
+ filt_el: numpy array (in
1022
+ sampling_rate: int
1023
+ voltage_cutoff: float
1024
+ max_breach_rate: float
1025
+ max_secs_above_cutoff: float
1026
+ max_mean_breach_rate_persec: float
1027
+
1028
+ Outputs:
1029
+ breach_rate: float
1030
+ breaches_per_sec: numpy array
1031
+ secs_above_cutoff: int
1032
+ mean_breach_rate_persec: float
1033
+ recording_cutoff: int
1034
+ """
999
1035
1000
1036
breach_rate = float (len (np .where (filt_el > voltage_cutoff )[0 ])
1001
1037
* int (sampling_rate ))/ len (filt_el )
0 commit comments