gallantlab / pycortex

Pycortex is a python-based toolkit for surface visualization of fMRI data
https://gallantlab.github.io/pycortex
BSD 2-Clause "Simplified" License
581 stars 137 forks source link

FileNotFoundError #517

Closed zhiliHAN closed 5 months ago

zhiliHAN commented 9 months ago

Dear all,

recently I run the pycortex code to plot flat image, however some error happened when I try to use my own data to plot (everything works fine when running examples).

I encountered the following error when I try cortex.quickshow(voxel_vol): ''' Cell In[58], line 1 ----> 1 cortex.quickshow(voxel_vol)

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/view.py:142, in make_figure(braindata, recache, pixelwise, thick, sampler, height, dpi, depth, with_rois, with_sulci, with_labels, with_colorbar, with_borders, with_dropout, with_curvature, extra_disp, with_connected_vertices, overlay_file, linewidth, linecolor, roifill, shadow, labelsize, labelcolor, cutout, curvature_brightness, curvature_contrast, curvature_threshold, fig, extra_hatch, colorbar_ticks, colorbar_location, roi_list, nanmean, **kwargs) 139 fig = ax.figure 141 # Add data --> 142 data_im, extents = composite.add_data(ax, dataview, pixelwise=pixelwise, thick=thick, sampler=sampler, 143 height=height, depth=depth, recache=recache, nanmean=nanmean) 145 layers = dict(data=data_im) 146 # Add curvature

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/composite.py:162, in add_data(fig, braindata, height, thick, depth, pixelwise, sampler, recache, nanmean) 160 raise TypeError('Please provide a Dataview, not a Dataset') 161 # Generate image (2D array, maybe 3D array) --> 162 im, extents = make_flatmap_image(dataview, recache=recache, pixelwise=pixelwise, sampler=sampler, 163 height=height, thick=thick, depth=depth, nanmean=nanmean) 164 # Check whether dataview has a cmap instance 165 cmapdict = dataview.get_cmapdict()

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/utils.py:56, in make_flatmap_image(braindata, height, recache, nanmean, kwargs) 54 data = braindata.vertices 55 else: ---> 56 pixmap = get_flatcache(braindata.subject, 57 braindata.xfmname, 58 height=height, 59 recache=recache, 60 kwargs) 61 if isinstance(braindata, dataset.Volume2D): 62 data = braindata.raw.volume

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/utils.py:182, in get_flatcache(subject, xfmname, pixelwise, thick, sampler, recache, height, depth) 180 else: 181 pixmap = _make_vertex_cache(subject, height=height) --> 182 np.savez(cachefile, data=pixmap.data, indices=pixmap.indices, indptr=pixmap.indptr, shape=pixmap.shape) 183 else: 184 from scipy import sparse

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:639, in savez(file, *args, *kwds) 555 @array_function_dispatch(_savez_dispatcher) 556 def savez(file, args, **kwds): 557 """Save several arrays into a single file in uncompressed .npz format. 558 559 Provide arrays as keyword arguments to store them under the (...) 637 638 """ --> 639 _savez(file, args, kwds, False)

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:736, in _savez(file, args, kwds, compress, allow_pickle, pickle_kwargs) 733 else: 734 compression = zipfile.ZIP_STORED --> 736 zipf = zipfile_factory(file, mode="w", compression=compression) 738 for key, val in namedict.items(): 739 fname = key + '.npy'

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:103, in zipfile_factory(file, *args, *kwargs) 101 import zipfile 102 kwargs['allowZip64'] = True --> 103 return zipfile.ZipFile(file, args, **kwargs)

File ~/.conda/envs/fMRI/lib/python3.9/zipfile.py:1248, in ZipFile.init(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps) 1246 while True: 1247 try: -> 1248 self.fp = io.open(file, filemode) 1249 except OSError: 1250 if filemode in modeDict:

FileNotFoundError: [Errno 2] No such file or directory: '/home/xxx/.conda/envs/fMRI/share/pycortex/db/fsaverage/cache/flatpixel_/home/xxx/.conda/envs/fMRI/share/pycortex/db/fsaverage/transforms/atlas_1024_nearest_l32.npz' ''' my system is Ubuntu 16.04.7 LTS python 3.9.16

Appreciate any reply

mvdoc commented 9 months ago

Hi, what type of data are you trying to visualize? is it volumetric or surface-based? it looks like you're using the "fsaverage" subject, but we use that to plot surface-based data and not volumetric data, so the transform is not needed to plot cortex.Vertex objects.

On Tue, Dec 12, 2023 at 4:33 PM Zhili Han @.***> wrote:

Dear all,

recently I run the pycortex code to plot flat image, however some error happened when I try to use my own data to plot (everything works fine when running examples).

I encountered the following error when I try cortex.quickshow(voxel_vol): ''' Cell In[58], line 1 ----> 1 cortex.quickshow(voxel_vol)

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/view.py:142, in make_figure(braindata, recache, pixelwise, thick, sampler, height, dpi, depth, with_rois, with_sulci, with_labels, with_colorbar, with_borders, with_dropout, with_curvature, extra_disp, with_connected_vertices, overlay_file, linewidth, linecolor, roifill, shadow, labelsize, labelcolor, cutout, curvature_brightness, curvature_contrast, curvature_threshold, fig, extra_hatch, colorbar_ticks, colorbar_location, roi_list, nanmean, **kwargs) 139 fig = ax.figure 141 # Add data --> 142 data_im, extents = composite.add_data(ax, dataview, pixelwise=pixelwise, thick=thick, sampler=sampler, 143 height=height, depth=depth, recache=recache, nanmean=nanmean) 145 layers = dict(data=data_im) 146 # Add curvature

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/composite.py:162, in add_data(fig, braindata, height, thick, depth, pixelwise, sampler, recache, nanmean) 160 raise TypeError('Please provide a Dataview, not a Dataset') 161 # Generate image (2D array, maybe 3D array) --> 162 im, extents = make_flatmap_image(dataview, recache=recache, pixelwise=pixelwise, sampler=sampler, 163 height=height, thick=thick, depth=depth, nanmean=nanmean) 164 # Check whether dataview has a cmap instance 165 cmapdict = dataview.get_cmapdict()

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/utils.py:56, in make_flatmap_image(braindata, height, recache, nanmean, kwargs) 54 data = braindata.vertices 55 else: ---> 56 pixmap = get_flatcache(braindata.subject, 57 braindata.xfmname, 58 height=height, 59 recache=recache, 60 kwargs) 61 if isinstance(braindata, dataset.Volume2D): 62 data = braindata.raw.volume

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/cortex/quickflat/utils.py:182, in get_flatcache(subject, xfmname, pixelwise, thick, sampler, recache, height, depth) 180 else: 181 pixmap = _make_vertex_cache(subject, height=height) --> 182 np.savez(cachefile, data=pixmap.data, indices=pixmap.indices, indptr=pixmap.indptr, shape=pixmap.shape) 183 else: 184 from scipy import sparse

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:639, in savez(file, *args, *kwds) 555 @array_function_dispatch(_savez_dispatcher) 556 def savez(file, args, **kwds): 557 """Save several arrays into a single file in uncompressed .npz format. 558 559 Provide arrays as keyword arguments to store them under the (...) 637 638 """ --> 639 _savez(file, args, kwds, False)

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:736, in _savez(file, args, kwds, compress, allow_pickle, pickle_kwargs) 733 else: 734 compression = zipfile.ZIP_STORED --> 736 zipf = zipfile_factory(file, mode="w", compression=compression) 738 for key, val in namedict.items(): 739 fname = key + '.npy'

File ~/.conda/envs/fMRI/lib/python3.9/site-packages/numpy/lib/npyio.py:103, in zipfile_factory(file, *args, *kwargs) 101 import zipfile 102 kwargs['allowZip64'] = True --> 103 return zipfile.ZipFile(file, args, **kwargs)

File ~/.conda/envs/fMRI/lib/python3.9/zipfile.py:1248, in ZipFile.init(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps) 1246 while True: 1247 try: -> 1248 self.fp = io.open(file, filemode) 1249 except OSError: 1250 if filemode in modeDict:

FileNotFoundError: [Errno 2] No such file or directory: '/home/xxx/.conda/envs/fMRI/share/pycortex/db/fsaverage/cache/flatpixel_/home/xxx/.conda/envs/fMRI/share/pycortex/db/fsaverage/transforms/atlas_1024_nearest_l32.npz' ''' my system is Ubuntu 16.04.7 LTS python 3.9.16

Appreciate any reply

— Reply to this email directly, view it on GitHub https://github.com/gallantlab/pycortex/issues/517, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABO5TGWJ7VDO4WCZIX57M5TYJDZUBAVCNFSM6AAAAABASKELKCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAZTQNZUHAYDMNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Matteo Visconti di Oleggio Castello, Ph.D. Postdoctoral Scholar Helen Wills Neuroscience Institute, UC Berkeley MatteoVisconti.com http://matteovisconti.com || github.com/mvdoc || linkedin.com/in/matteovisconti