src.canns.data¶
Data utilities for CANNs.
This module provides dataset management, loading, and downloading utilities. It consolidates data-related functionality previously scattered across the codebase.
Submodules¶
Attributes¶
Functions¶
|
Download a specific dataset. |
Get the data directory, creating it if necessary. |
|
|
Get path to a dataset, downloading/setting up if necessary. |
Get guide for uploading datasets to Hugging Face. |
|
List available datasets with descriptions. |
|
|
Universal data loading function that downloads and reads data from URLs. |
|
Load grid cell data for 2D CANN analysis. |
|
Load ROI data for 1D CANN analysis. |
Quick setup function to get datasets ready. |
Package Contents¶
- src.canns.data.get_dataset_path(dataset_key, auto_setup=True)[source]¶
Get path to a dataset, downloading/setting up if necessary.
- src.canns.data.get_huggingface_upload_guide()[source]¶
Get guide for uploading datasets to Hugging Face.
- Returns:
Upload guide text.
- Return type:
- src.canns.data.load(url, cache_dir=None, force_download=False, file_type=None)[source]¶
Universal data loading function that downloads and reads data from URLs.
- Parameters:
url (str) – URL to download data from.
cache_dir (str or Path, optional) – Directory to cache downloaded files. If None, uses temporary directory.
force_download (bool) – Force re-download even if file exists in cache.
file_type (str, optional) – Force specific file type (‘text’, ‘numpy’, ‘json’, ‘pickle’, ‘hdf5’). If None, auto-detect from file extension.
- Returns:
Loaded data.
- Return type:
Any
Examples
>>> # Load numpy data >>> data = load('https://example.com/data.npz') >>> >>> # Load text data with custom cache >>> data = load('https://example.com/data.txt', cache_dir='./cache') >>> >>> # Force specific file type >>> data = load('https://example.com/data.bin', file_type='numpy')
- src.canns.data.load_grid_data(source=None, dataset_key='grid_1')[source]¶
Load grid cell data for 2D CANN analysis.
- Parameters:
- Returns:
Dictionary containing spike data and metadata if successful, None otherwise. Expected keys: ‘spike’, ‘t’, and optionally ‘x’, ‘y’ for position data.
- Return type:
dict or None
Examples
>>> # Load default dataset >>> grid_data = load_grid_data() >>> >>> # Load from URL >>> grid_data = load_grid_data('https://example.com/grid_data.npz') >>> >>> # Load specific default dataset >>> grid_data = load_grid_data(dataset_key='grid_2')
- src.canns.data.load_roi_data(source=None)[source]¶
Load ROI data for 1D CANN analysis.
- Parameters:
source (str, Path, or None) – Data source. Can be: - URL string: downloads and loads from URL - Path: loads from local file - None: uses default CANNs dataset
- Returns:
ROI data array if successful, None otherwise.
- Return type:
ndarray or None
Examples
>>> # Load default dataset >>> roi_data = load_roi_data() >>> >>> # Load from URL >>> roi_data = load_roi_data('https://example.com/roi_data.txt') >>> >>> # Load from local file >>> roi_data = load_roi_data('./my_roi_data.txt')