# Exploring the CALM Brain Resource with almirah ## Load the dataset ```python from almirah import Dataset ``` ```python Dataset.options() ``` [] ```python ds = Dataset(name="calm-brain") ds.components ``` [, , ] ## Quering layouts ```python lay = ds.components[0] print(lay) len(lay.files) ``` 42652 ```python from almirah import Tag tags = Tag.options() len(tags) ``` 1589 ```python tags_names_possible = {tag.name for tag in tags} tags_names_possible ``` {'acquisition', 'datatype', 'direction', 'extension', 'run', 'sample', 'session', 'space', 'subject', 'suffix', 'task'} ```python Tag.options(name="datatype") ``` [, , , , , , , ] ```python files = lay.query(datatype="eeg") len(files) ``` 15821 ```python file = files[0] file.rel_path ``` 'sub-D0828/ses-101/eeg/sub-D0828_ses-101_task-auditoryPCP_run-01_events.json' ```python file.tags ``` {'datatype': 'eeg', 'extension': '.json', 'run': '01', 'session': '101', 'subject': 'D0828', 'suffix': 'events', 'task': 'auditoryPCP'} ## Querying databases ```python db = ds.components[2] db ``` ```python db.connect("username", "password") df = db.query(table="presenting_disorders") df[["subject", "session", "addiction"]].head() ```
subject session addiction
0 D0019 101 0
1 D0019 111 0
2 D0020 101 0
3 D0020 111 <NA>
4 D0021 101 0
## Generating summaries ```python anat_subject_tags = ds.query(returns="subject", datatype="anat") anat_subjects = {subject for t in anat_subject_tags for subject in t} len(anat_subjects) ``` 699 ```python eyetrack_subject_tags = ds.query(returns="subject", datatype="eyetrack") eyetrack_subjects = {subject for t in eyetrack_subject_tags for subject in t} len(eyetrack_subjects) ``` 1075 ```python df = db.query(table="subjects") len(df) ``` 2276 ```python df = db.query(table="modified_kuppuswamy_socioeconomic_scale") len(df) ``` 1444