clean_flatlines fails with AttributeError on a dataset loaded with an empty etc
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
Direzione di ricerca
Inizia da update_clean_channel_mask in eegprep/plugins/clean_rawdata/private/channel_removal.py, dove il traceback raggiunge etc.get, e segui come pop_loadset rappresenta un etc vuoto. Confrontalo con la normalizzazione suggerita nell’issue. Il lavoro è terminato quando clean_flatlines gestisce il dataset riprodotto quando rimuove un canale piatto; riesegui la riproduzione fornita per verificarlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
clean_flatlines raises AttributeError when it removes a channel from a dataset that pop_loadset returned with an empty etc, so a plain save and load of a dataset whose etc is empty breaks it.
Reproduction
eegprep 0.5.0, Python 3.12:
import numpy as np
from eegprep import clean_flatlines, eeg_checkset, eeg_emptyset, pop_loadset, pop_saveset
eeg = eeg_emptyset() # eeg["etc"] is {}
data = np.random.default_rng(0).standard_normal((4, 2500)).astype("float32")
data[3, 100:] = 0 # channel 4 is flat
eeg.update(data=data, nbchan=4, pnts=2500, trials=1, srate=250.0, xmin=0.0, xmax=9.996, chanlocs=[{"labels": f"C{i}"} for i in range(4)])
pop_saveset(eeg_checkset(eeg), "t.set")
loaded = pop_loadset("t.set")
print(type(loaded["etc"]), loaded["etc"].shape) # <class 'numpy.ndarray'> (0, 0)
clean_flatlines(loaded) # AttributeError: 'numpy.ndarray' object has no attribute 'get'
Traceback ends in eegprep/plugins/clean_rawdata/private/channel_removal.py, update_clean_channel_mask, at mask = etc.get("clean_channel_mask").
Cause
pop_saveset writes an empty etc as an empty matrix, and pop_loadset reads it back as a numpy.ndarray of shape (0, 0). update_clean_channel_mask then does etc = EEG.setdefault("etc", {}), which returns the existing array because the key is present, and calls .get on it. The call is reached only when a channel is actually removed, so a dataset without flat channels passes. Setting loaded["etc"] = {} before the call avoids the error.
Suggested fix
Treat an etc that is not a dict as empty where etc is used as a dict (for example if not isinstance(etc, dict): etc = {}; EEG["etc"] = etc in update_clean_channel_mask), or normalise an empty etc to {} in pop_loadset.
- Lingua principale
- Python
- Stelle
- 38
- Fork
- 7
- Merge medio
- 22h 11m
- PR unite (30g)
- 65
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sccn/eegprep
-
Add a half-count tie test for 2-D _trimmed_channel_scoresForse già presa @claude l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sccn/eegprep#570 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
clean_channels: raise on degenerate channel locations instead of returning a meaningless resultAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
sccn/eegprep#539 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sccn/eegprep
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
marimo-team/marimo#11768 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
btclib-org/btclib-node#2358 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 7 giorni
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MTSWebServices/RecTools#330 ·