Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/anonymize_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
# To ensure results are reproducible across runs, you can pass the
# ``random_state`` parameter, causing the random number generator to produce
# the same results every time you execute the function. This may come in handy
# e.g. in situations where you discover a problem with the data while working
# in situations where you discover a problem with the data while working
# with the anonymized dataset, fix the issue in the original dataset, and
# run anonymization again.
#
Expand All @@ -203,6 +203,15 @@
# in a dataset with multiple subjects will the effects of randomly-picked IDs
# become apparent.)
#
# A good random seed is truly random. Avoid using random seeds from popular
# culture, like "42", or "1337". To obtain a truly random seed, you can paste
# the following into your console:
# ``python -c "import secrets; print(secrets.randbits(31))"``
# Here, 31 bits correspond to the maximum seed "size" that the the legacy
# ``RandomState`` by NumPy, which many scientific libraries still rely on,
# can accept. For more information, see also this blog post on
# `NumPy RNG best practices <https://blog.scientific-python.org/numpy/numpy-rng/>`_.
#
# .. note::
# Passing ``random_state`` merely guarantees that subject IDs and time shift
# remain the same across anonymization runs if the original dataset
Expand All @@ -218,6 +227,6 @@
bids_root_in=bids_root,
bids_root_out=bids_root_anon,
datatypes="meg",
random_state=42,
random_state=293201004,
)
print_dir_tree(bids_root_anon)
2 changes: 1 addition & 1 deletion mne_bids/tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -3868,7 +3868,7 @@ def test_anonymize_dataset(_bids_validate, tmpdir):
bids_root_in=bids_root,
bids_root_out=bids_root_anon,
datatypes=["meg", "anat"],
random_state=42,
random_state=1442792182,
)
_bids_validate(bids_root_anon)
assert (bids_root_anon / "sub-1" / "ses-01" / "meg").exists()
Expand Down