|
| 1 | +# NEMAR Tools |
| 2 | + |
| 3 | +Tools for discovering and exploring EEG, MEG, and iEEG datasets formatted according to the Brain Imaging Data Structure (BIDS) from the NeuroElectroMagnetic Archive (NEMAR). |
| 4 | + |
| 5 | +NEMAR hosts hundreds of BIDS-formatted neuroscience datasets sourced from [OpenNeuro](https://openneuro.org/), covering various experimental paradigms and recording modalities. These tools query the NEMAR public API to help researchers find datasets matching their research interests. |
| 6 | + |
| 7 | +## Dataset Search |
| 8 | + |
| 9 | +### `search_nemar_datasets` |
| 10 | + |
| 11 | +Search NEMAR datasets with flexible text search and filtering. Fetches all datasets from the NEMAR API and filters client-side, returning compact summaries suitable for browsing. |
| 12 | + |
| 13 | +**Parameters:** |
| 14 | + |
| 15 | +| Parameter | Type | Description | |
| 16 | +|-----------|------|-------------| |
| 17 | +| `query` | string | Text search across dataset names, tasks, README, and authors (case-insensitive substring match) | |
| 18 | +| `modality_filter` | string | Filter by recording modality: `"EEG"`, `"MEG"`, `"iEEG"`, `"MRI"` (partial match, case-insensitive) | |
| 19 | +| `task_filter` | string | Filter by experimental task name, e.g. `"rest"`, `"gonogo"`, `"memory"` (partial match, case-insensitive) | |
| 20 | +| `has_hed` | boolean | If `true`, only return datasets with Hierarchical Event Descriptors (HED) annotations | |
| 21 | +| `min_participants` | int | Minimum number of participants required | |
| 22 | +| `limit` | int | Maximum results to return (default: 20, capped at 50) | |
| 23 | + |
| 24 | +**Example:** |
| 25 | + |
| 26 | +```python |
| 27 | +from src.assistants.nemar.tools import search_nemar_datasets |
| 28 | + |
| 29 | +# Find EEG datasets related to attention with at least 20 participants |
| 30 | +result = search_nemar_datasets.invoke({ |
| 31 | + "query": "attention", |
| 32 | + "modality_filter": "EEG", |
| 33 | + "min_participants": 20 |
| 34 | +}) |
| 35 | + |
| 36 | +# Find all datasets with HED annotations |
| 37 | +result = search_nemar_datasets.invoke({ |
| 38 | + "has_hed": True |
| 39 | +}) |
| 40 | +``` |
| 41 | + |
| 42 | +**Returns:** Formatted markdown string with matching dataset summaries, each showing dataset ID, name, modalities, tasks, participant count, and size. When no matches are found, returns a message listing the active filters and total dataset count. |
| 43 | + |
| 44 | +### `get_nemar_dataset_details` |
| 45 | + |
| 46 | +Get comprehensive metadata for a specific NEMAR dataset, including description, citation, licensing, experimental details, and README content. |
| 47 | + |
| 48 | +**Parameters:** |
| 49 | + |
| 50 | +| Parameter | Type | Description | |
| 51 | +|-----------|------|-------------| |
| 52 | +| `dataset_id` | string | Dataset identifier in the format `ds` followed by 4-6 digits (e.g. `"ds000248"`, `"ds005697"`) | |
| 53 | + |
| 54 | +**Example:** |
| 55 | + |
| 56 | +```python |
| 57 | +from src.assistants.nemar.tools import get_nemar_dataset_details |
| 58 | + |
| 59 | +result = get_nemar_dataset_details.invoke({ |
| 60 | + "dataset_id": "ds000248" |
| 61 | +}) |
| 62 | +``` |
| 63 | + |
| 64 | +**Returns:** Formatted markdown string with complete dataset information including: |
| 65 | + |
| 66 | +- OpenNeuro and NEMAR links |
| 67 | +- DOI and citation information |
| 68 | +- Authors, license, and BIDS version |
| 69 | +- Data characteristics (modalities, tasks, participants, sessions, file count, size, age range) |
| 70 | +- HED annotation status and version |
| 71 | +- Latest snapshot version |
| 72 | +- References, funding, acknowledgements, and how-to-acknowledge guidance |
| 73 | +- README content (truncated to 1500 characters for long entries) |
| 74 | + |
| 75 | +## Implementation Notes |
| 76 | + |
| 77 | +- The NEMAR API has no server-side search capability, so `search_nemar_datasets` fetches all datasets (~485) and filters client-side |
| 78 | +- Results are cached with a 5-minute TTL to avoid repeated API calls |
| 79 | +- The API endpoint is `https://nemar.org/api/dataexplorer/datapipeline` |
| 80 | +- Dataset IDs must match the pattern `ds` + 4-6 digits (validated before API calls) |
| 81 | + |
| 82 | +## External APIs |
| 83 | + |
| 84 | +| Service | Endpoint | Purpose | |
| 85 | +|---------|----------|---------| |
| 86 | +| NEMAR API | `https://nemar.org/api/dataexplorer/datapipeline/records` | Fetch all datasets for search | |
| 87 | +| NEMAR API | `https://nemar.org/api/dataexplorer/datapipeline/datasetid` | Fetch single dataset details | |
| 88 | + |
| 89 | +## Related Links |
| 90 | + |
| 91 | +- [NEMAR homepage](https://nemar.org) |
| 92 | +- [NEMAR Data Explorer](https://nemar.org/dataexplorer) |
| 93 | +- [OpenNeuro](https://openneuro.org/) (source platform for all NEMAR datasets) |
| 94 | +- [BIDS Specification](https://bids-specification.readthedocs.io/) (format standard for all NEMAR datasets) |
0 commit comments