ContextLab / hypertools

A Python toolbox for gaining geometric insights into high-dimensional data
http://hypertools.readthedocs.io/en/latest/
MIT License
1.83k stars 160 forks source link

hyperalignment isn't working correctly #26

Closed jeremymanning closed 7 years ago

jeremymanning commented 7 years ago

As we explored today, hyperalignment in both the Python and Matlab toolboxes seems to be broken. I propose replacing our implementations with existing implementations that are already known to work. One option is to use the SRM model in the BrainIAK toolbox: https://github.com/IntelPNI/brainiak/blob/master/brainiak/funcalign/srm.py

Another option is to use the Hyperalignment implementation from the PyMVPA2 toolbox: https://github.com/PyMVPA/PyMVPA/blob/master/mvpa2/algorithms/hyperalignment.py

It seems like the SRM/BrainIAK option would be easier, since the toolbox is smaller and less complicated (and the necessary function seems to rely on just a single file, with dependencies that we already have for other parts of our toolbox).

Thoughts?

jeremymanning commented 7 years ago

Note: the matlab version is also broken (in the same way as they python version), and it should be scrapped/replaced.

andrewheusser commented 7 years ago

I agree that we should just port over a python implementation. The intel version would be nice since its compact, but could potentially be more work to get going? Another option would be to ask the Haxby lab if they have a stand alone python implementation, or just rearrange the one they have to remove dependencies on other parts of pymvpa

jeremymanning commented 7 years ago

hey @swaroopgj -- i've added you to this issue to help track it. thanks very much for your help!

swaroopgj commented 7 years ago

@andrewheusser @KirstensGitHub do you happen to have some data or code with which I can re-create your bug?

andrewheusser commented 7 years ago

@swaroopgj yes, try running the examples/hypertools_demo-align_test.py

thanks for your help!

jeremymanning commented 7 years ago

from scipy.io import loadmat as load from mvpa2.suite import * import hypertools as hyp

data = load('test_data.mat') data = [data['spiral'], data['randwalk']]

aligned1 = hyp.align(data)

ha = Hyperalignment() mappers = ha(map(lambda x: Dataset(x), data)) aligned2 = [m.forward(d) for m, d in zip(mappers, data)]

test_data.mat.zip

jeremymanning commented 7 years ago

^ we want aligned1 (our implementation) and aligned2 (mvpa2 implementation) to be the same.

(note: download and unzip test_data.mat.zip)

swaroopgj commented 7 years ago

Sent a PR to fix the issue. @jeremymanning @andrewheusser Close this issue if you think it addresses this issue adequately.

andrewheusser commented 7 years ago

LGTM! @jeremymanning - the hyperalignment code appears to be working :) @swaroopgj added an example in hypertools_demo-align_test.py if you want to check it out.

It looks like we can still optimize the alignment (e.g. multiple iterations for step 2, regularizing at various steps) but the basic algorithm seems to be working! Thanks @swaroopgj!!