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

[Fix] build docs warning #968

Merged
merged 9 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 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
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
12 changes: 6 additions & 6 deletions neurokit2/emg/emg_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,16 @@ def emg_activation(

# Modify output produced by signal_formatpeaks.
for x in range(len(emg_amplitude)):
if df_activity["EMG_Activity"][x] != 0:
if df_activity.loc[x, "EMG_Activity"] != 0:
if df_activity.index[x] == df_activity.index.get_loc(x):
df_activity["EMG_Activity"][x] = 1
df_activity.loc[x, "EMG_Activity"] = 1
else:
df_activity["EMG_Activity"][x] = 0
if df_offsets["EMG_Offsets"][x] != 0:
df_activity.loc[x, "EMG_Activity"] = 0
if df_offsets.loc[x, "EMG_Offsets"] != 0:
if df_offsets.index[x] == df_offsets.index.get_loc(x):
df_offsets["EMG_Offsets"][x] = 1
df_offsets.loc[x, "EMG_Offsets"] = 1
else:
df_offsets["EMG_Offsets"][x] = 0
df_offsets.loc[x, "EMG_Offsets"] = 0

activity_signal = pd.concat([df_activity, df_onsets, df_offsets], axis=1)

Expand Down
4 changes: 2 additions & 2 deletions neurokit2/signal/signal_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def _resample_poly(signal, desired_length):

def _resample_pandas(signal, desired_length):
# Convert to Time Series
index = pd.date_range("20131212", freq="L", periods=len(signal))
index = pd.date_range("20131212", freq="ms", periods=len(signal))
resampled_signal = pd.Series(signal, index=index)

# Create resampling factor
resampling_factor = str(np.round(1 / (desired_length / len(signal)), 6)) + "L"
resampling_factor = str(np.round(1 / (desired_length / len(signal)), 6)) + "ms"

# Resample
resampled_signal = resampled_signal.resample(resampling_factor).bfill().values
Expand Down
Loading