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

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

Open
kretes opened this issue Jun 1, 2023 · 5 comments

Comments

@kretes
Copy link

kretes commented Jun 1, 2023

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 #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
Copy link

Same issue here with Python 3.10 and 3.11

@weberam2
Copy link

weberam2 commented Aug 9, 2023

Me too

@mikbuch
Copy link

mikbuch commented Oct 6, 2023

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

@marcobarilari
Copy link

me too

@amirzolal
Copy link

This is on ubuntu when using libsixel.

On ubuntu, use mlterm.

sudo apt install mlterm

After that, niicat -lb $filename will work.

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

6 participants