gallantlab / pycortex

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

Demo: "views" folder missing? #84

Closed MarabuRLI closed 7 years ago

MarabuRLI commented 10 years ago

I am trying to run the demo but it seems there is a folder missing After: ds = cortex.openFile("D:\Programme\Anaconda\S1retinotopy.hdf") The error message is (translated to english): The system can't find the given path: 'D:\Programme\Anaconda\share\pycortex\db\S1\views/* ._* ' I cecked the folder "S1" it contains folders called: anatomicals, surfaces and transforms as well a .svg file of the ROIs So is this "views" folder missing or is there another problem that i don't see? Thank you in advance (Pls consider i'm using Windows and am pretty new to Python)

alexhuth commented 10 years ago

I just noticed this recently as well. The "views" folder is a newly added feature and didn't make it into the demo subject. Should be an easy fix.

For now you can just create an empty "views" directory inside the subject directory, and everything should work!

On Apr 29, 2014, at 13:26, Kuraimegami notifications@github.com wrote:

I am trying to run the demo but it seems there is a folder missing After: ds = cortex.openFile("D:\Programme\Anaconda\S1_retinotopy.hdf") The error masseges is (translated to english): The system can't find the given path: 'D:\Programme\Anaconda\share\pycortex\db\S1\views/* .* ' I cecked the folder "S1" it contains folders called: anatomicals, surfaces and transforms as well a .svg file of the ROIs So is this "views" folder missing or is there another problem that i don't see? Thank you in advance (Pls consider i'm using Windows and am pretty new to Python)

— Reply to this email directly or view it on GitHub.

jamesgao commented 10 years ago

I thought Mark actually fixed this. However, if the directory was created before the fix was released, you will need to manually create the views directory. I'll check on the status of this...

MarabuRLI commented 10 years ago

Thank you two for your fast reply, alex have you also tried the last line "cortex.webshow(ds)"? Because i'm running in to an error there now ...maybe i did sth wrong while installing after all.

jamesgao commented 10 years ago

What error are you seeing? We should be able to get you running if you can describe what problem you're having.

MarabuRLI commented 10 years ago

well the error looks like that: In [1]: import cortex

In [2]: ds = cortex.openFile("S1_retinotopy.hdf")

In [3]: cortex.webshow(ds)

AttributeError Traceback (most recent call last)

in () ----> 1 cortex.webshow(ds) D:\Programme\Anaconda\lib\site-packages\cortex\webgl__init__.pyc in show(_args, *_kwargs) 1 2 def show(_args, *_kwargs): ----> 3 from . import view 4 return view.show(_args, *_kwargs) 5 D:\Programme\Anaconda\lib\site-packages\cortex\webgl\view.py in () 34 35 colormaps = glob.glob(os.path.join(cmapdir, "*.png")) ---> 36 colormaps = [(name_parse.match(cm).group(1), serve.make_base64(cm)) for cm in sorted(colormaps)] 37 38 viewopts = dict(voxlines="false", voxline_color="#FFFFFF", voxline_width ='.01' ) AttributeError: 'NoneType' object has no attribute 'group' and i did the following tests to see what is happening: In [4]: import os, glob In [5]: colormaps = glob.glob(os.path.join("D:/Programme/Anaconda/share/pycortex /colormaps", "*.png")) In [6]: print(colormaps) ['D:/Programme/Anaconda/share/pycortex/colormaps\\Accent.png', 'D:/Programme/Ana ...and so on In [7]: import re In [8]: name_parse = re.compile(r".*/(\w+).png") In [9]: test = [(name_parse.match(cm)) for cm in sorted(colormaps)] In [10]: print(test) [None, None, None, None, None, None, None, None, None, None, None, None, None, N ...and so on but if i do this for example (not sure if the name_parse makes rly sense): In [11]: name_parse = re.compile(r"(.\* _)_ *(\w+).png") In [12]: test = [(name_parse.match(cm)) for cm in sorted(colormaps)] In [13]: print(test) [<_sre.SRE_Match object at 0x0264A1D0>, <_sre.SRE_Match object at 0x06C2ABF0>, < ...and so on than i thought maybe i should try sth else and ran in to the next error: In [1]: import cortex In [2]: import numpy as np In [3]: cortex.quickshow((np.random.randn(31, 100, 100), "S1", "fullhead")) Cannot find shapely, using simple label placement ## Unzulässiger Parameter - none RuntimeError Traceback (most recent call last) in () ----> 1 cortex.quickshow((np.random.randn(31, 100, 100), "S1", "fullhead")) D:\Programme\Anaconda\lib\site-packages\cortex\quickflat.pyc in make_figure(brai ndata, recache, pixelwise, thick, sampler, height, dpi, depth, with_rois, with_l abels, with_colorbar, with_borders, with_dropout, with_curvature, linewidth, lin ecolor, roifill, shadow, labelsize, labelcolor, cutout, cvmin, cvmax, cvthr, fig , **kwargs) 173 roitex.seek(0) 174 oax = fig.add_axes((0,0,1,1)) --> 175 roi_im = plt.imread(roitex) 176 if cutout: 177 # STUPID BULLSHIT 1-PIXEL CHECK: D:\Programme\Anaconda\lib\site-packages\matplotlib\pyplot.pyc in imread(_args, * *kwargs) 2175 @docstring.copy_dedent(_imread) 2176 def imread(_args, *_kwargs): -> 2177 return _imread(_args, **kwargs) 2178 2179 D:\Programme\Anaconda\lib\site-packages\matplotlib\image.pyc in imread(fname, fo rmat) 1256 return handler(fd) 1257 else: -> 1258 return handler(fname) 1259 1260 RuntimeError: _image_module::readpng: file not recognized as a PNG file maybe the errors are connected, maybe i just did sth terribly wrong. i honestly have no clue.
jamesgao commented 10 years ago

Ah! Thanks for the very detailed debugging. I know the problem here -- I have a small script that loads up all the possible colormaps in the configured colormap directory. However, I'm using a regular expression to only grab the PNGs. A regular expression that only includes "/" as the directory separator. This breaks on windows because windows uses "\" instead of "/"

I will fix this ASAP.

jamesgao commented 10 years ago

Hi, can you give this new code a try? This is definitely the first time we've tried this with windows.

MarabuRLI commented 10 years ago

hi thank you for your effort. i think the "NoneType"-error is fixed. But i had to comment out line 82 "surfs.auxfile = ds" of the cortex/dataset/ init .py added while the "Fix up packed datasets" to figure out if it is fixed. (i found the line by trial-and-error) otherwise i got this: In [1]: import cortex

In [2]: ds = cortex.openFile("S1_retinotopy.hdf") HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:

000: ....\src\H5O.c line 246 in H5Oopen(): unable to open object

major: Symbol table
minor: Can't open object

001: ....\src\H5O.c line 1357 in H5O_open_name(): object not found

major: Symbol table
minor: Object not found

002: ....\src\H5Gloc.c line 430 in H5G_loc_find(): can't find object

major: Symbol table
minor: Object not found

003: ....\src\H5Gtraverse.c line 861 in H5G_traverse(): internal path traver

sal failed major: Symbol table minor: Object not found

004: ....\src\H5Gtraverse.c line 641 in H5G_traverse_real(): traversal opera

tor failed major: Symbol table minor: Callback failed

005: ....\src\H5Gloc.c line 385 in H5G_loc_find_cb(): object 'subjects' does

n't exist major: Symbol table minor: Object not found


ValueError Traceback (most recent call last)

in () ----> 1 ds = cortex.openFile("S1_retinotopy.hdf") D:\Programme\Anaconda\lib\site-packages\cortex\dataset__init__.pyc in from_file (cls, filename) 93 #load up the views generated by pycortex 94 for name, node in ds.h5['views'].items(): ---> 95 ds.views[name] = DataView.from_hdf(ds, node) 96 for bd in ds.views[name]: 97 loaded.add(bd.name) D:\Programme\Anaconda\lib\site-packages\cortex\dataset\views.pyc in from_hdf(cls , ds, node) 81 data.append(d) 82 else: ---> 83 bd = BrainData.from_hdf(ds, node.file.get(name)) 84 data.append(bd) 85 if len(data) < 2 and isinstance(data[0], BrainData): D:\Programme\Anaconda\lib\site-packages\cortex\dataset\braindata.pyc in from_hdf (dataset, node) 60 if "mask" in node.attrs: 61 try: ---> 62 surfs.getMask(subj, xfmname, node.attrs['mask']) 63 mask = node.attrs['mask'] 64 except IOError: D:\Programme\Anaconda\lib\site-packages\cortex\db.pyc in getMask(self, subject, xfmname, type) 434 def getMask(self, subject, xfmname, type='thick'): 435 try: --> 436 self.auxfile.getMask(subject, xfmname, type) 437 except (AttributeError, IOError): 438 pass D:\Programme\Anaconda\lib\site-packages\cortex\dataset__init__.pyc in getMask(s elf, subject, xfmname, maskname) 181 def getMask(self, subject, xfmname, maskname): 182 try: --> 183 group = self.h5['subjects'][subject]['transforms'][xfmname][ 'masks'] 184 return group[maskname] 185 except (KeyError, TypeError): D:\Programme\Anaconda\lib\site-packages\h5py_hl\group.pyc in __ getitem__(self, name) 151 raise ValueError("Invalid HDF5 object reference") 152 else: --> 153 oid = h5o.open(self.id, self._e(name), lapl=self._lapl) 154 155 otype = h5i.get_type(oid) D:\Programme\Anaconda\lib\site-packages\h5py\h5o.pyd in h5py.h5o.open (h5py\h5o. c:2947)() D:\Programme\Anaconda\lib\site-packages\h5py\h5i.pyd in h5py.h5i.wrap_identifier (h5py\h5i.c:998)() ValueError: Unrecognized type code -1 but even after commenting out the line and havveing the "NoneType"-error fixed i get a similar error like this: In [4]: ds = cortex.openFile("S1_retinotopy.hdf") Mask not found, generating... In [5]: cortex.webshow(ds) HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0: #000: ....\src\H5O.c line 246 in H5Oopen(): unable to open object major: Symbol table minor: Can't open object #001: ....\src\H5O.c line 1357 in H5O_open_name(): object not found major: Symbol table minor: Object not found #002: ....\src\H5Gloc.c line 430 in H5G_loc_find(): can't find object major: Symbol table minor: Object not found #003: ....\src\H5Gtraverse.c line 861 in H5G_traverse(): internal path traver sal failed major: Symbol table minor: Object not found #004: ....\src\H5Gtraverse.c line 641 in H5G_traverse_real(): traversal opera tor failed major: Symbol table minor: Callback failed #005: ....\src\H5Gloc.c line 385 in H5G_loc_find_cb(): object 'subjects' does n't exist major: Symbol table minor: Object not found --- ValueError Traceback (most recent call last) in () ----> 1 cortex.webshow(ds) D:\Programme\Anaconda\lib\site-packages\cortex\webgl__ init__.pyc in show(_args, *_kwargs) 2 def show(_args, *_kwargs): 3 from . import view ----> 4 return view.show(_args, *_kwargs) 5 6 def make_static(_args, *_kwargs): D:\Programme\Anaconda\lib\site-packages\cortex\webgl\view.pyc in show(data, type s, recache, cmap, layout, autoclose, open_browser, port, pickerfun, **kwargs) 172 surfs.auxfile = data 173 --> 174 package = Package(data) 175 metadata = json.dumps(package.metadata()) 176 images = package.images D:\Programme\Anaconda\lib\site-packages\cortex\webgl\data.pyc in __ init__(self, data) 24 for brain in self.uniques: 25 name = brain.name ---> 26 self.brains[name] = brain.to_json() 27 voldata = brain.volume 28 if not brain.movie: D:\Programme\Anaconda\lib\site-packages\cortex\dataset\braindata.pyc in to_json( self) 123 124 def to_json(self): --> 125 xfm = surfs.getXfm(self.subject, self.xfmname, 'coord').xfm 126 return dict( 127 data=self.name, D:\Programme\Anaconda\lib\site-packages\cortex\db.pyc in getXfm(self, subject, n ame, xfmtype) 340 if xfmtype == 'coord': 341 try: --> 342 return self.auxfile.getXfm(subject, name) 343 except (AttributeError, IOError): 344 pass D:\Programme\Anaconda\lib\site-packages\cortex\dataset__ init__.pyc in getXfm(se lf, subject, xfmname) 176 def getXfm(self, subject, xfmname): 177 try: --> 178 group = self.h5['subjects'][subject]['transforms'][xfmname] 179 return Transform(group['xfm'].value, group['xfm'].attrs['sha pe']) #return Transform(group['xfm'].value, tuple(group['xfm'].attrs['shape'])) 180 except (KeyError, TypeError): D:\Programme\Anaconda\lib\site-packages\h5py_hl\group.pyc in __ getitem__(self, name) 151 raise ValueError("Invalid HDF5 object reference") 152 else: --> 153 oid = h5o.open(self.id, self._e(name), lapl=self._lapl) 154 155 otype = h5i.get_type(oid) D:\Programme\Anaconda\lib\site-packages\h5py\h5o.pyd in h5py.h5o.open (h5py\h5o. c:2947)() D:\Programme\Anaconda\lib\site-packages\h5py\h5i.pyd in h5py.h5i.wrap_identifier (h5py\h5i.c:998)() ValueError: Unrecognized type code -1
MarabuRLI commented 10 years ago

hi, since there are so many errors with windows and i'm yet so unfamiliar with the package i decided to go with linux for now. the demo works fine there ^^

jamesgao commented 10 years ago

Sorry I couldn't help you further with Windows. We are a primarily Linux and Mac lab, so we didn't even have a Windows computer to test this with. I will set up a Virtual Machine and fix all the associated bugs. I'll keep this issue open until I fix all the Windows problems!