Commit 75a95ae4 authored by Andreas Tille's avatar Andreas Tille

Import Upstream version 2.0.0

parents
/scratch export-ignore
*.bin
*.log
*.pyc
*.c
doc/_build/
doc/build/
doc/manual
build/
dist/
MANIFEST
.project
.settings/
.idea/
Copyright (C) 2009-2011, Ecole Polytechnique Fédérale de Lausanne (EPFL) and
Hospital Center and University of Lausanne (UNIL-CHUV), Switzerland
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Ecole Polytechnique Fédérale de Lausanne (EPFL)
and Hospital Center and University of Lausanne (UNIL-CHUV) nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL "Ecole Polytechnique Fédérale de Lausanne (EPFL) and
Hospital Center and University of Lausanne (UNIL-CHUV)" BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
recursive-include cviewer *.png *.jpg *.ico *.gii *.ini *.so *.dll *.html *.csv *.c *.pyx *.py
include *.txt
include COPYRIGHT
include README.rst
include build_helpers.py
graft doc
graft examples
graft external
prune doc/manual
prune doc/manual/build
prune doc/build
prune libs-queue/
=================
Connectome Viewer
=================
The Connectome Viewer - Interactive Analysis and Visualization for MR Connectomics
The Connectome Viewer is a extensible, scriptable, pythonic software tool for visualization
and analysis in neuroimaging research. Employing the Connectome File Format, diverse data types
such as networks, surfaces, volumes, tracks and metadata are handled and integrated. The
Connectome Viewer is part of the MR Connectome Toolkit.
Copyright (C) 2009-2011, Ecole Polytechnique Fédérale de Lausanne (EPFL) and
Hospital Center and University of Lausanne (UNIL-CHUV), Switzerland
=======
Credits
=======
------
Author
------
Stephan Gerhard
------
Thanks
------
* Yaroslav Halchenko
* Patric Hagmann
* Leila Cammoun
* Jean-Philippe Thiran
* Xavier Gigandet
* Reto Meuli
* Benjamin Thyreau
* Alessandro Daducci
* Alia Lemkaddem
* Marie-Christine Ottet
* Djalel Meskaldji
* Francesca Pizzorni
* Christophe Chenes
* Alessandra Griffa
---------------------
Plugins/External code
---------------------
See plugin section in documentation for copyright and license of contributions.
* Enthought Evisage. Application Framework. Enthought.
* Mayavi2. Partly modified files. Prabhu Ramachandran and Gael Varoquaux
* Andrew Zalesky (Network-Based Statistics)
This diff is collapsed.
# Author: Stephan Gerhard <info@connectome.ch>
# Copyright (c) 2009, ETH Zurich, EPFL, CHUV
# License: BSD Style
""" Version information for Connectome Viewer
"""
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
from cviewer.version import version as __version__
\ No newline at end of file
"""Provide the path to the images
"""
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
from os.path import dirname, join
IMAGE_PATH = join(dirname(__file__), '..', 'resources', 'images')
RESOURCE_PATH = join(dirname(__file__), '..', 'resources')
\ No newline at end of file
"""Actions for the help menu """
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
# Enthought library imports
from enthought.pyface.action.api import Action
from enthought.traits.ui.api import auto_close_message
from enthought.mayavi.preferences.api import preference_manager
from enthought.pyface.image_resource import ImageResource
# Connectome Viewer imports
from common import IMAGE_PATH
def browser_open(url, decorated = False):
import os
import sys
if sys.platform == 'darwin':
os.system('open %s &' % url)
else:
import webbrowser
if webbrowser._iscommand('firefox') and \
preference_manager.root.open_help_in_light_browser:
# Firefox is installed, let's use it, we know how to make it
# chromeless.
if decorated:
webbrowser.open(url, autoraise=1)
else:
firefox = webbrowser.get('firefox')
firefox._invoke(['-chrome', url], remote=False, autoraise=True)
else:
webbrowser.open(url, autoraise=1)
class Bugfix(Action):
""" An action that pop up the bugfix GitHub page in a browser. """
name = "Bugfixes"
tooltip = "Bug Fixes ..."
description = "Bug Fixes ..."
image = ImageResource("bug.png", search_path=[IMAGE_PATH])
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
browser_open(url='http://github.com/LTS5/connectomeviewer/issues', decorated = True)
class Keybindings(Action):
""" An action that creates a temporary html file to show the key bindings.. """
name = "Key Bindings"
tooltip = "Show Key Bindings in Browser"
description = "Key Bindings"
image = ImageResource("keyboard.png", search_path=[IMAGE_PATH])
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
import os.path
browser_open(url=os.path.join(IMAGE_PATH, '..', 'keybindings', 'index.html'), decorated = True)
######################################################################
# `HelpIndex` class.
######################################################################
class HelpIndex(Action):
""" An action that pop up the help in a browser. """
name = "Help"
tooltip = "The Connectome Viewer User Guide"
description = "The Connectome Viewer User Guide"
image = ImageResource("help-browser.png", search_path=[IMAGE_PATH])
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
auto_close_message("Opening help in web browser...")
browser_open(url='http://www.connectomeviewer.org/documentation', decorated = True)
""" Helper class to load CFF files """
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
# Standard library imports
import os.path
# Enthought library imports
from enthought.io.api import File
from enthought.traits.api import Str, Bool
from enthought.pyface.action.api import Action
from enthought.pyface.api import FileDialog, OK
from enthought.pyface.image_resource import ImageResource
# Connectome Viewer imports
from common import IMAGE_PATH
from cviewer.plugins.ui.preference_manager import preference_manager
import cfflib
# Logging imports
import logging
logger = logging.getLogger('root.'+__name__)
######################################################################
# `OpenCFFFile` class.
######################################################################
class OpenCFile(Action):
""" An action that opens a data file depending on the supported
extensions. """
name = "Open CFF File"
description = "Open the File Dialog where you can select a .cff or meta.cml file"
tooltip = "Open a CFF file"
path = Str("MenuBar/File/LoadDataMenu")
image = ImageResource("cff-open.png", search_path=[IMAGE_PATH])
# Is the action enabled?
enabled = Bool(True)
# Is the action visible?
visible = Bool(True)
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event, cfile=None):
""" Performs the action. """
logger.info('Performing open connectome file action')
# helper variable to use this function not only in the menubar
exec_as_funct = True
if cfile is None:
# get the instance of the current CFile
# with the help of the Service Registry
cfile = self.window.application.get_service('cviewer.plugins.cff2.cfile.CFile')
exec_as_funct = False
wildcard = "Connectome Markup File v2.0 (meta.cml)|meta.cml|" \
"Connectome File Format v2.0 (*.cff)|*.cff|" \
"All files (*.*)|*.*"
dlg = FileDialog(wildcard=wildcard,title="Choose a Connectome File",\
resizeable=False, \
default_directory=preference_manager.cviewerui.cffpath,)
if dlg.open() == OK:
if not os.path.isfile(dlg.path):
logger.error("File '%s' does not exist!"%dlg.path)
return
# if file exists and has .cff ending
if os.path.exists(dlg.paths[0]) and (dlg.paths[0]).endswith('.cff'):
# close the cfile if one is currently loaded
cfile.close_cfile()
# load cfile data
cfile.load_cfile(dlg.paths[0])
self.window.status_bar_manager.message=''
elif os.path.exists(dlg.paths[0]) and (dlg.paths[0]).endswith('meta.cml'):
cfile.close_cfile()
cfile.load_cfile(dlg.paths[0], ismetacml = True)
else:
logger.info('Could not load file: '+ dlg.paths)
class SaveCFile(Action):
""" An action that save aconnectome file """
name = "Save CFF File"
description = "Save the connectome file"
tooltip = "Save a CFF file"
path = Str("MenuBar/File/LoadDataMenu")
image = ImageResource("cff-open.png", search_path=[IMAGE_PATH])
# Is the action enabled?
enabled = Bool(True)
# Is the action visible?
visible = Bool(True)
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event, cfile=None):
""" Performs the action. """
logger.info('Performing save connectome file action')
# helper variable to use this function not only in the menubar
exec_as_funct = True
cfile = self.window.application.get_service('cviewer.plugins.cff2.cfile.CFile')
wildcard = "Connectome File Format v2.0 (*.cff)|*.cff|" \
"All files (*.*)|*.*"
dlg = FileDialog(wildcard=wildcard,title="Save as Connectome File",\
resizeable=False, action = 'save as',\
default_directory=preference_manager.cviewerui.cffpath,)
if dlg.open() == OK:
if (dlg.paths[0]).endswith('.cff'):
cfflib.save_to_cff(cfile.obj, dlg.paths[0])
logger.info("Saved connectome file to %s" % dlg.paths[0])
""" Executes a script in the console """
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
# Adapted from enthought.mayavi.action.save_load
# Standard library imports.
import sys
from os.path import isfile, dirname
# Enthought library imports.
from enthought.pyface.api import FileDialog, OK
from enthought.pyface.action.api import Action
from cviewer.plugins.ui.preference_manager import preference_manager
# Local imports
from enthought.mayavi.plugins.script import get_imayavi
from enthought.mayavi.core.common import error, exception
######################################################################
# `RunScript` class.
######################################################################
class RunScript(Action):
""" An action that runs a mayavi script.
WARNING: this can be dangerous since the file runs execfile! """
tooltip = "Execute a Python script (typically a Mayavi script)"
description = "Execute a Python script (typically a Mayavi script)"
###########################################################################
# 'Action' interface.
###########################################################################
def perform(self, event):
""" Performs the action. """
wildcard = 'Python files (*.py)|*.py'
parent = self.window.control
# path from preference manager
pref_script_path = preference_manager.cviewerui.scriptpath
if pref_script_path == '':
# store executed script path in preferences
dialog = FileDialog(parent=parent,
title='Open Python file',
action='open', wildcard=wildcard,
)
else:
dialog = FileDialog(parent=parent,
title='Open Python file',
action='open', wildcard=wildcard,
default_directory=pref_script_path,
)
if dialog.open() == OK:
if not isfile(dialog.path):
error("File '%s' does not exist"%dialog.path, parent)
return
# Get the globals.
# The following code is taken from scripts/mayavi2.py.
g = sys.modules['__main__'].__dict__
if 'mayavi' not in g:
mv = get_imayavi(self.window)
g['mayavi'] = mv
g['engine'] = mv.engine
if 'cfile' not in g:
# load cfile reference into gloabl name space
cfile = self.window.application.get_service('cviewer.plugins.cff2.cfile.CFile')
g['cfile'] = cfile
# always store last executed path in preferences
# but this only gets definitely stored when one open the preference manager
preference_manager.cviewerui.scriptpath = dirname(dialog.path)
# Do execfile
try:
# If we don't pass globals twice we get NameErrors and nope,
# using exec open(script_name).read() does not fix it.
execfile(dialog.path, g, g)
except Exception, msg:
exception(str(msg))
This diff is collapsed.
""" The Connectome Viewer Envisage Workbench Application class
"""
# Copyright (C) 2009-2010, Ecole Polytechnique Federale de Lausanne (EPFL) and
# University Hospital Center and University of Lausanne (UNIL-CHUV)
#
# Modified BSD License
# Standard library imports
from enthought.traits.api import Bool
# Enthought library import
from enthought.envisage.ui.workbench.api import WorkbenchApplication
from enthought.pyface.api import AboutDialog, ImageResource, SplashScreen
# ConnectomeViewer imports
from cviewer.plugins.ui.preference_manager import preference_manager
from cviewer.action.common import IMAGE_PATH
from .info import version
# Logging imports
import logging
logger = logging.getLogger('root.'+__name__)
class CViewerWorkbenchApplication(WorkbenchApplication):
""" The ConnectoneViewer workbench application. """
# Turn this off if you don't want the workbench to start a GUI event loop.
start_gui_event_loop = Bool(True, desc='start a GUI event loop')
# Create an Envisage application.
id = 'ch.connectome.viewer'
# Path used to search for images
_image_path = [IMAGE_PATH, ]
# The icon used on window title bars etc.
icon = ImageResource('favicon.ico', search_path=_image_path)
# The name of the application (also used on window title bars etc).
name = "Connectome Viewer " + str(version)
###########################################################################
# 'WorkbenchApplication' interface.
###########################################################################
def run(self):
""" Run the application.
This does the following:
1) Starts the application
2) Creates and opens a workbench window
3) Starts the GUI event loop (only if start_gui_event_loop is
True)
4) When the event loop terminates, stops the application
This particular method is overridden from the parent class to
allow the user to not run the gui event loop as would be
necessary when the loop is started elsewhere or when run fron
IPython.
"""
# Make sure the GUI has been created (so that, if required, the splash
# screen is shown).
gui = self.gui
# Start the application.
if self.start():
# Create and open the first workbench window.
window = self.workbench.create_window(
position=self.window_position, size=self.window_size
)
window.open()
# We stop the application when the workbench has exited.
#self.workbench.on_trait_change(self._on_workbench_exited, 'exited')
# Start the GUI event loop if needed.
if self.start_gui_event_loop:
# THIS CALL DOES NOT RETURN UNTIL THE GUI IS CLOSED.
gui.start_event_loop()
return
def _about_dialog_default(self):
""" Initialize the About Dialog """
#from vtk import vtkVersion
#vtk_version = vtkVersion().GetVTKVersion()
#'VTK version %s' % (vtk_version),
from cviewer.version import version
adds = ['Connectome Viewer - Version %s' % ( version ),
'',
'Copyright &copy; 2009-2011, Ecole Polytechnique F&eacute;d&eacute;rale de Lausanne (EPFL) and',
'University Hospital Center and University of Lausanne (UNIL-CHUV)',
'',
'Author: Stephan Gerhard <em>info [at] connectomics.org</em>',
'Contributors: <em>see README file</em>',
'',
'This program comes with ABSOLUTELY NO WARRANTY',
'It is licensed under Modified BSD License',
]
about_dialog = AboutDialog(
parent = self.workbench.active_window.control,
image = ImageResource('cviewer_about.png',
search_path=self._image_path),
additions = adds,
)
return about_dialog
def _splash_screen_default(self):
""" Initialize the Splash Screen """
if preference_manager.cviewerui.show_splash_screen:
splash_screen = SplashScreen(
image = ImageResource('cviewer_about.png',
search_path=self._image_path),
show_log_messages = True,
)
else:
splash_screen = None
return splash_screen
''' Release data for Connectome Viewer
This script should do no imports. It only defines variables.
'''
version = '2.0.0'
is_release = False
long_description = \
"""
Connectome Viewer - A Framework for the Visualization and Analysis of Multi-Modal Multi-Scale
Connectome Data in Python
The aim of Connectome Viewer is to produce a platform-independent Python framework for
the analysis and visualization of Connectome data using an open development model.
The Connectome Viewer is a extensible, scriptable, pythonic software tool for visualization
and analysis in neuroimaging research on many spatial scales. Employing the Connectome File
Format, diverse data such as networks, surfaces, volumes, tracks and metadata are handled
and integrated.
Specifically, we aim to:
1. Provide an open source, mixed language scientific programming
framework for rapid development and quantitative analysis
2. Provide a visualization platform to readily visualize multi-modal data for
interactive data exploration
3. Allow for enhanced brain connectivity analysis and plotting
4. Provide the Connectome File Format to store a wide range of data types:
metadata, networks, surfaces, volumes, fiber tracks, time series
5. Create and maintain a wide base of developers to contribute plugins to
this framework.
6. To integrate this framework with software packages in neuroimaging and provide
an easily installable bundle.
"""
# these have to be done per install_requires
envisagecore_min_version = '3.1.2'
traitsbackendwx_min_version = '3.2.1'
envisageplugins_min_version = '3.1.2'