MIC-DKFZ / niicat

This is a tool to quickly preview nifti images on the terminal
GNU General Public License v2.0
53 stars 10 forks source link

error in plotter: `ctypes.ArgumentError: argument 2: TypeError: wrong type` #9

Open kretes opened 1 year ago

kretes commented 1 year ago

I get the following error when trying to run niicat on a nifti file:

Traceback (most recent call last):
  File "/raid/shared/tbartczak/conda/envs/tb/bin/niicat", line 50, in <module>
    main()
  File "/raid/shared/tbartczak/conda/envs/tb/bin/niicat", line 46, in main
    plot(args.nifti_file, dpi=args.dpi)
  File "/raid/shared/tbartczak/conda/envs/tb/lib/python3.11/site-packages/niicat/plotter.py", line 254, in plot
    return _plot_nifti_preview(iFile, return_fig=return_fig, dpi=dpi)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/shared/tbartczak/conda/envs/tb/lib/python3.11/site-packages/niicat/plotter.py", line 233, in _plot_nifti_preview
    _plot_sixel(fig)
  File "/raid/shared/tbartczak/conda/envs/tb/lib/python3.11/site-packages/niicat/plotter.py", line 36, in _plot_sixel
    res = _sixel_encode(fig.canvas.buffer_rgba(), fig.get_figwidth()* dpi, fig.get_figheight() * dpi)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/raid/shared/tbartczak/conda/envs/tb/lib/python3.11/site-packages/niicat/plotter.py", line 23, in _sixel_encode
    libsixel.sixel_dither_initialize(dither, data, w, h, libsixel.SIXEL_PIXELFORMAT_RGBA8888)
  File "/raid/shared/tbartczak/conda/envs/tb/lib/python3.11/site-packages/libsixel/__init__.py", line 503, in sixel_dither_initialize
    status = _sixel.sixel_dither_initialize(dither, data, width, height, pixelformat,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 2: TypeError: wrong type

I've installed niicat from source from the version in https://github.com/MIC-DKFZ/niicat/pull/8 as I got nibabel issues with pypi version.

From the stacktracie it seems that wrong datatype is passed to sixel when encoding figure?

My env: Python 3.11 matplotlib==3.7.1 matplotlib-inline==0.1.6 numpy==1.24.3 nibabel==5.1.0

afrendeiro commented 1 year ago

Same issue here with Python 3.10 and 3.11

weberam2 commented 1 year ago

Me too

mikbuch commented 1 year ago

Same here, tried with nii and nii.gz (python 3.11.5)

marcobarilari commented 8 months ago

me too

amirzolal commented 3 months ago

This is on ubuntu when using libsixel.

On ubuntu, use mlterm.

sudo apt install mlterm

After that, niicat -lb $filename will work.