Skip to content

Commit f907908

Browse files
DOC: Use rng in examples
1 parent 504fa11 commit f907908

34 files changed

Lines changed: 95 additions & 63 deletions

examples/datasets/spm_faces_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
raw.resample(100)
3737
raw.filter(1.0, None) # high-pass
3838
reject = dict(mag=5e-12)
39-
ica = ICA(n_components=0.95, max_iter="auto", random_state=0)
39+
ica = ICA(n_components=0.95, max_iter="auto", rng=0)
4040
ica.fit(raw, reject=reject)
4141
# compute correlation scores, get bad indices sorted by score
4242
eog_epochs = create_eog_epochs(raw, ch_name="MRT31-2908", reject=reject)

examples/inverse/mixed_norm_inverse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
return_residual=True,
8282
return_as_dipoles=True,
8383
verbose=True,
84-
random_state=0,
84+
rng=0,
8585
# for this dataset we know we should use a high alpha, so avoid some
8686
# of the slower (lower) alpha values
8787
sure_alpha_grid=np.linspace(100, 40, 10),

examples/preprocessing/find_ref_artifacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
ica_kwargs = dict(
7878
method="picard",
7979
fit_params=dict(tol=1e-4), # use a high tol here for speed
80-
random_state=99,
80+
rng=99,
8181
)
8282
all_picks = mne.pick_types(raw_tog.info, meg=True, ref_meg=True)
8383
ica_tog = ICA(n_components=60, max_iter="auto", allow_ref_meg=True, **ica_kwargs)

examples/preprocessing/ica_comparison.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run_ica(method, fit_params=None):
5050
method=method,
5151
fit_params=fit_params,
5252
max_iter="auto",
53-
random_state=0,
53+
rng=0,
5454
)
5555
t0 = time()
5656
ica.fit(raw, reject=reject)

examples/preprocessing/muscle_ica.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737

3838
# %%
3939
# Run ICA
40-
ica = mne.preprocessing.ICA(
41-
n_components=15, method="picard", max_iter="auto", random_state=97
42-
)
40+
ica = mne.preprocessing.ICA(n_components=15, method="picard", max_iter="auto", rng=97)
4341
ica.fit(raw)
4442

4543
# %%
@@ -104,7 +102,7 @@
104102

105103
# Run ICA
106104
ica = mne.preprocessing.ICA(
107-
n_components=15, method="picard", max_iter="auto", random_state=97
105+
n_components=15, method="picard", max_iter="auto", rng=97
108106
)
109107
ica.fit(raw)
110108
ica.plot_sources(raw)

examples/simulation/plot_stc_metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
location=location,
7777
extent=extent,
7878
subjects_dir=subjects_dir,
79-
random_state=random_state,
79+
rng=random_state,
8080
)
8181

8282
# Dipole
@@ -88,7 +88,7 @@
8888
location=location,
8989
extent=extent,
9090
subjects_dir=subjects_dir,
91-
random_state=random_state,
91+
rng=random_state,
9292
)
9393

9494
# WHAT?
@@ -128,15 +128,15 @@
128128
raw_region = raw_region.pick(picks=["eeg", "stim"], exclude="bads")
129129
cov = mne.make_ad_hoc_cov(raw_region.info)
130130
mne.simulation.add_noise(
131-
raw_region, cov, iir_filter=[0.2, -0.2, 0.04], random_state=random_state
131+
raw_region, cov, iir_filter=[0.2, -0.2, 0.04], rng=random_state
132132
)
133133

134134
# Dipole
135135
raw_dipole = mne.simulation.simulate_raw(info, source_simulator_dipole, forward=fwd)
136136
raw_dipole = raw_dipole.pick(picks=["eeg", "stim"], exclude="bads")
137137
cov = mne.make_ad_hoc_cov(raw_dipole.info)
138138
mne.simulation.add_noise(
139-
raw_dipole, cov, iir_filter=[0.2, -0.2, 0.04], random_state=random_state
139+
raw_dipole, cov, iir_filter=[0.2, -0.2, 0.04], rng=random_state
140140
)
141141

142142
###############################################################################

examples/simulation/simulate_evoked_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def data_fun(times):
6767
fwd["src"],
6868
n_dipoles=2,
6969
times=times,
70-
random_state=42,
70+
rng=42,
7171
labels=labels,
7272
data_fun=data_fun,
7373
)

examples/simulation/simulate_raw_data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def data_fun(times):
6767
fwd = mne.read_forward_solution(fwd_fname)
6868
src = fwd["src"]
6969
stc = simulate_sparse_stc(
70-
src, n_dipoles=n_dipoles, times=times, data_fun=data_fun, random_state=rng
70+
src, n_dipoles=n_dipoles, times=times, data_fun=data_fun, rng=rng
7171
)
7272
# look at our source data
7373
fig, ax = plt.subplots(1)
@@ -79,9 +79,9 @@ def data_fun(times):
7979
# Simulate raw data
8080
raw_sim = simulate_raw(raw.info, [stc] * 10, forward=fwd, verbose=True)
8181
cov = make_ad_hoc_cov(raw_sim.info)
82-
add_noise(raw_sim, cov, iir_filter=[0.2, -0.2, 0.04], random_state=rng)
83-
add_ecg(raw_sim, random_state=rng)
84-
add_eog(raw_sim, random_state=rng)
82+
add_noise(raw_sim, cov, iir_filter=[0.2, -0.2, 0.04], rng=rng)
83+
add_ecg(raw_sim, rng=rng)
84+
add_eog(raw_sim, rng=rng)
8585
raw_sim.plot()
8686

8787
##############################################################################

examples/simulation/simulated_raw_data_using_subject_anatomy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def data_fun(times, latency, duration):
204204
raw_sim = mne.simulation.simulate_raw(info, source_simulator, forward=fwd)
205205
raw_sim.set_eeg_reference(projection=True)
206206

207-
mne.simulation.add_noise(raw_sim, cov=noise_cov, random_state=0)
208-
mne.simulation.add_eog(raw_sim, random_state=0)
209-
mne.simulation.add_ecg(raw_sim, random_state=0)
207+
mne.simulation.add_noise(raw_sim, cov=noise_cov, rng=0)
208+
mne.simulation.add_eog(raw_sim, rng=0)
209+
mne.simulation.add_ecg(raw_sim, rng=0)
210210

211211
# Plot original and simulated raw data.
212212
raw_sim.plot(title="Simulated raw data")

examples/simulation/source_simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class to generate source estimates and raw data. It is meant to be a brief
8585
# simulator can be given directly to the simulate_raw function.
8686
raw = mne.simulation.simulate_raw(info, source_simulator, forward=fwd)
8787
cov = mne.make_ad_hoc_cov(raw.info)
88-
mne.simulation.add_noise(raw, cov, iir_filter=[0.2, -0.2, 0.04], random_state=97)
88+
mne.simulation.add_noise(raw, cov, iir_filter=[0.2, -0.2, 0.04], rng=97)
8989
raw.plot()
9090

9191
# %%

0 commit comments

Comments
 (0)