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

ENH: apply_forward; compute sensor space data from source estimate #21

Merged
merged 5 commits into from
Feb 8, 2012

Conversation

mluessi
Copy link
Contributor

@mluessi mluessi commented Feb 2, 2012

This is useful, e.g., when evaluating methods or when working with surrogate data in source space.


examples_folder = op.join(op.dirname(__file__), '..', '..', 'examples')
data_path = sample.data_path(examples_folder)
fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-meg-oct-6-fwd.fif')

fname_raw = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can use the tiny raw file in fiff/tests it will be faster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

times = deepcopy(stc.times[start:stop])
ch_names = deepcopy(fwd['sol']['row_names'])

return data, times, ch_names
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I don't really like about returning not an Evoked object is that there is no convenient way to work with such data, times, ch_names. You cannot really plot it and don't have access to measurement info to find channel type and so on. Why not passing an info parameter and eventually an evoked_template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats's true, the function doesn't return information such as channel types etc. My reason for having two functions (apply_forward and apply_forward_raw) was that the first doesn't require a template. So it is easier to use if one just wants to project source space data to the sensor space without wanting to store the result or visualize the channels.

How about adding a 3rd function apply_forward_evoked, which does the same thing as apply_forward_raw but for Evoked?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had an idea during the night. Basically data, times, and ch_names are attributes of an Evoked object. The Evoked has just an extra info attribute for the measurement info. So one option is to have BaseEvoked object and an extra info param in apply_forward. If info is not None you return an Evoked and if info is None then you return a BaseEvoked object that is just a namedtuple with 3 attributes (data, times and ch_names). Makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will make things confusing to the user. As BaseEvoked wouldn't have channel and measurement info, it wouldn't be possible to plot the sensor topography etc. Users are also likely to pass BaseEvoked to functions that expect Evoked and will be confused if it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok however that would avoid having 2 different functions for simultating Evoked and plain data. What is not clear to me is what you can actually do from plain data. You would not even be able to apply an inverse operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, let's just have 2 functions, apply_forward_raw and apply_forward_evoked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, let's just have 2 functions, apply_forward_raw and apply_forward_evoked.

maybe i am neat picking but if apply_inverse is not named
apply_inverse_evoked we should have apply_forward that works with an
Evoked instance… :)

@mluessi
Copy link
Contributor Author

mluessi commented Feb 6, 2012

Ok, now apply_forward returns Evoked, so it is consistent with apply_inverse.

@agramfort
Copy link
Member

one last thing before you want to kill me ... To me having a template and include, exclude parameters is a bit redundant. I would expect the output Evoked to have the same channels and the function to raise an error if a data channel in Evoked is not present in the forward. A typical use case would be to keep only the MEG channels and I don't feel it would be very convenient with include, exclude. I'd rather do first a pick_channels_evoked and then the apply_forward. I'm just trying to avoid having too many different ways to do the same thing. If you're fed up I can do it tomorrow if you want.

@mluessi
Copy link
Contributor Author

mluessi commented Feb 7, 2012

True, it is a bit redundant. At the moment, the returned Evoked/Raw object will have all the channels that are present in fwd, as the channel info is copied from there. The problem with using pick_channels_evoked is that the corresponding function doesn't exist for Raw (and it would be difficult to implement, as the data usually stays on disk).

How about we use pick_channels_forward and pick_types_forward (I can add this function)?

@agramfort
Copy link
Member

ok this makes things even simple. We had the pick forward functions
and it's the channels present in the forward that are included. So we
can get rid of include / exclude params and it works with both Evoked
and Raw. The info is used if present to complement based on channels
present in forward. If a channel is not in info we raise an exception.
ok?

@mluessi
Copy link
Contributor Author

mluessi commented Feb 7, 2012

Yes, it will be nice and clean :). Regarding raising an exception, isn't all the channel info included in fwd['chs']? At the moment I copy the channel information from there, so it should work even if a channel isn't present in the info of the template. Right?

@agramfort
Copy link
Member

Yes, it will be nice and clean :).

I like that !

Regarding raising an exception, isn't all the channel info included in fwd['chs']?

it should but you never know what users do :)

At the moment I copy the channel information from there, so it should work even if a channel isn't present in the info of the template. Right?

I think it shouldn't

@mluessi
Copy link
Contributor Author

mluessi commented Feb 7, 2012

Another attempt ;-)

@agramfort
Copy link
Member

maybe you can avoid the duplicated code in the tests and then press the green button ! thanks heaps !

agramfort added a commit that referenced this pull request Feb 8, 2012
ENH: apply_forward; compute sensor space data from source estimate
@agramfort agramfort merged commit 57708a3 into mne-tools:master Feb 8, 2012
@agramfort
Copy link
Member

merged ! I'll polish the tests

@agramfort
Copy link
Member

done !

@mluessi
Copy link
Contributor Author

mluessi commented Feb 8, 2012

thanks

dengemann added a commit that referenced this pull request May 13, 2015
larsoner added a commit that referenced this pull request Sep 17, 2015
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

Successfully merging this pull request may close these issues.

2 participants