catalystneuro / ecogVIS

Time series visualizer and data processing tools for Electrocorticography (ECoG) signals stored in NWB files, for Python.
BSD 3-Clause "New" or "Revised" License
23 stars 18 forks source link

Cannot save bad channels #89

Closed cbin-cnl closed 4 years ago

cbin-cnl commented 4 years ago

Originally had the issue that I couldn't open a nwb file without a "bad" channel column, but it looks like that has been addressed in #85 , so I installed the newest version of ecogVIS using the "setup.py" file. Is there a way of saving bad channels without having an existing bad channels column?

luiztauffer commented 4 years ago

hi @cbin-cnl , did the problem of opening a file get solved on your end? Do you get any specific error when trying to save a new file? If yes, can you copy the error track (printed in the terminal)?

cbin-cnl commented 4 years ago

Hi Luiz,

Yes I can open the file and add channels, but the gui crashes once I try to save. The error message is below: Traceback (most recent call last): File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/ecogvis-1.0.1-py3.6.egg/ecogvis/ecogvis.py", line 530, in save_badchannel self.model.BadChannelSave() File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/ecogvis-1.0.1-py3.6.egg/ecogvis/functions/subFunctions.py", line 748, in BadChannelSave self.nwb.electrodes['bad'].data[indices] = aux File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/common/table.py", line 504, in __getitem__ raise KeyError(key) KeyError: 'bad'

luiztauffer commented 4 years ago

thanks for the report! I'll check it

luiztauffer commented 4 years ago

@cbin-cnl it seems like you're not using the most updated code, could you please try installing the current repo version of EcogVIS in your working environment?

$ pip uninstall ecogvis
$ git clone https://github.com/catalystneuro/ecogVIS.git
$ cd ecogVIS
$ pip install .

I couldn't reproduce the error locally, this is probably because of some changes in ecogvis that were not published to pypi yet. If it's not urgent, you can also wait a couple of days max and I'll be releasing a new version, so you can upgrade through pip.

cbin-cnl commented 4 years ago

Hi Luiz, thanks for the quick response.

Unfortunately updating the code did not work, I still get the following error:

File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/ecogvis/ecogvis.py", line 530, in save_badchannel  
self.model.BadChannelSave()   
File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/ecogvis/functions/subFunctions.py", line 744, in BadChannelSave
self.nwb.electrodes['bad'].data[:] = aux
File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/common/table.py", line 504, in __getitem__
    raise KeyError(key)
KeyError: 'bad'

To clarify, I can open the file fine, but cannot save the channels unless the NWB file already has a "bad" electrodes column.

Thanks again

luiztauffer commented 4 years ago

of course, I can see it now I'll put a fix for this in the current PR and let you know once it's merged!

cbin-cnl commented 4 years ago

Great thanks so much!

luiztauffer commented 4 years ago

@cbin-cnl it took a bit, sorry, the merge is in place. could you please confirm this solved the problem on your end?

cbin-cnl commented 4 years ago

Hi Luiz,

Unfortunately it still looks like there is a problem with adding a column to an existing Electrode table. I'm getting the following error:

    self.model.BadChannelSave()
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/ecogvis-1.1.0-py3.6.egg/ecogvis/functions/subFunctions.py", line 765, in BadChannelSave
    data=aux,
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/utils.py", line 483, in func_call
    return func(args[0], **parsed['args'])
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/pynwb/file.py", line 494, in add_electrode_column
    call_docval_func(self.electrodes.add_column, kwargs)
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/utils.py", line 364, in call_docval_func
    return func(*fargs, **fkwargs)
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/utils.py", line 483, in func_call
    return func(args[0], **parsed['args'])
  File "/home/cbin-user/tdt2nwb/ecogvis/lib/python3.6/site-packages/hdmf/common/table.py", line 462, in add_column
    raise ValueError("column must have the same number of rows as 'id'")
ValueError: column must have the same number of rows as 'id'
Aborted (core dumped)

However, I think I can just ensure I have a "bad" channels column in my electrode table. Thank you.

luiztauffer commented 4 years ago

I'll get this fix, thanks for reporting it

luiztauffer commented 4 years ago

@cbin-cnl I managed to reproduce your error now is it the case that your electricalseries is mapped to a subset of electrodes smaller than the total number of electrodes? Just to make sure we found the same problem I'll fix it

cbin-cnl commented 4 years ago

Thanks Luiz, sorry just looking at this now. Thanks for making the change. Just wanted to check, the "save bad channels" button has been removed? Is the intention to just save a new NWB file with the bad channel annotation?

luiztauffer commented 4 years ago

@cbin-cnl that's correct. Do you have the specific need of saving it in the same file?

cbin-cnl commented 4 years ago

Hi Luiz, no, that should be fine, just wanted to make sure that was the intention.