Tutorial#
This page runs three dyads from a public hyperscanning dataset through every step of a dyadic study, from download to the cohort null tests. It takes about 25 minutes on a desktop and 1.6 GB of disk. NIRSPipe must be installed first.
The commands are written for a Mac or Linux terminal and Git Bash. In Windows PowerShell, end each continued line with a backtick (`) instead of \.
The data#
The InterGenSynchrony dataset (Moffat and Cross, OpenNeuro ds008192, CC0): adult pairs with caps over the left and right inferior frontal gyrus and temporo-parietal junction, drawing alone, drawing together twice, then a short collaborative task. The tutorial uses session 2 of dyads 1001, 1002 and 1003, 23 MB in all. Its channels.tsv files mark some channels bad, and NIRSPipe keeps those marks: the reports list them as rejected with the reason manual, beside the channels the screening rejects (Channel screening).
1. Download#
Make a working folder; every later command runs from it.
mkdir fnirs_demo
cd fnirs_demo
pip install openneuro-py
openneuro-py download --dataset ds008192 --target-dir ds008192 \
--include sub-101/ses-02 --include sub-201/ses-02 \
--include sub-102/ses-02 --include sub-202/ses-02 \
--include sub-105/ses-02 --include sub-203/ses-02
Save pairs.csv and roi.json into fnirs_demo. The first names the dyads (Pairs file), the second groups the channels into four regions (ROI mapping file).
2. Name the conditions#
The recordings mark each block with a bare number and a 1-second trigger. Rename the markers, then set every block to 300 s; each command makes one edit and writes a new copy (Editing markers).
nirspipe-prep edit-markers apply ds008192 renamed \
--participant-label 101 201 102 202 105 203 \
--rename 1:alone 2:together1 3:together2 4:collab \
1.0:alone 2.0:together1 3.0:together2 4.0:collab \
--skip-bids-validation
nirspipe-prep edit-markers apply renamed/marker_edited timed \
--participant-label 101 201 102 202 105 203 \
--set-duration 300 --skip-bids-validation
From here on the input dataset is timed/marker_edited.
3. Preprocess each person#
nirspipe timed/marker_edited derivatives participant \
--participant-label 101 201 102 202 105 203 \
--population adult --sci-threshold 0.8 \
--mode denoise \
--high-pass 0.01 --low-pass none \
--resample-sfreq 5 \
--by-condition --fc --roi-mapping roi.json \
--skip-bids-validation --nprocs 3
About 3.5 minutes. --population adult sets the cardiac and respiration bands and the DPF for adults (Population); short-channel regression runs by default, since the montage has short channels. Two settings are specific to this dataset:
Option |
Why |
|---|---|
|
The two caps of a pair recorded at slightly different rates, and the dyad analysis needs one rate |
|
Writes a report page per condition as well as per run |
Each person’s pages start at derivatives/sub-101/sub-101_desc-index_report.html.
4. Cohort page#
nirspipe timed/marker_edited derivatives group --skip-bids-validation
Writes derivatives/desc-subjects_report.html, derivatives/desc-subjects_qc.tsv, and derivatives/desc-conditions_qc.tsv with the same numbers for each condition.
5. Dyad analysis#
nirspipe-hyper derivatives hyper group \
--pairs-csv pairs.csv --desc errts --roi-mapping roi.json \
--band-fmin 0.02 --band-fmax 0.10 \
--chromophores hbo \
--wtc-phase-null 5 --isc-phase-null 100 --seed 1
About 9 minutes. Two settings only save time here. Five coherence scrambles is far too few; a study uses about 100, as the correlation does. --chromophores hbo limits both measures to HbO; without it HbO and HbR are both computed, which doubles the time. Each dyad’s pages start at hyper/group-1001/group-1001_desc-index_report.html.
Then the raw quality pages, in a tree of their own: each person’s first, then each dyad’s and the two cohort pages from those records, under two minutes:
nirspipe-qc timed/marker_edited qc participant \
--participant-label 101 201 102 202 105 203 \
--population adult --sci-threshold 0.8 \
--skip-bids-validation
nirspipe-qc timed/marker_edited qc group \
--pairs-csv pairs.csv --skip-bids-validation
Note
The members’ markers in dyads 1002 and 1003 disagree by 5 to 30 s after alignment, a fault in the recordings. Their condition results are not usable; the dyad pages list the differences under the alignment check.
6. Nulls#
The re-paired null, about 8 minutes, after which it draws each dyad’s pages again so their condition arrows read it; then the cohort test, which reads every null and chromophore the draws hold. --chromophores hbo on the first command matches the HbO-only run above; leave it out after a run with both chromophores.
nirspipe-hyper-pairnull derivatives hyper group \
--pairs-csv pairs.csv --roi-mapping roi.json --chromophores hbo
nirspipe-hyper-groupnull hyper group --task-label drawing \
--roi-mapping roi.json --seed 1
The cohort test writes hyper/task-drawing_desc-groupnull_report.html and its chromo-hbo_* tables.
7. Merge#
nirspipe-hyper-merge hyper group
What was written#
File |
What it is |
Explained in |
|---|---|---|
|
One person: every run and condition page |
|
|
All six people compared |
|
|
One dyad: coherence, correlation, nulls |
|
|
One dyad: raw quality and shared usable time |
|
|
All three dyads’ quality compared |
|
|
The cohort tests against both nulls |
|
|
Merged tables, one per kind, one row per dyad, pairing and condition |
Outputs lists every file the three trees hold.