Parcourir la source

create participants.tsv by running highspeed_bids_participants.m

Lennart Wittkuhn il y a 4 ans
Parent
commit
89aeeeb6dd
3 fichiers modifiés avec 44 ajouts et 11 suppressions
  1. 28 1
      code/docs/highspeed-bids-docs.Rmd
  2. 15 9
      code/events/highspeed-bids-participants.m
  3. 1 1
      participants.tsv

+ 28 - 1
code/docs/highspeed-bids-docs.Rmd

@@ -193,9 +193,36 @@ To detect the provencance of the run command in our DataLad dataset, we run:
 
 ```bash
 datalad run -m "create IntendedFor fields in fieldmap .json files" \
---input "./*/*/*/*.nii.gz" --output "./*/*/fmap/*.json" \ "python3 code/code/bids_conversion/highspeed_bids_fieldmaps.py ."
+--input "./*/*/*/*.nii.gz" --output "./*/*/fmap/*.json" \ "python3 code/code/bids_conversion/highspeed_bids_fieldmaps.py"
 ```
 
 ```{python, echo=TRUE, code=readLines(file.path(path_root, "code", "bids_conversion", "highspeed-bids-fieldmaps.py")), eval=FALSE, python.reticulate=FALSE}
 ```
 
+#### Creating the `participants.tsv` and `participants.json` files
+
+According to the [BIDS specification, version 1.1.0](https://bids.neuroimaging.io/bids_spec1.1.0.pdf) ...
+
+> [...] the purpose of this file is to describe properties of participants such as age, handedness, sex, etc. In case of single session studies this file has one compulsory column participant_id that consists of sub-<participant_label> , followed by a list of optional columns describing participants. Each participant needs to be described by one and only one row.
+
+In our case, this information was saved in the original behavioral data files that were created when participants performed the task during scanning.
+
+To extract this information from the behavioral files into the `participants.tsv` file we use the `code/events/highspeed_bids_participants.m` file.
+Since wrapping the execution of this script into a `datalad` run command appeared challenging, we just ran the script with paths not self-contained and just saved the changes in files.
+
+First, we had to unlock the `participants.tsv` file using `datalad unlock participants.tsv`
+
+The we ran `highspeed_bids_participants.m` using MATLAB version R2017b and saved the changes using `datalad save`.
+
+```{octave, echo=TRUE, code=readLines(file.path(path_root, "code", "events", "highspeed_bids_participants.m")), eval=FALSE}
+```
+
+Finally, we create the `participants.json` file using:
+```bash
+datalad run -m "create participants.json" \
+--output "participants.json" \
+"python3 code/bids_conversion/highspeed-bids-participants.py"
+```
+
+```{python, echo=TRUE, code=readLines(file.path(path_root, "code", "bids_conversion", "highspeed-bids-participants.py")), eval=FALSE, python.reticulate=FALSE}
+```

+ 15 - 9
code/events/highspeed-bids-participants.m

@@ -1,18 +1,22 @@
 %% HIGHSPEED: GET DATA OF THE HIGHSPEED TASK
 clear variables; clc; % clear workspace and command window
 
-path_base = '/Volumes/MPRG-Neurocode/Data/highspeed/main_mri/rawdata/';
-path_input = fullfile(path_base, 'behav_main');
-path_tardis = fullfile('/Users/wittkuhn/Volumes/tardis/highspeed');
-path_output = fullfile(path_tardis, 'bids');
-path_digitspan = fullfile(path_base, 'digit_span');
-allID = dlmread('/Users/wittkuhn/highspeed/highspeed_analysis/code/parameters/highspeed_participant_list.txt');
+path_base = strsplit(pwd,'code');
+path_base = path_base{1};
+path_input = fullfile(path_base, 'input', 'behavior', 'main');
+path_output = path_base;
+path_digitspan = fullfile(...
+    path_base, 'input', 'behavior', 'digitspan');
+allID = dlmread(fullfile(...
+    path_base, 'code', 'heudiconv', 'highspeed-participant-list.txt'));
 num_subs = length(allID);
 
 % get data
 dirData = dir(path_input);
 dirData = {dirData.name};
-dataFiles = dirData(contains(dirData,'session_1_run_4') & contains(dirData,cellstr(num2str(allID)))); % search for matching files
+dataFiles = dirData(...
+    contains(dirData,'session_1_run_4') & ...
+    contains(dirData,cellstr(num2str(allID))));
 
 covariates = table;
 covariates.participant_id = cell(num_subs,1);
@@ -63,9 +67,11 @@ for sub = 1:num_subs
 end
 
 % WRITE  DATA
-writetable(covariates,fullfile(path_output,'participants.csv'),'Delimiter','\t','WriteRowNames',true,...
+writetable(covariates,fullfile(path_output,'participants.csv'), ...
+    'Delimiter','\t','WriteRowNames',true, ...
     'QuoteStrings',true,'WriteVariableNames',true)
-copyfile(fullfile(path_output,'participants.csv'), fullfile(path_output,'participants.tsv'));
+copyfile(fullfile(path_output,'participants.csv'), ...
+    fullfile(path_output,'participants.tsv'));
 delete(fullfile(path_output,'participants.csv'));
 
 

+ 1 - 1
participants.tsv

@@ -1 +1 @@
-.git/annex/objects/Mz/mK/MD5E-s809--7198fa6dc6d326e1800e49406726c8fd.tsv/MD5E-s809--7198fa6dc6d326e1800e49406726c8fd.tsv
+.git/annex/objects/MF/XK/MD5E-s1329--62b253c643b56757532914de40a7a4cc.tsv/MD5E-s1329--62b253c643b56757532914de40a7a4cc.tsv