Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spatio_temporal_src_connectivity failure #185

Closed
larsoner opened this issue Nov 13, 2012 · 16 comments
Closed

spatio_temporal_src_connectivity failure #185

larsoner opened this issue Nov 13, 2012 · 16 comments

Comments

@larsoner
Copy link
Member

It looks like spatio_temporal_src_connectivity (which calls spatio_temporal_tris_connectivity) doesn't handle some source spaces correctly.

import mne
data_path = mne.datasets.sample.data_path('..')
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
inverse_operator = mne.minimum_norm.read_inverse_operator(fname_inv)
connectivity = mne.spatio_temporal_src_connectivity(inverse_operator['src'], 
                                                    n_times=1)
a = connectivity.shape[0] 
b = sum([s['nuse'] for s in inverse_operator['src']])
assert a == b

a is 8196 while b is 7498, so this fails. I assume this is because it either isn't designed to handle oct source spaces (?), in which case should we have it throw an error? Or is there some way to make it work with oct source spaces?

@larsoner
Copy link
Member Author

Yeah, it looks like it's only designed to work with Ico source spaces, not Oct -- is there some way to make it work with Oct, though? (I'm not too familiar with this...)

@larsoner
Copy link
Member Author

Okay, I take it back, it seems to work okay. If I add patch info and use:

connectivity = mne.spatio_temporal_src_connectivity(src, n_times=1, dist=5e-3)

I get a connectivity matrix of the same size (8196 x 8196). So the inverse operator is selecting a subset of vertices to use...?

@larsoner
Copy link
Member Author

In any case, we should figure out how to deal with the mismatch between the source estimates that are generated, and the size of these connectivity matrices.

@agramfort
Copy link
Member

can it be because some sources are too close to the inner skull and excluded from the source space?

@agramfort
Copy link
Member

the --mintdist param in the mne_do_forward_solution

@mluessi
Copy link
Contributor

mluessi commented Nov 13, 2012

+1 this would make most sense

@larsoner
Copy link
Member Author

Probably. I'm not sure if there is an easy way to detect this just from the source space instance, though, so I'm not sure how we'd throw an error...

@agramfort
Copy link
Member

can you give the lines of code that would fail as a test?

@larsoner
Copy link
Member Author

Sure thing:

import mne
data_path = mne.datasets.sample.data_path('..')
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'
inverse_operator = mne.minimum_norm.read_inverse_operator(fname_inv)
connectivity = mne.spatio_temporal_src_connectivity(inverse_operator['src'], 
                                                    n_times=1)
a = connectivity.shape[0] 
b = sum([s['nuse'] for s in inverse_operator['src']])
assert a == b

@larsoner
Copy link
Member Author

Basically, a user could assume that the STC they get from using that inverse_operator could be used in spatio-temporal clustering, and it can't very easily since the inverse_operator does not use the whole source space.

@larsoner
Copy link
Member Author

One solution would be to morph the STC from the subject to itself, going from the subset of vertices used by inverse_operator to the full set of source space vertices, but this seems less appealing than somehow being able to generate a connectivity matrix that is compatible with the inverse_operator in the first place.

@agramfort
Copy link
Member

Basically, a user could assume that the STC they get from using that inverse_operator could be used in spatio-temporal clustering, and it can't very easily since the inverse_operator does not use the whole source space.

why should the spatio temporal clustering break if sources are ignored
by the inverse operator?
I agree that it can produce artifacts like a clustering not going over
the top of the gyrus but is
that a really issue? just asking.

@larsoner
Copy link
Member Author

The clustering breaks because the STC files generated by that inverse_operator will not have the same number of vertices as the connectivity matrix. They will have b vertices, while the connectivity matrix will have a vertices.

@agramfort
Copy link
Member

The clustering breaks because the STC files generated by that inverse_operator will not have the same number of vertices as the connectivity matrix. They will have b vertices, while the connectivity matrix will have a vertices.

how about restricting the connectivity to the used vertices that you
find in the source space structure?

iuse key if I remember.

@larsoner
Copy link
Member Author

That could work. I can give it a shot and see how it goes.

dengemann added a commit to dengemann/mne-python that referenced this issue Nov 13, 2012
This is the first draft in which I tried to find a remedy for the API issues described in mne-tools#185 which ensue from integrating PCA and ICA.
To keep things as consistent a possible and only minmally change the API I choose class method approach for initializing from raw or epochs; it basically merges the init and the decomposition into one step. I integrated @agramfort 's max_n_components arg and at the same time the user can select the n_components via explained variance. Also note that with this approach we may fully control the PCA, e.g. jsut drop components for ICA but keep them for the final unmixing.
This isn't fully wokring yet but the API and the examples clearly expose the idea behind it. @agramfort @mluessi @Eric89GXL -- I would be happy to get some general feedback before putting further effort in cleaning up / testing.
@larsoner
Copy link
Member Author

Alright @agramfort, I think this fixes the issue, and I added a test. I have it raise a warning to the user so they know it's being subsampled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants