Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.8 #926

Merged
merged 76 commits into from
Apr 6, 2024
Merged

0.2.8 #926

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
fd86de2
0.2.8
DominiqueMakowski Nov 6, 2023
c13a97e
Add requests
DominiqueMakowski Nov 6, 2023
d006bf4
Update setup.py
DominiqueMakowski Nov 6, 2023
03dea78
add function head of visibility-graph detector
JonasEmrich Dec 12, 2023
c3718f6
add FastNVG implementation
JonasEmrich Dec 13, 2023
84076ce
activate detector in ecg_findpeaks()
JonasEmrich Dec 13, 2023
4c93d18
fix code formatting
JonasEmrich Dec 13, 2023
4eff069
minor
DominiqueMakowski Dec 13, 2023
d12f22f
adapt cleaning documentation
JonasEmrich Dec 14, 2023
7674b25
updated documentation and removed method by koka2022
JonasEmrich Dec 14, 2023
a3a6513
Add deprecation warning for method koka2022
JonasEmrich Dec 15, 2023
79b4888
[Hotfix] requests is not builtin anymore
DominiqueMakowski Dec 18, 2023
8b6d145
Add fig2img
DominiqueMakowski Dec 18, 2023
388b9f6
Merge branch 'master' into dev
DominiqueMakowski Dec 18, 2023
87c8c60
Update eeg_1min_200hz.pickle
DominiqueMakowski Dec 18, 2023
72e7601
Merge branch 'dev' into pr/939
DominiqueMakowski Dec 18, 2023
51b48bd
Merge pull request #939 from JonasEmrich/ecg_peaks_vgmethod
DominiqueMakowski Dec 21, 2023
11f8d59
remove tests from project
Jan 2, 2024
2c410f4
change prune to recursive-exclude tests
Jan 2, 2024
cdbefba
Merge pull request #941 from Ninebell/dev
DominiqueMakowski Jan 3, 2024
efe3269
Optimise _ecg_findpeaks_elgendi
purpl3F0x Jan 4, 2024
2a1c621
Merge pull request #943 from purpl3F0x/dev
DominiqueMakowski Jan 10, 2024
b365588
[Fix + Improvement] Faster _ecg_findpeaks_hamilton and bug-fix
purpl3F0x Jan 10, 2024
576fa90
Added minimum N in rodrigues2021 peaks detector
LucaCerina Jan 17, 2024
b25b8bb
Merge pull request #949 from LucaCerina/bugfix-function_ecg_findpeaks…
DominiqueMakowski Jan 17, 2024
7abb936
update docstring to reflect implementation of khodadad2018
danibene Jan 18, 2024
e74b5f8
update description of khodadad2018 to reflect implementation of cleaning
danibene Jan 18, 2024
ba9b3a3
Merge pull request #952 from danibene/docs/rsp_clean_khodadad2018
DominiqueMakowski Jan 19, 2024
56aba7f
Merge pull request #947 from purpl3F0x/dev
DominiqueMakowski Jan 21, 2024
c016a9b
[BUG] rr xcorr arange steps don't match
birm Feb 5, 2024
b55b383
Fix poetry config
stasinos Feb 17, 2024
d4d76a0
Make sparsEDA return a (tonic,phasic) pair
stasinos Feb 17, 2024
b5e045a
Fix wrong variable name
stasinos Feb 17, 2024
a9bae21
Add dep to cvxopt to also execute cvxEDA test
stasinos Feb 17, 2024
57184a4
Send resampled signal to sparsEDA algorithm
stasinos Feb 17, 2024
ef42a48
Fix version number
stasinos Feb 17, 2024
9bac0b6
SCR should be computed before resampling back to original sr
stasinos Feb 17, 2024
edcc563
Use new_sr instead of original sampling_rate
stasinos Feb 17, 2024
0d271d8
Comment out assigning MSE to avoid style check fail
stasinos Feb 17, 2024
1a7743b
Update ecg_hrv.ipynb
Adam-Antios Feb 29, 2024
baf4ab7
Merge pull request #967 from Adam-Antios/patch-1
danibene Mar 2, 2024
d3d2b0e
Commit style fixes
DominiqueMakowski Mar 2, 2024
092f4f0
use loc to index dataframe
danibene Mar 2, 2024
1372e75
Commit style fixes
danibene Mar 2, 2024
71cecb2
fix order of inputs to loc
danibene Mar 2, 2024
2a342f3
use .loc to index df_offsets
danibene Mar 2, 2024
0a00152
actually use .loc to index df_offsets (wow, tests are important)
danibene Mar 2, 2024
aa87bde
use .loc in utils_complexity_symbolize
danibene Mar 2, 2024
376b4cf
Update utils_complexity_symbolize.py
danibene Mar 2, 2024
e72aff1
replace "L" by "ms"
danibene Mar 2, 2024
6f0f0a2
replace with "ms" in resampling_factor
danibene Mar 2, 2024
f62627d
Merge pull request #960 from birm/patch-1
DominiqueMakowski Mar 3, 2024
0ea8a2b
Merge pull request #968 from danibene/fix/build_docs_warning
danibene Mar 3, 2024
34f3a90
refactor hamilton method
danibene Mar 10, 2024
496d5dc
add expected_ecg_findpeaks_hamilton_good_4000.csv
danibene Mar 10, 2024
7a7fd83
add expected_ecg_findpeaks_hamilton_bad_500.csv
danibene Mar 10, 2024
c794622
add regression test for ecg_findpeaks_hamilton
danibene Mar 10, 2024
8377bba
include _ecg_findpeaks_hamilton in tests_ecg_findpeaks
danibene Mar 10, 2024
2ee5a75
reformat dev version with black
danibene Mar 10, 2024
79532f5
update expected results after changes in 0.2.8
danibene Mar 11, 2024
f6c21f2
update expected bad 500 results after changes in 0.2.8
danibene Mar 11, 2024
590cda6
add flag for when missed peak is added
danibene Mar 11, 2024
6e2b150
remote extra imports
danibene Mar 11, 2024
67afccc
adding sampling rate parameter to eda_intervalrelated method
tilly111 Mar 12, 2024
3948d84
[Fix] read_acqknowledge now also imports duplicated channel names
DerAndereJohannes Mar 22, 2024
88bc754
[Feature] stim_events_find to retrieve multi-channel stimulus events
DerAndereJohannes Mar 24, 2024
2f923ce
Merge pull request #966 from stasinos/issue-964
DominiqueMakowski Mar 24, 2024
bd3939c
Merge pull request #974 from tilly111/bugfix-eda_analyze_sampling_rate
DominiqueMakowski Mar 24, 2024
24939c7
Merge pull request #975 from DerAndereJohannes/fix_acqknowledge_dupli…
DominiqueMakowski Mar 24, 2024
8e27aef
Merge pull request #973 from danibene/fix/ecg_findpeaks_refactor
danibene Mar 24, 2024
5d550d6
Rework stim_events_find into events_find
DerAndereJohannes Mar 26, 2024
deb70d0
Make the events non-overlapping
DominiqueMakowski Mar 31, 2024
016f244
[Fix] Update changelog to reflect changing find_events
DerAndereJohannes Mar 31, 2024
8da97e7
Merge pull request #976 from DerAndereJohannes/find_stimulus_events
DominiqueMakowski Apr 1, 2024
4cd9ec4
[Feature] add 'columns' selection argument in epochs_plot()
DominiqueMakowski Apr 1, 2024
8e4ee00
Remove codeclimate
DominiqueMakowski Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions .codeclimate.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,4 @@ studies/complexity_structure/README_cache/
studies/complexity_structure/manuscript_cache/
studies/complexity_eeg/data_attractor.csv
studies/complexity_eeg/data_delay.csv
testing.ipynb
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ include NEWS.rst
include LICENSE
include README.rst

recursive-include tests *
recursive-exclude tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py *.jpg *.png *.gif

11 changes: 11 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
News
=====

0.2.8
-------------------
New Features
+++++++++++++

* New feature `events_find()`: is now able to combine multiple digital input channels,
retrieve events from the combined events channel and differentiate between the inputs that
occur simultaneously.



0.2.4
-------------------
Fixes
Expand Down
Binary file modified data/eeg_1min_200hz.pickle
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/examples/ecg_hrv/ecg_hrv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Heart Rate Varability (HRV)"
"# Heart Rate Variability (HRV)"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions neurokit2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Top-level package for NeuroKit."""

import datetime
import platform

Expand Down Expand Up @@ -32,12 +33,12 @@
from .video import *

# Info
__version__ = "0.2.7"
__version__ = "0.2.8"


# Maintainer info
__author__ = "The NeuroKit development team"
__email__ = "[email protected]"
__email__ = "[email protected]"


# Citation
Expand Down
17 changes: 9 additions & 8 deletions neurokit2/complexity/utils_complexity_symbolize.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def complexity_symbolize(signal, method="mean", c=3, random_state=None, show=Fal
symbolic = (signal > np.nanmean(signal)).astype(int)
if show is True:
df = pd.DataFrame({"A": signal, "B": signal})
df["A"][df["A"] > np.nanmean(signal)] = np.nan
df["B"][df["B"] <= np.nanmean(signal)] = np.nan
df.loc[df["A"] > np.nanmean(signal), "A"] = np.nan
df.loc[df["B"] <= np.nanmean(signal), "B"] = np.nan
df.plot()
plt.axhline(y=np.nanmean(signal), color="r", linestyle="dotted")
plt.title("Method A")
Expand All @@ -194,8 +194,8 @@ def complexity_symbolize(signal, method="mean", c=3, random_state=None, show=Fal
symbolic = (signal > np.nanmedian(signal)).astype(int)
if show is True:
df = pd.DataFrame({"A": signal, "B": signal})
df["A"][df["A"] > np.nanmedian(signal)] = np.nan
df["B"][df["B"] <= np.nanmedian(signal)] = np.nan
df.loc[df["A"] > np.nanmedian(signal), "A"] = np.nan
df.loc[df["B"] <= np.nanmedian(signal), "B"] = np.nan
df.plot()
plt.axhline(y=np.nanmean(signal), color="r", linestyle="dotted")
plt.title("Binarization by median")
Expand All @@ -206,8 +206,9 @@ def complexity_symbolize(signal, method="mean", c=3, random_state=None, show=Fal
symbolic = np.logical_or(signal < m - sd, signal > m + sd).astype(int)
if show is True:
df = pd.DataFrame({"A": signal, "B": signal})
df["A"][np.logical_or(signal < m - sd, signal > m + sd)] = np.nan
df["B"][~np.isnan(df["A"])] = np.nan
condition = np.logical_or(signal < m - sd, signal > m + sd)
df.loc[condition, "A"] = np.nan
df.loc[~np.isnan(df["A"]), "B"] = np.nan
df.plot()
plt.axhline(y=m - sd, color="r", linestyle="dotted")
plt.axhline(y=m + sd, color="r", linestyle="dotted")
Expand All @@ -217,8 +218,8 @@ def complexity_symbolize(signal, method="mean", c=3, random_state=None, show=Fal
symbolic = np.signbit(np.diff(signal)).astype(int)
if show is True:
df = pd.DataFrame({"A": signal, "B": signal})
df["A"][np.insert(symbolic, 0, False)] = np.nan
df["B"][~np.isnan(df["A"])] = np.nan
df.loc[np.insert(symbolic, 0, False), "A"] = np.nan
df.loc[~np.isnan(df["A"]), "B"] = np.nan
df.plot()
plt.title("Method C")

Expand Down
6 changes: 2 additions & 4 deletions neurokit2/data/database.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pathlib
import urllib.parse
import urllib
import zipfile

import requests


def download_from_url(url, destination_path=None):
"""**Download Files from URLs**
Expand All @@ -26,7 +24,7 @@ def download_from_url(url, destination_path=None):
destination_path = _download_path_sanitize(url, destination_path)

# Download the file
response = requests.get(url)
response = urllib.request.urlopen(url)

if response.status_code == 200:
with destination_path.open("wb") as file:
Expand Down
31 changes: 19 additions & 12 deletions neurokit2/data/read_acqknowledge.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
import os

from collections import Counter

import numpy as np
import pandas as pd

from ..signal import signal_resample


def read_acqknowledge(
filename, sampling_rate="max", resample_method="interpolation", impute_missing=True
):
def read_acqknowledge(filename, sampling_rate="max", resample_method="interpolation", impute_missing=True):
"""**Read and format a BIOPAC's AcqKnowledge file into a pandas' dataframe**

The function outputs both the dataframe and the sampling rate (retrieved from the
Expand Down Expand Up @@ -69,10 +69,7 @@ def read_acqknowledge(
filename += ".acq"

if os.path.exists(filename) is False:
raise ValueError(
"NeuroKit error: read_acqknowledge(): couldn't"
" find the following file: " + filename
)
raise ValueError("NeuroKit error: read_acqknowledge(): couldn't" " find the following file: " + filename)

# Read file
file = bioread.read(filename)
Expand All @@ -84,24 +81,34 @@ def read_acqknowledge(
freq_list.append(file.named_channels[channel].samples_per_second)
sampling_rate = np.max(freq_list)

# Counter for checking duplicate channel names
channel_counter = Counter()

# Loop through channels
data = {}
for channel in file.named_channels:
signal = np.array(file.named_channels[channel].data)
for channel_num, channel in enumerate(file.channels):
signal = np.array(file.channels[channel_num].data)

# Fill signal interruptions
if impute_missing is True and np.isnan(np.sum(signal)):
signal = pd.Series(signal).fillna(method="pad").values

# Resample if necessary
if file.named_channels[channel].samples_per_second != sampling_rate:
if file.channels[channel_num].samples_per_second != sampling_rate:
signal = signal_resample(
signal,
sampling_rate=file.named_channels[channel].samples_per_second,
sampling_rate=file.channels[channel_num].samples_per_second,
desired_sampling_rate=sampling_rate,
method=resample_method,
)
data[channel] = signal

# If there is a duplicate channel name, append a number
if channel_counter[channel.name] == 0:
data[channel.name] = signal
else:
data[f"{channel.name} ({channel_counter[channel.name]})"] = signal

channel_counter[channel.name] += 1

# Sanitize lengths
lengths = []
Expand Down
10 changes: 8 additions & 2 deletions neurokit2/data/read_xdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ def read_xdf(filename, upsample=2, fillmissing=None):

# Special treatment for some devices
if stream["info"]["name"][0] == "Muse":
# Rename GYRO channels and add ACCelerometer
# Rename GYRO channels
if stream["info"]["type"][0] == "GYRO":
dat = dat.rename(columns={"X": "GYRO_X", "Y": "GYRO_Y", "Z": "GYRO_Z"})
dat["ACC"] = np.sqrt(dat["GYRO_X"] ** 2 + dat["GYRO_Y"] ** 2 + dat["GYRO_Z"] ** 2)
# Compute movement
dat["GYRO"] = np.sqrt(dat["GYRO_X"] ** 2 + dat["GYRO_Y"] ** 2 + dat["GYRO_Z"] ** 2)

if stream["info"]["type"][0] == "ACC":
dat = dat.rename(columns={"X": "ACC_X", "Y": "ACC_Y", "Z": "ACC_Z"})
# Compute acceleration
dat["ACC"] = np.sqrt(dat["ACC_X"] ** 2 + dat["ACC_Y"] ** 2 + dat["ACC_Z"] ** 2)

# Muse - PPG data has three channels: ambient, infrared, red
if stream["info"]["type"][0] == "PPG":
Expand Down
Loading
Loading