Comments (14)
Exactly, in this case to do so, one channel had to be renamed to match the name in the montage.
from mne-icalabel.
Can you use the version on main
?
Also, the exemplar = np.mean(data_[similar_pts], axis=0)
line is nowhere in mne-icalabel I think? Is there a missing error message?
from mne-icalabel.
Indeed a couple of missing error message, can you share the full traceback? Found the lines here
mne-icalabel/mne_icalabel/iclabel/utils.py
Line 245 in 1c0418b
Also, could you save the ICA decomposition with ica.save
and share the ICA decomposition and the Raw file (you can save it with raw_filt.save
)?
from mne-icalabel.
Arf, the traceback is incomplete because it's a Jupyter notebook, sneaky ...
on the left side..
from mne-icalabel.
Thanks for your reply!
Below is the complete traceback
from mne-icalabel.
Can you use the version on
main
?
Sorry, I don't know what main
means... = =
from mne-icalabel.
Also, could you save the ICA decomposition with
ica.save
and share the ICA decomposition and the Raw file (you can save it withraw_filt.save
)?
I'm not sure if I can upload raw files, because these are from confidential patient data.
from mne-icalabel.
main
means the not-yet-released code, i.e. the version available as of today on the GitHub repository. You can install it in an environment by doing pip install git+https://github.com/mne-tools/mne-icalabel
. This is to eliminate the possibility of a bug that has already been fixed but has not yet been released.
I'm not sure if I can upload raw files, because these are from confidential patient data.
Unlucky, as it's difficult to debug if we can not reproduce the error.
Pinging @yjmantilla who authored the gdatav4
translation, by any chance does this error look familiar to you?
If you don't mind, I would like to give you a couple of short code snippets that I'd like you to run and return the output here to help us debug the issue further without providing us with the RAW/ICA files. Would that be OK with you?
Do you only use Jupyter or also other IDEs, and especially do you know how to use breakpoints and debug mode?
from mne-icalabel.
main
means the not-yet-released code, i.e. the version available as of today on the GitHub repository. You can install it in an environment by doingpip install git+https://github.com/mne-tools/mne-icalabel
. This is to eliminate the possibility of a bug that has already been fixed but has not yet been released.
The development version has been installed, and the same bug appeared.
If you don't mind, I would like to give you a couple of short code snippets that I'd like you to run and return the output here to help us debug the issue further without providing us with the RAW/ICA files. Would that be OK with you? Do you only use Jupyter or also other IDEs, and especially do you know how to use breakpoints and debug mode?
OK, I can debug locally through your code.
Is it possible to debug using .py files through vscode?
from mne-icalabel.
Thanks for the help, yes you could debug using VSCode, but if you are not familiar with breakpoints and debug mode, there is no gain compare to Jupyter.
In the following part, raw
designs the Raw recording used to fit the ICA and ica
the ICA decomposition. Here are the code snippet:
First let's get some information on your Raw
recording, especially about the channels:
- MNE information
Paste in this thread the printed information:
from mne import sys_info
print (mne.sys_info())
raw.info
Paste in this thread the printed information:
# remove identification information if present
raw.info["description"] = ""
raw.info["device_info"] = dict()
raw.info["experimenter"] = ""
raw.info["subject_info"] = dict()
raw.info["temp"] = None
# display information
print (raw.info)
- Montage
Paste in this thread the figure returned by:
raw.get_montage().plot()
icawinv
Return the file icawinv.npy
:
import numpy as np
# Compute icawinv
n_components = ica.n_components_
s = np.sqrt(ica.pca_explained_variance_)[:n_components]
u = ica.unmixing_matrix_ / s
v = ica.pca_components_[:n_components, :]
weights = (u * s) @ v
icawinv = np.linalg.pinv(weights)
del weights
# sanity-check
assert icawinv.shape[-1] == ica.n_components_
assert icawinv.ndim == 2
np.save("icawinv.npy", icawinv, allow_pickle=False)
picks
of the topoplot feature
Paste in this thread the printed information:
print (ica.ch_names)
- EEG channels coordinates in spherical coordinate system
Return the file rd.npy
and th.npy
:
import numpy as np
from mne_icalabel.iclabel.utils import _mne_to_eeglab_locs
rd, th = _mne_to_eeglab_locs(raw, ica.ch_names)
np.save("rd.npy", rd, allow_pickle=False)
np.save("th.npy", th, allow_pickle=False)
That should be enough for debug and for me to reproduce the error locally.
from mne-icalabel.
Thanks for the help, yes you could debug using VSCode, but if you are not familiar with breakpoints and debug mode, there is no gain compare to Jupyter.
Sorry for not getting back to you for such a long time.
After changing a batch of data, the issue did not occur again. Therefore, it should have been a problem with that particular batch of data.
Thank you very much for your patient guidance !
from mne-icalabel.
I'm getting this error. Test file is attached, and the test script is here:
import mne, mne_icalabel
if __name__ == "__main__":
fn = './test_raw.fif'
raw = mne.io.read_raw_fif(fn, preload=True)
standard = mne.channels.make_standard_montage(kind = 'biosemi64')
raw.set_montage(standard, on_missing='ignore')
raw.set_eeg_reference(['LMA', 'RMA'])
raw.filter(l_freq=1, h_freq=100, picks=None)
ica = mne.preprocessing.ICA(n_components=0.999999, method='infomax', fit_params=dict(extended=True), max_iter='auto', random_state=1)
ica.fit(raw, picks=['eeg'])
ic_labels = mne_icalabel.label_components(raw, ica, method='iclabel')
labels = ic_labels["labels"]
exclude_idx = [idx for idx, label in enumerate(labels) if label not in ["brain", "other"]]
ica.exclude = exclude_idx
from mne-icalabel.
Thanks for the reproducible example, it makes debugging way simpler. The error occurs because of a nan
in the x
and y
variables here:
mne-icalabel/mne_icalabel/iclabel/_utils.py
Lines 210 to 211 in a7b4c84
This is due to raw.set_montage(standard, on_missing='ignore')
, which ignored missing entries. But we actually need a montage with ALL electrodes coordinates to compute the topographic map feature. We could ignore missing channels in the interpolation function, further down the road, but I think we should also issue a warning further up the road. Here is a corrected code snippet for your file:
from mne.io import read_raw_fif
from mne.preprocessing import ICA
from mne_icalabel import label_components
fname = r"C:\Users\scheltie\Downloads\test_raw.fif"
raw = read_raw_fif(fname, preload=True)
raw.rename_channels({"Afz": "AFz"})
raw.set_montage("biosemi64")
raw.set_eeg_reference(["LMA", "RMA"])
raw.filter(l_freq=1, h_freq=100, picks=None)
raw.drop_channels(["LMA", "RMA"])
ica = ICA(
n_components=0.999999,
method="infomax",
fit_params=dict(extended=True),
max_iter="auto",
random_state=1,
)
ica.fit(raw, picks=["eeg"])
ic_labels = label_components(raw, ica, method="iclabel")
I'll think about it and open a PR to close this issue.
from mne-icalabel.
Okay great, thanks! So in general, I should try to set the montage without ignoring anything?
It looks like you drop the mastoids before ICA. Any particular reason? I tried it with and without that and it works either way.
from mne-icalabel.
Related Issues (20)
- [GUI] Missing or non-expandable ICA properties HOT 1
- [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
- 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
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.