diff --git a/doc/examples/tutorial_HD_dataset.md b/doc/examples/tutorial_HD_dataset.md index f39572bc..0e60d3f2 100644 --- a/doc/examples/tutorial_HD_dataset.md +++ b/doc/examples/tutorial_HD_dataset.md @@ -41,8 +41,9 @@ Downloading the data It's a small NWB file. ```{code-cell} ipython3 -path = "Mouse32-140822.nwb" -if path not in os.listdir("."): +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +path = os.path.join(data_dir, "Mouse32-140822.nwb") +if not os.path.exists(path): r = requests.get(f"https://osf.io/jb2gd/download", stream=True) block_size = 1024*1024 with open(path, 'wb') as f: diff --git a/doc/examples/tutorial_calcium_imaging.md b/doc/examples/tutorial_calcium_imaging.md index 396a8bcf..4f7b41bb 100644 --- a/doc/examples/tutorial_calcium_imaging.md +++ b/doc/examples/tutorial_calcium_imaging.md @@ -42,8 +42,9 @@ Downloading the data First things first: let's find our file. ```{code-cell} ipython3 -path = "A0670-221213.nwb" -if path not in os.listdir("."): +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +path = os.path.join(data_dir, "A0670-221213.nwb") +if not os.path.exists(path): r = requests.get(f"https://osf.io/sbnaw/download", stream=True) block_size = 1024*1024 with open(path, 'wb') as f: diff --git a/doc/examples/tutorial_phase_preferences.md b/doc/examples/tutorial_phase_preferences.md index 40f3c98e..757aa5f5 100644 --- a/doc/examples/tutorial_phase_preferences.md +++ b/doc/examples/tutorial_phase_preferences.md @@ -42,8 +42,9 @@ Downloading the data Let's download the data and save it locally. ```{code-cell} ipython3 -path = "Achilles_10252013_EEG.nwb" -if path not in os.listdir("."): +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +path = os.path.join(data_dir, "Achilles_10252013_EEG.nwb") +if not os.path.exists(path): r = requests.get(f"https://osf.io/2dfvp/download", stream=True) block_size = 1024 * 1024 with open(path, "wb") as f: diff --git a/doc/examples/tutorial_wavelet_decomposition.md b/doc/examples/tutorial_wavelet_decomposition.md index 46791298..e7d9d9e1 100644 --- a/doc/examples/tutorial_wavelet_decomposition.md +++ b/doc/examples/tutorial_wavelet_decomposition.md @@ -51,8 +51,9 @@ Let's download the data and save it locally jupyter: outputs_hidden: false --- -path = "Achilles_10252013_EEG.nwb" -if path not in os.listdir("."): +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +path = os.path.join(data_dir, "Achilles_10252013_EEG.nwb") +if not os.path.exists(path): r = requests.get(f"https://osf.io/2dfvp/download", stream=True) block_size = 1024 * 1024 with open(path, "wb") as f: diff --git a/doc/user_guide/02_input_output.md b/doc/user_guide/02_input_output.md index 9588ff9b..c9b584bf 100644 --- a/doc/user_guide/02_input_output.md +++ b/doc/user_guide/02_input_output.md @@ -43,9 +43,10 @@ import os import requests, math import tqdm -nwb_path = 'A2929-200711.nwb' +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +nwb_path = os.path.join(data_dir, "A2929-200711.nwb") -if nwb_path not in os.listdir("."): +if not os.path.exists(nwb_path): r = requests.get(f"https://osf.io/fqht6/download", stream=True) block_size = 1024*1024 with open(nwb_path, 'wb') as f: @@ -266,10 +267,11 @@ print(sta) import zipfile -project_path = "MyProject" +data_dir = os.environ.get("PYNAPPLE_DATA_DIR", ".") +project_path = os.path.join(data_dir, "MyProject") -if project_path not in os.listdir("."): +if not os.path.exists(project_path): r = requests.get(f"https://osf.io/a9n6r/download", stream=True) block_size = 1024*1024 with open(project_path+".zip", 'wb') as f: @@ -278,7 +280,7 @@ if project_path not in os.listdir("."): f.write(data) with zipfile.ZipFile(project_path+".zip", 'r') as zip_ref: - zip_ref.extractall(".") + zip_ref.extractall(data_dir) ```