Skip to content

Commit

Permalink
now
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtfa committed Dec 3, 2024
1 parent 133fddf commit 850c9b6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
6 changes: 4 additions & 2 deletions almkanal/almkanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def do_ica(
)

if self.info.ica is None:
self.info.ica = ica_info
self.info.ica = [ica_info]

self.raw, ica, ica_ids = run_ica(self.raw, **ica_info)
self.ica = [ica]
Expand All @@ -109,10 +109,12 @@ def do_ica(
# Take care of case where you ran multiple icas.
# TODO: When we end up applying them to the noise cov dont forget
# to also do it successively.
self.info.ica.update(ica_info)
self.info.ica.append(ica_info)

self.raw, ica, ica_ids = run_ica(self.raw, **ica_info)
assert isinstance(self.ica, list)
self.ica.append(ica)
assert isinstance(self.ica_ids, list)
self.ica_ids.append(ica_ids)

def do_events(
Expand Down
2 changes: 1 addition & 1 deletion almkanal/data_utils/data_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ class InfoClass:
raw: bool = False
epoched: bool = False
maxwell: dict | None = None
ica: ICAInfoDict | None = None
ica: list[ICAInfoDict] | None = None
trf_epochs: dict | None = None
5 changes: 4 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
ICA_NCOMPS = [10, 20]

#Maxwell options
MW_DESTINATION = [None, (0, 0, .4)]
MW_DESTINATION = [None, (0, 0, .4)]

#Source options
SOURCE = ['surface', 'volume']
49 changes: 25 additions & 24 deletions tests/test_raw.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from almkanal.almkanal import AlmKanal
import pytest
from .settings import CH_PICKS, ICA_TRAIN, ICA_EOG, ICA_ECG, ICA_THRESH, ICA_RESAMPLE, ICA_NCOMPS
from .settings import CH_PICKS, ICA_TRAIN, ICA_EOG, ICA_ECG, ICA_THRESH, ICA_RESAMPLE, ICA_NCOMPS, SOURCE
import mne

def test_maxwell(gen_mne_data_raw):
Expand All @@ -9,42 +9,42 @@ def test_maxwell(gen_mne_data_raw):
ak.do_maxwell()


@pytest.mark.parametrize('resample_freq', ICA_RESAMPLE, scope='session')
#@pytest.mark.parametrize('resample_freq', ICA_RESAMPLE, scope='session')
@pytest.mark.parametrize('ecg', ICA_ECG, scope='session')
@pytest.mark.parametrize('eog', ICA_EOG, scope='session')
@pytest.mark.parametrize('threshold', ICA_THRESH, scope='session')
#@pytest.mark.parametrize('threshold', ICA_THRESH, scope='session')
@pytest.mark.parametrize('train', ICA_TRAIN, scope='session')
#@pytest.mark.parametrize('n_components', ICA_NCOMPS, scope='session')
def test_ica(gen_mne_data_raw, train, eog, ecg, resample_freq, threshold):
def test_ica(gen_mne_data_raw, train, eog, ecg):

ak = AlmKanal(raw=gen_mne_data_raw)
ak.do_ica(n_components=10,
train=train,
eog=eog,
ecg=ecg,
resample_freq=resample_freq,
threshold=threshold
resample_freq=200,
threshold=0.4
)


# def test_double_ica(gen_mne_data_raw):
def test_double_ica(gen_mne_data_raw):

# ak = AlmKanal(raw=gen_mne_data_raw)
# ak.do_ica(n_components=10,
# train=False,
# eog=True,
# ecg=False,
# resample_freq=100,
# threshold=0.4
# )
ak = AlmKanal(raw=gen_mne_data_raw)
ak.do_ica(n_components=10,
train=False,
eog=True,
ecg=False,
resample_freq=100,
threshold=0.4
)

# ak.do_ica(n_components=10,
# train=False,
# eog=True,
# ecg=False,
# resample_freq=100,
# threshold=0.4
# )
ak.do_ica(n_components=10,
train=False,
eog=True,
ecg=False,
resample_freq=100,
threshold=0.4
)


def test_ica_plot(gen_mne_data_raw):
Expand Down Expand Up @@ -75,15 +75,16 @@ def test_epoching(gen_mne_data_raw):

ak.do_epochs(tmin=-0.2, tmax=0.5, event_id=event_dict)


def test_fwd(gen_mne_data_raw):
@pytest.mark.parametrize('source', SOURCE, scope='session')
def test_fwd(gen_mne_data_raw, source):
ak = AlmKanal(raw=gen_mne_data_raw)
ak.do_fwd_model(subject_id='sample',
subjects_dir='./')

ak.pick_dict['meg'] = 'mag'
ak.do_src(subject_id = 'sample',
subjects_dir = './',
source=source,
return_parc=True,)


Expand Down

0 comments on commit 850c9b6

Please sign in to comment.