Skip to content

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

@kretes

Description

@kretes

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions