Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in create_distance_map in Windows #51

Closed
phcerdan opened this issue Sep 3, 2020 · 10 comments
Closed

Exception in create_distance_map in Windows #51

phcerdan opened this issue Sep 3, 2020 · 10 comments

Comments

@phcerdan
Copy link
Owner

phcerdan commented Sep 3, 2020

Reported in https://discourse.vtk.org/t/vmtk-center-lines-extraction-how-to-accelerate-it-and-how-to-extract-center-lines-from-small-vessel/4103/13

sgextImg = sgext.itk.IUC3P()
sgextImg.from_pyarray(mask*255)
dmap_image = sgext.scripts.create_distance_map(input=sgextImg, verbose=True)
thin_image = sgext.scripts.thin(input=sgextImg,
                   table_folder= sgext.tables_folder,
                   skel_type="end",
                   select_type="dmax",
                   input_distance_map_image=dmap_image,
                   persistence=2,
                   visualize=False,
                   verbose=True
                   )

dmap_image = sgext.scripts.create_distance_map(input=sgextImg, verbose=True)

unhandled win32 exception occurred in python.exe

My environment is:

win10
Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
sgext: I don't know the version. I think it is the latest version.
@NeuZhangQiang
Copy link

How can I get more verbose error about that exception?

dmap_image = sgext.scripts.create_distance_map(input=sgextImg, verbose=True)

This code cause a vs bug. And the picture is:
image

I am sorry that the character is Chinese. But it means:

unhandled win32 exception occurred in python.exe

@phcerdan
Copy link
Owner Author

phcerdan commented Sep 3, 2020

I am not sure to be honest, let me try to reproduce it. Thanks for your time on this.

@phcerdan
Copy link
Owner Author

phcerdan commented Sep 3, 2020

@NeuZhangQiang you could try meanwhile with:

sgextImg = sgext.itk.IUC3P()
sgextImg.from_pyarray(mask*255)
dmap_image = sgext.itk.IF3P()
thin_image = sgext.scripts.thin(input=sgextImg,
                   table_folder= sgext.tables_folder,
                   skel_type="end",
                   select_type="first",
                   input_distance_map_image=dmap_image,
                   persistence=2,
                   visualize=False,
                   verbose=True
                   )

I have changed select_type to "first" and dmap_image is initialized to an empty image.
This will be solved in the next release.

I will explore meanwhile the exception in create_distance_map.

@NeuZhangQiang
Copy link

I have tested the following code:

mask = np.zeros(shape=[500, 500, 400], dtype=np.uint8)
mask[250:350, 250:350, 100:300] = 255
sgextImg = sgext.itk.IUC3P()
sgextImg.from_pyarray(mask)
dmap_image = sgext.itk.IF3P()
thin_image = sgext.scripts.thin(input=sgextImg,
                   table_folder= sgext.tables_folder,
                   skel_type="end",
                   select_type="first",
                   input_distance_map_image=dmap_image,
                   persistence=2,
                   visualize=False,
                   verbose=True
                   )

And the bug is:

TypeError: thin(): incompatible function arguments. The following argument types are supported:
    1. (input: itk::SmartPointer<itk::Image<unsigned char,3> >, skel_type: str, select_type: str, tables_folder: str, persistence: int = 0, input_distance_map_image: itk::SmartPointer<itk::Image<float,3> > = None, profile: bool = False, verbose: bool = False, visualize: bool = False) -> itk::SmartPointer<itk::Image<unsigned char,3> >

Invoked with: kwargs: input=Dimension: 3
LargestPossibleRegion: 
  Index: [0, 0, 0]
  Size (i,j,k) (c_array): [400, 500, 500]
Origin: [0, 0, 0]
Spacing: [1, 1, 1]
Direction: 
1 0 0
0 1 0
0 0 1
Buffer: 
ImportImageContainer (00000292CCE157E0)
  RTTI typeinfo:   class itk::ImportImageContainer<unsigned __int64,unsigned char>
  Reference Count: 1
  Modified Time: 56
  Debug: Off
  Object Name: 
  Observers: 
    none
  Pointer: 00000292CE1AB040
  Container manages memory: false
  Size: 100000000
  Capacity: 100000000
, table_folder='D:\\ProgramData\\Anaconda3\\envs\\general\\lib\\site-packages\\sgext\\tables', skel_type='end', select_type='first', input_distance_map_image=Dimension: 3
LargestPossibleRegion: 
  Index: [0, 0, 0]
  Size (i,j,k) (c_array): [0, 0, 0]
Origin: [0, 0, 0]
Spacing: [1, 1, 1]
Direction: 
1 0 0
0 1 0
0 0 1
Buffer: 
ImportImageContainer (00000292CCE138E0)
  RTTI typeinfo:   class itk::ImportImageContainer<unsigned __int64,float>
  Reference Count: 1
  Modified Time: 66
  Debug: Off
  Object Name: 
  Observers: 
    none
  Pointer: 0000000000000000
  Container manages memory: true
  Size: 0
  Capacity: 0
, persistence=2, visualize=False, verbose=True

@phcerdan
Copy link
Owner Author

phcerdan commented Sep 3, 2020

Ok, I will release the next version of sgext today to solve the latest one.

Umm, could you try the version with the distance map, but in a much smaller image, just in case the exception is related to memory:

mask = np.zeros(shape=[50, 50, 40], dtype=np.uint8)
mask[25:35, 25:35, 10:30] = 255
sgextImg.from_pyarray(mask)
dmap_image = sgext.scripts.create_distance_map(input=sgextImg, verbose=True)
thin_image = sgext.scripts.thin(input=sgextImg,
                   table_folder= sgext.tables_folder,
                   skel_type="end",
                   select_type="dmax",
                   input_distance_map_image=dmap_image,
                   persistence=2,
                   visualize=False,
                   verbose=True
                   )

@phcerdan
Copy link
Owner Author

phcerdan commented Sep 3, 2020

I cannot reproduce it, have you checked if it was a memory problem? Let me know

@NeuZhangQiang
Copy link

I have run the following code:

mask = np.zeros(shape=[50, 50, 40], dtype=np.uint8)
mask[25:35, 25:35, 10:30] = 255

sgextImg = sgext.itk.IUC3P()
sgextImg.from_pyarray(mask)
# dmap_image = sgext.itk.IF3P()
dmap_image = sgext.scripts.create_distance_map(input=sgextImg, verbose=True)
thin_image = sgext.scripts.thin(input=sgextImg,
                   table_folder= sgext.tables_folder,
                   skel_type="end",
                   select_type="dmax",
                   input_distance_map_image=dmap_image,
                   persistence=2,
                   visualize=False,
                   verbose=True
                   )

But the bug is still reported:

New Block [Create Distance Map]
EndBlock [Create Distance Map] (39 ms)
Traceback (most recent call last):
  File "E:/Keypoint/data/bronchi/sgextScript.py", line 24, in <module>
    verbose=True
TypeError: thin(): incompatible function arguments. The following argument types are supported:
    1. (input: itk::SmartPointer<itk::Image<unsigned char,3> >, skel_type: str, select_type: str, tables_folder: str, persistence: int = 0, input_distance_map_image: itk::SmartPointer<itk::Image<float,3> > = None, profile: bool = False, verbose: bool = False, visualize: bool = False) -> itk::SmartPointer<itk::Image<unsigned char,3> >

Invoked with: kwargs: input=Dimension: 3
LargestPossibleRegion: 
  Index: [0, 0, 0]
  Size (i,j,k) (c_array): [40, 50, 50]
Origin: [0, 0, 0]
Spacing: [1, 1, 1]
Direction: 
1 0 0
0 1 0
0 0 1
Buffer: 
ImportImageContainer (000002BAB2E45FE0)
  RTTI typeinfo:   class itk::ImportImageContainer<unsigned __int64,unsigned char>
  Reference Count: 1
  Modified Time: 56
  Debug: Off
  Object Name: 
  Observers: 
    none
  Pointer: 000002BAB36E5F00
  Container manages memory: false
  Size: 100000
  Capacity: 100000
, table_folder='D:\\ProgramData\\Anaconda3\\envs\\general\\lib\\site-packages\\sgext\\tables', skel_type='end', select_type='dmax', input_distance_map_image=Dimension: 3
LargestPossibleRegion: 
  Index: [0, 0, 0]
  Size (i,j,k) (c_array): [40, 50, 50]
Origin: [0, 0, 0]
Spacing: [1, 1, 1]
Direction: 
1 0 0
0 1 0
0 0 1
Buffer: 
ImportImageContainer (000002BAB2E47F60)
  RTTI typeinfo:   class itk::ImportImageContainer<unsigned __int64,float>
  Reference Count: 1
  Modified Time: 69
  Debug: Off
  Object Name: 
  Observers: 
    none
  Pointer: 000002BAB3757D30
  Container manages memory: true
  Size: 100000
  Capacity: 100000
, persistence=2, visualize=False, verbose=True
Time elapsed: 0

The environment is:

win10, 32 GB memory
Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
sgext-0.9.12

And I think it is not a memory problem.

@phcerdan
Copy link
Owner Author

phcerdan commented Sep 4, 2020

Please update sgext: pip install --upgrade sgext to solve the thin(): incompatible function arguments error. Fixed in 29cdaa2.

I am closing this issue, you were able to create_distance_map in windows with no exception.

@phcerdan phcerdan closed this as completed Sep 4, 2020
@vijosam
Copy link

vijosam commented Sep 10, 2020

@phcerdan Thanks for sharing your wonderful package. I notice that the lastest version in pypi is 0.9.13 and the incompatible function arguments error in thin() also exists. Could you fix this?

@phcerdan
Copy link
Owner Author

@LydiaLS That error could be triggered for many parameters, please open a new issue, post the minimal code that you are using, and the platform. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants