Skip to content

Commit

Permalink
Rename flags and methods (#152)
Browse files Browse the repository at this point in the history
* ENH: Make flags and methods more readable

* FIX: formatting
  • Loading branch information
scott-huberty authored Nov 7, 2023
1 parent 6197698 commit 6b1db59
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 83 deletions.
3 changes: 1 addition & 2 deletions examples/plot_10_run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Run pyLossless on a BIDS dataset.
=================================
In this notebook, we will run the pyLossless pipeline on a publicly available dataset
that is already in BIDS format.
In this notebook, we will run the pyLossless pipeline on a publicly available dataset.
"""

# %%
Expand Down
33 changes: 13 additions & 20 deletions pylossless/assets/ll_default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ sd_t_pad: 1
in_path: []
montage_info: [0.0, -16.0, 0.0, -0.02, 0.0, -1.58, 10.7, 11.5, 11.5]


################## General info about the project ####################
project:
readme: '# Q1K ACAR Dataset'
readme: "# Q1K ACAR Dataset"

# Montage use to make file BIDS compliant.
# Can be path to digitized montage OR a string of one of mne's built in
Expand All @@ -23,22 +22,22 @@ project:
# if empty, the pipeline will use the electrodes.tsv sidecar file, if created
# during the BIDS conversion.
# If specified, needs to be a string of one of mne's built in standard montages.
analysis_montage: ''
analysis_montage: ""

set_montage_kwargs: {}

coordsys:
EEGCoordinateSystem: Other
EEGCoordinateUnits: metres

general_info:
authors: [Q1K Neuroimaging group]
institution_Name: McGill University
institution_address: 3775 Rue University, Montreal, QC
dataset_doi: []
funding: Azrieli Foundationt
how_to_acknowledge: tba
license: ''
license: ""
name: Q1K Mismatched Negativity
references_and_links: []

Expand All @@ -52,22 +51,21 @@ project:
power_line_frequency: 60
software_filters: n/a
software_versions: NetStation V4.5

######################## Task break detection ########################
# See arguments definition from mne.preprocessing.annotate_breaks
find_breaks:

############################## epoching ##############################
epoching:
overlap: 0

# See arguments definition from mne.Epochs
epochs_args:
baseline: null
tmax: 1
tmin: 0


########################### EEG filtering ############################
# See arguments definition from mne.io.Raw.filter & mne.io.Raw.notch_filter
filtering:
Expand All @@ -77,7 +75,6 @@ filtering:
notch_filter_args:
freqs: []


############################## SLURM #################################
# Options for running the pipeline on a cluster
# through SLURM
Expand All @@ -95,41 +92,37 @@ slurm_options:
nearest_neighbors:
n_nbr_ch: 3
n_nbr_epoch: 3


####################### Pipeline steps config ########################
bridge:
bridged_channels:
bridge_trim: 40
bridge_z: 6

ch_ch_sd:
noisy_channels:
flag_crit: 0.2
outlier_method: quantile
outliers_kwargs:
k: 16
lower: 0.3
upper: 0.7

ch_low_r:
uncorrelated_channels:
flag_crit: 0.2
outlier_method: quantile
outliers_kwargs:
k: 16
lower: 0.3
upper: 0.7

epoch_ch_sd:
noisy_epochs:
flag_crit: 0.2
outlier_method: quantile
outliers_kwargs:
k: 16
lower: 0.3
upper: 0.7

epoch_gap:
min_gap_ms: 2000

epoch_low_r:
uncorrelated_epochs:
flag_crit: 0.2
outlier_method: quantile
outliers_kwargs:
Expand All @@ -139,7 +132,7 @@ epoch_low_r:

################################ ICA #################################
ica:
ic_ic_sd:
noisy_ic_epochs:
flag_crit: 0.2
outlier_method: quantile
outliers_kwargs:
Expand Down
6 changes: 3 additions & 3 deletions pylossless/config/rejection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class RejectionPolicy(ConfigMixin):
in for the rejection policy.
ch_flags_to_reject : list of str
List of channel flags to apply. "all" is the same as
``["ch_sd", "low_r", "bridge"]``, meaning that any channels that
have been flagged ``"ch_sd"``, ``"low_r"``, or ``"bridge"`` will
``["noisy", "uncorrelated", "bridged"]``, meaning that any channels that
have been flagged ``"noisy"``, ``"uncorrelated"``, or ``"bridged"`` will
be applied. Defaults to "all".
ic_flags_to_reject : list of str
List of IC flags to apply. "all" is the same as
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
remove_flagged_ics=True,
):
if ch_flags_to_reject == "all":
ch_flags_to_reject = ["ch_sd", "low_r", "bridge"]
ch_flags_to_reject = ["noisy", "uncorrelated", "bridged"]
if ic_flags_to_reject == "all":
ic_flags = ["muscle", "ecg", "eog", "channel_noise", "line_noise"]
ic_flags_to_reject = ic_flags
Expand Down
11 changes: 6 additions & 5 deletions pylossless/flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class FlaggedEpochs(dict):
:class:`mne.Epochs`) to the ``'manual'`` dictionary key.
load_from_raw:
Add any :class:`mne.Annotations` in a loaded :class:`mne.io.Raw` file
that start with ``'bad_pylossless'`` to the FlaggedEpochs class.
Add any pylossless :class:`mne.Annotations` in a loaded :class:`mne.io.Raw`
file to the FlaggedEpochs class.
Notes
-----
Expand Down Expand Up @@ -181,7 +181,7 @@ def add_flag_cat(self, kind, bad_epoch_inds, epochs):
Parameters
----------
kind : str
Should be one of ``'ch_sd'``, ``'low_r'``, ``'ic_sd1'``.
Should be one of ``'noisy'``, ``'uncorrelated'``, ``'noisy_ICs'``.
bad_epochs_inds : list | tuple
Indices for the epochs in an :class:`mne.Epochs` object. Will be
the values for the ``kind`` dictionary key.
Expand All @@ -195,10 +195,11 @@ def add_flag_cat(self, kind, bad_epoch_inds, epochs):
self.ll.add_pylossless_annotations(bad_epoch_inds, kind, epochs)

def load_from_raw(self, raw):
"""Load ``'bad_pylossless'`` annotations from raw object."""
"""Load pylossless annotations from raw object."""
sfreq = raw.info["sfreq"]
lossless_descriptions = ["bad_noisy", "bad_uncorrelated", "bad_noisy_ICs"]
for annot in raw.annotations:
if annot["description"].startswith("bad_pylossless"):
if annot["description"] in lossless_descriptions:
ind_onset = int(np.round(annot["onset"] * sfreq))
ind_dur = int(np.round(annot["duration"] * sfreq))
inds = np.arange(ind_onset, ind_onset + ind_dur)
Expand Down
Loading

0 comments on commit 6b1db59

Please sign in to comment.