Skip to content

Commit

Permalink
Relative latency grid. Correct reqs.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
tfiers committed Apr 25, 2019
1 parent de5f72d commit 0d70d4f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions sharp/config/default/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
)


Expand Down
3 changes: 2 additions & 1 deletion sharp/tasks/plot/paper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])


Expand Down
23 changes: 21 additions & 2 deletions sharp/tasks/plot/paper/grid.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -182,11 +192,20 @@ 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)"
fstring = "{x:.0f}"

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

0 comments on commit 0d70d4f

Please sign in to comment.