cellpose icon indicating copy to clipboard operation
cellpose copied to clipboard

Error when setting anisotropy

Open giocard opened this issue 3 years ago • 1 comments

Hi,

depending on the size of the stack and the value set for anisotropy, cellpose can fail to complete because during a resizing step one of the dimensions is set to zero. One way to reproduce the error is to generate an empty stack of 512x512x12 pixels and then to run the following command

cellpose --dir "C:\directory\containing\image\generated" --pretrained_model nuclei --chan 1 --chan2 0 --diameter 50.00 --verbose --use_gpu --do_3D --anisotropy 0.2000

With the latest 2.0.5 version I get the following error

Traceback (most recent call last): File "c:\conda\envs\cellpose\lib\runpy.py", line 193, in run_module_as_main "main", mod_spec) File "c:\conda\envs\cellpose\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Conda\envs\cellpose\Scripts\cellpose.exe_main.py", line 7, in File "c:\conda\envs\cellpose\lib\site-packages\cellpose_main.py", line 246, in main model_loaded=True) File "c:\conda\envs\cellpose\lib\site-packages\cellpose\models.py", line 260, in eval model_loaded=model_loaded) File "c:\conda\envs\cellpose\lib\site-packages\cellpose\models.py", line 567, in eval stitch_threshold=stitch_threshold, File "c:\conda\envs\cellpose\lib\site-packages\cellpose\models.py", line 592, in _run_cp tile_overlap=tile_overlap) File "c:\conda\envs\cellpose\lib\site-packages\cellpose\core.py", line 604, in _run_3D xsl = transforms.resize_image(xsl, rsz=rescaling[p]) File "c:\conda\envs\cellpose\lib\site-packages\cellpose\transforms.py", line 551, in resize_image imgs[i] = cv2.resize(img, (Lx, Ly), interpolation=interpolation) cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-memyuvq3\opencv\modules\imgproc\src\resize.cpp:4054: error: (-215:Assertion failed) inv_scale_x > 0 in function 'cv::resize'

giocard avatar Jul 13 '22 16:07 giocard

hmm are you sure your anisotropy is less than 1? that means there is denser sampling in Z than in XY

we should catch this error though

carsen-stringer avatar Aug 11 '22 21:08 carsen-stringer

added error catch, thanks for reporting this

carsen-stringer avatar Jan 12 '23 16:01 carsen-stringer