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 from mdp.nodes import FastICANode, CuBICANode
19
20
22 """Mapper to project data onto ICA components estimated from some dataset.
23
24 After the mapper has been instantiated, it has to be train first. The ICA
25 mapper only handles 2D data matrices.
26 """
27 - def __init__(self, algorithm='cubica', transpose=False, **kwargs):
32
33 __doc__ = enhancedDocString('ICAMapper', locals(), ProjectionMapper)
34
35
37 """Determine the projection matrix onto the components from
38 a 2D samples x feature data matrix.
39 """
40 white_param = {}
41
42
43
44 if dataset.samples.shape[1] > dataset.samples.shape[0] \
45 and not self._transpose:
46 white_param['svd'] = True
47
48 if self._algorithm == 'fastica':
49 node = FastICANode(white_parm=white_param,
50 dtype=dataset.samples.dtype)
51 elif self._algorithm == 'cubica':
52 node = CuBICANode(white_parm=white_param,
53 dtype=dataset.samples.dtype)
54 else:
55 raise NotImplementedError
56
57
58
59
60
61 node.train(dataset.samples)
62 self._proj = N.asmatrix(node.get_projmatrix())
63 self._recon = N.asmatrix(node.get_recmatrix())
64