Package mvpa
[hide private]
[frames] | no frames]

Source Code for Package mvpa

  1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- 
  2  # vi: set ft=python sts=4 ts=4 sw=4 et: 
  3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
  4  # 
  5  #   See COPYING file distributed along with the PyMVPA package for the 
  6  #   copyright and license terms. 
  7  # 
  8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
  9  """MultiVariate Pattern Analysis 
 10   
 11   
 12  Package Organization 
 13  ==================== 
 14  The mvpa package contains the following subpackages and modules: 
 15   
 16  .. packagetree:: 
 17     :style: UML 
 18   
 19  :group Algorithms: algorithms 
 20  :group Anatomical Atlases: atlases 
 21  :group Basic Data Structures: datasets 
 22  :group Classifiers (supervised learners): clfs 
 23  :group Feature Selections: featsel 
 24  :group Mappers (usually unsupervised learners): mappers 
 25  :group Measures: measures 
 26  :group Miscellaneous: base misc support 
 27  :group Unittests: tests 
 28   
 29  :author: `Michael Hanke <michael.hanke@gmail.com>`__, 
 30           `Yaroslav Halchenko <debian@onerussian.com>`__, 
 31           `Per B. Sederberg <persed@princeton.edu>`__ 
 32  :requires: Python 2.4+ 
 33  :version: 0.4.8 
 34  :see: `The PyMVPA webpage <http://www.pymvpa.org>`__ 
 35  :see: `GIT Repository Browser <http://git.debian.org/?p=pkg-exppsy/pymvpa.git;a=summary>`__ 
 36   
 37  :license: The MIT License <http://www.opensource.org/licenses/mit-license.php> 
 38  :copyright: |copy| 2006-2010 Michael Hanke <michael.hanke@gmail.com> 
 39  :copyright: |copy| 2007-2010 Yaroslav O. Halchenko <debian@onerussian.com> 
 40   
 41  :newfield contributor: Contributor, Contributors (Alphabetical Order) 
 42  :contributor: `Emanuele Olivetti <emanuele@relativita.com>`__ 
 43  :contributor: `Per B. Sederberg <persed@princeton.edu>`__ 
 44   
 45  .. |copy| unicode:: 0xA9 .. copyright sign 
 46  """ 
 47   
 48  __docformat__ = 'restructuredtext' 
 49   
 50  # canonical PyMVPA version string 
 51  __version__ = '0.4.8' 
 52   
 53  import os 
 54  import random 
 55  import numpy as N 
 56  from mvpa.base import cfg 
 57  from mvpa.base import externals 
 58  from mvpa.base.info import wtf 
 59   
 60  # locate data root -- data might not be installed, but if it is, it should be at 
 61  # this location 
 62  pymvpa_dataroot = os.path.join(os.path.dirname(__file__), 'data') 
 63   
 64  if not __debug__: 
 65      try: 
 66          import psyco 
 67          psyco.profile() 
 68      except ImportError: 
 69          from mvpa.base import verbose 
 70          verbose(2, "Psyco online compilation is not enabled") 
 71  else: 
 72      # Controllable seeding of random number generator 
 73      from mvpa.base import debug 
 74   
 75      debug('INIT', 'mvpa') 
 76   
 77  if cfg.has_option('general', 'seed'): 
 78      _random_seed = cfg.getint('general', 'seed') 
 79  else: 
 80      _random_seed = int(N.random.uniform()*(2**31-1)) 
 81   
82 -def seed(random_seed):
83 """Uniform and combined seeding of all relevant random number 84 generators. 85 """ 86 N.random.seed(random_seed) 87 random.seed(random_seed)
88 89 seed(_random_seed) 90 91 # import the main unittest interface 92 from mvpa.tests import run as test 93 94 # PyMVPA is useless without numpy 95 # Also, this check enforcing population of externals.versions 96 # for possible later version checks, hence don't remove 97 externals.exists('numpy', force=True, raiseException=True) 98 # We might need to suppress the warnings so enforcing check here, 99 # it is ok if it would fail 100 externals.exists('scipy', force=True, raiseException=False) 101 102 if __debug__: 103 debug('RANDOM', 'Seeding RNG with %d' % _random_seed) 104 debug('INIT', 'mvpa end') 105 106 # Attach custom top-level exception handler 107 if cfg.getboolean('debug', 'wtf', default=False): 108 import sys 109 _sys_excepthook = sys.excepthook
110 - def _pymvpa_excepthook(*args):
111 """Custom exception handler to report also pymvpa's wtf 112 113 Calls original handler, and then collects WTF and spits it out 114 """ 115 ret = _sys_excepthook(*args) 116 sys.stdout.write("PyMVPA's WTF: collecting information... hold on...") 117 sys.stdout.flush() 118 wtfs = wtf() 119 sys.stdout.write("\rPyMVPA's WTF: \n") 120 sys.stdout.write(str(wtfs)) 121 return ret
122 sys.excepthook = _pymvpa_excepthook 123