Skip to content

Commit 60408b2

Browse files
committed
Fix bugs in testing auto-sorting
1 parent 80ff07d commit 60408b2

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

blech_post_process.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@
6565
description = 'Spike extraction and sorting script')
6666
parser.add_argument('dir_name',
6767
help = 'Directory containing data files')
68-
parser.add_argument('--show-plot', '-p',
69-
help = 'Show waveforms while iterating (True/False)', default = 'True')
7068
parser.add_argument('--sort-file', '-f', help = 'CSV with sorted units',
7169
default = None)
70+
parser.add_argument('--show-plot',
71+
help = 'Show waveforms while iterating',
72+
action = 'store_true')
73+
parser.add_argument('--keep-raw', help = 'Keep raw data in hdf5 file',
74+
action = 'store_true')
7275
args = parser.parse_args()
7376

7477
############################################################
@@ -132,7 +135,11 @@
132135

133136

134137
# Delete the raw node, if it exists in the hdf5 file, to cut down on file size
135-
repacked_bool = post_utils.delete_raw_recordings(hdf5_name)
138+
if args.keep_raw == 'False':
139+
repacked_bool = post_utils.delete_raw_recordings(hdf5_name)
140+
else:
141+
repacked_bool = False
142+
print('=== Keeping raw data in hdf5 file ===')
136143

137144
# Open the hdf5 file
138145
if repacked_bool:
@@ -193,12 +200,12 @@
193200
energy,
194201
amplitudes,
195202
predictions,
196-
) = post_utils.load_data_from_disk(electrode_num, num_clusters)
203+
) = post_utils.load_data_from_disk(dir_name, electrode_num, num_clusters)
197204

198205
# Re-show images of neurons so dumb people like Abu can make sure they
199206
# picked the right ones
200207
#if ast.literal_eval(args.show_plot):
201-
if args.show_plot == 'True':
208+
if args.show_plot:
202209
post_utils.gen_select_cluster_plot(electrode_num, num_clusters, clusters)
203210

204211
############################################################

blech_units_plot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
# Import 3rd part code
1212
from utils import blech_waveforms_datashader
13-
from utils import memory_monitor as mm
1413
from utils.blech_utils import imp_metadata, pipeline_graph_check
1514
from utils.blech_process_utils import gen_isi_hist
1615

pipeline_testing/prefect_pipeline.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,17 @@ def select_clusters(data_dir):
214214
raise_error_if_error(process,stderr,stdout)
215215

216216
@task(log_prints=True)
217-
def post_process(data_dir, use_file = True):
217+
def post_process(data_dir, use_file = True, keep_raw = False):
218218
script_name = 'blech_post_process.py'
219-
dir_pos = data_dir
220-
plot_flag = '-p ' + 'False'
221219
sorted_units_path = glob(os.path.join(data_dir, '*sorted_units.csv'))[0]
222220
if use_file:
223221
file_flag = '-f' + sorted_units_path
222+
run_list = ["python", script_name, data_dir, file_flag]
224223
else:
225-
file_flag = ''
226-
process = Popen(["python", script_name, dir_pos, plot_flag, file_flag],
227-
stdout = PIPE, stderr = PIPE)
224+
run_list = ["python", script_name, data_dir]
225+
if keep_raw:
226+
run_list.append('--keep-raw')
227+
process = Popen(run_list, stdout = PIPE, stderr = PIPE)
228228
stdout, stderr = process.communicate()
229229
raise_error_if_error(process,stderr,stdout)
230230

@@ -342,7 +342,8 @@ def run_spike_test():
342342
change_waveform_classifier(use_classifier=1)
343343
change_auto_params(use_auto=1)
344344
run_jetstream_bash(data_dir)
345-
post_process(data_dir, use_file = False)
345+
# Keep raw in the first pass so jetstream step can be rerun
346+
post_process(data_dir, use_file = False, keep_raw = True)
346347

347348
# Run with classifier disabled and manual sorting
348349
change_waveform_classifier(use_classifier=0)

0 commit comments

Comments
 (0)