|
634 | 634 | " else '/tmp/mne_data'\n" |
635 | 635 | ")\n" |
636 | 636 | "os.makedirs(mne_data_path, exist_ok=True)\n" |
| 637 | + "if mne_data_path == '/tmp/mne_data':\n" |
| 638 | + " from pyodide.http import pyfetch\n" |
| 639 | + " sample_dir = os.path.join(mne_data_path, 'MNE-sample-data')\n" |
| 640 | + " for req in [\n" |
| 641 | + " 'version.txt',\n" |
| 642 | + " 'MEG/sample/sample_audvis_raw.fif',\n" |
| 643 | + " 'MEG/sample/sample_audvis_filt-0-40_raw.fif',\n" |
| 644 | + " 'MEG/sample/sample_audvis_raw-eve.fif',\n" |
| 645 | + " 'MEG/sample/sample_audvis-ave.fif',\n" |
| 646 | + " 'MEG/sample/sample_audvis-cov.fif',\n" |
| 647 | + " 'MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif',\n" |
| 648 | + " 'MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif',\n" |
| 649 | + " 'subjects/sample/mri/T1.mgz',\n" |
| 650 | + " 'subjects/sample/bem/sample-oct-6-src.fif',\n" |
| 651 | + " 'subjects/sample/bem/sample-5120-5120-5120-bem-sol.fif',\n" |
| 652 | + " 'subjects/sample/surf/rh.pial',\n" |
| 653 | + " 'subjects/sample/surf/lh.pial',\n" |
| 654 | + " ]:\n" |
| 655 | + " dest = os.path.join(sample_dir, req)\n" |
| 656 | + " if not os.path.exists(dest):\n" |
| 657 | + " os.makedirs(os.path.dirname(dest), exist_ok=True)\n" |
| 658 | + " try:\n" |
| 659 | + " res = await pyfetch(\n" |
| 660 | + " f'../files/mne_data/MNE-sample-data/{req}'\n" |
| 661 | + " )\n" |
| 662 | + " with open(dest, 'wb') as f:\n" |
| 663 | + " f.write(await res.bytes())\n" |
| 664 | + " except Exception as e:\n" |
| 665 | + " print(f'Failed to fetch {req}: {e}')\n" |
637 | 666 | "os.environ['MNE_DATA'] = mne_data_path\n" |
638 | 667 | "os.environ['MNE_DATASETS_SAMPLE_PATH'] = mne_data_path\n" |
639 | 668 | "\n" |
|
0 commit comments