Code Monkey home page Code Monkey logo

pysurfer's Introduction

PySurfer: Neuroimaging visualization in Python

PySurfer is a Python package for interacting with a cortical surface representations of neuroimaging data. It extends Mayavi's powerful visualization engine with a high-level interface for working with MRI and MEG data.

PySurfer offers both a command-line interface designed to broadly the Freesurfer Tksurfer program and a Python library for writing scripts to efficiently explore complex datasets and prepare publication-ready figures.

To goal of the project is to facilitate the production of figures that are both beautiful and scientifically informative.

Important Links

Install

This packages uses setuptools. To install it for all users, run:

python setup.py build
sudo python setup.py install

If you do not have sudo privileges, you can install locally:

python setup.py install --home

For information about dependencies, please see the online documentation

License

Available under the Revised BSD (3-clause) license.

Testing

You can launch the test suite by running nosetests from the source folder.

Another way to test is to build the documentation, which will run the example scripts and automatically generate static image output. From the source directory:

cd doc/
make clean
make html

The resulting documentation will live at _build/html/index.html, which can be compared to the online docs.

Either method will work only if you have Freesurfer installed on your machine with a valid SUBJECTS_DIR folder.

pysurfer's People

Contributors

aestrivex avatar agramfort avatar christianbrodbeck avatar ctw avatar dengemann avatar diego0020 avatar dingkunliu avatar effigies avatar gpiantoni avatar kingjr avatar larsoner avatar lauragwilliams avatar matthew-brett avatar mluessi avatar mwaskom avatar satra avatar sburns avatar sermetpekin avatar wmvanvliet avatar yarikoptic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysurfer's Issues

Nibabel dependency specification

Is there a reason nibabel is not specified as a normal dependency in setup.py? Sorry if this has been discussed before, I couldn't find an answer in past issues. I assume mayavi is not because it's hard to install from the PYPI, but installing nibabel from the PYPI is straight forward.

Please clarify contact address

What is the preferred way to contact the pysurfer development team? I want to push the Debian packaging further, but I cannot find any information on how to contact you, other than digging out your individual email adresses or filing a bug ;-)

Could you please but some contact info in the sources/docs?

Thanks,

Michael

FIX: nosetests lead to segmentation fault

While running the terst-suite, Test plotting of Brain with different arguments ... exposes a Segmentation fault: 11. I'm using Canopy64 and numpy 1.8 --- probably some mild backend-issue which could be tackled using the config. I'll look into it later

Cannot install PySurfer

Ooops, I think the changes @mluessi made to the setup.py broke something, at least for me:

[PySurfer]{master}$ python setup.py install
/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
  warnings.warn(msg)
/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
  warnings.warn(msg)
running install
running bdist_egg
running egg_info
running build_src
build_src
Traceback (most recent call last):
  File "setup.py", line 65, in <module>
    scripts=['bin/pysurfer'],
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/numpy/distutils/core.py", line 186, in setup
    return old_setup(**new_attr)
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/numpy/distutils/command/install.py", line 57, in run
    r = self.setuptools_run()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/numpy/distutils/command/install.py", line 51, in setuptools_run
    self.do_egg_install()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/install.py", line 93, in do_egg_install
    self.run_command('bdist_egg')
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/bdist_egg.py", line 177, in run
    self.run_command("egg_info")
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Users/mwaskom/anaconda/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/numpy/distutils/command/egg_info.py", line 9, in run
    _egg_info.run(self)
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 185, in run
    self.find_sources()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 261, in find_sources
    mm.run()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 327, in run
    self.add_defaults()
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 363, in add_defaults
    sdist.add_defaults(self)
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/setuptools/command/sdist.py", line 211, in add_defaults
    if not self.distribution.include_package_data:
AttributeError: NumpyDistribution instance has no attribute 'include_package_data'

[PySurfer]{master}$ python -c "import numpy; print numpy.__version__"
1.7.1

Installation with anaconda on OS X fails

I don't know if this is really our fault, but it seems like something we should at least warn people about.

I'm trying out anaconda because I saw that they now package Mayavi and I was hopeful that would let me get PySurfer working on a 64 bit installation. So I installed anaconda, updated it, and then did conda install mayavi. This seemed to work ok, and I could start the mayavi app (though not without getting an ImportError about wx).

Then I figured OK let's try PySurfer. Which lead to the following two failures:

[mwaskom@ben-octocore ~]$ pip install pysurfer
Downloading/unpacking pysurfer
  Running setup.py egg_info for package pysurfer
    Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.
    Complete output from command python setup.py egg_info:
    Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.

----------------------------------------
Command python setup.py egg_info failed with error code -6 in /private/var/folders/RK/RK5q1cfCE6CoFSziaUGCxU++636/-Tmp-/pip-build-mwaskom/pysurfer
Storing complete log in /Users/mwaskom/.pip/pip.log


[mwaskom@ben-octocore ~]$ easy_install pysurfer
Searching for pysurfer
Reading http://pypi.python.org/simple/pysurfer/
Best match: pysurfer 0.4
Downloading https://pypi.python.org/packages/source/p/pysurfer/pysurfer-0.4.tar.gz#md5=29a819390c8c866ec66d0109029ca93b
Processing pysurfer-0.4.tar.gz
Writing /var/folders/RK/RK5q1cfCE6CoFSziaUGCxU++636/-Tmp-/easy_install-2AuPIR/pysurfer-0.4/setup.cfg
Running pysurfer-0.4/setup.py -q bdist_egg --dist-dir /var/folders/RK/RK5q1cfCE6CoFSziaUGCxU++636/-Tmp-/easy_install-2AuPIR/pysurfer-0.4/egg-dist-tmp-C4VijA
Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/  or in the resources directory of your application bundle.
Abort trap

So, like I said above, this might not be something we're particularly doing wrong, but it seems like it's worth warning people about if it's unavoidable. If any of the other devs (or people like @GaelVaroquaux or @satra) have insights about how to get PySurfer working on a 64 bit OS X install and want to help write up a doc page about it, that would great. I haven't sunk a ton of time into it, but I don't have the slightest idea how I would successfully get it working, and it's starting to be a major impediment.

split screen rendering failing

something weird is going on with split rendering with pysurfer 0.5 under a miniconda 2.7 environment on centos 6.5. (pysurfer S001 split inflated)

error

Closing figures is triggering a segfault

On Canopy 64 OS X, running the following script triggers a segfault when on the second call to b.close():

from surfer import Brain
    for hemi in ["lh", "rh"]:
    b = Brain("fsaverage", hemi, "inflated")
    b.close()

Trying to investigate further what's going on...

Improve narrative docs

I'd like to have two additional doc pages about using PySurfer:

  • Short vignette on why you might want to use PySurfer, i.e. the advantages of surface-based visualization over volume-based, or over the crappy renderings offered by other packages
  • Detailed explanation of how to use PySurfer to visualize data in the MNI-volume, aimed at people who aren't familiar with Freesurfer.

Incorporate Neurosynth data into PySurfer

This is a placeholder for some functionality I'd like to add at some point. I think it would be nice to be able to do, e.g.

brain.add_neurosynth_term("executive", "reverse")

And get a map with the reverse inference statistics for the term "executive" plotted.

I used to have a toy notebook to do something similar, but the downloading API has changed and so that no longer works.

We'd probably want to go straight from the coordinates to the surface anyway, rather than detouring through a volume image.

CC: @tyarkoni who will probably have quick answers to questions that come up when I start actually working on this

0.4 easy_install is broken

Just ran into this on my macbook (currently set up with EPD7.3 32 Bit):

[~]$ easy_install -U pysurfer
Searching for pysurfer
Reading http://pypi.python.org/simple/pysurfer/
Best match: pysurfer 0.4
Downloading https://pypi.python.org/packages/source/p/pysurfer/pysurfer-0.4.tar.gz#md5=b07665a6c412b39b1c531c820cdec92e
Processing pysurfer-0.4.tar.gz
Writing /var/folders/rr/svlz5yhs0tsdqnsp8g4qg65m0000gn/T/easy_install-161OzB/pysurfer-0.4/setup.cfg
Running pysurfer-0.4/setup.py -q bdist_egg --dist-dir /var/folders/rr/svlz5yhs0tsdqnsp8g4qg65m0000gn/T/easy_install-161OzB/pysurfer-0.4/egg-dist-tmp-5QEAHq
error: SandboxViolation: os.open('/Users/mwaskom/.matplotlib/tmpcmqzee', 2818, 384) {}

The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand.  Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.

Any ideas? @Eric89GXL ?

PS pip seems to work fine.

object handles don't save image properly; only active figure is saved

the saved images reflect whichever of the windows is currently active, not the object on which save_image is called.

br1 = Brain('fsaverage', 'lh', 'inflated', title='lh')
br2 = Brain('fsaverage', 'rh', 'inflated', title='rh')

br1.save_image('lh.png')
br2.save_image('rh.png')

Test failure on saving image

Got this testing locally. The travis build is green, but hasn't run in a while? git blame says the code line belongs to @agramfort and the test belongs to @christianbrodbeck. Any ideas?

======================================================================
ERROR: Test image saving
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/mwaskom/anaconda/lib/python2.7/site-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/Users/mwaskom/Code/PySurfer/surfer/tests/test_viz.py", line 58, in test_image
    brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
  File "/Users/mwaskom/Code/PySurfer/surfer/viz.py", line 1979, in save_montage
    border_size)
  File "/Users/mwaskom/Code/PySurfer/surfer/viz.py", line 97, in make_montage
    mins = np.min(slices_a[:, :, 0], axis=0)
IndexError: too many indices

Do we still need to protect the mlab import?

In surfer.viz Each method of the Brain object that plots something does its own import of mayavi.mlab. The original thinking on this, if I remember correctly, was

  • Importing mayavi.mlab takes a while
  • PySurfer was the only tool with Freesurfer i/o, which was useful outside the context of plotting
  • We didn't want people to have to boot up mayavi just to read in a label or whatever

Now that io has been moved to nibabel, is this line of thought defunct? It would clean up the code quite a bit, and stifle pyflakes.

Also, is it time to remove the mayavi backwards compatibility? It's been a while since from enthought.mayavi import mlab was en vogue.

make unittests usable without freesurfer's fsaverage

Please refactor unittests so
they operate on some very stripped down dataset (which you could ship along)
instead of a bulky fsaverage from freesurfer. ATM:

$> python2.6 /usr/bin/nosetests -s -v surfer/tests
/usr/bin/nosetests:5: UserWarning: Module paste was already imported from None, but /usr/lib/python2.6/dist-packages is being added to sys.path
  from pkg_resources import load_entry_point
Failure: ValueError (Test suite relies on the definition of SUBJECTS_DIR) ... ERROR

======================================================================
ERROR: Failure: ValueError (Test suite relies on the definition of SUBJECTS_DIR)
----------------------------------------------------------------------
Traceback (most recent call last): 
  File "/usr/lib/python2.6/dist-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)    
  File "/usr/lib/python2.6/dist-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.6/dist-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/yoh/proj/nipy/nipy-suite/pysurfer/surfer/tests/test_io.py", line 10, in <module>
    raise ValueError('Test suite relies on the definition of SUBJECTS_DIR')
ValueError: Test suite relies on the definition of SUBJECTS_DIR

Offscreen rendering is broken

The following line is broken for me on 0.4:

b = Brain("fsaverage", "lh", "smoothwm", offscreen=True)

With the following traceback:

AttributeError                            Traceback (most recent call last)
<ipython-input-2-01c82883788a> in <module>()
----> 1 Brain("fsaverage", "lh", "smoothwm", offscreen=True)

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pysurfer-0.4-py2.7.egg/surfer/viz.pyc in __init__(self, subject_id, hemi, surf, curv, title, config_opts, figure, subjects_dir, views, show_toolbar, offscreen)
    399         # force rendering so scene.lights exists
    400         _force_render(self._figures, self._window_backend)
--> 401         self.toggle_toolbars(show_toolbar)
    402         _force_render(self._figures, self._window_backend)
    403         self._toggle_render(False)

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pysurfer-0.4-py2.7.egg/surfer/viz.pyc in toggle_toolbars(self, show)
    570                     bar.setVisible(show)
    571                 else:
--> 572                     bar.Show(show)
    573
    574     def _get_one_brain(self, d, name):

AttributeError: 'NoneType' object has no attribute 'Show'

@agramfort or @Eric89GXL can you reproduce this?

failing example: Plot MEG inverse solution

This example fails on my machine http://pysurfer.github.io/examples/plot_meg_inverse_solution.html

from surfer.io import read_stc
stc_fname = os.path.join('meg_source_estimate-lh' + '.stc') 
stc = read_stc(stc_fname)

raises

----> 1 stc = read_stc(stc_fname)

/usr/lib/pymodules/python2.7/surfer/io.pyc in read_stc(filepath)
    305 
    306     # read the number of timepts

--> 307     data_n = int(np.fromfile(fid, dtype=">I4", count=1))
    308 
    309     if ((file_length / 4 - 4 - vertices_n) % (data_n * vertices_n)) != 0:

TypeError: only length-1 arrays can be converted to Python scalars

In [4]: np.version
Out[4]: '1.6.1'

In [8]: surfer.version
Out[8]: '0.4.dev'

install errors on osx with conda

installs without error but package requirements are not satisfied.

$ conda create -n testsurfer mayavi pip

$ source activate testsurfer
prepending /software/anaconda/envs/testsurfer/bin to PATH

$ pip install /software/nipy-repo/PySurfer/
Unpacking /software/nipy-repo/PySurfer
  Running setup.py (path:/var/folders/sm/488rz12j279_gyxrq7z971zw0000gn/T/pip-v0Ywau-build/setup.py) egg_info for package from file:///software/nipy-repo/PySurfer

Installing collected packages: pysurfer
  Running setup.py install for pysurfer

    changing mode of build/scripts-2.7/pysurfer from 644 to 755
    changing mode of /software/anaconda/envs/testsurfer/bin/pysurfer to 755
Successfully installed pysurfer
Cleaning up...

$ pysurfer fsaverage lh inflated
Traceback (most recent call last):
  File "/software/anaconda/envs/testsurfer/bin/pysurfer", line 9, in <module>
    from surfer._commandline import parser
  File "/software/anaconda/envs/testsurfer/lib/python2.7/site-packages/surfer/__init__.py", line 1, in <module>
    from .viz import Brain, TimeViewer  # noqa
  File "/software/anaconda/envs/testsurfer/lib/python2.7/site-packages/surfer/viz.py", line 6, in <module>
    from scipy import stats, ndimage, misc
ImportError: No module named scipy

Problem modifying colorbar properties after using custom LUT

Just noticed this in the docs I built after the colormap enhancements, sorry.

Turns out that in the probabilistic colormap example, modifying the number of hues and labels on the colorbar reverts the colormap from RdPu, which the code asks for, to Greys, which I chose as the default string to pass to the mlab functions (with the expectation that it would signify problems with the colormap choice by its lack of color).

I'll fix this, I'm just opening the issue because I can't get to it right now.

I actually don't think we're doing anything wrong here; we're using the approved way of specifying a custom colormap. So I think it might be a mayavi bug in communication between the colorbar and the colormap. But at the very least I'll fix the example.

pysurfer command line program is broken when missing wx

On Canopy 64 for Mac OS X, Mayavi can run with a qt backend. However, the pysurfer command line program does not have the option to choose a different gui backend for the IPython session, so it does not fully work on this install (the viewer window loads and is interactive, but the terminal is frozen).

Brain method to get current view as ndarray

@agramfort or others, does PySurfer have a function that allows converting the current view to a bitmap / ndarray?

I know there is a .save_image() function, but I don't see one that allows you to get that data as an ndarray right away (say, for adding several to a single plot before saving it to disk). Basically I want to combine a matplotlib plot with several "brains" and normal plots on it, and this seemed like the most natural way. One way would be to save each brain image to disk, then them each in, but this seems less ideal.

I can work on adding a method if one does not exist, just wanted to double check before I hack hack hack...

add_annotation should only remove existing from targeted hemisphere

If I do

b = Brain("fsaverage", "split", "inflated")
for hemi in ["lh", "rh"]:
    b.add_annotation("aparc", hemi=hemi)

It adds the left hemi annotation but then removes it when it adds the right hemisphere. This can be fixed with

b = Brain("fsaverage", "split", "inflated")
for hemi in ["lh", "rh"]:
    b.add_annotation("aparc", hemi=hemi, remove_existing=False)

But if feels like that should be hemisphere-specific?

Any reason to have _pysurfer-load.py in bin/?

I'm asking because system-wide install would put it in /usr/bin although it is not meant to be used by an end-user. In the Debian package I could install it in a private directory (e.g. /usr/share/pysurfer) and patch the pysurfer script to load it from there. However, I wonder why it is not simply located in surfer/ as well and gets installed together with the rest of the package. The advantage for me would be: no need to patch, byte-compiling is handled properly by Debian helpers, and multiple Python-version support comes automatically.

I see no disadvantage of moving it to surfer/

Do you agree? Would you consider moving it?

Michael

show `label == 0` with transparency

i'm trying to show regions on the brain and i would like to turn in_labels == 0 transparent. is there a way one could do this easily?

def show_brains(in_labels=None, surface='inflated'):
    if in_labels is not None:
        n_clusters = len(np.unique(in_labels))
    brain_lh = Brain("fsaverage", "lh", surface, title="left",
                  config_opts=dict(cortex="low_contrast"))
    if in_labels is not None:
        brain_lh.add_data(in_labels)
        brain_lh.data["colorbar"].number_of_colors = n_clusters
    if in_labels is not None:
        brain_lh.data["colorbar"].lut_mode = 'Set1'
    return brain_lh

mayavi doesn't have enthought namespace anymore

While doing the Debian packaging I noticed that mayavi2 (at least on Debian) doesn't use the enthought namespace anymore. That means that

from enthought.mayavi import mlab

fails. Remove enthought solves the problem. However, on older releases or Ubuntu that would now fail. Please add a safety layer to allow both types of imports.

Thanks

KeyError in viz.py

Hi all,

I am calling pysurfer from mne-python to mark source locations on an inflated brain. It works on the left hemisphere, but, when I try to mark locations on the right hemisphere, I get:
KeyError: 'lh'

Here's a minimal code example, which reproduces the KeyError and shows that it works on the left hemisphere (the error is in the call to brain_rh._geo.coords[idx_rh]):

from surfer import Brain
from mayavi import mlab

idx_lh = [70909]
brain_lh = Brain('sample', 'lh', 'inflated', subjects_dir=subjects_dir)
coords = brain_lh._geo.coords[idx_lh]

for coord in coords:
    points = mlab.points3d(coord[0], coord[1], coord[2], scale_factor=10,
                           color=(1., 0., 0.), opacity=1.0)

idx_rh = [77685]
brain_rh = Brain('sample', 'rh', 'inflated', subjects_dir=subjects_dir)
coords = brain_rh._geo.coords[idx_rh]

for coord in coords:
    points = mlab.points3d(coord[0], coord[1], coord[2], scale_factor=10,
                           color=(1., 0., 0.), opacity=1.0)

By changing line 339 in surfer.viz.py from self.geo = dict() to self.geo = dict(lh=None, rh=None) I can avoid the KeyError and the plotting on both hemispheres works.

Do I make any mistake in calling the pysurfer functions? Would be nice if you could check if the error is reproducable on other machines. If that's the case, I can send a pull request for changing this line in viz.py.

Bye Daniel

montage -- clipping works only with black backround

due to use of scipy.find_objects which would need background to be 0's (should it be filled in with 0s then first -- since we are looking for contineous brain -- it should fill in quite nicely)

also it would be nice to be able to pass background information inside the save_montage

make examples usable for users

ATM they assume being a copy under doc/auto_examples which forbids their use by users straight of the directory where they are contained (i.e. examples)

offscreen rendering still requires exported display

Hi,

I'm running pysurfer on a cluster and pysurfer is still exporting a display "in the background".

I'm running ubuntu 14.04 LTS,
ssh -XYC into cluster,
python pysurferscrip.py

and pysurfer launches a VTK/opengle process of somekind on the computer I'm using to ssh.


brain=Brain('fsaverage', hemi_str, 'pial', curv=None,
config_opts={"cortex": "bone",
"background": "white"}, offscreen=True)

memory leak?

I'm saving a lot of images of time courses for different conditions and groups, and each time I load in a new stc file, my memory goes up. I've tried del, .close(), .clear(), and gc.collect(). I'm not appending anything. Just replacing variables with new data as I move through the loops.

setup issue with no X display

i think setup should complete without a display, no?

$ python setup.py install
Unable to access the X Display, is $DISPLAY set properly?

QPixmap errors when trying to use Brain

When trying to load a brain surface with the command:

from surfer.viz import Brain
brain = Brain(subject, 'lh', 'inflated')

I got these error messages and no display window showed up:

QPixmap: It is not safe to use pixmaps outside the GUI thread
QObject::startTimer: QTimer can only be used with threads started with QThread

This error doesn't come up each time, and it's hard to predict when it will happen. Could it be some issue with python itself?

ENH: Python 3 compatibility and changing backend

Over at mne-python we're looking into migrating to Python3, and one of our biggest roadblocks will be PySurfer / Mayavi. @agramfort has mentioned that Mayavi may not ever be migrated to 3.0, so it might be worth switching to a different backend. I also had to do some pretty ugly hacks to get TraitsUI to support visualization scripting, since it's not built to do that (it is not supported by the devs).

I'm up for looking into the various other backend options here if people are open to the idea of switching backends for 0.5. Having done a little bit of low-level OpenGL work recently, I think it might be possible to go to a backend that only gives us low-level OpenGL calls (as opposed to high-level abstraction like VTK/Mayavi) without too much hassle.

What do people think?

Here are a list of potential ones (I'll update as people suggest or I find them):

  • pyqtgraph (MIT)
    • Abstractions for 3D surface plotting
    • Built-in mouse / keyboard interaction
    • Has widgets (GUI-like functionality possible)
    • Requires QT4 / PySide (Mayavi more or less did, too)
  • vispy (BSD)
    • Fairly low-level access to OpenGL
  • VTK no 3.0 date yet
  • XTK most programming in JavaScript, Web interface makes local file usage problematic
  • pyopengl / glumpy / pyglet / pygame raw OpenGL only as last resort
  • VPython a distribution more than a package
  • visvis (BSD) probably not complete enough mesh rendering options

io.read_annot returns None

it turns out io.read_annot can return None. I don't know if this occurs when a pb occurs or if it can be ignored.
I have a pb with a database I've just been given.

Should we do a release soon?

@agramfort @Eric89GXL @christianmbrodbeck

We have some nice new features (pretty surface normal enhancement, better colormap handling, some various improvements to saving images and movies that Christian has contributed). It might be worth doing a release, especially if a move to a completely different backend is still on the horizon.

I also have been putting off two documentation projects:

  • Short vignette on why you might want to use PySurfer, i.e. the advantages of surface-based visualization over volume-based, or over the crappy renderings offered by other packages
  • Detailed explanation of how to use PySurfer to visualize data in the MNI-volume, aimed at people who aren't familiar with Freesurfer.

Having a release target would encourage me to finish these.

We should also finally come together on an "official" guide for using PySurfer on a Mac, including the information shared here and our own experiences. I think @Eric89GXL has also used it successfully on a Windows box, so some information on how that can work would be great too.

Does anyone else have near-term projects they'd like to get in a 0.5?

I'm happy to be a release manager for this round.

ENH: avoid having to run FreeSurferEnv.sh

In the different places where pysurfer calls freesurfer commands, the following idiom would enable working without sourcing "FreeSurferEnv.sh" before opening Python:

subprocess.call(
      'source $FREESURFER_HOME/FreeSurferEnv.sh; mri_vol2surf --src %s --out %s.left.mgz --srcreg $FREESURFER_HOME/average/mni152.register.dat --hemi lh'
      % (tmp_file.name, outfile), shell=True, executable="/bin/bash")

It would be trivial to change the various calls to "subprocess.call" like this, and thus make things more user-friendly.

smooth videos of MEG time courses

Hi folks,

I just noticed that on invoking brain.save_image_sequence the brain-- I mean the cortical surface depicted, not the STC-- suffers from tiny changes in position and shape, as if jumping forward in time would interfere with the visualisation.
As I assemble a video from the resulting images it looks like a video taken in a moving environment, e.g. a train or a car.
First, does this description make sense to you,
second if it does, does anyone have any ideas this can be improved?

Best
-- Denis

0.4 release

@agramfort suggested that we move forward with releasing PySurfer 0.4, and gave me some instructions on how to do so. If there aren't any objections, I can do it sometime tomorrow or next week. @mwaskom you had mentioned a possible release, thoughts?

Curvature displayed incorrectly when not using builtin surfaces with hemi="split"

This is kind of weird. I usually plot on a partially-inflated surface. But I was playing around with hemi="split" today, and found that when I do that the right hemisphere is plotted with the left hemisphere curvature file:

screenshot 2014-03-27 15 18 59

This doesn't happen using this surface in a single window, or when using e.g. inflated or pial.

Any idea what could be causing this @Eric89GXL ? I didn't see the surfaces hardcoded anywhere in viz.py, but maybe I missed it.

Show both hemispheres

It has come up repeatedly that it would be desirable to be able to show/manage both hemispheres with a single class. (mne-tools/mne-python#500 (comment), mne-tools/mne-python#418 (comment)).

1) I have been experimenting with a "parent" class that contains .lh and .rh, both Brain instances, and 'wraps' commands such as saving images, and has a show method that accepts values like 'lh medial' which would hide the right hemisphere. That has the advantage of leaving the current Brain class intact, but probably has to duplicate a lot of the methods.

What would be other options?

Get rid of the config file?

I almost always find the config_opts dictionary to be a huge pain. The lack of tab completion in IPython means I always have to hunt to find the right name for the keys, and it's weird to pass an extra dictionary of keyword arguments.

I can't even remember why those options were implemented this way, though I suspect it made reading them from the config file easier. I would like to get rid of the config_opts dictionary and make its entries first-class keyword arguments in Brain. (We can keep config_opts for a release cycle or two and fire a warning when people use it, to avoid too much disruption).

But more generally, it's worth thinking about just killing the config file itself. I've come to really dislike this approach to customization because it means the scripts/notebooks you write aren't fully reproducible without metadata, and there's no indication in the code that the metadata existed at the time it was executed. (i.e., the script won't even crash, you'll just get a result that looks different).

I also suspect that the config file is relatively underutilized.

Would anyone object to just getting rid of the config file and making everything be specified in the Brain constructor?

backends and multithreading

The current pysurfer code to use traitsui involves strange hacks to make the GUI busy for a short time while X renders the mayavi window but also without causing the GUI to enter an event loop and block. This section of code is very difficult to understand and maintain. A much more natural solution would be to use multithreading and explicit management of locking constructs to ensure that all of the events happen at the correct time.

The problem with this code is mainly with traitsui, which is an interactive GUI but which pysurfer is trying to use as a noninteractive GUI. Traitsui doesn't expose an API to usefully allow for precise timing of the GUI to be controlled in a multithreaded environment. In order to get the correct behavior without generating potential race conditions (which I think is what is happening now, only it is a race condition that is extremely unlikely to ever lose the race), I don't think embedding mayavi in traitsui will work.

I don't know any visualization libraries other than mayavi but I have been working on some simple tests to operate on VTK windows can be managed and display at the correct times in GUI code that does not involve traitsui -- I have proof of concept tests that suggest this should work with wxpython and tk (but it did not work at all with pyqt). As wxpython is not included in anaconda by default (and nothing about the GUI layout in pysurfer is particularly complex), tk is probably the better choice.

I'm of the opinion that to fix the current problems with traitsui, pysurfer should move in this direction (and I anticipate doing the majority of the work). This won't per se help eliminate dependencies on python 2.7 more quickly, but it will provide something more stable and maintainable so that pysurfer might later move to multiple backends as has been discussed before.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.