File size: 2,225 Bytes
bd4a96a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
"""Download ROI flow data from HuggingFace.

Downloads the probe embedding, ROI vectors, ROI centers, and OOS manifold
points needed for ROI flow mode.

Usage:
    python scripts/download_roi_flow_data.py
"""

import os
import sys
from pathlib import Path

PROJECT_ROOT = Path(__file__).resolve().parent.parent
DATA_DIR = PROJECT_ROOT / "data" / "roi_flow"


def _fix_ssl():
    try:
        import certifi
        os.environ["SSL_CERT_FILE"] = certifi.where()
        os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
    except ImportError:
        pass


def main():
    _fix_ssl()

    try:
        from huggingface_hub import hf_hub_download
    except ImportError:
        print("huggingface_hub not installed. Install with:")
        print("  pip install huggingface_hub")
        sys.exit(1)

    REPO_ID = "Pixedar/mindVisualizer-roi-flow-data"
    FILES = [
        # Probe data
        "probe_embed.npy",
        "probe_roi.npy",
        "probe_roi_centers.npy",
        # Manifold OOS points
        "universal_soul_2sdm_rest_points.ply",
        # MDN flow field (manifold space, not brain space)
        "mdn_training_all_points.npy",
        "mdn_universal_raw_grid64_meta.json",
        "mdn_universal_all_grid64_mean_xyz3.bin",
        "mdn_universal_all_grid64_mu1_xyz3.bin",
        "mdn_universal_all_grid64_mu2_xyz3.bin",
        "mdn_universal_all_grid64_pi.bin",
        "mdn_universal_all_grid64_entropy.bin",
    ]

    DATA_DIR.mkdir(parents=True, exist_ok=True)

    for fname in FILES:
        dest = DATA_DIR / fname
        if dest.exists():
            print(f"  [skip] {fname} (already exists)")
            continue

        print(f"  Downloading {fname}...")
        try:
            downloaded = hf_hub_download(
                repo_id=REPO_ID,
                filename=fname,
                repo_type="dataset",
                local_dir=str(DATA_DIR),
            )
            print(f"  [ok] {fname}")
        except Exception as e:
            print(f"  [error] {fname}: {e}")

    print(f"\nDone! Files saved to: {DATA_DIR}")
    print("\nYou can now run ROI flow mode:")
    print("  python examples/roi_flow_mode.py")


if __name__ == "__main__":
    main()