diff --git a/requirements.txt b/requirements.txt index c7ad49a..208fbbd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,4 @@ git+https://github.com/tfiers/seaborn#seaborn git+https://github.com/tfiers/raincloud#raincloud # Closed source for now - download and install manually -# git+https://bitbucket.org/kloostermannerflab/fklab-python-core/src/master -#fklab +# git+https://bitbucket.org/kloostermannerflab/fklab-python-core/src/master#fklab diff --git a/sharp/config/default/tasks.py b/sharp/config/default/tasks.py index 6584278..3e4fd35 100644 --- a/sharp/config/default/tasks.py +++ b/sharp/config/default/tasks.py @@ -99,6 +99,7 @@ def get_tasks_to_run(): from sharp.tasks.plot.misc.training import PlotValidLoss from sharp.tasks.plot.paper.PR_curve import Plot_PR_Curve from sharp.tasks.plot.paper.signals import PlotSignals + from sharp.tasks.plot.paper.grid import RelativeLatencyGrid return ( # *tasks_on_hold(), @@ -107,9 +108,11 @@ def get_tasks_to_run(): # AccuracyGrid(envelope_maker=ApplyOnlineBPF()), # LatencyGrid(envelope_maker=ApplyRNN()), # LatencyGrid(envelope_maker=ApplyOnlineBPF()), - Plot_PR_Curve(), + # RelativeLatencyGrid(envelope_maker=ApplyRNN()), + # RelativeLatencyGrid(envelope_maker=ApplyOnlineBPF()), + # Plot_PR_Curve(), PlotLatency(), - PlotSignals(), + # PlotSignals(), ) diff --git a/sharp/tasks/plot/paper/__init__.py b/sharp/tasks/plot/paper/__init__.py index 348b581..b494f14 100644 --- a/sharp/tasks/plot/paper/__init__.py +++ b/sharp/tasks/plot/paper/__init__.py @@ -2,6 +2,7 @@ from sharp.config.load import config from sharp.data.hardcoded.style import blue, pink +from sharp.data.types.evaluation.sweep import ThresholdSweep from sharp.data.types.evaluation.threshold import ThresholdEvaluation from sharp.tasks.evaluate.sweep import ThresholdSweeper from sharp.tasks.neuralnet.apply import ApplyRNN @@ -29,7 +30,7 @@ labels = ("Band-pass filter", "Recurrent neural net") -def get_sweeps() -> Tuple[ThresholdSweeper, ...]: +def get_sweeps() -> Tuple[ThresholdSweep, ...]: return tuple([sweeper.output().read() for sweeper in sweepers]) diff --git a/sharp/tasks/plot/paper/grid.py b/sharp/tasks/plot/paper/grid.py index 03251d3..b81f0cc 100644 --- a/sharp/tasks/plot/paper/grid.py +++ b/sharp/tasks/plot/paper/grid.py @@ -1,10 +1,11 @@ from colorsys import rgb_to_hls +from logging import getLogger from matplotlib.cm import get_cmap from matplotlib.colorbar import ColorbarBase from matplotlib.colors import Normalize from matplotlib.ticker import StrMethodFormatter -from numpy import arange, max +from numpy import arange, max, mean, percentile from sharp.config.load import config from sharp.data.files.figure import FigureTarget @@ -19,6 +20,8 @@ from sharp.tasks.signal.reference import MakeReference from sharp.util.misc import cached +log = getLogger(__name__) + class PaperGridPlotter(FigureMaker): envelope_maker: EnvelopeMaker = TaskParameter() @@ -57,6 +60,13 @@ def filename(self): return f"{self.__class__.__name__} -- {self.envelope_maker.title}" def work(self): + log.info( + ( + self.filename, + mean(self.data_matrix), + percentile(self.data_matrix, [25, 50, 100]), + ) + ) self.plot_grid() self.plot_colorbar() @@ -182,7 +192,6 @@ def get_data(self, sweep): class LatencyGrid(PaperGridPlotter): - # cmap_range = (0.15, 0.48) cmap_range = (8, 32) cmap = get_cmap("viridis_r") colorbar_label = "Detection latency (ms)" @@ -190,3 +199,13 @@ class LatencyGrid(PaperGridPlotter): def get_data(self, sweep): return sweep.at_max_F2().abs_delays_median * 1000 + + +class RelativeLatencyGrid(PaperGridPlotter): + cmap_range = (0.15, 0.48) + cmap = get_cmap("viridis_r") + colorbar_label = "Detection latency" + fstring = "{x:.0%}" + + def get_data(self, sweep): + return sweep.at_max_F2().rel_delays_median