Skip to content

Commit c013b3e

Browse files
Updating the default config to be compatible with adult recordings. (lina-usc#173)
* Updating the default config to be compatible with adult recordings. * Code linting. * Fixing tests. * Fixing spelling. * Fixing simulation test.
1 parent f89122d commit c013b3e

File tree

7 files changed

+180
-29
lines changed

7 files changed

+180
-29
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
######################### General properties #########################
2+
#ref_loc_file: derivatives/pylossless/code/misc/standard_1020_ll_ref19.elc
3+
#montage_info: [0.0, -16.0, 0.0, -0.02, 0.0, -1.58, 10.7, 11.5, 11.5]
4+
5+
################## General info about the project ####################
6+
project:
7+
readme: "# Description of the dataset"
8+
9+
# Montage use to make file BIDS compliant.
10+
# Can be path to digitized montage OR a string of one of mne's built in
11+
# standard montages as specified by mne.channels.get_builtin_montages().
12+
# Can be left empty if the input dataset is already in BIDS format.
13+
bids_montage: GSN-HydroCel-129
14+
15+
# montage used while running the lossless pipeline.
16+
# if empty, the pipeline will use the electrodes.tsv sidecar file, if created
17+
# during the BIDS conversion.
18+
# If specified, needs to be a string of one of mne's built in standard montages.
19+
analysis_montage: ""
20+
21+
set_montage_kwargs: {}
22+
23+
coordsys:
24+
EEGCoordinateSystem: Other
25+
EEGCoordinateUnits: metres
26+
27+
general_info:
28+
authors: [Unspecified]
29+
institution_Name: Unspecified
30+
institution_address: Unspecified
31+
dataset_doi: []
32+
funding: Unspecified
33+
how_to_acknowledge: tba
34+
license: ""
35+
name: Unspecified
36+
references_and_links: []
37+
38+
t_info:
39+
EEG_placement_scheme: EGI 129
40+
cap_manufacturer: EGI
41+
cap_manufacturers_model_name: Hydrocel 129 Channel
42+
hardware_filters: n/a
43+
manufacturer: Electrical Geodesics
44+
manufacturers_model_name: NetAmps300
45+
power_line_frequency: 60
46+
software_filters: n/a
47+
software_versions: NetStation V4.5
48+
49+
######################## Task break detection ########################
50+
# See arguments definition from mne.preprocessing.annotate_breaks
51+
find_breaks:
52+
53+
############################## epoching ##############################
54+
epoching:
55+
overlap: 0
56+
57+
# See arguments definition from mne.Epochs
58+
epochs_args:
59+
baseline: null
60+
tmax: 1
61+
tmin: 0
62+
63+
########################### EEG filtering ############################
64+
# See arguments definition from mne.io.Raw.filter & mne.io.Raw.notch_filter
65+
filtering:
66+
filter_args:
67+
h_freq: 100
68+
l_freq: 1
69+
notch_filter_args:
70+
freqs: [60]
71+
72+
############################## SLURM #################################
73+
# Options for running the pipeline on a cluster
74+
# through SLURM
75+
slurm_options:
76+
account: def-emayada
77+
job_name: pylossless
78+
memory: 16g
79+
mpi: false
80+
num_tasks: 1
81+
program_options: []
82+
threads_per_task: []
83+
time_limit: 2h
84+
85+
########################## Nearest neighbor ##########################
86+
nearest_neighbors:
87+
n_nbr_ch: 3
88+
n_nbr_epoch: 3
89+
90+
####################### Pipeline steps config ########################
91+
bridged_channels:
92+
bridge_trim: 40
93+
bridge_z: 6
94+
95+
noisy_channels:
96+
flag_crit: 0.2
97+
outlier_method: quantile
98+
outliers_kwargs:
99+
k: 6
100+
lower: 0.25
101+
upper: 0.75
102+
103+
uncorrelated_channels:
104+
flag_crit: 0.2
105+
outlier_method: quantile
106+
outliers_kwargs:
107+
k: 6
108+
lower: 0.25
109+
upper: 0.75
110+
111+
noisy_epochs:
112+
flag_crit: 0.2
113+
outlier_method: quantile
114+
outliers_kwargs:
115+
k: 6
116+
lower: 0.25
117+
upper: 0.75
118+
119+
uncorrelated_epochs:
120+
flag_crit: 0.2
121+
outlier_method: quantile
122+
outliers_kwargs:
123+
k: 6
124+
lower: 0.25
125+
upper: 0.75
126+
127+
################################ ICA #################################
128+
ica:
129+
noisy_ic_epochs:
130+
flag_crit: 0.2
131+
outlier_method: quantile
132+
outliers_kwargs:
133+
k: 6
134+
lower: 0.25
135+
upper: 0.75
136+
137+
# See arguments definition from mne.preprocessing.ICA
138+
ica_args:
139+
run1:
140+
method: fastica
141+
run2:
142+
method: infomax
143+
fit_params:
144+
extended: True

pylossless/assets/ll_default_config.yaml renamed to pylossless/assets/ll_default_config_infants.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
######################### General properties #########################
2-
aref_trim: 30
3-
order: 1
4-
out_path: derivatives/EEG-IP-L
5-
ref_loc_file: derivatives/EEG-IP-L/code/misc/standard_1020_ll_ref19.elc
6-
save_f_res: 1
7-
sd_t_pad: 1
8-
in_path: []
9-
montage_info: [0.0, -16.0, 0.0, -0.02, 0.0, -1.58, 10.7, 11.5, 11.5]
2+
#ref_loc_file: derivatives/pylossless/code/misc/standard_1020_ll_ref19.elc
3+
#montage_info: [0.0, -16.0, 0.0, -0.02, 0.0, -1.58, 10.7, 11.5, 11.5]
104

115
################## General info about the project ####################
126
project:
13-
readme: "# Q1K ACAR Dataset"
7+
readme: "# Description of the dataset"
148

159
# Montage use to make file BIDS compliant.
1610
# Can be path to digitized montage OR a string of one of mne's built in
@@ -31,14 +25,14 @@ project:
3125
EEGCoordinateUnits: metres
3226

3327
general_info:
34-
authors: [Q1K Neuroimaging group]
35-
institution_Name: McGill University
36-
institution_address: 3775 Rue University, Montreal, QC
28+
authors: [Unspecified]
29+
institution_Name: Unspecified
30+
institution_address: Unspecified
3731
dataset_doi: []
38-
funding: Azrieli Foundationt
32+
funding: Unspecified
3933
how_to_acknowledge: tba
4034
license: ""
41-
name: Q1K Mismatched Negativity
35+
name: Unspecified
4236
references_and_links: []
4337

4438
t_info:

pylossless/config/config.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ConfigMixin(dict):
1515
"""Base configuration file class for pipeline procedures."""
1616

1717
DEFAULT_CONFIG_PATH = (
18-
Path(__file__).parent.parent / "assets" / "ll_default_config.yaml"
18+
Path(__file__).parent.parent / "assets"
1919
)
2020

2121
def read(self, file_name):
@@ -51,11 +51,16 @@ def print(self):
5151
class Config(ConfigMixin):
5252
"""Representation of configuration file for running the pipeline."""
5353

54-
DEFAULT_CONFIG_PATH = (
55-
Path(__file__).parent.parent / "assets" / "ll_default_config.yaml"
56-
)
54+
def load_default(self, kind="adults"):
55+
"""Get the default pylossless config file.
5756
58-
def load_default(self):
59-
"""Get the default pylossless config file."""
60-
self.read(Config.DEFAULT_CONFIG_PATH)
57+
Parameters
58+
----------
59+
kind : str | pathlib.Path
60+
Can be either 'adults' or 'infants'. Default to 'adults'.
61+
"""
62+
path = Config.DEFAULT_CONFIG_PATH / f"ll_default_config_{kind}.yaml"
63+
if not path.exists():
64+
raise ValueError(f"No default configuration for kind '{kind}'.")
65+
self.read(path)
6166
return self

pylossless/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def pipeline_fixture():
1919
"""Return a namedTuple containing MNE eyetracking raw data and events."""
2020
raw, config, bids_path = load_openneuro_bids()
21-
raw.crop(tmin=0, tmax=60) # take 60 seconds for speed
21+
# raw.crop(tmin=0, tmax=60) # Too short for ICA to converge in some tests.
2222
annots = Annotations(
2323
onset=[1, 15], duration=[1, 1], description=["test_annot", "test_annot"]
2424
)
@@ -28,6 +28,7 @@ def pipeline_fixture():
2828
config["find_breaks"]["min_break_duration"] = 9
2929
config["find_breaks"]["t_start_after_previous"] = 1
3030
config["find_breaks"]["t_stop_before_next"] = 0
31+
config["ica"]["ica_args"]["run1"]["max_iter"] = 5000
3132
config.save("test_config.yaml")
3233
pipeline = ll.LosslessPipeline("test_config.yaml")
3334
not_in_1020 = ["EXG1", "EXG2", "EXG3", "EXG4", "EXG5", "EXG6", "EXG7", "EXG8"]

pylossless/datasets/datasets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def load_openneuro_bids(subject="pd6"):
3333
openneuro = ll.utils.import_optional_dependency("openneuro")
3434

3535
config = ll.config.Config()
36-
config.load_default()
36+
# TODO: Tests were developed using this configuration. The adult version
37+
# should probably be used instead, but this change will require fixing the
38+
# tests accordingly.
39+
config.load_default("infants")
3740
config["project"]["bids_montage"] = ""
3841
config["project"]["analysis_montage"] = "standard_1020"
3942
config["project"]["set_montage_kwargs"]["on_missing"] = "warn"

pylossless/tests/test_simulated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# LOAD DEFAULT CONFIG
1313
config = ll.config.Config()
14-
config.load_default()
14+
config.load_default("infants")
1515
config["noisy_channels"]["outliers_kwargs"]["lower"] = 0.25
1616
config["noisy_channels"]["outliers_kwargs"]["upper"] = 0.75
1717
# short file, raise threshold so epochs w/ blinks dont cause flag

pylossless/tests/test_utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ def test_import_optional_dependency():
55
from pylossless.utils import check
66

77
# Test the case where the package is not installed.
8-
with pytest.raises(ImportError, match="Missing optional dependency 'astropy'."):
9-
# choosing a package that will probably never be added to the requirements!
10-
check.import_optional_dependency("astropy")
8+
package = "sdgssfersfsdesdfsefsdfsdt"
9+
with pytest.raises(ImportError, match=f"Missing optional dependency '{package}'."):
10+
# Choosing a package that will probably never be added to the requirements!
11+
# We also choose a name of a package that is likely not to exist at all
12+
# to avoid the corresponding package is installed in the development
13+
# environment of developers.
14+
check.import_optional_dependency(package)
1115

1216
# Test the case where the package is installed.
1317
mne = check.import_optional_dependency("mne", raise_error=False)
1418
assert mne is not None
1519

1620
# Test the where case package is not installed but we don't want to raise an error.
17-
astropy = check.import_optional_dependency("astropy", raise_error=False)
18-
assert astropy is None
21+
ret_val = check.import_optional_dependency(package, raise_error=False)
22+
assert ret_val is None

0 commit comments

Comments
 (0)