TLSeparation / source

Source code of the TLSeparation Python package.
GNU General Public License v3.0
30 stars 16 forks source link

Error when loading in numpy array to automated_separation.generic_tree() #5

Open tim-devereux opened 2 years ago

tim-devereux commented 2 years ago

Hi @mattbv, @philwilkes. I've been getting this error when loading a NumPy array into automated_separation.generic_tree(). The array is the correct dimension. This error isn't present when using tlseparation with Python 2.7. Thanks for any assistance.

`--------------------------------------------------------------------------- AssertionError Traceback (most recent call last)

in ----> 1 wood_final, leaf_final = tlseparation.scripts.automated_separation.generic_tree(arr, knn_list=[40, 50, 80, 100, 120], voxel_size=0.04, retrace_steps=40) /opt/conda/lib/python3.7/site-packages/tlseparation/scripts/automated_separation.py in generic_tree(arr, knn_list, voxel_size, retrace_steps) 662 # root of the tree. 663 path_mask = voxel_path_detection(arr, voxel_size, retrace_steps, 100, --> 664 voxel_size * 1.77, False) 665 # Filtering path_mask points by feature threshold. In this case, 666 # feature 4 has a very distinctive pattern for wood and leaf. Usually /opt/conda/lib/python3.7/site-packages/tlseparation/classification/path_detection.py in voxel_path_detection(point_cloud, voxel_size, k_retrace, knn, nbrs_threshold, verbose) 173 detect_main_pathways with %s number of steps retraced' % k_retrace) 174 path_mask_voxel = detect_main_pathways(vox_coords, k_retrace, knn, --> 175 nbrs_threshold, verbose=verbose) 176 # Re-indexing point_cloud indices from voxels coordinates detected as 177 # part of the path. /opt/conda/lib/python3.7/site-packages/tlseparation/classification/path_detection.py in detect_main_pathways(point_cloud, k_retrace, knn, nbrs_threshold, verbose, max_iter) 228 # dimensions. 229 assert point_cloud.ndim == 2, "point_cloud must be an array with 2\ --> 230 dimensions, n_points x 3 (x, y, z)." 231 assert point_cloud.shape[1] == 3, "point_cloud must be a 3D point cloud.\ 232 Make sure it has the shape n_points x 3 (x, y, z)." AssertionError: point_cloud must be an array with 2 dimensions, n_points x 3 (x, y, z).` ![image](https://user-images.githubusercontent.com/25172134/152483313-4a3e8d90-9f90-4e36-9d6e-432c508e7f05.png)
ylevental commented 2 years ago

Hello, I also noticed this

IMLHF commented 2 years ago

python2 is required

philwilkes commented 2 years ago

I have had issues with running tlseparation and think it might be down to conflicting or newer dependencies. I have found if I run this version 21a5a9d in Python 2 using:

scipy==0.19.0 pandas==0.19.2 numpy==1.11.3 networkx==1.11 scikit_learn==0.19.1

works for me (as noted in #6).

If you do something like

conda create -n tlsep2 python=2
conda activate tlsep2
pip install -r requirements.txt

Should give you

_libgcc_mutex 0.1 main
_openmp_mutex 4.5 1_gnu
ca-certificates 2022.4.26 h06a4308_0
certifi 2020.6.20 pyhd3eb1b0_3
decorator 4.4.2 pypi_0 pypi libffi 3.3 he6710b0_2
libgcc-ng 9.3.0 h5101ec6_17
libgomp 9.3.0 h5101ec6_17
libstdcxx-ng 9.3.0 hd4cf53a_17
ncurses 6.3 h7f8727e_2
networkx 1.11 pypi_0 pypi numpy 1.11.3 pypi_0 pypi pandas 0.19.2 pypi_0 pypi pip 19.3.1 py27_0
python 2.7.18 ha1903f6_2
python-dateutil 2.8.2 pypi_0 pypi pytz 2022.1 pypi_0 pypi readline 8.1.2 h7f8727e_1
scikit-learn 0.19.1 pypi_0 pypi scipy 0.19.0 pypi_0 pypi setuptools 44.0.0 py27_0
six 1.16.0 pypi_0 pypi sqlite 3.38.3 hc218d9a_0
tk 8.6.11 h1ccaba5_1
wheel 0.37.1 pyhd3eb1b0_0
zlib 1.2.12 h7f8727e_2