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

WIP: ICA clean raw data #296

Closed
wants to merge 11 commits into from

Conversation

MerlinDumeur
Copy link
Contributor

This code works for one dataset, on one subject.
I will do the tests soon when I get the time.

I open this PR for feedback.
Some ironing out will need to be done, this is very much still a work in progress.

@agramfort
Copy link
Member

I would suggest to remove all auto reject related code here and to focus on the rest. We can add auto reject in a next PR

@MerlinDumeur
Copy link
Contributor Author

MerlinDumeur commented Apr 16, 2021

If this is because the checks fail, I think it would be an easy fix, but it's probably best to keep autoreject separate for now.
It work fine for me though, so it shouldn't be too hard to add later.

selection = epochs.selection

# Not sure why it is necessary to recreate epochs when we already have them
if config.no_epoching:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The base code recreates an epoch object, but I don't understand why. Here I just reuse the epochs created last step, not sure if that's okay

Copy link
Member

Choose a reason for hiding this comment

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

but I don't understand why.

Because we filter the raw data again with a high-pass filter suitable for ICA. We then create new epochs from the newly-filtered data. You'd have to do the same for the "no epoching" case

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 completely missed that, thanks

Comment on lines 98 to 99
msg = f'Rejecting ICs: {ica.exclude}'
logger.info(gen_log_message(message=msg, step=5, subject=subject,
Copy link
Member

Choose a reason for hiding this comment

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

This should be logged for both cases, i.e. should be outside the if block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep that's what I intended to do, will fix

@@ -184,7 +184,9 @@ def process(config: PathLike,
script_paths = [*SCRIPT_PATHS['init'], *script_paths]

for script_path in script_paths:
step_name = script_path.name.replace('.py', '')[3:]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed because it did not work with file names such as recon_all.py or 04a-run_ica.py

@MerlinDumeur
Copy link
Contributor Author

I looked at how mne handles the computation of the source PSD for raw data (mne.minimum_norm.compute_source_psd), and it appears that it just creates an Epoch instance with only 1 epoch which is the length of the raw recording, and calls the mne.minimum_norm.compute_source_psd_epochs function.

We could maybe take inspiration from this? I could adapt the PR

@agramfort
Copy link
Member

agramfort commented Apr 20, 2021

as soon as you have an epoch you're blocked to ignore/remove transient artifacts

@MerlinDumeur
Copy link
Contributor Author

yes that's true but that will be always be a problem anyway. If I can't epoch my data because I need long recordings, then there's not much I can about it either way, unless I missed something.

It would be nice to have mne functions on raw data that ignore transient artifacts based on annotations, but I don't think that's available yet? For instance if I want the compute the PSD on raw data, it does not take into account BAD annotations

@agramfort
Copy link
Member

agramfort commented Apr 20, 2021 via email

@larsoner
Copy link
Member

larsoner commented Feb 6, 2024

As of #840 ICA (and SSP) are now also applied to raw data and saved to disk as proc-clean

@larsoner larsoner closed this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants