[DRAFT] Redesign/datasets ICA addition#56
Merged
Conversation
…oper caching usage. ica still not leveraging caching correctly
Collaborator
|
Move this to the other PR. |
Drew-Wagner
requested changes
Mar 18, 2025
Collaborator
Drew-Wagner
left a comment
There was a problem hiding this comment.
Thanks for this Victor! Here are my recommendations
Comment on lines
+86
to
+102
| def process( | ||
| self, raw: mne.io.RawArray, raw_path: Union[str, Path] | ||
| ) -> mne.io.RawArray: | ||
| """Process raw data with ICA, computing or loading from cache.""" | ||
|
|
||
| ica_path = self.get_ica_path(raw_path) | ||
|
|
||
| if not ica_path.exists(): | ||
| ica = self.compute_ica(raw, ica_path) | ||
| else: | ||
| ica = mne.preprocessing.read_ica(ica_path, verbose="ERROR") | ||
|
|
||
| # Create a copy of the raw data before applying ICA | ||
| raw_ica = raw.copy() | ||
| ica.apply(raw_ica) | ||
|
|
||
| return raw_ica |
Collaborator
There was a problem hiding this comment.
Suggested change
| def process( | |
| self, raw: mne.io.RawArray, raw_path: Union[str, Path] | |
| ) -> mne.io.RawArray: | |
| """Process raw data with ICA, computing or loading from cache.""" | |
| ica_path = self.get_ica_path(raw_path) | |
| if not ica_path.exists(): | |
| ica = self.compute_ica(raw, ica_path) | |
| else: | |
| ica = mne.preprocessing.read_ica(ica_path, verbose="ERROR") | |
| # Create a copy of the raw data before applying ICA | |
| raw_ica = raw.copy() | |
| ica.apply(raw_ica) | |
| return raw_ica | |
| @property | |
| def dynamic_item(self): | |
| @takes("raw", "fpath") | |
| @provides("raw", "ica_path") | |
| def process( | |
| raw: mne.io.RawArray, fpath: Union[str, Path] | |
| ): | |
| """Process raw data with ICA, computing or loading from cache.""" | |
| ica_path = self.get_ica_path(fpath) | |
| if not ica_path.exists(): | |
| ica = self.compute_ica(raw, ica_path) | |
| else: | |
| ica = mne.preprocessing.read_ica(ica_path, verbose="ERROR") | |
| # Create a copy of the raw data before applying ICA | |
| raw_ica = raw.copy() | |
| ica.apply(raw_ica) | |
| yield raw_ica | |
| yield ica_path | |
| return process |
Collaborator
There was a problem hiding this comment.
function inside one function is not super nice
Collaborator
There was a problem hiding this comment.
I think it is necessary though for it to work with the @takes and @provides decorators.
Co-authored-by: Drew Wagner <33100250+Drew-Wagner@users.noreply.github.com>
Comment on lines
+100
to
+107
| bids_path.root = bids_path.root / ".." / "derivatives" / folder_name | ||
| # Keep the same base entities: | ||
| bids_path.update( | ||
| suffix="eeg", # override or confirm suffix | ||
| extension=".fif", | ||
| description=desc, # <-- This sets a desc=ica entity | ||
| check=True, # If you do not want BIDSPath to fail on derivative checks | ||
| ) |
Collaborator
There was a problem hiding this comment.
Suggested change
| bids_path.root = bids_path.root / ".." / "derivatives" / folder_name | |
| # Keep the same base entities: | |
| bids_path.update( | |
| suffix="eeg", # override or confirm suffix | |
| extension=".fif", | |
| description=desc, # <-- This sets a desc=ica entity | |
| check=True, # If you do not want BIDSPath to fail on derivative checks | |
| ) | |
| ica_path = bids_path.update( | |
| processing="ica", suffix="ica" | |
| ) |
description update Co-authored-by: Bru <b.aristimunha@gmail.com>
description update 2 Co-authored-by: Bru <b.aristimunha@gmail.com>
Co-authored-by: Bru <b.aristimunha@gmail.com>
Collaborator
|
The base branch should be |
Drew-Wagner
reviewed
Mar 27, 2025
Drew-Wagner
reviewed
Mar 27, 2025
…ity of hashing inclusion.
Collaborator
|
Thank you @vmcru!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added ica as dynamic item to preprocessing pipeline. uses BIDSPath and exposes method and other features. still has issues with the use of caching.