Comments (9)
Thank you! I managed to reproduce it with this sample, changing the duration of epochs to 4 seconds:
from mne import make_fixed_length_epochs
from mne.datasets import sample
from mne.io import read_raw
from mne.preprocessing import ICA
from mne_icalabel import label_components
# load raw instance
directory = sample.data_path() / "MEG" / "sample"
fname = "sample_audvis_filt-0-40_raw.fif"
raw = read_raw(directory / fname, preload=False)
raw.pick_types(eeg=True)
raw.crop(tmin=0, tmax=20)
raw.load_data()
# create epochs
epochs = make_fixed_length_epochs(raw, duration=4., preload=True)
# fit an ICA on epochs
ica = ICA(n_components=5, method="picard")
ica.fit(epochs)
# run ICLabel
label_components(epochs, ica, method="iclabel")
I'll have a look.
from mne-icalabel.
Thats amazing! Thanks so much, my automated workflow is working super well now.
Hopefully i can use this to get some classification results on my super noisy data
from mne-icalabel.
Hello, thank you for reporting the issue! but I can not reproduce based on your description..
from mne import make_fixed_length_epochs
from mne.datasets import sample
from mne.io import read_raw
from mne.preprocessing import ICA
from mne_icalabel import label_components
# load raw instance
directory = sample.data_path() / "MEG" / "sample"
fname = "sample_audvis_filt-0-40_raw.fif"
raw = read_raw(directory / fname, preload=False)
raw.pick_types(eeg=True)
raw.crop(tmin=0, tmax=20)
raw.load_data()
# create epochs
epochs = make_fixed_length_epochs(raw, duration=1., preload=True)
# fit an ICA on epochs
ica = ICA(n_components=5, method="picard")
ica.fit(epochs)
# run ICLabel
label_components(epochs, ica, method="iclabel")
Outputs:
>>> {'y_pred_proba': array([0.96021754, 0.4062748 , 0.92534626, 0.95375717, 0.5524776 ],
dtype=float32),
'labels': ['eye blink', 'other', 'brain', 'brain', 'other']}
Could you try to reproduce the issue by using a dataset from the MNE sample dataset as I did above, or could you share a minimally reproducible example with the attached files that raises the error?
from mne-icalabel.
Looks similar to the issue in #38
from mne-icalabel.
If it helps I'm having a look at the line this is caused by. The shape of my raw and epochs are
epochs.get_data().shape
(909, 122, 513)
raw.get_data().shape
(122, 584600)
The index variable calculated in _eeg_rpsd_constants
for raw and epochs is
# raw
(128, 9133)
# epochs
(128, 7)
from mne-icalabel.
It's difficult to debug if I can not reproduce the error. Could you share some script and files to reproduce it?
For the shapes, with the example from the MNE sample dataset, I have:
epochs.get_data().shape
>>> (20, 59, 150)
raw.get_data().shape
>>> (59, 3004)
Which looks similar to you, assuming you do have 122 EEG channels and 909 epochs.
And for the index variables in _eeg_rpsd_constants
, breaking on line 274 (executing it):
mne-icalabel/mne_icalabel/iclabel/features.py
Line 274 in ecc6a91
# with inst as Epochs
>>> (150, 1)
# with inst as Raw
>>> (150, 39)
It's difficult to say if it's normal or not as it depends on the number of samples in your data and on the sampling frequency.
What happens if you try to re-fit a fresh ICA instance on the epochs?
from mne.preprocessing import ICA
from mne_icalabel import label_components
ica = ICA(n_components=5, method="picard") # just to speed-up
ica.fit(epochs)
label_components(raw, ica, method="iclabel")
from mne-icalabel.
Am I correct in assuming the sampling frequency of your data is 128 Hz?
from mne-icalabel.
Yeah, I downsampled the raw to 128Hz and then went
raw.resample(128)
raw.notch_filter(freqs=None, method='spectrum_fit', n_jobs=12)
raw.filter(7, 35, n_jobs=12)
raw.set_eeg_reference()
events, event_ids = mne.events_from_annotations(
raw, verbose = False)
epochs = mne.Epochs(
raw=raw,
events=events,
event_id=event_ids,
preload=True,
tmin=0,
tmax=4,
baseline=None,
event_repeated='merge',
)
ica = mne.preprocessing.ICA(
method='picard', fit_params=dict(extended=True, ortho=False)
)
ica.fit(epochs)
# ICA Labels
ic_labels = label_components(raw, ica, method='iclabel') # epochs object causes error
labels = ic_labels["labels"]
exclude_idx = [idx for idx, label in enumerate(labels)
if label not in ["brain"]]
print(f"Excluding these ICA components: {exclude_idx}")
# Apply ICA
ica.plot_overlay(epochs.average(), exclude=exclude_idx)
ica.apply(epochs, exclude=exclude_idx)
from mne-icalabel.
@sourestdeeds It's fixed on main and will be fixed in release >= 0.2.0
.
from mne-icalabel.
Related Issues (20)
- [DOC] Clarify the types of data to be used HOT 2
- [JOSS] Nitpicks on the paper HOT 1
- No module named 'numpy.typing' HOT 2
- mne_icalabel ImportError HOT 4
- Example render for 0.4 stable website HOT 4
- Possibly want to freeze GH actions at Ubuntu 20.04? HOT 1
- ValueError: need at least one array to concatenate HOT 6
- ONNX/Tensorflow Port HOT 3
- "arrays used as indices must be of integer (or boolean) type" HOT 14
- Set black to max_chars=88 per line
- ICLabel doesn't work with combined MEG/EEG data
- Evaluate and support MEGNet HOT 2
- Guidelines to contribute a new model HOT 4
- Dropdown version selector is broken HOT 1
- Use of IClabel with MEG data. HOT 2
- DOC: tables in dark mode are unreadable HOT 1
- Outdated docs for label_components() HOT 1
- Re-build stable documentation HOT 2
- mne_icalabel ImportError HOT 1
- FutureWarning in latest pytorch release
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mne-icalabel.