@@ -93,8 +93,8 @@ class UnitLevelReport(dj.Computed):
9393 definition = """
9494 -> ephys.CuratedClustering.Unit
9595 ---
96- cluster_quality_label : varchar(100)
97- waveform_plotly : longblob
96+ cluster_quality_label : varchar(100)
97+ waveform_plotly : longblob
9898 autocorrelogram_plotly : longblob
9999 depth_waveform_plotly : longblob
100100 """
@@ -151,11 +151,14 @@ class QualityMetricCutoffs(dj.Lookup):
151151
152152 def insert_new_cutoffs (
153153 cls ,
154- cutoffs_id : int ,
155- amplitude_cutoff_maximum : float ,
156- presence_ratio_minimum : float ,
157- isi_violations_maximum : float ,
154+ cutoffs_id : int = None ,
155+ amplitude_cutoff_maximum : float = None ,
156+ presence_ratio_minimum : float = None ,
157+ isi_violations_maximum : float = None ,
158158 ):
159+ if not cutoffs_id :
160+ cutoffs_id = (dj .U ().aggr (cls , n = "max(cutoffs_id)" ).fetch1 ("n" ) or 0 ) + 1
161+
159162 insert1_skip_full_duplicates ( # depends on element-interface/pull/43
160163 cls ,
161164 dict (
@@ -179,43 +182,19 @@ class QualityMetricSet(dj.Manual):
179182class QualityMetricReport (dj .Computed ):
180183 definition = """
181184 -> QualityMetricSet
185+ ---
186+ plot_grid : longblob
182187 """
183188
184- class Cluster (dj .Part ):
185- definition = """
186- -> master
187- ---
188- firing_rate_plot : longblob
189- presence_ratio_plot : longblob
190- amp_cutoff_plot : longblob
191- isi_violation_plot : longblob
192- snr_plot : longblob
193- iso_dist_plot : longblob
194- d_prime_plot : longblob
195- nn_hit_plot : longblob
196- """
197-
198189 def make (self , key ):
199190 from .plotting .qc import QualityMetricFigs
200191
201192 cutoffs = (QualityMetricCutoffs & key ).fetch1 ()
202193 qc_key = ephys .QualityMetrics & key
203- qc_figs = QualityMetricFigs (qc_key , ** cutoffs )
204-
205- # ADD SAVEFIG?
206194
207- self .insert1 (key )
208- self .Cluster .insert1 (
209- dict (
210- ** key ,
211- firing_rate_plot = qc_figs .firing_rate_plot ().to_plotly_json (),
212- presence_ratio_plot = qc_figs .presence_ratio_plot ().to_plotly_json (),
213- amp_cutoff_plot = qc_figs .amp_cutoff_plot ().to_plotly_json (),
214- isi_violation_plot = qc_figs .isi_violation_plot ().to_plotly_json (),
215- snr_plot = qc_figs .snr_plot ().to_plotly_json (),
216- iso_dist_plot = qc_figs .iso_dist_plot ().to_plotly_json (),
217- d_prime_plot = qc_figs .d_prime_plot ().to_plotly_json (),
218- nn_hit_plot = qc_figs .nn_hit_plot ().to_plotly_json (),
195+ self .insert1 (
196+ key .update (
197+ dict (plot_grid = QualityMetricFigs (qc_key , ** cutoffs ).get_grid ().to_json )
219198 )
220199 )
221200
0 commit comments