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

cortex.quickshow IndexError #469

Open
mingxue1204 opened this issue Oct 30, 2022 · 5 comments
Open

cortex.quickshow IndexError #469

mingxue1204 opened this issue Oct 30, 2022 · 5 comments

Comments

@mingxue1204
Copy link

I'm trying to plot a flatmap and can't get past quickshow. I've processed a subject's data with freesurfer and goyt the transform files and the surfaces, then put them in the subject file below the database. After that I'm trying to start a quickshow to see the map but encounter the following error:

Traceback (most recent call last):  File "/run/user/1003/gvfs/smb-hare:server=172.22.124.104,share=mingxue/Project/code/make_mapper.py", line 23, in <module>
    cortex.quickshow(voxel_vol)

  File "/home/mingxue/.local/lib/python3.8/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 "/home/mingxue/.local/lib/python3.8/site-packages/cortex/quickflat/composite.py", line 162, in add_data
    im, extents = make_flatmap_image(dataview, recache=recache, pixelwise=pixelwise, sampler=sampler,
  File "/home/mingxue/.local/lib/python3.8/site-packages/cortex/quickflat/utils.py", line 44, in make_flatmap_image
    mask, extents = get_flatmask(braindata.subject, height=height, recache=recache)
  File "/home/mingxue/.local/lib/python3.8/site-packages/cortex/quickflat/utils.py", line 137, in get_flatmask
    mask, extents = _make_flatmask(subject, height=height)
  File "/home/mingxue/.local/lib/python3.8/site-packages/cortex/quickflat/utils.py", line 362, in _make_flatmask
    left, right = polyutils.trace_poly(polyutils.boundary_edges(polys))
  File "/home/mingxue/.local/lib/python3.8/site-packages/cortex/polyutils/misc.py", line 136, in trace_poly
    hemisphere_0, hemisphere_1 = components[order[-1]], components[order[-2]]
IndexError: index -1 is out of bounds for axis 0 with size 0

Can anyone help me with this? Thanks a lot~~~

@mvdoc
Copy link
Contributor

mvdoc commented Oct 30, 2022

Hi @mingxue1204, have you manually flattened the surfaces and imported them with cortex.freesurfer.import_subj? cortex.quickshow requires flattened surfaces. If you don't have flattened surfaces, you can use the webgl viewer with cortex.webgl.show, but you'll need to have access to a physical display.

You can check this tutorial by @tknapen's lab on how to do the cutting and flattening.

@mingxue1204
Copy link
Author

Thank you for your kindly reply~ I'll have a try! ^_^

@mingxue1204
Copy link
Author

Hi @mingxue1204, have you manually flattened the surfaces and imported them with cortex.freesurfer.import_subj? cortex.quickshow requires flattened surfaces. If you don't have flattened surfaces, you can use the webgl viewer with cortex.webgl.show, but you'll need to have access to a physical display.

You can check this tutorial by @tknapen's lab on how to do the cutting and flattening.

Sorry to bother again. I encounter an error when I'm trying to import a subject by using the command' cortex.freesurfer.import_subj("subj01")', the error is as follows:

----> 1 cortex.freesurfer.import_subj("subj01")

File ~/.local/lib/python3.8/site-packages/cortex/freesurfer.py:206, in import_subj(fs_subject, cx_subject, freesurfer_subject_dir, whitematter_surf)
    204         pts, polys, _ = get_surf(fs_subject, hemi, fsname, freesurfer_subject_dir=freesurfer_subject_dir)
    205         fname = str(surfs.format(subj=cx_subject, name=name, hemi=hemi))
--> 206         formats.write_gii(fname, pts=pts + surfmove, polys=polys)
    208 for curv, info in dict(sulc="sulcaldepth", thickness="thickness", curv="curvature").items():
    209     lh, rh = [parse_curv(curvs.format(hemi=hemi, name=curv)) for hemi in ['lh', 'rh']]

File ~/.local/lib/python3.8/site-packages/cortex/formats.pyx:193, in cortex.formats.write_gii()

File ~/.local/lib/python3.8/site-packages/nibabel/deprecator.py:181, in Deprecator.__call__.<locals>.deprecator.<locals>.deprecated_func(*args, **kwargs)
    178 @functools.wraps(func)
    179 def deprecated_func(*args, **kwargs):
    180     if until and self.is_bad_version(until):
--> 181         raise error_class(message)
    182     warnings.warn(message, warn_class, stacklevel=2)
    183     return func(*args, **kwargs)

ExpiredDeprecationError: from_array method is deprecated. Please use GiftiDataArray constructor instead.

* deprecated from version: 2.1
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0

what should I do next to fix this? thank you so much for your great patience~

@mvdoc
Copy link
Contributor

mvdoc commented Nov 2, 2022

Oh, thanks for sharing that. We need to fix our code to adapt to Nibabel's new version. In the meanwhile, you could downgrade nibabel to < 4.0 (python -m pip install "nibabel<4")

@mingxue1204
Copy link
Author

Oh, thanks for sharing that. We need to fix our code to adapt to Nibabel's new version. In the meanwhile, you could downgrade nibabel to < 4.0 (python -m pip install "nibabel<4")

Thank you so much for your reply! That problem has been solved by downgrading the nibabel ^_^.

However, I seem to have another problem ... Sorry to bother again...
I've used the tksurfer to cut the surface and got the file named like 'lh.full.patch.3d'. Then I tried to flatten the surface by using the command 'mris_flatten lh.full.patch.3d lh.full.flat.patch.3d'. Then followed by the command 'mris_convert lh.full.flat.patch.3d flat_lh.gii' to get the gifti file.
After that I put the file into the surfaces file under subject's database and use the following code to check my experimental results:

import cortex
import cortex.polyutils
import numpy as np
import matplotlib.pyplot as plt
from voxelwise_tutorials.viz import plot_flatmap_from_mapper

subject = "subj01"
xfm = 'fullhead'

voxel_vol = cortex.Volume(array_scores, subject, xfm)  #'array_scores' stands for the volumn data
mapper = cortex.get_mapper(subject, xfm, 'line_nearest', recache=True)
vertex_map = mapper(voxel_vol)
cortex.quickshow(vertex_map)
plt.show()

The results is really weird! It only shows the part that I tend to remove during the surface cutting process. Is there anything wrong with my operation? Thank you so much for your great patience!

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

2 participants