Skip to content

Conversation

@BabaSanfour
Copy link
Member

Fixes #12310.

Updating mne.filter.MixinFilter methods to work with Source Estimated data

@BabaSanfour
Copy link
Member Author

working to fix the failed tests

@BabaSanfour
Copy link
Member Author

All tests passed.
I think the functions are decent.
For SourceEstimate.resample the function overwrite the MixinFilter.resample so I did not update the latter. However I think that SourceEstimate.resample can be integrated into MixinFilter.resample. Not sure if this would have any implication on speed but I think it would improve the code.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Looks like a good start! See some inline comments.

Any new functionality should be accompanied by unit tests, so in mne/tests/test_source_estimate.py we'll need some basic tests of the new functions that have been added for at least the SourceEstimate class.

BabaSanfour and others added 12 commits February 4, 2024 16:55
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@BabaSanfour
Copy link
Member Author

I have addressed all of the suggestions. I also added one function to test to stc.apply_function in test_source_estimate.py . For the object.apply_hilbert function, the test_evoked.py has the test function for raw, epochs and evoked objects, I wonder if the tests should be added in the same function. Also, to test object.apply_function there is pre-existing data in ../io/tests/data . Should we use for example raw data to generate sources? or is there a way to get access for stc_test_data ?

@BabaSanfour BabaSanfour requested a review from larsoner February 5, 2024 21:43
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

For the object.apply_hilbert function, the test_evoked.py has the test function for raw, epochs and evoked objects, I wonder if the tests should be added in the same function.

Sure!

Should we use for example raw data to generate sources? or is there a way to get access for stc_test_data ?

I would just use np.random.default_rng(0).normal(...) like here:

def _fake_stc(n_time=10, is_complex=False):
np.random.seed(7)
verts = [np.arange(10), np.arange(90)]
data = np.random.rand(100, n_time)
if is_complex:
data.astype(complex)
return SourceEstimate(data, verts, 0, 1e-1, "foo")

But don't use np.random.seed, that's bad practice -- use class-based methods after instantiating a default_rng instead (modern best practice for NumPy random that we haven't fully adopted yet but should at some point!).

Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
pre-commit-ci bot and others added 5 commits February 6, 2024 17:30
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
@BabaSanfour BabaSanfour requested a review from larsoner February 6, 2024 20:41
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Just three minor tweaks, marking for merge-when-green, thanks in advance @BabaSanfour !

@larsoner larsoner enabled auto-merge (squash) February 8, 2024 17:56
@larsoner larsoner merged commit 7045590 into mne-tools:main Feb 13, 2024
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
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.

apply_hilbert for source estimated data

2 participants