ABI-Software / ICMA

Cardiac ultrasound and MRI image processing and analysis
11 stars 17 forks source link

No module _context #3

Closed dijbi closed 5 years ago

dijbi commented 5 years ago

Hi,

I did follow the steps in the README. After launching the .bat, i have an error with a unrecognized module Here are the logs:

Traceback (most recent call last):
  File "C:\Users\***\Miniconda3\lib\site-packages\zinc-3.1.1_amd64_windows_python_3.6-py3.6.egg\opencmiss\zinc\context.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\***\Miniconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: Le module spécifié est introuvable.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "icma\ICMA.py", line 46, in <module>
    from icma.widgets import ICMAMain, WorkspaceWidget, LogConsole, Disclaimer
  File "C:\Program Files\ICMA-master\Python\ICMA2.0\icma\widgets.py", line 46, in <module>
    from viewers.VTKWidgets import DicomCollageViewer, SpeckleTrackingWindow
  File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 51, in <module>
    from speckleTracking.TrackAndView import TrackAndView
  File "C:\Program Files\ICMA-master\Python\ICMA2.0\speckleTracking\TrackAndView.py", line 39, in <module>
    from capmodel.LV import Heart
  File "C:\Program Files\ICMA-master\Python\ICMA2.0\capmodel\LV.py", line 37, in <module>
    from opencmiss.zinc.context import Context
  File "C:\Users\***\Miniconda3\lib\site-packages\zinc-3.1.1_amd64_windows_python_3.6-py3.6.egg\opencmiss\zinc\context.py", line 17, in <module>
    _context = swig_import_helper()
  File "C:\Users\***\Miniconda3\lib\site-packages\zinc-3.1.1_amd64_windows_python_3.6-py3.6.egg\opencmiss\zinc\context.py", line 16, in swig_import_helper
    return importlib.import_module('_context')
  File "C:\Users\***\Miniconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_context'

Context.py, _context.pyd are in the right directory : C:\Users***\Miniconda3\lib\site-packages\zinc-3.1.1_amd64_windows_python_3.6-py3.6.egg\opencmiss\zinc

Any help for the next step to follow ? Thks

Jagirhussan commented 5 years ago

Could you check if you have installed opencmiss-zinc stack correctly. It appears that python is not able to load the corresponding dll's. Pre built libraries for Opencmiss-zinc can be downloaded from http://opencmiss.org/downloads.html#/package/opencmisslibs/download

Once you have installed it, ensure you can load it by starting a python shell and check if the following import statement works from opencmiss.zinc.context import Context

dijbi commented 5 years ago

Hello,

thanks à lot. I had already downloaded the prebuilt binary. After adding manually the path to my system path, there was no import problem with _context. 👍

What stucks me now is Elementfieldtemplate from opencmiss.zinc

File "icma\ICMA.py", line 46, in <module> from icma.widgets import ICMAMain, WorkspaceWidget, LogConsole, Disclaimer File "C:\Program Files\ICMA-master\Python\ICMA2.0\icma\widgets.py", line 47, in <module> from meshing.zincMeshGenerator import ICMAMeshGenerator File "C:\Program Files\ICMA-master\Python\ICMA2.0\meshing\zincMeshGenerator.py", line 39, in <module> from opencmiss.zinc.element import Element, Elementbasis, Elementfieldtemplate ImportError: cannot import name 'Elementfieldtemplate'

I can easily import Element & ElementBasis from a python prompt, but not Elementfieldtemplate. Any suggestions ?

Thanks again

Jagirhussan commented 5 years ago

Could you check the version of opencmiss-zinc that has been installed. You can find this using the following commands import opencmiss.zinc print opencmiss.zinc.version

dijbi commented 5 years ago

Hi

import opencmiss.zinc print opencmiss.zinc.version

throws an error that statesthat opencmiss.zinc has no version attribute AttributeError: module 'opencmiss.zinc' has no attribute 'version'

BYT, import opencmiss.zinc throws no error print(opencmiss.zinc) gives me <module 'opencmiss.zinc' from 'C:\\Program Files\\OpenCMISS Libraries SDK\\lib\\python3.6\\Release\\opencmiss.zinc\\opencmiss\\zinc\\__init__.py'>

From the OpenCmiss website, the version downloaded is Version: 1.3.0, for Windows

Thxs for the help !

rchristie commented 5 years ago

Try the latest development release (it’s a good idea to use it anyway):

http://opencmiss.org/downloads.html#/package/opencmisslibs/devreleases

BTW If the following works, then a version of zinc is installed: from opencmiss.zinc.context import Context

I’m not sure that version code you wrote should work; after the above command enter: context = Context('test') print(context.getVersionString())

The above uses the print() syntax for Python 3. Beware that Python 2 is being deprecated – by Python – in the next few months, and we’ll follow suit.

cheers, Richard

From: djibi notifications@github.com Sent: Thursday, 7 March 2019 9:18 AM To: ABI-Software/ICMA ICMA@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [ABI-Software/ICMA] No module _context (#3)

Hi

import opencmiss.zinc print opencmiss.zinc.version

throws an error that statesthat opencmiss.zinc has no version attribute AttributeError: module 'opencmiss.zinc' has no attribute 'version'

BYT, import opencmiss.zinc throws no error print(opencmiss.zinc) gives me <module 'opencmiss.zinc' from 'C:\Program Files\OpenCMISS Libraries SDK\lib\python3.6\Release\opencmiss.zinc\opencmiss\zinc\init.py'>

From the OpenCmiss websitehttp://opencmiss.org/downloads.html#/package/opencmisslibs/download, the version downloaded is Version: 1.3.0, for Windows

Thxs for the help !

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/ABI-Software/ICMA/issues/3#issuecomment-470260377, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AA0ElrC1wHggs327eYgsASFpYy6Xmiquks5vUCKEgaJpZM4bbPUc.

dijbi commented 5 years ago

Hooray, i did launch the software. Thanks a lot @rchristie 👍 👍

FYI, i used the dev version: 1.3.0.20171204225554, the last one (Version: 1.3.0.20180309013242) did not work either.

I tried w/ 2 examples from 2 differents ultrasound machines, that gives two differents errors.

1) Phillips Cx50 : the INFO output from the Log windows shows : 2019-03-20 19:55:53,644 - INFO - Parsing local DICOMDIR C:/Users/djibi/Dev/ICMA/t/*****/DICOMDIR 2019-03-20 19:55:53,644 - INFO - DICOMFileDirectory: Creating DICOM directory from C:/Users/djibi/Dev/ICMA/t/*****/DICOMDIR 2019-03-20 19:55:53,872 - INFO - DICOMFileDirectory: Parsing of DICOMDIR completed 2019-03-20 19:55:53,952 - INFO - Retrieved 0 patients 2019-03-20 19:55:53,952 - INFO - Updating Patients Model

2) Siemens Acusson SC2000 : the app crashes.

Output from the command line print : Traceback (most recent call last): File "C:\Program Files\ICMA-master\Python\ICMA2.0\dicomio\DirectoryManager.py", line 460, in run self.parserDICOMDIR(dicomDir,os.path.dirname(self.dicomdir)) File "C:\Program Files\ICMA-master\Python\ICMA2.0\dicomio\DirectoryManager.py", line 583, in parserDICOMDIR pname = value.split('^') AttributeError: 'PersonName3' object has no attribute 'split'

Any solution why it's not loading ? Does anyone has some US DICOM examples i could use to test ?

Jagirhussan commented 5 years ago

Hi, Thanks for the observations and report. The issues are related pydicom's inability (under python 3) to deal with compressed dicom data. The other option you have is to revert to python 2.7 where this does not occur.

dijbi commented 5 years ago

Hi Thanks for the answer

i decided to revert to python 2.7. i can not get to make the app work, i have now a VTK error.

Traceback (most recent call last): File "icma\ICMA.py", line 46, in <module> from icma.widgets import ICMAMain, WorkspaceWidget, LogConsole, Disclaimer File "C:\Program Files\ICMA-master\Python\ICMA2.0\icma\widgets.py", line 46, in <module> from viewers.VTKWidgets import DicomCollageViewer, SpeckleTrackingWindow File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 49, in <module> from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor File "C:\Users\****\Miniconda2\lib\site-packages\vtk\qt\QVTKRenderWindowInteractor.py", line 36, in <module> import Qt ImportError: No module named Qt

Conda list (for packages versions under Miniconda 2 `

Link to Opencmiss via PYTHONPATH (unchanged version 1.3.0.20171204225554).

Could you print the version you have w/ your working ICMA ? Thx !

dijbi commented 5 years ago

Update : Seems to be a PyQt 4 vs 5 import problem. I change directly inside the QVTKRenderWindowInteractor.py file to force tje use of PyQt5 with a qt alias not to mess up too much the code. (from PyQt5 import Qt as qt) -- not a good thing to mess up the code but the error is not showing up anymore

Run into the opencmiss.zinc link error (with _context not being recognized), albeit the path inside PYTHONPATH being correct, albeit loading without error the opencmiss.zinc...

dijbi commented 5 years ago

For people interested in using ICMA w/ Python 2.7, here are my notes (to be completed) :

dijbi commented 5 years ago

I am not loosing faith.... yet

I have PyQt5 installed, but an error is still thrown : (base) C:\Program Files\ICMA-master\Python\ICMA2.0>python icma\ICMA.py Traceback (most recent call last): File "icma\ICMA.py", line 46, in <module> from icma.widgets import ICMAMain, WorkspaceWidget, LogConsole, Disclaimer File "C:\Program Files\ICMA-master\Python\ICMA2.0\icma\widgets.py", line 46, in <module> from viewers.VTKWidgets import DicomCollageViewer, SpeckleTrackingWindow File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 49, in <module> from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor File "C:\Users\****\Miniconda2\lib\site-packages\vtk\qt4\QVTKRenderWindowInteractor.py", line 11, in <module> raise ImportError("Cannot load either PyQt or PySide") ImportError: Cannot load either PyQt or PySide

Under the python bash, i can load PyQt5 but not pyqt When i tried to install PySide, the app launches but an error is still thrown :

(base) C:\Program Files\ICMA-master\Python\ICMA2.0>python icma\ICMA.py QObject::connect: Cannot queue arguments of type 'QTextBlock' (Make sure 'QTextBlock' is registered using qRegisterMetaType().) QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Traceback (most recent call last): File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 707, in setupUi iv = MultiFrameDicomViewer(ddm) File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 303, in __init__ self.setupUi(self) File "C:\Program Files\ICMA-master\Python\ICMA2.0\viewers\VTKWidgets.py", line 327, in setupUi self.frame = QVTKRenderWindowInteractor(Form) File "C:\Users\djibi\Miniconda2\lib\site-packages\vtk\qt\QVTKRenderWindowInteractor.py", line 233, in __init__ QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) TypeError: 'PySide.QtGui.QWidget' called with wrong argument types: PySide.QtGui.QWidget(MultiFrameDicomViewer, WindowFlags) Supported signatures: PySide.QtGui.QWidget(PySide.QtGui.QWidget = None, PySide.QtCore.Qt.WindowFlags = 0)

Any tips ? Thx

dijbi commented 5 years ago

I uninstall PySlide, modified lib\site-packages\vtk\qt4\QVTKRenderWindowInteractor.py" to force the use of PyQT5

import vtk.qt
try:
    import PyQt5
    vtk.qt.PyQtImpl = "PyQt5"
except ImportError:
    try:
        import PySide
        vtk.qt.PyQtImpl = "PySide"
    except ImportError:
        raise ImportError("Cannot load either PyQt or PySide")

from vtk.qt.QVTKRenderWindowInteractor import *

if __name__ == "__main__":
    print(PyQtImpl)
    QVTKRenderWidgetConeExample()

ICMA is launching (hooray). I can read a ACUSON 2000 DICOM, but the image shows up as one line....

Capture.

I have see in pydicom issues section that two packages were needed to decompress compressed DICOM. Can someone confirm if it is possible ?

Thx

Jagirhussan commented 5 years ago

Thanks for your heroic efforts and persistence. I have done a fresh install of miniconda 2.7 on windows, installed the required packages and run the application. Below is the sequence of package installation commands

conda install pyqt=5 conda install scipy pandas requests opencv matplotlib pillow xlswriter conda install -c clinicalgraphics pydicom gdcm

Downloaded VTK‑7.1.1‑cp27‑cp27m‑win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk

pip install VTK-7.1.1-cp27-cp27m-win_amd64.whl

Linked to opencmiss i,e. \lib\python2.7\Release\opencmiss.zinc via python path and was able to execute the application, view dicoms and create models.

Screenshot of the app along with installed packages icmascwithdependencies

dijbi commented 5 years ago

Thanks a lot, with almost the same package version, i succeeded to lauch the software. I had to install diskcache. FYI I uploaded studies with a lot of cine loops & still pictures and the app crashed. then, i extracted some (2 or 3) cine loops, and i was OK. With a phillips Cx50 study, i still have some compression issue, do you think it will make the LV strain less accurate ? or totally wrong ?

Here are my logs when i opened a Phillips Cx50 study :

Traceback (most recent call last): File "C:\Users\***\Miniconda2\lib\site-packages\vtk\qt\QVTKRenderWindowIntera ctor.py", line 435, in keyPressEvent key = str(ev.text()) UnicodeEncodeError: 'ascii' codec can't encode character u'\xb2' in position 0: ordinal not in range(128)

what if i transcode the DICOM file w/ another codec ? Thks for saving my hopes ! :1

Jagirhussan commented 5 years ago

I think the crashing may be due to memory issues. We rely on packages such as vtk, pydicom etc and would not be able to address these. The error is thrown by QVTKRenderWindowInteractor and not by a dicom module. So I donot think that this is a compression issue. Speckle tracking on compressed dicom's is not recommended. Since the errors that you are raising now are not related to the initial issue i.e. 'No module _context'. I am closing this issue as resolved. Please log a different issue if you run into one.