Skip to content

Commit

Permalink
created hilbert.pyx. working on doc testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rayarxti committed Feb 14, 2024
1 parent efa2f8e commit bb56b9d
Show file tree
Hide file tree
Showing 63 changed files with 72,667 additions and 68 deletions.
4 changes: 4 additions & 0 deletions C_Optimized_Functions.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Metadata-Version: 2.1
Name: C-Optimized-Functions
Version: 0.0.0
License-File: LICENSE
14 changes: 14 additions & 0 deletions C_Optimized_Functions.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
LICENSE
README.md
pyproject.toml
setup.py
C_Optimized_Functions.egg-info/PKG-INFO
C_Optimized_Functions.egg-info/SOURCES.txt
C_Optimized_Functions.egg-info/dependency_links.txt
C_Optimized_Functions.egg-info/top_level.txt
ieeg/calc/concat.c
ieeg/calc/mixup.c
ieeg/timefreq/hilbert.c
ieeg/calc/concat.c
ieeg/calc/mixup.c
ieeg/timefreq/hilbert.c
1 change: 1 addition & 0 deletions C_Optimized_Functions.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions C_Optimized_Functions.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
concat
hilbert
mixup
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions build/lib.win-amd64-cpython-311/ieeg/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from os import PathLike as PL

import mne.io
from mne.epochs import BaseEpochs
from mne.evoked import Evoked
from mne.io import base
from numba import njit
from numpy import ndarray, random

PathLike = str | PL
RunDict = dict[int, mne.io.Raw]
SubDict = dict[str, RunDict]
Doubles = tuple[float, float] | list[float, float] | ndarray[(2,), float]
Signal = base.BaseRaw | BaseEpochs | Evoked
ListNum = int | float | ndarray | list | tuple


@njit(cache=True)
def _rand_seed(seed: int = 42):
random.seed(seed)
Empty file.
105 changes: 105 additions & 0 deletions build/lib.win-amd64-cpython-311/ieeg/_tests/test_ieeg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import os

import mne
import numpy as np
import pytest
from bids import BIDSLayout
from mne.io import BaseRaw
from mne_bids import BIDSPath

from ieeg.io import raw_from_layout

bids_root = mne.datasets.epilepsy_ecog.data_path()
seeg = mne.io.read_raw(mne.datasets.misc.data_path() /
'seeg' / 'sample_seeg_ieeg.fif')
layout = BIDSLayout(bids_root)


def test_bids():
assert "pt1" in layout.get_subjects()


def test_bidspath_from_layout():
from ieeg.io import bidspath_from_layout
expected = "sub-pt1_ses-presurgery_task-ictal_ieeg.eeg"
bidspath = bidspath_from_layout(layout, subject="pt1",
extension=".eeg")
assert isinstance(bidspath, BIDSPath)
assert bidspath.basename == expected


def test_raw_from_layout():
raw = raw_from_layout(layout, subject="pt1", extension=".vhdr")
assert isinstance(raw, BaseRaw)


@pytest.mark.parametrize("n_jobs", [1, 8])
def test_line_filter(n_jobs):
from ieeg.mt_filter import line_filter
mne.set_log_file("output.log",
"%(levelname)s: %(message)s - %(asctime)s",
overwrite=True)
mne.set_log_level("DEBUG")
raw = raw_from_layout(layout, subject="pt1", preload=True,
extension=".vhdr")
filt = line_filter(raw, raw.info['sfreq'], [60])
raw_dat = raw._data
filt_dat = filt._data
assert filt_dat.shape == raw_dat.shape
params = dict(method='multitaper', tmax=20, fmin=55, fmax=65,
bandwidth=0.5, n_jobs=n_jobs)
rpsd = raw.compute_psd(**params)
fpsd = filt.compute_psd(**params)
assert np.mean(np.abs(rpsd.get_data() - fpsd.get_data())) > 1e-10


if os.path.isfile("spec.npy"):
spec_check = np.load("spec.npy")
else:
spec_check = np.load("ieeg/_tests/spec.npy")


def test_spect_1():
from ieeg.timefreq.multitaper import spectrogram
raw = raw_from_layout(layout, subject="pt1", preload=True,
extension=".vhdr")
freqs = np.arange(10, 20, 2)
spectra = spectrogram(raw, freqs, 'onset', -0.5, 0.5, 'onset', -1, -0.5,
n_jobs=-1, picks=[0, 1], decim=10, pad="0.5s")
out = spectra._data
assert np.allclose(out, spec_check)


def test_spect_2():
from ieeg.timefreq.multitaper import spectrogram
from ieeg.navigate import trial_ieeg
raw = raw_from_layout(layout, subject="pt1", preload=True,
extension=".vhdr")
freqs = np.arange(10, 20, 2)
on1 = trial_ieeg(raw, 'onset', (-1, 1))
on2 = trial_ieeg(raw, 'onset', (-1.5, 0))
spectra = spectrogram(on1, freqs, on2, n_jobs=-1, picks=[0, 1], decim=10,
pad="0.5s")
out = spectra._data
assert np.allclose(out, spec_check)


@pytest.mark.parametrize("input1, input2, expected", [
(4, np.inf, ['LAMY 7', 'RAHP 3']),
(3, 2, ['LAMY 7', 'LPHG 6', 'LBRI 3', 'RAHP 3', 'LENT 3', 'LPIT 5'])
])
def test_outlier(input1, input2, expected):
from ieeg.navigate import channel_outlier_marker
outs = channel_outlier_marker(seeg, input1, input2)
assert outs == expected


@pytest.mark.parametrize("outliers, n_out", [
(4, 89955),
(5, 25987)
])
def test_trial_outlier(outliers, n_out):
from ieeg.navigate import trial_ieeg, outliers_to_nan
trials = trial_ieeg(seeg, 'Response', (-1, 1))
outs = outliers_to_nan(trials, outliers)
assert np.isnan(outs._data).sum() == n_out
Loading

0 comments on commit bb56b9d

Please sign in to comment.