Skip to content

Commit

Permalink
shorten strings through 88 character length
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheltienne committed Aug 16, 2023
1 parent 084f15e commit aa4d672
Show file tree
Hide file tree
Showing 23 changed files with 366 additions and 454 deletions.
222 changes: 100 additions & 122 deletions pycrostates/cluster/_base.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions pycrostates/cluster/aahc.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ def fit(
@copy_doc(_BaseCluster.save)
def save(self, fname: Union[str, Path]):
super().save(fname)
# TODO: to be replaced by a general writer than infers the writer from
# the file extension.
# TODO: to be replaced by a general writer than infers the writer from the file
# extension.
# pylint: disable=import-outside-toplevel
from ..io.fiff import _write_cluster

# pylint: enable=import-outside-toplevel

_write_cluster(
Expand Down Expand Up @@ -250,7 +249,6 @@ def _compute_maps(

# pylint: enable=too-many-locals
# --------------------------------------------------------------------

@property
def normalize_input(self) -> bool:
"""If set, the input data is normalized along the channel dimension.
Expand Down
32 changes: 15 additions & 17 deletions pycrostates/cluster/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class ModKMeans(_BaseCluster):
----------
%(n_clusters)s
n_init : int
Number of time the k-means algorithm is run with different centroid
seeds. The final result will be the run with the highest Global
Explained Variance (GEV).
Number of time the k-means algorithm is run with different centroid seeds. The
final result will be the run with the highest Global Explained Variance (GEV).
max_iter : int
Maximum number of iterations of the K-means algorithm for a single run.
tol : float
Relative tolerance with regards estimate residual noise in the cluster
centers of two consecutive iterations to declare convergence.
Relative tolerance with regards estimate residual noise in the cluster centers
of two consecutive iterations to declare convergence.
%(random_state)s
References
Expand Down Expand Up @@ -151,16 +150,15 @@ def fit(
Parameters
----------
inst : Raw | Epochs | ChData
MNE `~mne.io.Raw`, `~mne.Epochs` or `~pycrostates.io.ChData` object
from which to extract :term:`cluster centers`.
MNE `~mne.io.Raw`, `~mne.Epochs` or `~pycrostates.io.ChData` object from
which to extract :term:`cluster centers`.
picks : str | list | slice | None
Channels to include. Note that all channels selected must have the
same type. Slices and lists of integers will be interpreted as
channel indices. In lists, channel name strings (e.g.
``['Fp1', 'Fp2']``) will pick the given channels. Can also be the
string values “all” to pick all channels, or “data” to pick data
channels. ``"eeg"`` (default) will pick all eeg channels.
Note that channels in ``info['bads']`` will be included if their
Channels to include. Note that all channels selected must have the same
type. Slices and lists of integers will be interpreted as channel indices.
In lists, channel name strings (e.g. ``['Fp1', 'Fp2']``) will pick the given
channels. Can also be the string values ``“all”`` to pick all channels, or
``“data”`` to pick data channels. ``"eeg"`` (default) will pick all eeg
channels. Note that channels in ``info['bads']`` will be included if their
names or indices are explicitly provided.
%(tmin_raw)s
%(tmax_raw)s
Expand Down Expand Up @@ -224,8 +222,8 @@ def fit(
)
else:
logger.error(
"All the K-means run failed to converge. Please adapt the "
"tolerance and the maximum number of iteration."
"All the K-means run failed to converge. Please adapt the tolerance "
"and the maximum number of iteration."
)
self.fitted = False # reset variables related to fit
return # break early
Expand Down Expand Up @@ -427,6 +425,6 @@ def _check_tol(tol: Union[int, float]) -> Union[int, float]:
_check_type(tol, ("numeric",), item_name="tol")
if tol <= 0:
raise ValueError(
"The tolerance must be a positive number. Provided: '{tol}'."
f"The tolerance must be a positive number. Provided: '{tol}'."
)
return tol
12 changes: 5 additions & 7 deletions pycrostates/cluster/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ def _optimize_order(
def optimize_order(inst: Cluster, template_inst: Cluster):
"""Optimize the order of cluster centers between two cluster instances.
Optimize the order of cluster centers in an instance of a clustering
algorithm to maximize auto-correlation, based on a template instance
as determined by the Hungarian algorithm.
The two cluster instances must have the same number of cluster centers
and the same polarity setting.
Optimize the order of cluster centers in an instance of a clustering algorithm to
maximize auto-correlation, based on a template instance as determined by the
Hungarian algorithm. The two cluster instances must have the same number of cluster
centers and the same polarity setting.
Parameters
----------
Expand All @@ -40,8 +39,7 @@ def optimize_order(inst: Cluster, template_inst: Cluster):
Returns
-------
order : list of int
The new order to apply to inst to maximize auto-correlation
of cluster centers.
The new order to apply to inst to maximize auto-correlation of cluster centers.
"""
from .._base import _BaseCluster

Expand Down
32 changes: 15 additions & 17 deletions pycrostates/datasets/lemon/lemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,20 @@
def data_path(subject_id: str, condition: str) -> Path:
r"""Get path to a local copy of preprocessed EEG recording from the LEMON dataset.
Get path to a local copy of preprocessed EEG recording from the
mind-brain-body dataset of MRI, EEG, cognition, emotion, and peripheral
physiology in young and old adults\ :footcite:p:`babayan_mind-brain-body_2019`.
If there is no local copy of the recording, this function will fetch it
from the online repository and store it. The default location is
``~/pycrostates_data``.
Get path to a local copy of preprocessed EEG recording from the mind-brain-body
dataset of MRI, EEG, cognition, emotion, and peripheral physiology in young and old
adults\ :footcite:p:`babayan_mind-brain-body_2019`. If there is no local copy of the
recording, this function will fetch it from the online repository and store it. The
default location is ``~/pycrostates_data``.
Parameters
----------
subject_id : str
The subject id to use. For example ``'010276'``.
The list of available subjects can be found
on this `FTP server <https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/EEG_MPILMBB_LEMON/EEG_Raw_BIDS_ID>`_.
The list of available subjects can be found on this
`FTP server <https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/EEG_MPILMBB_LEMON/EEG_Raw_BIDS_ID>`_.
condition : str
Can be ``'EO'`` for eyes open condition or ``'EC'`` for eyes closed
condition.
Can be ``'EO'`` for eyes open condition or ``'EC'`` for eyes closed condition.
Returns
-------
Expand All @@ -51,8 +49,8 @@ def data_path(subject_id: str, condition: str) -> Path:
- ``pip install pymatreader``
- ``conda install -c conda-forge pymatreader``
Note that an environment created via the MNE installers includes
``pymatreader`` by default.
Note that an environment created via the MNE installers includes ``pymatreader`` by
default.
References
----------
Expand All @@ -65,7 +63,7 @@ def data_path(subject_id: str, condition: str) -> Path:
config = get_config()
fetcher = pooch.create(
path=config["PREPROCESSED_LEMON_DATASET_PATH"],
base_url="https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/EEG_MPILMBB_LEMON/EEG_Preprocessed_BIDS_ID/EEG_Preprocessed/", # noqa,
base_url="https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/EEG_MPILMBB_LEMON/EEG_Preprocessed_BIDS_ID/EEG_Preprocessed/", # noqa: E501
version=None,
registry=None,
)
Expand All @@ -86,8 +84,8 @@ def data_path(subject_id: str, condition: str) -> Path:
def standardize(raw: BaseRaw):
"""Standardize :class:`~mne.io.Raw` from the lemon dataset.
This function will interpolate missing channels from the standard setup,
then reorder channels and finally reference to a common average.
This function will interpolate missing channels from the standard setup, then
reorder channels and finally reference to a common average.
Parameters
----------
Expand All @@ -102,8 +100,8 @@ def standardize(raw: BaseRaw):
Notes
-----
If you don't want to interpolate missing channels, you can use
:func:`mne.channels.equalize_channels` instead to have the same electrodes
across different recordings.
:func:`mne.channels.equalize_channels` instead to have the same electrodes across
different recordings.
"""
raw = raw.copy()
# fmt: off
Expand Down
17 changes: 8 additions & 9 deletions pycrostates/io/ch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin):
"""ChData stores atemporal data with its spatial information.
ChData is similar to a raw instance where temporality has been removed.
Only the spatial information, stored as a `~pycrostates.io.ChInfo` is
`~pycrostates.io.ChData` is similar to a raw instance where temporality has been
removed. Only the spatial information, stored as a `~pycrostates.io.ChInfo` is
retained.
Parameters
----------
data : array
Data array of shape ``(n_channels, n_samples)``.
info : mne.Info | ChInfo
Atemporal measurement information. If a `mne.Info` is provided, it is
converted to a `~pycrostates.io.ChInfo`.
Atemporal measurement information. If a `mne.Info` is provided, it is converted
to a `~pycrostates.io.ChInfo`.
"""

def __init__(self, data: NDArray[float], info: Union[Info, CHInfo]):
Expand All @@ -36,9 +36,8 @@ def __init__(self, data: NDArray[float], info: Union[Info, CHInfo]):
_check_type(info, (Info, ChInfo), "info")
if data.ndim != 2:
raise ValueError(
"Argument 'data' should be a 2D array "
"(n_channels, n_samples). The provided array "
f"shape is {data.shape} which has {data.ndim} "
"Argument 'data' should be a 2D array (n_channels, n_samples). The "
f"provided array shape is {data.shape} which has {data.ndim} "
"dimensions."
)
if not len(info["ch_names"]) == data.shape[0]:
Expand Down Expand Up @@ -118,8 +117,8 @@ def pick(self, picks, exclude="bads"):
----------
%(picks_all)s
exclude : list | str
Set of channels to exclude, only used when picking based on
types (e.g., ``exclude="bads"`` when ``picks="meg"``).
Set of channels to exclude, only used when picking based on types (e.g.,
``exclude="bads"`` when ``picks="meg"``).
Returns
-------
Expand Down
Loading

0 comments on commit aa4d672

Please sign in to comment.