Package mvpa :: Package algorithms :: Module hyperalignment
[hide private]
[frames] | no frames]

Source Code for Module mvpa.algorithms.hyperalignment

  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  """Hyperalignment of functional data to the common space 
 10   
 11  References: TODO... 
 12   
 13  see SMLR code for example on how to embed the reference so in future 
 14  it gets properly referenced... 
 15  """ 
 16   
 17  __docformat__ = 'restructuredtext' 
 18   
 19  from mvpa.support.copy import deepcopy 
 20   
 21  from mvpa.base import warning 
 22  from mvpa.misc.state import StateVariable, ClassWithCollections 
 23  from mvpa.misc.param import Parameter 
 24  from mvpa.misc.transformers import GrandMean 
 25   
 26  if __debug__: 
 27      from mvpa.base import debug 
 28   
 29   
30 -class Hyperalignment(ClassWithCollections):
31 """ ... 32 33 Given a set of datasets (may be just data) provide mapping of 34 features into a common space 35 """ 36 37 # May be something we might store optionally upon user request 38 who_knows_maybe_something_to_store_optionally = \ 39 StateVariable(enabled=False, doc= """....""") 40 41 # Lets use built-in facilities to specify parameters which 42 # constructor should accept 43 alignment = Parameter(None, # might provide allowedtype later on 44 doc="""... XXX If `None` (default) an instance of 45 :class:`~mvpa.mappers.procrustean.ProcrusteanMapper` is 46 used.""") 47 48 levels = Parameter(3, allowedtype='int', min=1, 49 doc="Number of levels ....XXX ") 50 51 combiner1 = Parameter('mean', # 52 doc="XXX ") 53 54 combiner2 = Parameter('mean', # 55 doc="XXX ") 56 57
58 - def __init__(self, 59 alignment=None, 60 levels=3, 61 combiner1='mean', 62 combiner2='mean', 63 **kwargs):
64 65 ClassWithCollections.__init__(self, **kwargs) 66 67 if self.params.alignment == None: 68 self.params.alignment = ProcrusteanMapper() 69 70 raise NotImlementedError, "WiP! Use development branch of version >= 0.5.0"
71 72
73 - def __call__(self, data):
74 """Estimate mappers for each data(set) 75 76 Parameters 77 ---------- 78 data : list or tuple of dataset of data 79 XXX 80 81 Returns 82 ------- 83 A list of trained Mappers ... of length equal to len(data) 84 """ 85 params = self.params # for quicker access ;) 86 nelements = len(data) 87 88 # might prefer some other way to initialize... later 89 result = [deepcopy(params.alignment) for i in xrange(nelements)] 90 91 # Level 1 92 commonspace = data[0] 93 for m, d in zip(mappers[1:], data[1:]): 94 # XXX For now lets just call this way: 95 m.train(d, commonspace) 96 commonspace = mean(m.forward(d), commonspace)# here yarik stopped ;) 97 98 99 # Level 2 to params.levels 100 101 102 return result
103