def _combine_metrics(metrics1, metrics2, metrics_out): code = ''' #!/bin/bash ml-exec-process ms3.combine_cluster_metrics -i metrics_list:{} metrics_list:{} -o metrics_out:{} '''.format(metrics1, metrics2, metrics_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.combine_metrics')
def _isolation_metrics(timeseries, firings, metrics_out, pair_metrics_out): code = ''' #!/bin/bash ml-exec-process ms3.isolation_metrics -i timeseries:{} firings:{} -o metrics_out:{} pair_metrics_out:{} -p compute_bursting_parents:true '''.format(timeseries, firings, metrics_out, pair_metrics_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.isolation_metrics')
def _cluster_metrics(timeseries, firings, metrics_out): code = ''' #!/bin/bash ml-exec-process ms3.cluster_metrics -i timeseries:{} firings:{} -o cluster_metrics_out:{} -p samplerate:30000 '''.format(timeseries, firings, metrics_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.cluster_metrics')
def _mask_out_artifacts(timeseries_in, timeseries_out): code = ''' #!/bin/bash ml-exec-process ms3.mask_out_artifacts -i timeseries:{} -o timeseries_out:{} -p threshold:6 interval_size:2000 '''.format(timeseries_in, timeseries_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.mask_out_artifacts')
def _whiten(timeseries_in, timeseries_out): code = ''' #!/bin/bash ml-exec-process ms3.whiten -i timeseries:{} -o timeseries_out:{} '''.format(timeseries_in, timeseries_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.whiten')
def _bandpass_filter(timeseries_in, timeseries_out): code = ''' #!/bin/bash ml-exec-process ms3.bandpass_filter -i timeseries:{} -o timeseries_out:{} -p samplerate:30000 freq_min:300 freq_max:6000 '''.format(timeseries_in, timeseries_out) print(code) script = ShellScript(code) script.start() retcode = script.wait() if retcode != 0: raise Exception('problem running ms3.bandpass_filter')
def _run(self, recording: se.RecordingExtractor, output_folder: Path): dataset_dir = output_folder / 'ironclust_dataset' source_dir = Path(__file__).parent samplerate = recording.get_sampling_frequency() num_channels = recording.get_num_channels() num_timepoints = recording.get_num_frames() duration_minutes = num_timepoints / samplerate / 60 if self.verbose: print( 'Num. channels = {}, Num. timepoints = {}, duration = {} minutes' .format(num_channels, num_timepoints, duration_minutes)) if self.verbose: print('Creating argfile.txt...') txt = '' for key0, val0 in self.params.items(): txt += '{}={}\n'.format(key0, val0) txt += 'samplerate={}\n'.format(samplerate) with (dataset_dir / 'argfile.txt').open('w') as f: f.write(txt) tmpdir = output_folder / 'tmp' os.makedirs(str(tmpdir), exist_ok=True) if self.verbose: print( 'Running ironclust in {tmpdir}...'.format(tmpdir=str(tmpdir))) shell_cmd = ''' #!/bin/bash cd {tmpdir} /run_irc {dataset_dir} {tmpdir} {dataset_dir}/argfile.txt '''.format(tmpdir=str(tmpdir), dataset_dir=str(dataset_dir)) shell_script = ShellScript(shell_cmd) shell_script.start() retcode = shell_script.wait() if retcode != 0: raise Exception('ironclust returned a non-zero exit code') result_fname = str(tmpdir / 'firings.mda') if not os.path.exists(result_fname): raise Exception('Result file does not exist: ' + result_fname) samplerate_fname = str(tmpdir / 'samplerate.txt') with open(samplerate_fname, 'w') as f: f.write('{}'.format(samplerate))