pBFSLab / FastCSR

28 stars 5 forks source link

Levelset regression model inference failed. #5

Closed stebo85 closed 9 months ago

stebo85 commented 10 months ago

I tried to run the tool on the test data provided and get this error:

python3 pipeline.py --sd ../data --sid sub-001  --t1 ../data/sub-001.nii.gz
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py Please cite the following paper when using FastCSR:
****************************************
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py ------------------------Generate mri/orig.mgz file--------------------------------
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py The mri/orig.mgz file already exists, skip this step.
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py -----------------------Generate mri/filled.mgz file-------------------------------
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py The mri/filled.mgz file already exists, skip this step.
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py --------------------Generate mri/aseg.presurf.mgz file----------------------------
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py The mri/aseg.presurf.mgz file already exists, skip this step.
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py ---------------------Generate mri/brainmask.mgz file------------------------------
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py The mri/brainmask.mgz file already exists, skip this step.
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py -------------------------Generate mri/wm.mgz file---------------------------------
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py The mri/wm.mgz file already exists, skip this step.
[INFO] 2023-12-08 07:10:30 PID: 15 pipeline.py -------------------Generate mri/?h_levelset.nii.gz file---------------------------
[ERROR] 2023-12-08 07:10:47 PID: 15 pipeline.py Levelset regression model inference failed.

this is the list of python packages installed and their versions:

Package             Version             
------------------- --------------------
antspyx             0.4.2               
batchgenerators     0.25                
certifi             2019.11.28          
chardet             3.0.4               
chart-studio        1.1.0               
contourpy           1.1.1               
cycler              0.12.1              
dbus-python         1.2.16              
dicom2nifti         2.4.9               
distro-info         0.23+ubuntu1.1      
fonttools           4.46.0              
future              0.18.3              
idna                2.8                 
imageio             2.33.0              
importlib-resources 6.1.1               
joblib              1.3.2               
kiwisolver          1.4.5               
lazy-loader         0.3                 
linecache2          1.0.0               
matplotlib          3.7.4               
MedPy               0.4.0               
networkx            3.1                 
nibabel             5.1.0               
nighres             1.2.0               
nnunet              1.7.0               
numpy               1.24.4              
packaging           23.2                
pandas              2.0.3               
patsy               0.5.4               
Pillow              10.1.0              
pip                 20.0.2              
plotly              5.18.0              
psutil              5.9.6               
pydicom             2.4.3               
PyGObject           3.36.0              
pyparsing           3.1.1               
python-apt          2.0.1+ubuntu0.20.4.1
python-dateutil     2.8.2               
python-gdcm         3.0.22              
pytz                2023.3.post1        
PyWavelets          1.4.1               
PyYAML              6.0.1               
requests            2.22.0              
requests-unixsocket 0.2.0               
retrying            1.3.4               
scikit-image        0.21.0              
scikit-learn        1.3.2               
scipy               1.10.1              
setuptools          45.2.0              
sh                  2.0.6               
SimpleITK           2.3.1               
six                 1.14.0              
sklearn             0.0.post12          
statsmodels         0.14.0              
tenacity            8.2.3               
threadpoolctl       3.2.0               
tifffile            2023.7.10           
torch               1.9.1+cpu           
torchaudio          0.9.1               
torchvision         0.10.1+cpu          
tqdm                4.66.1              
traceback2          1.4.0               
typing-extensions   4.8.0               
tzdata              2023.3              
unattended-upgrades 0.1                 
unittest2           1.1.0               
urllib3             1.25.8              
webcolors           1.13                
wheel               0.34.2              
zipp                3.17.0   
weiwei2027 commented 10 months ago

@stebo85 Hi~, this may be because there are relatively new packages in the installation package and there are compatibility issues during operation. You can try running with --parallel_scheduling off and --verbose to get more error related information.

stebo85 commented 9 months ago

Dear @weiwei2027,

The first error was caused by the source code assuming that the model is the same directory as the code. The next error seems to be related to a too new nibabel version:

[INFO] 2023-12-11 00:50:25 PID: 24 pipeline.py ------------------------Generate surf/?h.orig file--------------------------------
Traceback (most recent call last):
  File "levelset2surf.py", line 106, in <module>
    levelset2surf(fastcsr_subjects_dir, subj, hemi, suffix)
  File "levelset2surf.py", line 57, in levelset2surf
    tc_ret = nighres.shape.topology_correction(img, 'signed_distance_function',
  File "/usr/local/lib/python3.8/dist-packages/nighres/shape/topology_correction.py", line 109, in topology_correction
    data = img.get_data()
  File "/usr/local/lib/python3.8/dist-packages/nibabel/deprecator.py", line 208, in deprecated_func
    raise exception(message)
nibabel.deprecator.ExpiredDeprecationError: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
[ERROR] 2023-12-11 00:50:43 PID: 24 pipeline.py Surface generation failed.

I am trying to downgrade nibabel and see if I can get past that. It would have helped a lot if you had provided a proper dockerfile that allows building the correct container with correct version or a docker image in the registry ...

stebo85 commented 9 months ago

Dear @weiwei2027,

I tried downgrading nibabel to the version you seemed to have used, but this collides with numpy again:

pipeline.py --sd ./data --sid sub-001  --t1 ./data/sub-001.nii.gz --parallel_scheduling off --verbose
Traceback (most recent call last):
  File "pipeline.py", line 13, in <module>
    import ants
  File "/usr/local/lib/python3.8/dist-packages/ants/__init__.py", line 7, in <module>
    from .core import *
  File "/usr/local/lib/python3.8/dist-packages/ants/core/__init__.py", line 2, in <module>
    from .ants_image import *
  File "/usr/local/lib/python3.8/dist-packages/ants/core/ants_image.py", line 29, in <module>
    from .. import registration, segmentation, utils, viz
  File "/usr/local/lib/python3.8/dist-packages/ants/registration/__init__.py", line 3, in <module>
    from .affine_initializer import *
  File "/usr/local/lib/python3.8/dist-packages/ants/registration/affine_initializer.py", line 7, in <module>
    from .. import utils
  File "/usr/local/lib/python3.8/dist-packages/ants/utils/__init__.py", line 5, in <module>
    from .convert_nibabel import *
  File "/usr/local/lib/python3.8/dist-packages/ants/utils/convert_nibabel.py", line 6, in <module>
    import nibabel as nib
  File "/usr/local/lib/python3.8/dist-packages/nibabel/__init__.py", line 65, in <module>
    from . import nifti1 as ni1
  File "/usr/local/lib/python3.8/dist-packages/nibabel/nifti1.py", line 26, in <module>
    from .quaternions import fillpositive, quat2mat, mat2quat
  File "/usr/local/lib/python3.8/dist-packages/nibabel/quaternions.py", line 31, in <module>
    MAX_FLOAT = np.maximum_sctype(np.float)
  File "/usr/local/lib/python3.8/dist-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:

can you post which versions of packages you originally used?

weiwei2027 commented 9 months ago

@stebo85 Thanks for your feedback. It seems that providing a requirements.txt file is very necessary. Now I recommend that you lower the numpy version to 1.20 or 1.19. Ignore the warning from pip that nighres requires a lower version of numpy.

stebo85 commented 9 months ago

@weiwei2027 ,

yes, a requirements file would be useful - or fixing package versions in your docker file. I downgraded numpy to 1.19.5, but no success:

python3 pipeline.py --sd ./data --sid sub-001  --t1 ./data/sub-001.nii.gz --parallel_scheduling off --verbose
Traceback (most recent call last):
  File "pipeline.py", line 13, in <module>
    import ants
  File "/usr/local/lib/python3.8/dist-packages/ants/__init__.py", line 7, in <module>
    from .core import *
  File "/usr/local/lib/python3.8/dist-packages/ants/core/__init__.py", line 2, in <module>
    from .ants_image import *
  File "/usr/local/lib/python3.8/dist-packages/ants/core/ants_image.py", line 19, in <module>
    import pandas as pd
  File "/usr/local/lib/python3.8/dist-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
  File "/usr/local/lib/python3.8/dist-packages/pandas/compat/__init__.py", line 25, in <module>
    from pandas.compat.numpy import (
  File "/usr/local/lib/python3.8/dist-packages/pandas/compat/numpy/__init__.py", line 25, in <module>
    raise ImportError(
ImportError: this version of pandas is incompatible with numpy < 1.20.3
your numpy version is 1.19.5.
weiwei2027 commented 9 months ago

@stebo85 so frustrating. All these problems are mainly caused by nighres being too old. New versions of other software will have various compatibility errors. Unfortunately, there is no running environment on my computer, and I cannot provide you with accurate runnable software version information. At the time this code was released, these issues did not exist, which may be a clue to downgrading the software version. Or please check the article and code first. Some parts may still be of reference value, but some parts are out of date.

pBFSLab commented 9 months ago

Hi @stebo85, We'll update the docker and codes with updated dependencies this week. Will let you know after updating.

pBFSLab commented 9 months ago

Hi @stebo85 , We have updated docker/Dockerfile_cpu and docker/Dockerfile_gpu. The FastCSR Docker image has been uploaded to dockerhub. The address is: https://hub.docker.com/r/ninganme/fastcsr/tags. run example: sudo docker run -it --gpus 'device=0' -v $TestDataPath:/root/data --rm ninganme/fastcsr:last --sid sub-001 --sd /root/data --optimizing_surface off

stebo85 commented 9 months ago

Dear @IndiLab - fantastic that works :)