Skip to content

Commit

Permalink
FIX: Some
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Dec 20, 2024
1 parent 323d48b commit ae14a5e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 42 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies:
- qdarkstyle !=3.2.2
- qtpy
- scikit-learn
- scipy >=1.11.1
- scipy >=1.11
- sip
- snirf
- statsmodels
Expand Down
20 changes: 0 additions & 20 deletions mne/commands/mne_flash_bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ def run():
"been registered with the T1.mgz file."
),
)
parser.add_option(
"-n",
"--noconvert",
dest="noconvert",
action="store_true",
default=False,
help=(
"[DEPRECATED] Assume that the Flash MRI images "
"have already been converted to mgz files"
),
)
parser.add_option(
"-u",
"--unwarp",
Expand Down Expand Up @@ -139,15 +128,6 @@ def run():
help="Use copies instead of symlinks for surfaces",
action="store_true",
)
parser.add_option(
"-p",
"--flash-path",
dest="flash_path",
default=None,
help="[DEPRECATED] The directory containing flash5.mgz "
"files (defaults to "
"$SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps",
)

options, _ = parser.parse_args()

Expand Down
1 change: 1 addition & 0 deletions mne/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3415,6 +3415,7 @@ def _add_raw(
init_kwargs.setdefault("fmax", fmax)
plot_kwargs.setdefault("show", False)
with warnings.catch_warnings():
# SciPy warning about too short a data segment given the window size
warnings.simplefilter(action="ignore", category=FutureWarning)
fig = raw.compute_psd(**init_kwargs).plot(**plot_kwargs)
self._add_figure(
Expand Down
4 changes: 1 addition & 3 deletions mne/time_frequency/tests/test_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ def test_unaggregated_spectrum_to_data_frame(raw, long_format, method, output):
pytest.importorskip("pandas")
from pandas.testing import assert_frame_equal

from mne.utils.dataframe import _inplace

# aggregated spectrum → dataframe
orig_df = raw.compute_psd(method=method).to_data_frame(long_format=long_format)
# unaggregated welch or complex multitaper →
Expand All @@ -329,7 +327,7 @@ def test_unaggregated_spectrum_to_data_frame(raw, long_format, method, output):
orig_df = orig_df.loc[subset(orig_df["freq"])]
# sort orig_df, because at present we can't actually prevent pandas from
# sorting at the agg step *sigh*
_inplace(orig_df, "sort_values", by=grouping_cols, ignore_index=True)
orig_df.sort_values(by=grouping_cols, ignore_index=True)
# aggregate
df = df.drop(columns=drop_cols)
gb = df.groupby(grouping_cols, as_index=False, observed=False)
Expand Down
20 changes: 4 additions & 16 deletions mne/utils/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from ..defaults import _handle_default
from ._logging import logger, verbose
from .check import check_version


@verbose
Expand Down Expand Up @@ -48,17 +47,6 @@ def _convert_times(times, time_format, meas_date=None, first_time=0):
return times


def _inplace(df, method, **kwargs):
_meth = getattr(df, method) # used for set_index() and rename()

# TODO: deprecation in Pandas 3.0, can remove once we require 3+
if check_version("pandas", "3.0"):
return _meth(**kwargs)
else:
# "copy" in signature(_meth).parameters
return _meth(**kwargs, copy=False)


@verbose
def _build_data_frame(
inst,
Expand Down Expand Up @@ -86,16 +74,16 @@ def _build_data_frame(
df.insert(i, k, v)
# build Index
if long_format:
df = _inplace(df, "set_index", keys=default_index)
df.set_index(keys=default_index)
df.columns.name = col_kind
elif index is not None:
df = _inplace(df, "set_index", keys=index)
df.set_index(keys=index)
if set(index) == set(default_index):
df.columns.name = col_kind
# long format
if long_format:
df = df.stack().reset_index()
df = _inplace(df, "rename", columns={0: "value"})
df.rename(columns={0: "value"})
# add column for channel types (as appropriate)
ch_map = (
None
Expand All @@ -113,7 +101,7 @@ def _build_data_frame(
df.insert(col_index, "ch_type", ch_type)
# restore index
if index is not None:
df = _inplace(df, "set_index", keys=index)
df.set_index(keys=index)
# convert channel/vertex/ch_type columns to factors
to_factor = [
c for c in df.columns.tolist() if c not in ("freq", "time", "value")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"numpy >= 1.25,<3", # 2023/06/17
"packaging",
"pooch >= 1.5",
"scipy >= 1.11.1", # 2023/06/25
"scipy >= 1.11", # 2023/06/25
"tqdm",
]
description = "MNE-Python project for MEG and EEG data analysis."
Expand Down
2 changes: 1 addition & 1 deletion tools/environment_old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- python =3.10
- numpy =1.25
- scipy =1.11.1
- scipy =1.11
- matplotlib =3.7
- pandas =2.0
- scikit-learn
Expand Down

0 comments on commit ae14a5e

Please sign in to comment.