1
2
3
4
5
6
7
8
9 """Data mapper"""
10
11 __docformat__ = 'restructuredtext'
12
13 import numpy as N
14
15 from mvpa.base.dochelpers import enhancedDocString
16 from mvpa.mappers.base import ProjectionMapper
17
18 import mvpa.base.externals as externals
19 if externals.exists('mdp', raiseException=True):
20 from mdp.nodes import FastICANode, CuBICANode
21
22
24 """Mapper to project data onto ICA components estimated from some dataset.
25
26 After the mapper has been instantiated, it has to be train first. The ICA
27 mapper only handles 2D data matrices.
28 """
29 - def __init__(self, algorithm='cubica', transpose=False, **kwargs):
34
35 __doc__ = enhancedDocString('ICAMapper', locals(), ProjectionMapper)
36
37
39 """Determine the projection matrix onto the components from
40 a 2D samples x feature data matrix.
41 """
42 white_param = {}
43
44
45
46 if dataset.samples.shape[1] > dataset.samples.shape[0] \
47 and not self._transpose:
48 white_param['svd'] = True
49
50 if self._algorithm == 'fastica':
51 node = FastICANode(white_parm=white_param,
52 dtype=dataset.samples.dtype)
53 elif self._algorithm == 'cubica':
54 node = CuBICANode(white_parm=white_param,
55 dtype=dataset.samples.dtype)
56 else:
57 raise NotImplementedError
58
59
60
61
62
63 node.train(dataset.samples)
64 self._proj = N.asmatrix(node.get_projmatrix())
65 self._recon = N.asmatrix(node.get_recmatrix())
66