BouchardLab / nsds_lab_to_nwb

Python package to convert NSDS Lab data to NWB files.
https://nsds-lab-to-nwb.readthedocs.io/en/latest/
0 stars 4 forks source link

TDT: raise error when user tries to get a datastream that does not exist #8

Closed jihyunbak closed 3 years ago

jihyunbak commented 3 years ago

Copied from PR #7 .

error report

original comment

tried to run the entire builder on the example dataset R56_B10 (after uncommenting tdt_originator.make (line 111) in nwb_builder.py), got the following error:

$ python -u generate_nwb.py 
read from t=0s to t=1460.64s
read from t=0s to t=1460.64s
Traceback (most recent call last):
  File "generate_nwb.py", line 41, in <module>
    nwb_content = nwb_builder.build()
  File "/home/jhbak/proj/nsds_lab_to_nwb/nsds_lab_to_nwb/nwb_builder.py", line 111, in build
    self.tdt_originator.make(nwb_content, electrode_table_regions)
  File "/home/jhbak/proj/nsds_lab_to_nwb/nsds_lab_to_nwb/components/tdt/tdt_originator.py", line 16, in make
    electrode_table_regions[device_name])
  File "/home/jhbak/proj/nsds_lab_to_nwb/nsds_lab_to_nwb/components/tdt/tdt_manager.py", line 24, in extract_tdt
    data, tdt_params = self.__extract_from_tdt_files(device_name, dev_conf)
  File "/home/jhbak/proj/nsds_lab_to_nwb/nsds_lab_to_nwb/components/tdt/tdt_manager.py", line 56, in __extract_from_tdt_files
    num_channels = len(header.stores[device_name].chan)
  File "/home/jhbak/opt/anaconda3/envs/nsdsnwb/lib/python3.7/site-packages/tdt/__init__.py", line 77, in __getitem__
    val = getattr(self, key)
AttributeError: 'StructType' object has no attribute 'ECoG'

Quick debugging shows that in TdtManager.__extract_from_tdt_files, line 56, header.stores is a struct with fields

ipdb> header.stores
aud0    [struct]
aud1    [struct]
mrk1    [struct]
aud2    [struct]
Wave    [struct]
Poly    [struct]
mark    [struct]

confirming that there's no ECoG in this case.

suggested approach

original comment

@jthermiz said:

I think this should be treated as an error. I can throw an exception if a user tries to get a data stream that doesn't exist with an error message stating "Data stream does not exist. Here's a list of data streams in this file: Poly, ....". I can also write a method within tdt_manager that returns data streams in a file so at an end user can query what data stream exists before importing. What do you think of this approach?