Skip to content

cortex.quickshow TypeError and ExpatError #438

Open
@EllieMo

Description

@EllieMo

Hello,
I'm trying to plot a flatmap and can't seem to get past quickshow. I've been following code from the example gallery; (https://gallantlab.github.io/pycortex/auto_examples/datasets/plot_volumeRGB.html#sphx-glr-auto-examples-datasets-plot-volumergb-py - but same problem with other examples) as that is what I'm aiming for. I seem to be having an error potentially related to my data and another one just
(macOS, python 3.9)

When I use the example data I do get part of the plot I would expect with this error message:

  File "/usr/local/lib/python3.9/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "/usr/local/lib/python3.9/site-packages/nibabel/untitled0.py", line 39, in <module>
    cortex.quickshow(vol_data, with_colorbar=False)

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/view.py", line 197, in make_figure
    roi_im = composite.add_rois(ax, dataview, extents=extents, height=height, linewidth=linewidth, linecolor=linecolor,

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/composite.py", line 208, in add_rois
    svgobject = db.get_overlay(dataview.subject, overlay_file=overlay_file)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 344, in get_overlay
    pts, polys = self.get_surf(subject, "flat", merge=True, nudge=True)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 30, in memofn
    self._memocache[h] = fn(self, *args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 494, in get_surf
    left, right = [ self.get_surf(subject, type, hemisphere=h) for h in ["lh", "rh"]]

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 494, in <listcomp>
    left, right = [ self.get_surf(subject, type, hemisphere=h) for h in ["lh", "rh"]]

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 30, in memofn
    self._memocache[h] = fn(self, *args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 520, in get_surf
    return formats.read(fnm)

  File "cortex/formats.pyx", line 23, in cortex.formats.read

  File "cortex/formats.pyx", line 51, in cortex.formats.read_gii

  File "cortex/formats.pyx", line 56, in cortex.formats.read_gii

  File "/usr/local/lib/python3.9/site-packages/nibabel/loadsave.py", line 52, in load
    img = image_klass.from_filename(filename, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/gifti.py", line 904, in from_filename
    img = klass.from_file_map(file_map, buffer_size=buffer_size)

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/gifti.py", line 898, in from_file_map
    parser.parse(fptr=file_map['image'].get_prepare_fileobj('rb'))

  File "/usr/local/lib/python3.9/site-packages/nibabel/xmlutils.py", line 103, in parse
    parser.ParseFile(fptr)

  File "/private/tmp/pythonA3.9-20220326-99703-2lqkv4/Python-3.9.12/Modules/pyexpat.c", line 407, in StartElement

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/parse_gifti_fast.py", line 119, in StartElementHandler
    self.img = GiftiImage()

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/gifti.py", line 576, in __init__
    super(GiftiImage, self).__init__(header=header, extra=extra,

TypeError: super(type, obj): obj must be an instance or subtype of type

when using my own data it fails at a similar place (empty plot though) with a different error:

File "/usr/local/lib/python3.9/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "/Users/me/Desktop/RGB_MAP.py", line 53, in <module>
    cortex.quickshow(vol_data, with_colorbar=False)

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/view.py", line 142, in make_figure
    data_im, extents = composite.add_data(ax, dataview, pixelwise=pixelwise, thick=thick, sampler=sampler,

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/composite.py", line 162, in add_data
    im, extents = make_flatmap_image(dataview, recache=recache, pixelwise=pixelwise, sampler=sampler,

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/utils.py", line 44, in make_flatmap_image
    mask, extents = get_flatmask(braindata.subject, height=height, recache=recache)

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/utils.py", line 126, in get_flatmask
    mask, extents = _make_flatmask(subject, height=height)

  File "/usr/local/lib/python3.9/site-packages/cortex/quickflat/utils.py", line 350, in _make_flatmask
    pts, polys = db.get_surf(subject, "flat", merge=True, nudge=True)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 30, in memofn
    self._memocache[h] = fn(self, *args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 494, in get_surf
    left, right = [ self.get_surf(subject, type, hemisphere=h) for h in ["lh", "rh"]]

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 494, in <listcomp>
    left, right = [ self.get_surf(subject, type, hemisphere=h) for h in ["lh", "rh"]]

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 30, in memofn
    self._memocache[h] = fn(self, *args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/cortex/database.py", line 520, in get_surf
    return formats.read(fnm)

  File "cortex/formats.pyx", line 23, in cortex.formats.read

  File "cortex/formats.pyx", line 51, in cortex.formats.read_gii

  File "cortex/formats.pyx", line 56, in cortex.formats.read_gii

  File "/usr/local/lib/python3.9/site-packages/nibabel/loadsave.py", line 52, in load
    img = image_klass.from_filename(filename, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/gifti.py", line 904, in from_filename
    img = klass.from_file_map(file_map, buffer_size=buffer_size)

  File "/usr/local/lib/python3.9/site-packages/nibabel/gifti/gifti.py", line 898, in from_file_map
    parser.parse(fptr=file_map['image'].get_prepare_fileobj('rb'))

  File "/usr/local/lib/python3.9/site-packages/nibabel/xmlutils.py", line 103, in parse
    parser.ParseFile(fptr)

ExpatError: not well-formed (invalid token): line 1, column 0

Has anyone seen either of these before and how did you solve them?

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