Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

In the new version, Using 2D Viewer to view RT Structure, and selects multiple organs. Rolling with mouse is too laggy #112

Open
goodsave opened this issue Oct 17, 2018 · 8 comments
Assignees
Labels

Comments

@goodsave
Copy link

In the new version, Using 2D Viewer to view RT Structure, and selects multiple organs. Rolling with mouse is too laggy. In old version, mouse rolling will be smooth. Where do I need to repair it? I'm in a hurry to fix it.

my email : goodsave@qq.com
I hope to receive your reply.

@bastula bastula self-assigned this Oct 17, 2018
@bastula bastula added the bug label Oct 17, 2018
@bastula
Copy link
Owner

bastula commented Oct 17, 2018

I'm not exactly sure why it is so slow because it was ok with wxPython 2.8.10.1. I'm pretty sure that this is due to the upgrade to wxPython 4.

The main issue is that structure coordinate parsing happens for every slice every time you change the image slice position. This slowness happens with even 1 structure selected.

In the short term I recommend using the old released binary version (or if you can run from old source).
The long term fix is to cache the structure data even before the 2D image opens.

@goodsave
Copy link
Author

goodsave commented Oct 18, 2018

ok, I carefully compared the code between the old version and the new version in 2dview.py, and found that there was not much difference between them.

I tried to use the old version, but the dependence of matplotlib could not be installed, so I gave up.

I'm going to try it in multithreading and try using the cache you mentioned.

If there is any progress, I will continue to comment here. Thank U!

@bastula
Copy link
Owner

bastula commented Oct 18, 2018 via email

@goodsave
Copy link
Author

goodsave commented Nov 1, 2018

I wrote a simple cached version of the 2dview plug-in. You can get it in the attachment.
But it's not very good because it‘ll takes a lot of time to cache after a patient is selected.

By the way, There is no improvement in using multithreading to rewrite computing coordinates,because Python multithreading can not effectively utilize multi-core CPU.
My personal advice is to use C++ to rewrite the code of calculating coordinates and then use Python to invoke it if time permits.

Besides, Could you tell me what tools you pack into exe?

2dview.txt

@bastula
Copy link
Owner

bastula commented Nov 1, 2018

Thank you for posting your modification. Your solution seems to work, but is slow as you mentioned.

I think there can be some optimization done with GetContourPixelData as it's purely a lookup function. It could be written using some Numpy ufuncs or functions.

For the exe, I just used py2exe, but I'm not sure if that is maintained anymore. You could try pyinstaller.

@goodsave
Copy link
Author

goodsave commented Nov 6, 2018

Allright,thank for your suggestion. I simply rewrote the part of the calculation coordinates with numpy. It's very fast now. The revised code is as follows:
def GetContourPixelData(self, pixlut, contour, prone=False, feetfirst=False): pixeldata = [] for p, point in enumerate(contour): if (not prone and not feetfirst): xIndex = np.argwhere(pixlut[0] > point[0]) elif (feetfirst or prone): xIndex = np.argwhere(pixlut[0] < point[0]) if (not prone): yIndex = np.argwhere(pixlut[1] > point[1]) elif (prone): yIndex = np.argwhere(pixlut[1] < point[1]) pixeldata.append((xIndex.min(), yIndex.min())) return pixeldata

@bastula
Copy link
Owner

bastula commented Nov 6, 2018

Awesome! So no need for threading right?

@goodsave
Copy link
Author

goodsave commented Nov 6, 2018

No need for caching and multithreading. Python's multithreading has no effect in CPU intensive type.
In addition,there are also some small BUG.

1.The position of the RS display is down to the right. Simple repair method:
path.MoveToPoint(point[0]-1, point[1]-1) path.AddLineToPoint(point[0]-1, point[1]-1)

2.Zoom button does not appear at the beginning.

3.Pyinstaller packaging in Python36 encountered various problems.

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

No branches or pull requests

2 participants