Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel/2024 #3

Merged
merged 103 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
61efad6
[DATALAD] Recorded changes
bpinsard Apr 7, 2005
720b97b
[DATALAD] Recorded changes
bpinsard Apr 7, 2005
02e58da
fix fmap phase
bpinsard Apr 7, 2005
1aefce1
fix complex event files
bpinsard Apr 7, 2005
c9d726e
fill IntendedFor
bpinsard Apr 7, 2005
51abcfc
removing failed conversions
bpinsard Oct 16, 2021
5d62a6a
[DATALAD] Recorded changes
bpinsard Oct 16, 2021
1ce3c79
[DATALAD] Recorded changes
bpinsard Oct 16, 2021
d82bf6e
[DATALAD] Recorded changes
bpinsard Oct 16, 2021
0c1c784
[DATALAD] Recorded changes
bpinsard Oct 16, 2021
d7279ac
[DATALAD] Recorded changes
bpinsard Oct 16, 2021
b63c9a7
[DATALAD] removed content
bpinsard Oct 16, 2021
d0b6ad8
remove fmap phase data
bpinsard Oct 16, 2021
934bcff
fill IntendedFor of fixed sessions
bpinsard Oct 18, 2021
b675b25
Merge branch 'convert' into rel/2021
bpinsard Oct 18, 2021
4f0c982
merge events files
bpinsard Oct 18, 2021
ff7a549
update things raw ds
bpinsard Oct 18, 2021
7787d48
Custom .gitattributes
bpinsard Oct 18, 2021
5858f9a
Merge remote-tracking branch 'ria-beluga/rel/2021' into rel/2021
bpinsard Oct 18, 2021
10e6f41
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
76183bd
Merge remote-tracking branch 'ria-beluga/rel/2021' into rel/2021
bpinsard Oct 18, 2021
7ebb522
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
d84cdc2
Merge remote-tracking branch 'ria-beluga/rel/2021' into rel/2021
bpinsard Oct 18, 2021
62532d7
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
bc3c3f7
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
2254757
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
181bab9
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
be00fa8
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
9453730
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
0b706d7
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
0317528
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
11c7b01
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
971e906
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
b8a4a92
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
46fdd25
[DATALAD] Recorded changes
bpinsard Oct 18, 2021
908265c
remove part-phase epi fieldmaps
bpinsard Oct 18, 2021
d9af195
fill IntendedFor of new sessions
bpinsard Nov 5, 2021
72c587a
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
550496a
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
ee02239
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
3c721fc
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
ff0da1b
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
7f77152
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
1d9217a
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
013e866
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
7a64100
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
d266506
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
95d5a24
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
7af9308
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
cdb3fe0
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
b3035dc
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
2f02a1a
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
ab6ebda
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
b0e0ba1
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
2daf1e7
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
0284a11
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
d350116
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
6c7545b
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
391c27b
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
e6432a7
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
97afbab
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
03f17b8
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
8af4fb1
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
231e8c5
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
c993c80
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
2ff53a9
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
ea2e241
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
a4dabf9
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
26a54bd
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
14ba393
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
7d03441
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
7ff8bb9
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
ea46e39
[DATALAD] Recorded changes
bpinsard Nov 5, 2021
68abaaf
fill IntendedFor for new sessions
bpinsard Apr 4, 2022
211733a
update temp files
bpinsard Apr 4, 2022
c842593
fix fmap phase
bpinsard Apr 4, 2022
2f9c65d
[DATALAD] Recorded changes
bpinsard Apr 4, 2022
3d57cc7
[DATALAD] Recorded changes
bpinsard Apr 4, 2022
5a2b0da
[DATALAD] Recorded changes
bpinsard Apr 4, 2022
c07812e
fix session zero padding from acquisition error
bpinsard Apr 4, 2022
ff475f1
fill IntendedFor
bpinsard Apr 4, 2022
a0ed6a8
fix fmap phase
bpinsard Apr 4, 2022
fab136e
remove individual scans.json
bpinsard Apr 6, 2022
23bc101
[DATALAD] Recorded changes
bpinsard Apr 6, 2022
b9b6da9
[DATALAD] removed content
bpinsard Apr 6, 2022
e0cf256
[DATALAD] removed content
bpinsard Apr 6, 2022
fad74f1
[DATALAD] Recorded changes
bpinsard Apr 6, 2022
f5de2b7
[DATALAD] removed content
bpinsard Apr 6, 2022
add722b
fix fmap phase
bpinsard Apr 6, 2022
b7a381f
fill IntendedFor
bpinsard Apr 8, 2022
0e58f38
[DATALAD] Added subdataset
bpinsard Apr 8, 2022
7188314
[DATALAD] removed content
bpinsard Apr 8, 2022
4495b29
add remaining sessions events files
bpinsard Apr 8, 2022
aa22882
Merge remote-tracking branch 'ria-beluga/rel/2021' into rel/2021
bpinsard Apr 8, 2022
7299432
merge events
bpinsard Nov 10, 2022
6d176ac
Merge branch 'p06_things08' into rel/2021
bpinsard Nov 10, 2022
2f8c996
Merge remote-tracking branch 'ria-sequoia/rel/2021' into rel/2021
bpinsard Nov 10, 2022
8462962
import fixed+enriched events and eyetracking data
bpinsard Nov 10, 2022
1dd489f
bidsignore some stuffs
bpinsard Nov 29, 2024
696abcd
fix bids
bpinsard Nov 29, 2024
5195d36
updated events.tsv column and added code
MarieStLaurent Nov 29, 2024
b1ea36a
stimuli submodule to zipped_img branch
MarieStLaurent Jan 11, 2025
ab8ea8c
Merge pull request #4 from courtois-neuromod/rel/2024_dev
MarieStLaurent Jan 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .bidsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/anat/*localizer*
**/anat/*scout*
**/*_dup*
**/*_eyetrack*
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.json annex.largefiles=nothing
*.txt annex.largefiles=nothing
*.tsv annex.largefiles=nothing
*events.tsv annex.largefiles=anything
*.nii.gz annex.largefiles=anything
*.tgz annex.largefiles=anything
*_scans.tsv annex.largefiles=anything
*_scans.tsv annex.largefiles=anything
*.tsv.gz annex.largefiles=anything
29 changes: 29 additions & 0 deletions .github/workflows/bids-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# run bids validator on datalad BIDS dataset
name: bids-validator

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
bids-validator:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Run bids-validator
run: docker run -v $GITHUB_WORKSPACE:/bids bids/validator --remoteFiles --ignoreSymlinks --config.ignore=43 /bids
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[submodule "stimuli"]
path = stimuli
url = [email protected]:courtois-neuromod/things.stimuli.git
datalad-id = 5504289b-0ac5-4f7c-a6cd-86af1f5c2135
datalad-url = [email protected]:courtois-neuromod/things.stimuli.git
127 changes: 127 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
THINGS events.tsv and eye-tracking analyses
===========================================

# Events.tsv files validation & correction

``cleanup/clean_events.py`` processes raw ``*events.tsv`` files outputted by Psychopy to validate and correct (if necessary) the condition, subcondition and accuracy metrics, based on the images previously shown to a participant throughout the multi-session task. The script also computes the duration of delays between image repetitions (in days for between-session repeats, and in seconds for within-session repeats).

The raw input data processed by this script contains scan dates, which are subject identifiers. For confidentiality, they cannot be released publicly in this repository. Nevertheless, the script is provided as a reference.

The file ``qc_notes.md`` contains additional details about any issue with the experiment and how it was resolved.

**Input**:
- A subject's raw ``*events.tsv`` files, across sessions (~36) and runs (6 per session), identified by scan date. E.g., ``sub-01_ses-012_202*****-******_task-thingsmemory_run-2_events.tsv``
- A subject's ``sub-*_scandates.txt`` file, a text file that lists all sessions and their date of acquisition.
- A subject's raw ``*.log`` files outputted by Psychopy, with logged timestamps per trial (note that a session can produce multiple log files if psychopy was stopped and relauched). E.g., ``sub-01_ses-012_202xxxxx-xxxxxx.log``
- If needed: a subject's ``sub-*_ses-*_202xxxxx-xxxxxx.pupil/task-thingsmemory_run-*/000/eye0_timestamps.npy`` eyetracking timestamp files to derive onset trial-wise onset times within each run.

**Output**:
- De-identified, validated and updated ``*events.tsv`` files (to be released). Columns and their values are described in ``cneuromod-things/THINGS/fmriprep/sourcedata/things/task-things_events.json``
- ``sub-*_desc-run_errorReport.txt``, a text file that lists every run for which there is no psychopy log file (in those cases, trialwise timestamps are estimated from eyetracking data), or for which atypical entries (needing corrections) were flagged.
- ``sub-*_desc-trial_errorReport.txt``, a text file that lists every trial for which a correction was made (e.g., to the repetition number, condition, subcondition or accuracy) due to a deviation from the pre-planned protocol (e.g., a session was administered out of order).
- ``sub-*_task-things_concatTrials.tsv``, a temp file that concatenates all trials across sessions, for QCing (cannot be released because it contains scanning dates).

--------------------

# Eye-tracking data processing

The steps below compile, drift correct and analyze eye-tracking data collected while participants completed the THINGS task. Data were acquired with a custom pipeline that integrated [Pupil Lab](https://pupil-labs.com/)'s open source software with [PsychoPy](https://www.psychopy.org/).

Note that data processed during Steps 1 to 3 contain identifiers (e.g., scan dates, movies of the subject's eye ``eye0.mp4``). To protect confidentiality, these files cannot be released publicly in the current repository. However, the scripts used to process the raw data for these steps are provided as a reference.


## Step 1. Export and QC gaze data

**1.1 Extract gaze data from Pupil Labs files and produce charts for QCing**

The script ``eyetracking/step1_eyetrack_prep.py``:
- compiles an overview of available eyetracking files (``pupils.pldata``, ``gaze.pldata`` and ``eye0.mp4``, which are exported by the pupil software, and Psychopy log files) and exports a list of existing files (``file_list.tsv``).
- exports gaze data from Pupil Labs files (``gaze.pldata``) to ``.npz``
- generates plots of gaze and pupil positions over time (per run) to QC the data (e.g., flag camera freezes, missing pupils, excessive drift, etc)

To run, the script requires CNeuroMod's forked version of the Pupil software repository ([link](https://github.com/courtois-neuromod/pupil/tree/gigevision_rebase), commit ``dd26b6a``) to be installed as a sub-module, as well as dependencies specified in the repo's README and requirements.txt.

**Input**:
- ``*events.tsv`` files across sessions (~36) and runs (6 per session), identified by scan date. E.g., ``sub-01_ses-012_202*****-******_task-thingsmemory_run-2_events.tsv``
- ``sub-*_ses-*_2021xxxx-xxxxxx.log`` files outputted by Psychopy
- ``sub-*_ses-*_2021xxxx-xxxxxx.pupil`` directories with ``pupil.pldata``, ``eye0.mp4`` and ``gaze.pldata`` files

**Output**:
- ``sub-*_ses-*_run-*_2021xxxx-xxxxxx_task-thingsmemory_gaze2D.npz``, timestamped gaze and pupil position (uncorrected for drift) per run.
- ``sub-*_ses-*_run-*_2021xxxx-xxxxxx_task-thingsmemory_QCplot.png``, a series of charts of uncorrected gaze and pupil position plotted over time in x and y.
- ``file_list.tsv``, a compilation of existing eye-tracking files per run for the entire dataset.


**1.2 Offline manual quality check**

Assess the quality of each run by reviewing the graphs generated in Step 1, and
compile a list of clean runs to apply gaze drift correction (in Step 2).

Open ``file_list.tsv`` (created in Step 1) as a spreadsheet, and enter QC info:
- Add columns ``no_pupil_data``, ``DO_NOT_USE``, ``pupilConf_thresh``, ``Pass_DriftCorr``, ``Fails_DriftCorr`` and ``notes``
- Enter "1" under "no_pupil_data" for runs without eye-tracking data
- Enter "1" under "DO_NOT_USE" for runs to be excluded (corrupt/no data)
- Detail any issue under "notes" (e.g., gaps, drifts, low confidence data...)

Save this spreadsheet as ``QCed_file_list.tsv`` in the ``QC_gaze`` directory created inside the specified output directory by ``eyetracking/step1_eyetrack_prep.py``. Note that some runs might require the pupil confidence threshold to be lowered below the default (0.9). In ``QCed_file_list.tsv``, enter the new confidence threshold parameter under ``pupilConf_thresh`` [0.0-1.0] for that run.


## Step 2. Drift correction

**2.1 Adjust gaze drift correction parameters (iterative process)**

This step corrects drift and exports plots of drift-corrected gaze to perform quality checks.

The script ``eyetracking/step2_eyetrack_prep.py`` performs drift correction on runs of gaze data according to parameters specified in ``QCed_file_list.tsv`` (created in Step 1.2), and generates charts of uncorrected and corrected gaze positions over time to help flag runs that fail drift correction.

It can be ran for multiple iterations, adjusting parameters like confidence threshold (``pupilConf_thresh``) per run in ``QCed_file_list.tsv`` and reviewing the charts of drift-corrected gaze until runs are considered well-corrected or beyond fixing.

Compile a final list of runs to drift-correct and export in a bids-compliant format: in ``QCed_file_list.tsv``, enter ``1`` under ``Fails_DriftCorr`` or ``Pass_DriftCorr``, depending. Save this final list as ``QCed_finalbids_list.tsv`` in the ``QC_gaze`` directory (inside the specified output directory).


**Input**:
- ``QCed_file_list.tsv``, a working list of runs to drift correct.
- ``sub-*_ses-*_run-*_2021xxxx-xxxxxx_task-thingsmemory_gaze2D.npz``, timestamped gaze and pupil position (uncorrected for drift) per run.
- ``info.player.json`` files to derive run onset time.
- ``*events.tsv`` files across sessions (~36) and runs (6 per session), identified by scan date. E.g., ``sub-01_ses-012_202*****-******_task-thingsmemory_run-2_events.tsv``
- ``sub-*_ses-*_2021xxxx-xxxxxx.log`` files outputted by PsychoPy

**Output**:
- ``sub-*_ses-*_run-*_2021xxxx-xxxxxx_task-thingsmemory_DCplot.png``, a series of charts of corrected gaze and pupil position plotted over time in x and y.


**2.2 Export drift corrected gaze and eye-tracking metrics**

Re-run the ``eyetracking/step2_eyetrack_prep.py`` script one last time, this time adding the ``--is_final`` flag as an argument.

The script:
- performs drift correction on runs of gaze data according to parameters specified in ``QCed_finalbids_list.tsv``
- exports gaze and pupil metrics in bids-compliant format (``.tsv.gz``), according to proposed [bids extension guidelines](https://bids-specification--1128.org.readthedocs.build/en/1128/modality-specific-files/eye-tracking.html#sidecar-json-document-eyetrackjson)
- exports ``*events.tsv`` files with added trial-wise metrics of fixation compliance.

**Input**:
- ``QCed_finalbids_list.tsv``, a finalized list of runs to drift correct.
- ``sub-*_ses-*_run-*_2021xxxx-xxxxxx_task-thingsmemory_gaze2D.npz``, timestamped gaze and pupil position (uncorrected for drift) per run.
- ``info.player.json`` files to derive run onset time.
- ``*events.tsv`` files across sessions (~36) and runs (6 per session), identified by scan date. E.g., ``sub-01_ses-012_202*****-******_task-thingsmemory_run-2_events.tsv``
- ``sub-*_ses-*_2021xxxx-xxxxxx.log`` files outputted by PsychoPy

**Output**:
- ``sub-*_ses-*_2021xxxx-xxxxxx_task-thingsmemory_run-*_events.tsv``, ``events.tsv`` files with added fixation compliance metrics.
- ``sub-*_ses-*_task-things_run-*_eyetrack.tsv.gz``, BIDs compliant eye-tracking data, including timestamped pupil and gaze position (uncorrected and drift-corrected).


## Step 3. Reconcile events.tsv files

The script ``eyetracking/step3_reconcile_events.py`` reconciles two sets of ``events.tsv`` files. It extracts the trial-wise eye-tracking metrics added to events.tsv files (from Step 2.2), and inserts these metrics into the validated and cleaned up events.tsv files that contain additional behavioural metrics (those produced with the ``cleanup/clean_events.py`` script).

Note that a handful of ``raw events.tsv`` files required manual relabelling to be properly associated with their validated file (e.g., ``sub-06``'s ``ses-020`` was accidentally ran and saved under sub-01), so this step is not fully automated.

The fixation compliance metrics included in the output ``events.tsv`` files are described in ``cneuromod-things/THINGS/fmriprep/sourcedata/things/task-things_events.json``


**Input**:
- ``sub-*_ses-*_2021xxxx-xxxxxx_task-thingsmemory_run-*_events.tsv``, ``events.tsv`` files with added fixation compliance metrics.

**Output**:
- ``sub-*_ses-*_task-things_run-*_events.tsv``, validated ``events.tsv`` files with added behavioural and fixation compliance metrics.
Loading
Loading