catalystneuro / tye-lab-to-nwb

NWB Conversion project for the Tye lab at the Salk Institute.
MIT License
0 stars 0 forks source link

TypeError: Can't instantiate abstract class FiberPhotometryInterface with abstract method add_to_nwbfile #37

Closed laurelrr closed 11 months ago

laurelrr commented 11 months ago

I am testing out the fiber_photometry module for the first time. I have built my conda environment "tye_lab_to_nwb" with the following commands:

conda activate tye_lab_to_nwb
pip install -e .
pip install -r src/tye_lab_to_nwb/fiber_photometry/requirements.txt

I update the convert_session.py to point to the correct photometry_file_path and output_dir_path locations. Then I run python src/tye_lab_to_nwb/fiber_photometry/convert_session.py and I get the following error:

(tye_lab_to_nwb_env) lkeyes@node32:~/Projects/GIT/tye-lab-to-nwb$ python src/tye_lab_to_nwb/fiber_photometry/convert_session.py
Traceback (most recent call last):
  File "/nadata/snlkt/home/lkeyes/Projects/GIT/tye-lab-to-nwb/src/tye_lab_to_nwb/fiber_photometry/convert_session.py", line 50, in <module>
    session_to_nwb(
  File "/nadata/snlkt/home/lkeyes/Projects/GIT/tye-lab-to-nwb/src/tye_lab_to_nwb/fiber_photometry/convert_session.py", line 16, in session_to_nwb
    interface = FiberPhotometryInterface(file_path=str(file_path))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Can't instantiate abstract class FiberPhotometryInterface with abstract method add_to_nwbfile
weiglszonja commented 11 months ago

This is similar to #33 where we had to update the custom interfaces to keep up with the latest neuroconv changes. I opened #35 to fix this.

weiglszonja commented 11 months ago

This should be fixed by #35, @laurelrr Can you try again after pulling the latest changes?

Usage example

conda activate tye_lab_to_nwb
pip install -r src/tye_lab_to_nwb/fiber_photometry/requirements.txt
python src/tye_lab_to_nwb/fiber_photometry/convert_session.py

or parallel convert with a session_config.xlsx file as described in fiber_photometry_notes.md

conda activate tye_lab_to_nwb
pip install -r src/tye_lab_to_nwb/fiber_photometry/requirements.txt
python src/tye_lab_to_nwb/fiber_photometry/convert_all_sessions.py
laurelrr commented 11 months ago

I am getting this error

(tye_lab_to_nwb_env) lkeyes@nikola:~/Projects/GIT/tye-lab-to-nwb$ python src/tye_lab_to_nwb/fiber_photometry/convert_session.py
Traceback (most recent call last):
  File "/nadata/snlkt/home/lkeyes/Projects/GIT/tye-lab-to-nwb/src/tye_lab_to_nwb/fiber_photometry/convert_session.py", line 11, in <module>
    from nwbinspector import inspect_nwbfile
ImportError: cannot import name 'inspect_nwbfile' from 'nwbinspector' (/home/lkeyes/anaconda3/envs/tye_lab_to_nwb_env/lib/python3.11/site-packages/nwbinspector/__init__.py)
CodyCBakerPhD commented 11 months ago

What version is it running?

pip show nwbinspector
laurelrr commented 11 months ago

(tye_lab_to_nwb_env) lkeyes@nikola:~/Projects/GIT/tye-lab-to-nwb$ pip show nwbinspector Name: nwbinspector Version: 0.4.27 Summary: Tool to inspect NWB files for best practices compliance. Home-page: https://nwbinspector.readthedocs.io/ Author: Ryan Ly, Ben Dichter, and Cody Baker. Author-email: rly@lbl.gov, ben.dichter@gmail.com, cody.baker@catalystneuro.com License: BSD-3-Clause Location: /home/lkeyes/anaconda3/envs/tye_lab_to_nwb_env/lib/python3.11/site-packages Requires: click, isodate, jsonschema, natsort, numpy, packaging, pynwb, PyYAML, tqdm Required-by: dandi, tye-lab-to-nwb

CodyCBakerPhD commented 11 months ago

I'd do pip install -U nwbinspector, it's up to 0.4.30 right now and DANDI upload prefers to have latest available version

laurelrr commented 11 months ago

I got this error when I ran pip install -U nwbinspector ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. boto3 1.24.96 requires botocore<1.28.0,>=1.27.96, but you have botocore 1.31.17 which is incompatible.

But it appears to have converted the file! Thanks

weiglszonja commented 11 months ago

Yes, but I would also suggest to create a new virtual environment here. I tested with running with these steps in the terminal:

conda create --name fiberphotometryenv39 python=3.9
conda activate fiberphotometryenv39 
pip install -r src/tye_lab_to_nwb/fiber_photometry/requirements.txt
pip install -e .
python src/tye_lab_to_nwb/fiber_photometry/convert_session.py 

this should also install nwbinspector=0.4.30

laurelrr commented 11 months ago

Yes, that is much cleaner. Thanks!

laurelrr commented 11 months ago

OK, it looks like that worked; I was able to convert the subjects. However, I have a "best practice violation" in all my log outputs. Is there an action I should take on this?

(fiberphotometryenv39) lkeyes@nikola:~/Projects/GIT/tye-lab-to-nwb$ cat /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1_inspector_result.txt               **************************************************
NWBInspector Report Summary

Timestamp: 2023-10-16 12:49:32.504429-07:00
Platform: Linux-4.19.0-25-amd64-x86_64-with-glibc2.28
NWBInspector version: 0.4.30

Found 7 issues over 1 files:
       1 - BEST_PRACTICE_VIOLATION
       6 - BEST_PRACTICE_SUGGESTION
**************************************************

0  BEST_PRACTICE_VIOLATION
==========================

0.0  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_roi_response_series_link_to_plane_segmentation - 'RoiResponseSeries' object at location '/acquisition/RoiResponseSeriesRegion0G'
       Message: rois field does not point to a PlaneSegmentation table.

1  BEST_PRACTICE_SUGGESTION
===========================

1.1  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_description - 'Subject' object at location '/general/subject'
       Message: Description is missing.

1.2  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_experiment_description - 'NWBFile' object at location '/'
       Message: Experiment description is missing.

1.3  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_keywords - 'NWBFile' object at location '/'
       Message: Metadata /general/keywords is missing.

1.4  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_single_row - 'FluorophoresTable' object with name 'fluorophores'
       Message: This table has only a single row; it may be better represented by another data type.

1.5  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_single_row - 'PhotodetectorsTable' object with name 'photodetectors'
       Message: This table has only a single row; it may be better represented by another data type.

1.6  /snlkt/data/hao/Neurotensin/NWB/Fiber_Photometry/nwbfiles/FearLearning_earlyAcq_Mouse1.nwb: check_single_row - 'FibersTable' object with name 'fibers'
       Message: This table has only a single row; it may be better represented by another data type.
CodyCBakerPhD commented 11 months ago

@laurelrr Good catch! That one can be ignored, it's something we are aware of but it's an oddity with respect to the extension + interactions with the inspector