def save_nwb(output_path, v, sweep, sweep_by_type= None): '''Save a single voltage output result into an existing sweep in a NWB file. This is intended to overwrite a recorded trace with a simulated voltage. Parameters ---------- output_path : string file name of a pre-existing NWB file. v : numpy array voltage sweep : integer which entry to overwrite in the file. ''' output = NwbDataSet(output_path) output.set_sweep(sweep, None, v) if sweep_by_type is not None: sweep_by_type = {t: [sweep] for t, ss in sweeps_by_type.items() if sweep in ss} sweep_features = extract_cell_features.extract_sweep_features(output, sweep_by_type) try: spikes = sweep_features[sweep]['spikes'] spike_times = [s['threshold_t'] for s in spikes] output.set_spike_times(sweep, spike_times) except Exception as e: logging.info("sweep %d has no sweep features. %s" % (sweep, e.args))
def save_nwb(output_path, v, sweep, sweeps_by_type): '''Save a single voltage output result into an existing sweep in a NWB file. This is intended to overwrite a recorded trace with a simulated voltage. Parameters ---------- output_path : string file name of a pre-existing NWB file. v : numpy array voltage sweep : integer which entry to overwrite in the file. ''' output = NwbDataSet(output_path) output.set_sweep(sweep, None, v) sweep_by_type = {t: [ sweep ] for t, ss in sweeps_by_type.items() if sweep in ss } sweep_features = extract_cell_features.extract_sweep_features(output, sweep_by_type) try: spikes = sweep_features[sweep]['spikes'] spike_times = [ s['threshold_t'] for s in spikes ] output.set_spike_times(sweep, spike_times) except Exception, e: logging.info("sweep %d has no sweep features. %s" % (sweep, e.message) )
def write_sweep_response(file_name, sweep_number, response, spike_times): ''' Overwrite the response in a file. ''' logging.debug("writing sweep") write_start_time = time.time() ephds = NwbDataSet(file_name) ephds.set_sweep(sweep_number, stimulus=None, response=response) ephds.set_spike_times(sweep_number, spike_times) logging.debug("write time %f" % (time.time() - write_start_time))
def save_nwb(output_path, v, sweep): """Save a single voltage output result into an existing sweep in a NWB file. This is intended to overwrite a recorded trace with a simulated voltage. Parameters ---------- output_path : string file name of a pre-existing NWB file. v : numpy array voltage sweep : integer which entry to overwrite in the file. """ output = NwbDataSet(output_path) output.set_sweep(sweep, None, v)
def save_nwb(output_path, v, sweep): '''Save a single voltage output result into an existing sweep in a NWB file. This is intended to overwrite a recorded trace with a simulated voltage. Parameters ---------- output_path : string file name of a pre-existing NWB file. v : numpy array voltage sweep : integer which entry to overwrite in the file. ''' output = NwbDataSet(output_path) output.set_sweep(sweep, None, v) sweep_features = extract_cell_features.extract_sweep_features(output_path, [sweep]) spikes = sweep_features[sweep]['mean']['spikes'] spike_times = [ s['t'] for s in spikes ] output.set_spike_times(sweep, spike_times)