YttriLab / B-SOID

Behavioral segmentation of open field in DeepLabCut, or B-SOID ("B-side"), is a pipeline that pairs unsupervised pattern recognition with supervised classification to achieve fast predictions of behaviors that are not predefined by users.
GNU General Public License v3.0
191 stars 55 forks source link

IndexError: arrays used as indices must be of integer (or boolean) type #73

Closed Nercules closed 1 year ago

Nercules commented 1 year ago

BACKGROUND I downloaded the B-SOiD repository, and setup a conda environment with the requirements.yaml file. However, I noticed that there where some issues with downloading the Python dependencies, so I changes some things in the .yaml file:

OUTPUTS OF pip list

Package             Version
------------------- -------------------
altair              4.1.0
appnope             0.1.3
argh                0.26.2
argon2-cffi         20.1.0
astor               0.8.1
async-generator     1.10
attrs               20.2.0
backcall            0.2.0
base58              2.0.1
bleach              3.2.1
blinker             1.4
boto3               1.15.15
botocore            1.18.15
cachetools          4.1.1
certifi             2020.6.20
cffi                1.14.3
chardet             3.0.4
click               7.1.2
cycler              0.10.0
decorator           4.4.2
defusedxml          0.6.0
entrypoints         0.3
enum-compat         0.0.3
ffmpeg-python       0.2.0
future              0.18.2
gitdb               4.0.5
GitPython           3.1.11
h5py                2.10.0
hdbscan             0.8.26
idna                2.10
imageio             2.9.0
imageio-ffmpeg      0.4.2
ipykernel           5.3.4
ipython             7.18.1
ipython-genutils    0.2.0
ipywidgets          7.5.1
jedi                0.17.2
Jinja2              2.11.2
jmespath            0.10.0
joblib              0.17.0
jsonschema          3.2.0
jupyter-client      6.1.7
jupyter-core        4.6.3
jupyterlab-pygments 0.1.2
kiwisolver          1.2.0
llvmlite            0.34.0
MarkupSafe          1.1.1
matplotlib          3.3.2
mistune             0.8.4
nbclient            0.5.0
nbconvert           6.0.7
nbformat            5.0.7
nest-asyncio        1.4.1
networkx            2.5
notebook            6.1.4
numba               0.51.2
numexpr             2.7.1
numpy               1.19.1
olefile             0.46
opencv-python       4.4.0.44
packaging           20.4
pandas              1.1.3
pandocfilters       1.4.2
parso               0.7.1
pathtools           0.1.2
pexpect             4.8.0
pickleshare         0.7.5
Pillow              7.2.0
pip                 20.2.3
prometheus-client   0.8.0
prompt-toolkit      3.0.7
protobuf            3.13.0
psutil              5.7.2
ptyprocess          0.6.0
pyarrow             1.0.1
pycparser           2.20
pydeck              0.5.0b1
Pygments            2.7.1
pyparsing           2.4.7
pyrsistent          0.17.3
python-dateutil     2.8.1
pytz                2020.1
PyWavelets          1.1.1
PyYAML              5.3.1
pyzmq               19.0.2
randfacts           0.2.4
requests            2.24.0
s3transfer          0.3.3
scikit-image        0.17.2
scikit-learn        0.23.2
scipy               1.5.2
seaborn             0.11.0
Send2Trash          1.5.0
setuptools          49.6.0.post20200925
sip                 6.5.1
six                 1.15.0
smmap               3.0.4
streamlit           0.71.0
tables              3.6.1
terminado           0.9.1
testpath            0.4.4
threadpoolctl       2.1.0
tifffile            2020.10.1
toml                0.10.1
toolz               0.11.1
tornado             5.1.1
tqdm                4.50.2
traitlets           5.0.4
tzlocal             2.1
umap-learn          0.4.6
urllib3             1.25.10
validators          0.18.1
watchdog            0.10.3
wcwidth             0.2.5
webencodings        0.5.1
wheel               0.35.1
widgetsnbextension  3.5.1

I used DLC as pose estimation software, I extracted .h5 and .csv files. I tried to use both in B-SOiD and got the following errors.

.csv ERROR

IndexError: arrays used as indices must be of integer (or boolean) type
Traceback:

File "/home/nicky/anaconda3/envs/bsoidv2/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app.py", line 42, in <module>
    processor.compile_data()
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app/data_preprocess.py", line 104, in compile_data
    file_j_processed, p_sub_threshold = adp_filt(file_j_df, self.pose_chosen)
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app/bsoid_utilities/likelihoodprocessing.py", line 87, in adp_filt
    datax = curr_df1[1:, np.array(xIndex)]

.h5 ERROR

IndexError: arrays used as indices must be of integer (or boolean) type
Traceback:

File "/home/nicky/anaconda3/envs/bsoidv2/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app.py", line 42, in <module>
    processor.compile_data()
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app/data_preprocess.py", line 138, in compile_data
    file_j_processed, p_sub_threshold = adp_filt_h5(file_j_df, self.pose_chosen)
File "/home/nicky/Documents/School/Stage/Code/B-SOID/bsoid_app/bsoid_utilities/likelihoodprocessing.py", line 127, in adp_filt_h5
    datax = curr_df1[:, np.array(xIndex)]

SYSTEM

Nercules commented 1 year ago

I managed to fix the error, it was caused by an data read fault. DLC has changed their data structures a little. and the B-SOiD doesn't has dynamic reads. I think this is because the software seems to not be supported anymore (last update 2-3 years ago).

The fix Change in the script B-SOID/bsoid_app/bsoid_utilities/likelihoodprocessing.py the forloop on lines 79 - 85:

    for header in pose:
        if currdf[0][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[0][header + 1] == "x":
            xIndex.append(header)
        elif currdf[0][header + 1] == "y":
            yIndex.append(header)

to

    for header in pose:
        if currdf[1][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[1][header + 1] == "x":
            xIndex.append(header)
        elif currdf[1][header + 1] == "y":
            yIndex.append(header)

I ran into an other error when continuing the process. I will try fixing these errors and updating you.

Nercules commented 1 year ago

I managed to fix the error, it was caused by an data read fault. DLC has changed their data structures a little. and the B-SOiD doesn't has dynamic reads. I think this is because the software seems to not be supported anymore (last update 2-3 years ago).

The fix Change in the script B-SOID/bsoid_app/bsoid_utilities/likelihoodprocessing.py the forloop on lines 79 - 85:

    for header in pose:
        if currdf[0][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[0][header + 1] == "x":
            xIndex.append(header)
        elif currdf[0][header + 1] == "y":
            yIndex.append(header)

to

    for header in pose:
        if currdf[1][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[1][header + 1] == "x":
            xIndex.append(header)
        elif currdf[1][header + 1] == "y":
            yIndex.append(header)

I ran into an other error when continuing the process. I will try fixing these errors and updating you.

Nercules commented 1 year ago

I managed to fix the error, it was caused by an data read fault. DLC has changed their data structures a little. and the B-SOiD doesn't has dynamic reads. I think this is because the software seems to not be supported anymore (last update 2-3 years ago).

The fix Change in the script B-SOID/bsoid_app/bsoid_utilities/likelihoodprocessing.py the forloop on lines 79 - 85:

    for header in pose:
        if currdf[0][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[0][header + 1] == "x":
            xIndex.append(header)
        elif currdf[0][header + 1] == "y":
            yIndex.append(header)

to

    for header in pose:
        if currdf[1][header + 1] == "likelihood":
            lIndex.append(header)
        elif currdf[1][header + 1] == "x":
            xIndex.append(header)
        elif currdf[1][header + 1] == "y":
            yIndex.append(header)

I ran into an other error when continuing the process. I will try fixing these errors and updating you.