baiwenjia / ukbb_cardiac

Some code for processing and analysing UK Biobank cardiac MR images.
Apache License 2.0
153 stars 66 forks source link

VTK reading errors #12

Open jrhomburger opened 2 years ago

jrhomburger commented 2 years ago

Receiving the following error when running:

vtkPolyDataReader (0x55a6391564c0): Error reading ascii cell data! for file: /data/mri/ukb-cardiac-mri/1000948/cine_motion/myo_contour_ED_z02.vtk

Resulting in:

Traceback (most recent call last):
  File "/opt/ukbb_cardiac/short_axis/eval_strain_sax.py", line 55, in <module>
    data_dir, args.par_dir, motion_dir, "{0}/strain_sa".format(data_dir)
  File "/opt/ukbb_cardiac/common/cardiac_utils.py", line 1143, in cine_2d_sa_motion_and_strain_analysis
    "{0}/myo_contour_fr".format(output_dir), T, dt, output_name_stem
  File "/opt/ukbb_cardiac/common/cardiac_utils.py", line 816, in evaluate_strain_by_length
    p1 = np.array(points.GetPoint(ids.GetId(0)))
ValueError: expects 0 <= i && i < GetNumberOfIds()

I have MIRTK installed and VTK package linked - not sure what is causing this error.

iimog commented 2 years ago

This happens when your python vtk version is more recent than the vtk version used for compiling mirtk. You probably have vtk version 9 in python and vtk 7 in mirtk. Two possible solutions are:

  1. use the most recent mirtk version from github and compile it with vtk version 9 (only works since July 2022)
  2. add a line instructing vtk to write the old file format version in python
    writer.SetFileVersion(42)

    You might still get a warning but it should work.

jrhomburger commented 2 years ago

Thanks - this is helpful. Saw many of your changes - have you considered merging that back into the main repository? I think many of those are much needed for this to work with current data.

also, were you able to get this work with current version TF or did you have to use a past version of TF? It may be worth including a requirements.txt with versions of the packages you are using. In the past, we had to downgrade TF to 2.1 for the models to work.

iimog commented 2 years ago

I'd be happy to merge my changes into the main repository. I was hesitant to create a pull request because many of these changes just make the code work with current library versions while breaking backwards compatibility. If @baiwenjia is interested, in merging anyway, I'll gladly create a pull request.

It is a good idea to document working library versions. For me, the code works with tensorflow version 2.9.1.

my full conda environment ``` # packages in environment at /home/markus/miniconda3/envs/ukbb_cardiac: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge abseil-cpp 20211102.0 h27087fc_1 conda-forge absl-py 1.2.0 pyhd8ed1ab_0 conda-forge aiohttp 3.8.1 py39hb9d737c_1 conda-forge aiosignal 1.2.0 pyhd8ed1ab_0 conda-forge alsa-lib 1.2.6.1 h7f98852_0 conda-forge aom 3.4.0 h27087fc_1 conda-forge astunparse 1.6.3 pyhd8ed1ab_0 conda-forge async-timeout 4.0.2 pyhd8ed1ab_0 conda-forge attr 2.5.1 h166bdaf_0 conda-forge attrs 22.1.0 pyh71513ae_1 conda-forge blinker 1.4 py_1 conda-forge blosc 1.21.1 h83bc5f7_3 conda-forge brotli 1.0.9 h166bdaf_7 conda-forge brotli-bin 1.0.9 h166bdaf_7 conda-forge brotlipy 0.7.0 py39hb9d737c_1004 conda-forge brunsli 0.1 h9c3ff4c_0 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.18.1 h7f98852_0 conda-forge c-blosc2 2.2.0 h7a311fb_0 conda-forge ca-certificates 2022.6.15 ha878542_0 conda-forge cached-property 1.5.2 hd8ed1ab_1 conda-forge cached_property 1.5.2 pyha770c72_1 conda-forge cachetools 5.0.0 pyhd8ed1ab_0 conda-forge cairo 1.16.0 ha61ee94_1011 conda-forge certifi 2022.6.15 py39hf3d152e_0 conda-forge cffi 1.15.1 py39he91dace_0 conda-forge cfitsio 4.1.0 hd9d235c_0 conda-forge charls 2.3.4 h9c3ff4c_0 conda-forge charset-normalizer 2.1.0 pyhd8ed1ab_0 conda-forge click 8.1.3 py39hf3d152e_0 conda-forge cloudpickle 2.1.0 pyhd8ed1ab_0 conda-forge cmake 3.23.3 h5432695_0 conda-forge cryptography 37.0.4 py39hd97740a_0 conda-forge curl 7.83.1 h7bff187_0 conda-forge cycler 0.11.0 pyhd8ed1ab_0 conda-forge cytoolz 0.12.0 py39hb9d737c_0 conda-forge dask-core 2022.7.1 pyhd8ed1ab_0 conda-forge dav1d 1.0.0 h166bdaf_1 conda-forge dbus 1.13.6 h5008d03_3 conda-forge double-conversion 3.2.0 h9c3ff4c_0 conda-forge eigen 3.2 3 bioconda expat 2.4.8 h27087fc_0 conda-forge ffmpeg 4.4.2 gpl_h2b602b6_106 conda-forge fftw 3.3.10 nompi_h77c792f_102 conda-forge font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 hab24e00_0 conda-forge fontconfig 2.14.0 h8e229c2_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge fonttools 4.34.4 py39hb9d737c_0 conda-forge freeglut 3.2.2 h9c3ff4c_1 conda-forge freetype 2.10.4 h0708190_1 conda-forge frozenlist 1.3.1 py39hb9d737c_0 conda-forge fsspec 2022.7.1 pyhd8ed1ab_0 conda-forge gast 0.4.0 pyh9f0ad1d_0 conda-forge gettext 0.19.8.1 h73d1719_1008 conda-forge giflib 5.2.1 h36c2ea0_2 conda-forge gl2ps 1.4.2 h0708190_0 conda-forge glew 2.1.0 h9c3ff4c_2 conda-forge glib 2.72.1 h6239696_0 conda-forge glib-tools 2.72.1 h6239696_0 conda-forge gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.7.6 hf3e180e_5 conda-forge google-auth 2.9.1 pyh6c4a22f_0 conda-forge google-auth-oauthlib 0.4.6 pyhd8ed1ab_0 conda-forge google-pasta 0.2.0 pyh8c360ce_0 conda-forge graphite2 1.3.13 h58526e2_1001 conda-forge grpc-cpp 1.46.3 hbd84cd8_2 conda-forge grpcio 1.46.3 py39h7ad10b3_2 conda-forge gst-plugins-base 1.20.3 hf6a322e_0 conda-forge gstreamer 1.20.3 hd4edc92_0 conda-forge h5py 3.7.0 nompi_py39h63b1161_100 conda-forge harfbuzz 5.1.0 hf9f4e7c_0 conda-forge hdf4 4.2.15 h10796ff_3 conda-forge hdf5 1.12.1 nompi_h2386368_104 conda-forge icu 70.1 h27087fc_0 conda-forge idna 3.3 pyhd8ed1ab_0 conda-forge imagecodecs 2022.7.31 py39he992b3b_0 conda-forge imageio 2.21.0 pyhfa7a67d_0 conda-forge importlib-metadata 4.11.4 py39hf3d152e_0 conda-forge jack 1.9.18 h8c3723f_1002 conda-forge jasper 2.0.33 ha77e612_0 conda-forge jpeg 9e h166bdaf_2 conda-forge jsoncpp 1.9.5 h4bd325d_1 conda-forge jxrlib 1.1 h7f98852_2 conda-forge keras 2.9.0 pyhd8ed1ab_0 conda-forge keras-preprocessing 1.1.2 pyhd8ed1ab_0 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge kiwisolver 1.4.4 py39hf939315_0 conda-forge krb5 1.19.3 h3790be6_0 conda-forge lame 3.100 h7f98852_1001 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 4.0.0 h27087fc_0 conda-forge libaec 1.0.6 h9c3ff4c_0 conda-forge libavif 0.10.1 h166bdaf_1 conda-forge libblas 3.9.0 15_linux64_openblas conda-forge libbrotlicommon 1.0.9 h166bdaf_7 conda-forge libbrotlidec 1.0.9 h166bdaf_7 conda-forge libbrotlienc 1.0.9 h166bdaf_7 conda-forge libcap 2.64 ha37c62d_0 conda-forge libcblas 3.9.0 15_linux64_openblas conda-forge libclang 14.0.6 default_h2e3cab8_0 conda-forge libclang13 14.0.6 default_h3a83d3e_0 conda-forge libcups 2.3.3 hf5a7f15_1 conda-forge libcurl 7.83.1 h7bff187_0 conda-forge libdb 6.2.32 h9c3ff4c_0 conda-forge libdeflate 1.12 h166bdaf_0 conda-forge libdrm 2.4.112 h166bdaf_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libevent 2.1.10 h9b69904_4 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libflac 1.3.4 h27087fc_0 conda-forge libgcc-ng 12.1.0 h8d9b700_16 conda-forge libgfortran-ng 12.1.0 h69a702a_16 conda-forge libgfortran5 12.1.0 hdcd56e2_16 conda-forge libglib 2.72.1 h2d90d5f_0 conda-forge libglu 9.0.0 he1b5a44_1001 conda-forge libgomp 12.1.0 h8d9b700_16 conda-forge libiconv 1.16 h516909a_0 conda-forge libidn2 2.3.3 h166bdaf_0 conda-forge liblapack 3.9.0 15_linux64_openblas conda-forge liblapacke 3.9.0 15_linux64_openblas conda-forge libllvm14 14.0.6 he0ac6c6_0 conda-forge libnetcdf 4.8.1 nompi_h329d8a1_102 conda-forge libnghttp2 1.47.0 h727a467_0 conda-forge libnsl 2.0.0 h7f98852_0 conda-forge libogg 1.3.4 h7f98852_1 conda-forge libopenblas 0.3.20 pthreads_h78a6416_1 conda-forge libopencv 4.6.0 py39he08f5c2_2 conda-forge libopus 1.3.1 h7f98852_1 conda-forge libpciaccess 0.16 h516909a_0 conda-forge libpng 1.6.37 h753d276_3 conda-forge libpq 14.4 hd77ab85_0 conda-forge libprotobuf 3.20.1 h6239696_0 conda-forge libsndfile 1.0.31 h9c3ff4c_1 conda-forge libssh2 1.10.0 ha56f1ee_2 conda-forge libstdcxx-ng 12.1.0 ha89aaad_16 conda-forge libtasn1 4.18.0 h166bdaf_1 conda-forge libtheora 1.1.1 h7f98852_1005 conda-forge libtiff 4.4.0 h0d92c0b_2 conda-forge libtool 2.4.6 h9c3ff4c_1008 conda-forge libudev1 249 h166bdaf_4 conda-forge libunistring 0.9.10 h7f98852_0 conda-forge libuuid 2.32.1 h7f98852_1000 conda-forge libuv 1.44.2 h166bdaf_0 conda-forge libva 2.15.0 h166bdaf_0 conda-forge libvorbis 1.3.7 h9c3ff4c_0 conda-forge libvpx 1.11.0 h9c3ff4c_3 conda-forge libwebp 1.2.3 h522a892_1 conda-forge libwebp-base 1.2.3 h166bdaf_2 conda-forge libxcb 1.13 h7f98852_1004 conda-forge libxkbcommon 1.0.3 he3ba5ed_0 conda-forge libxml2 2.9.14 h22db469_3 conda-forge libzip 1.9.2 hc869a4a_0 conda-forge libzlib 1.2.12 h166bdaf_2 conda-forge libzopfli 1.0.3 h9c3ff4c_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge loguru 0.6.0 py39hf3d152e_1 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge markdown 3.4.1 pyhd8ed1ab_0 conda-forge markupsafe 2.1.1 py39hb9d737c_1 conda-forge matplotlib 3.5.2 py39hf3d152e_1 conda-forge matplotlib-base 3.5.2 py39h700656a_1 conda-forge multidict 6.0.2 py39hb9d737c_1 conda-forge munkres 1.0.7 py_1 bioconda mysql-common 8.0.30 haf5c9bc_0 conda-forge mysql-libs 8.0.30 h28c427c_0 conda-forge ncurses 6.3 h27087fc_1 conda-forge nettle 3.8.1 hc379101_1 conda-forge networkx 2.8.5 pyhd8ed1ab_0 conda-forge nibabel 4.0.1 pyhd8ed1ab_0 conda-forge nspr 4.32 h9c3ff4c_1 conda-forge nss 3.78 h2350873_0 conda-forge numpy 1.23.1 py39hba7629e_0 conda-forge oauthlib 3.2.0 pyhd8ed1ab_0 conda-forge opencv 4.6.0 py39hf3d152e_2 conda-forge openh264 2.2.0 h27087fc_2 conda-forge openjpeg 2.4.0 hb52868f_1 conda-forge openssl 1.1.1q h166bdaf_0 conda-forge opt_einsum 3.3.0 pyhd8ed1ab_1 conda-forge p11-kit 0.24.1 hc5aa10d_0 conda-forge packaging 21.3 pyhd8ed1ab_0 conda-forge pandas 1.4.3 py39h1832856_0 conda-forge partd 1.2.0 pyhd8ed1ab_0 conda-forge pcre 8.45 h9c3ff4c_0 conda-forge pillow 9.2.0 py39hae2aec6_0 conda-forge pip 22.2.2 pyhd8ed1ab_0 conda-forge pixman 0.40.0 h36c2ea0_0 conda-forge ply 3.11 py_1 conda-forge portaudio 19.6.0 h57a0ea0_5 conda-forge proj 9.0.1 h93bde94_1 conda-forge protobuf 3.20.1 py39h5a03fae_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge pugixml 1.11.4 h9c3ff4c_0 conda-forge pulseaudio 14.0 h7f54b18_8 conda-forge py-opencv 4.6.0 py39hef51801_2 conda-forge pyasn1 0.4.8 py_0 conda-forge pyasn1-modules 0.2.7 py_0 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pydicom 2.3.0 pyh6c4a22f_0 conda-forge pyjwt 2.4.0 pyhd8ed1ab_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge pyqt 5.15.7 py39h18e9c17_0 conda-forge pyqt5-sip 12.11.0 py39h5a03fae_0 conda-forge pysocks 1.7.1 py39hf3d152e_5 conda-forge python 3.9.13 h9a8a25e_0_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-flatbuffers 1.12 pyhd8ed1ab_1 conda-forge python_abi 3.9 2_cp39 conda-forge pytz 2022.1 pyhd8ed1ab_0 conda-forge pyu2f 0.1.5 pyhd8ed1ab_0 conda-forge pywavelets 1.3.0 py39hd257fcd_1 conda-forge pyyaml 6.0 py39hb9d737c_4 conda-forge qt-main 5.15.4 ha5833f6_2 conda-forge re2 2022.06.01 h27087fc_0 conda-forge readline 8.1.2 h0f457ee_0 conda-forge requests 2.28.1 pyhd8ed1ab_0 conda-forge requests-oauthlib 1.3.1 pyhd8ed1ab_0 conda-forge rhash 1.4.3 h166bdaf_0 conda-forge rsa 4.9 pyhd8ed1ab_0 conda-forge scikit-image 0.19.3 py39h1832856_0 conda-forge scipy 1.9.0 py39h8ba3f38_0 conda-forge setuptools 63.3.0 py39hf3d152e_0 conda-forge sip 6.6.2 py39h5a03fae_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.9 hbd366e4_1 conda-forge sqlite 3.39.2 h4ff8645_0 conda-forge svt-av1 1.1.0 h27087fc_1 conda-forge tbb 2021.5.0 h924138e_1 conda-forge tbb-devel 2021.5.0 h924138e_1 conda-forge tensorboard 2.9.0 pyhd8ed1ab_0 conda-forge tensorboard-data-server 0.6.0 py39hd97740a_2 conda-forge tensorboard-plugin-wit 1.8.1 pyhd8ed1ab_0 conda-forge tensorflow 2.9.1 cpu_py39h4655687_0 conda-forge tensorflow-base 2.9.1 cpu_py39hfe2e05e_0 conda-forge tensorflow-estimator 2.9.1 cpu_py39heaff504_0 conda-forge termcolor 1.1.0 pyhd8ed1ab_3 conda-forge tifffile 2022.7.31 pyhd8ed1ab_0 conda-forge tk 8.6.12 h27826a3_0 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.2 py39hb9d737c_0 conda-forge typing-extensions 4.3.0 hd8ed1ab_0 conda-forge typing_extensions 4.3.0 pyha770c72_0 conda-forge tzdata 2022a h191b570_0 conda-forge unicodedata2 14.0.0 py39hb9d737c_1 conda-forge urllib3 1.26.11 pyhd8ed1ab_0 conda-forge utfcpp 3.2.1 ha770c72_0 conda-forge vtk 9.1.0 qt_py39h105b9e9_211 conda-forge werkzeug 2.2.1 pyhd8ed1ab_0 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge wrapt 1.14.1 py39hb9d737c_0 conda-forge x264 1!161.3030 h7f98852_1 conda-forge x265 3.5 h924138e_3 conda-forge xcb-util 0.4.0 h516909a_0 conda-forge xcb-util-image 0.4.0 h166bdaf_0 conda-forge xcb-util-keysyms 0.4.0 h516909a_0 conda-forge xcb-util-renderutil 0.3.9 h166bdaf_0 conda-forge xcb-util-wm 0.4.1 h516909a_0 conda-forge xorg-fixesproto 5.0 h7f98852_1002 conda-forge xorg-inputproto 2.3.2 h7f98852_1002 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.0.10 h7f98852_0 conda-forge xorg-libsm 1.2.3 hd9c2040_1000 conda-forge xorg-libx11 1.7.2 h7f98852_0 conda-forge xorg-libxau 1.0.9 h7f98852_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h7f98852_1 conda-forge xorg-libxfixes 5.0.3 h7f98852_1004 conda-forge xorg-libxi 1.7.10 h7f98852_0 conda-forge xorg-libxrender 0.9.10 h7f98852_1003 conda-forge xorg-libxt 1.2.1 h7f98852_2 conda-forge xorg-renderproto 0.11.1 h7f98852_1002 conda-forge xorg-xextproto 7.3.0 h7f98852_1002 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.2.5 h516909a_1 conda-forge yaml 0.2.5 h7f98852_2 conda-forge yarl 1.7.2 py39hb9d737c_2 conda-forge zfp 0.5.5 h9c3ff4c_8 conda-forge zipp 3.8.1 pyhd8ed1ab_0 conda-forge zlib 1.2.12 h166bdaf_2 conda-forge zlib-ng 2.0.6 h166bdaf_0 conda-forge zstd 1.5.2 h8a70e8d_2 conda-forge ```