Skip to content

Commit

Permalink
added data example and set behavior based on if on readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronearlerichardson committed Jan 10, 2024
1 parent 6e6f73e commit 48f20c9
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __call__(self, gallery_conf, fname, when):
warnings.filterwarnings("ignore", category=DeprecationWarning)
import pyvista
# if os.getenv("PYVISTA_OFF_SCREEN", "false").lower() == "true":
if True:
if os.environ.get("READTHEDOCS") == "True":
pyvista.start_xvfb()
pyvista.OFF_SCREEN = True
pyvista.BUILDING_GALLERY = True
Expand All @@ -218,6 +218,7 @@ def __call__(self, gallery_conf, fname, when):
'backreferences_dir': 'gen_modules/backreferences',
# Modules for which function/class level galleries are created. In
# this case sphinx_gallery and ieeg in a tuple of strings.
'expected_failing_examples': ['../examples/plot_data.py'],
"plot_gallery": "True",
'doc_module': ('sphinx_gallery', 'ieeg'),
"reset_modules": ("matplotlib", Resetter()), # called w/each script
Expand Down
67 changes: 67 additions & 0 deletions examples/plot_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Load IEEG Data Example
======================
This example demonstrates the discrepancy between the provided examples and the actual data loading process.
The provided examples:
1. Use `mne` library and `raw_from_layout` function to load IEEG data.
2. Use `mne` library and `read_raw` function to load IEEG data.
However, the actual data loading process involves using the `ieeg.io` module and the `get_data` and `raw_from_layout` functions.
"""

# %% Example 1
# ECoG data in BIDS file structure saved in the [BrainVision Core Data Format](https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/)
import mne
from ieeg.io import raw_from_layout
from bids import BIDSLayout
bids_root = mne.datasets.epilepsy_ecog.data_path()
layout = BIDSLayout(bids_root)
raw1 = raw_from_layout(layout, subject="pt1", preload=True, extension=".vhdr")
raw1.plot()

# %% Example 2
# SEEG data saved in the [FIF file format](https://mne.tools/stable/auto_tutorials/io/plot_20_reading_eeg_data.html#sphx-glr-auto-tutorials-io-plot-20-reading-eeg-data-py)
import mne
misc_path = mne.datasets.misc.data_path()
raw2 = mne.io.read_raw(misc_path / 'seeg' / 'sample_seeg_ieeg.fif')
raw2


# %% Actual Data Loading Process
# ECoG / SEEG data in BIDS file structure saved in the [European data format](https://www.edfplus.info/specs/edf.html)
import os
from ieeg.io import get_data, raw_from_layout

HOME = os.path.expanduser("~")
LAB_root = os.path.join(HOME, "Box", "CoganLab")
layout = get_data("SentenceRep", root=LAB_root)
subjects = layout.get(return_type="id", target="subject")

for subject in subjects:
# do stuff with each subject data
pass

print(subjects)

"""
The provided examples above do not reflect the actual data loading process used in this script.
To load the IEEG data, the following steps are taken:
1. Import the necessary modules:
- `ieeg.io` module for data loading functions.
- `os` module for file path manipulation.
2. Set the home directory and the root folder containing the BIDS formatted data.
3. Use the `get_data` function from `ieeg.io` to obtain a BIDSLayout object with the specified root folder and task name.
4. Get the list of subjects from the BIDSLayout object.
5. Iterate over each subject and perform the desired operations on the subject data.
Note: The actual code provided above is not executable as it contains placeholders and references to specific file paths on the user's computer.
"""
3 changes: 2 additions & 1 deletion examples/plot_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@

# response data points are length 201, while baseline is 200. We need to
# trim the response data to match the baseline with [..., :-1]
mask2 = stats.window_averaged_shuffle(resp._data[..., :-1], base._data, 1000)
mask2 = stats.window_averaged_shuffle(resp._data[..., :-1], base._data, 1000,
stat_func=stats.mean_diff)
plt.imshow(mask2[:, None])

0 comments on commit 48f20c9

Please sign in to comment.