Skip to content

Commit

Permalink
GUI plots now save to results dir in png format
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobpennington committed May 30, 2024
1 parent 0226eb5 commit 298a086
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kilosort/gui/message_log_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def print_settings(self):
# values and the values that are actually being used.
settings_text = "settings = "
settings = self.gui.settings_box.settings.copy()
settings['probe'] = '... (use dump probe)'
settings['probe'] = '... (use print probe)'
s = pprint.pformat(settings, indent=4, sort_dicts=False)
settings_text += s[0] + '\n ' + s[1:-1] + '\n' + s[-1]

Expand Down
3 changes: 1 addition & 2 deletions kilosort/gui/run_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,5 @@ def add_plot_data(self, plot_type):
clu = self.current_worker.clu
tF = self.current_worker.tF
is_refractory = self.current_worker.is_refractory
device = self.parent.device
plot_spike_positions(plot_window, ops, st, clu, tF, is_refractory,
device)
settings)
15 changes: 12 additions & 3 deletions kilosort/gui/sanity_plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path

import pyqtgraph as pg
import scipy
import pyqtgraph.exporters
import numpy as np
import matplotlib
import torch
Expand Down Expand Up @@ -46,6 +48,8 @@ def plot_drift_amount(plot_window, dshift, settings):
p1.plot(t, dshift[:,i], pen=color)

plot_window.show()
save_path = str(Path(settings['results_dir']) / 'drift_amount.png')
pg.exporters.ImageExporter(plot_window.plot_widget.scene()).export(save_path)


def plot_drift_scatter(plot_window, st0, settings):
Expand Down Expand Up @@ -93,6 +97,8 @@ def plot_drift_scatter(plot_window, st0, settings):
left_ax.setTickPen('k')

plot_window.show()
save_path = str(Path(settings['results_dir']) / 'drift_scatter.png')
pg.exporters.ImageExporter(plot_window.plot_widget.scene()).export(save_path)


def plot_diagnostics(plot_window, wPCA, Wall0, clu0, settings):
Expand Down Expand Up @@ -142,10 +148,11 @@ def plot_diagnostics(plot_window, wPCA, Wall0, clu0, settings):

# Finished, draw plot
plot_window.show()
save_path = str(Path(settings['results_dir']) / 'diagnostics.png')
pg.exporters.ImageExporter(plot_window.plot_widget.scene()).export(save_path)


def plot_spike_positions(plot_window, ops, st, clu, tF, is_refractory,
device=None):
def plot_spike_positions(plot_window, ops, st, clu, tF, is_refractory, settings):

p1 = plot_window.plot_widget.addPlot(
row=0, col=0, labels={'bottom': 'Depth (um)', 'left': 'Lateral (um)'}
Expand Down Expand Up @@ -177,3 +184,5 @@ def plot_spike_positions(plot_window, ops, st, clu, tF, is_refractory,
brush=brushes)
p1.addItem(scatter)
plot_window.show()
save_path = str(Path(settings['results_dir']) / 'spike_positions.png')
pg.exporters.ImageExporter(plot_window.plot_widget.scene()).export(save_path)

0 comments on commit 298a086

Please sign in to comment.