From e057799f722b64d7490a2290017cb33ec981248f Mon Sep 17 00:00:00 2001 From: luiztauffer Date: Thu, 21 May 2020 22:54:12 +0700 Subject: [PATCH] fix #89 --- ecogvis/functions/subFunctions.py | 9 ++++++++- ecogvis/functions/tdt_to_nwb/chang2nwb.py | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ecogvis/functions/subFunctions.py b/ecogvis/functions/subFunctions.py index 2933c58..42d3ed6 100755 --- a/ecogvis/functions/subFunctions.py +++ b/ecogvis/functions/subFunctions.py @@ -759,7 +759,14 @@ def BadChannelSave(self): aux = [False] * self.nChTotal for ind in self.badChannels: aux[ind] = True - self.nwb.electrodes['bad'].data[:] = aux + if 'bad' not in self.nwb.electrodes: + self.nwb.add_electrode_column( + name='bad', + description='electrode identified as too noisy', + data=aux, + ) + else: + self.nwb.electrodes['bad'].data[:] = aux def DrawMarkTime(self, position): """Marks temporary reference line when adding a new interval.""" diff --git a/ecogvis/functions/tdt_to_nwb/chang2nwb.py b/ecogvis/functions/tdt_to_nwb/chang2nwb.py index ce25a77..e1e28dd 100644 --- a/ecogvis/functions/tdt_to_nwb/chang2nwb.py +++ b/ecogvis/functions/tdt_to_nwb/chang2nwb.py @@ -565,8 +565,6 @@ def chang2nwb(blockpath, out_file_path=None, save_to_file=False, htk_config=None nwbfile_dict.update(metadata['NWBFile']) nwbfile = NWBFile(**nwbfile_dict) - nwbfile.add_electrode_column('bad', 'electrode identified as too noisy') - # Electrophysiology ecephys_dict = { 'Device': [{'name': 'auto_device'}], @@ -614,6 +612,7 @@ def chang2nwb(blockpath, out_file_path=None, save_to_file=False, htk_config=None # Electrodes table n_electrodes = data.shape[1] + nwbfile.add_electrode_column('bad', 'electrode identified as too noisy') bad_elecs_inds = get_bad_elecs(blockpath) for elec_counter in range(n_electrodes): bad = elec_counter in bad_elecs_inds