Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/workflows/run_tests_narps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: "matlab: narps dataset"

on:

push:
branches:
- main
- dev
pull_request:
branches: ["*"]

# to trigger update manually from the Action tab in github
workflow_dispatch:
inputs:
log:
description: "run tests manually"
required: false

jobs:

cache_test_data:

runs-on: ubuntu-22.04

steps:
- name: "Make cachedir"
run: |
mkdir -p /tmp/.cache/data && \
chmod 777 /tmp/.cache/data

- name: Set git ID
run: |
git config --global user.name 'bipdsm GH-Action User' && \
git config --global user.email 'remi_gau@hotmail.com'

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
shell: bash -l {0}
run: |
sudo apt-get update -y
sudo apt-get install -y git-annex
python -m pip install --upgrade pip
pip install datalad

- name: Datalad WTF
run: |
datalad wtf

- name: Install cached data
uses: actions/cache@v3
id: cache
with:
path: /tmp/.cache/data
key: ds001734-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
ds001734-${{ github.ref_name }}-
ds001734-

- name: "Install raw and fMRIPrep derivatives of ds001734"
run: |
cd /tmp/.cache/data
datalad install ///openneuro/ds001734
datalad install ///openneuro-derivatives/ds001734-fmriprep
cd ds001734-fmriprep && \
datalad get sub-00[1-4]/anat/*MNI152NLin2009cAsym*mask.nii.gz \
sub-00[1-4]/anat/*MNI152NLin2009cAsym*T1w.nii.gz \
sub-00[1-4]/func/*MNI152NLin2009cAsym*desc-preproc*bold.nii.gz \
sub-*/func/*tsv \
sub-*/func/*json
datalad status

tests_matlab:

needs: [cache_test_data]

runs-on: ubuntu-22.04

steps:

- name: Clone bidspm
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0

- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1.2.3
with:
# MATLAB release to set up R2020a
release: R2020a

- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install validators
run: make install

- name: Install SPM
run: |
git clone https://github.com/spm/spm12.git --depth 1

- name: Copy Macs toolbox to SPM inputs_folder
run: cp -rv lib/MACS spm12/toolbox/MACS

- name: Run commands
uses: matlab-actions/run-command@v1.1.2
with:
command: |
root_dir = getenv('GITHUB_WORKSPACE');
fprintf('\nroot dir is %s\n', root_dir);
addpath(fullfile(root_dir, 'spm12'));
cd(fullfile(root_dir, 'demos', 'openneuro'));
run ds001734_run;
50 changes: 50 additions & 0 deletions .github/workflows/test_narps.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%
% Analysis of the NARPS dataset
%
% (C) Copyright 2022 bidspm developers

clear;
clc;

root_dir = getenv('GITHUB_WORKSPACE');

addpath(fullfile(pwd, '..', '..'));
bidspm();

% The directory where the data are located
bids_dir = '/tmp/.cache/data/ds001734';
fmriprep_dir = '/tmp/.cache/data/ds001734-fmriprep';
output_dir = fullfile(root_dir, 'outputs', 'ds001734', 'derivatives');

subject_label = {'001', '002', '003', '004'};
task = {'MGT'};
space = {'MNI152NLin2009cAsym'};

bidspm(fmriprep_dir, output_dir, 'subject', ...
'action', 'smooth', ...
'participant_label', subject_label, ...
'task', task, ...
'space', space, ...
'fwhm', 8);

%% Statistics

preproc_dir = fullfile(root_dir, 'outputs', 'ds001734', 'derivatives', 'bidspm-preproc');
model_file = fullfile(returnRootDir, ...
'demos', ...
'openneuro', ...
'models', ...
'model-narps_desc-U26C_smdl.json');

%% Subject level analysis

bidspm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', subject_label, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'ignore', {'slice_timing'}, ...
'skip_validation', true, ...
'verbosity', 0, ...
'space', space, ...
'fwhm', 8);
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# General
.DS_Store

Expand All @@ -9,6 +7,7 @@
*.html
*.ps

new_events.tsv

tmp

Expand Down
11 changes: 11 additions & 0 deletions demos/openneuro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ data_ds001168:
cd inputs && datalad install ///openneuro/ds001168
cd inputs/ds001168 && datalad get ds001168/sub-0[12]

data_ds001734:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds001734
cd inputs && datalad install ///openneuro-derivatives/ds001734-fmriprep
cd inputs/ds001734-fmriprep && datalad get sub-00[1]/anat/*MNI152NLin2009cAsym*mask.nii.gz
cd inputs/ds001734-fmriprep && datalad get sub-00[1]/anat/*MNI152NLin2009cAsym*T1w.nii.gz
cd inputs/ds001734-fmriprep && datalad get sub-00[1]/func/*MNI152NLin2009cAsym*desc-preproc*bold.nii.gz
cd inputs/ds001734-fmriprep && datalad get sub-*/func/*tsv
cd inputs/ds001734-fmriprep && datalad get sub-*/func/*json


data_ds002799:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds002799
Expand Down
46 changes: 42 additions & 4 deletions demos/openneuro/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Demos based on openneuro datasets

- ds000001: one task, one session, several runs
- ds000114: several tasks, several sessions,
one or several runs depending on task
- ds000114: several tasks, several sessions, one or several runs depending on
task
- ds001168: resting state, several sessions, several acquisition, fieldmaps,
physio data
- ds002799: resting state and task, several sessions, with fmriprep data
Expand All @@ -15,8 +15,8 @@ All those data can be installed with
Datalad datasets can be accessed via their siblings on:
https://github.com/OpenNeuroDatasets

Check the content of the `Makefile` to see the code snippets you need to run
to install those datasets.
Check the content of the `Makefile` to see the code snippets you need to run to
install those datasets.

Otherwise you can also get them by using the Datalad superdataset.

Expand All @@ -31,3 +31,41 @@ cd openneuro/dsXXXXXX
# get rest data first subject
datalad get /openneuro/dsXXXXXX/sub-0001/func/sub-0001*
```

## NARPS: ds001734

More details here:

https://docs.google.com/spreadsheets/d/1FU_F6kdxOD4PRQDIHXGHS4zTi_jEVaUqY_Zwg0z6S64/edit#gid=1019165812&range=A51

TODO: add expected value to the model

```matlab
% compute euclidean distance to the indifference line defined by
% gain twice as big as losses
% https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
a = 0.5;
b = -1;
c = 0;
x = onsets{iRun}.gain;
y = onsets{iRun}.loss;
dist = abs(a * x + b * y + c) / (a^2 + b^2)^.5;
onsets{iRun}.EV = dist; % create an "expected value" regressor
```

TODO: transformers cannot yet be appled to confounds

```json
{
"Description": "Time points with a framewise displacement (as calculated by fMRIprep) > 0.5 mm were censored (no interpolation) at the subject level GLM..",
"Name": "Threshold",
"Input": [
"framewise_displacement"
],
"Threshold": 0.5,
"Binarize": true,
"Output": [
"thres_framewise_displacement"
]
},
```
9 changes: 4 additions & 5 deletions demos/openneuro/ds000114_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

% The directory where the data are located
root_dir = fileparts(mfilename('fullpath'));
bids_dir = fullfile(root_dir, 'inputs', 'ds000114');
output_dir = fullfile(root_dir, 'outputs', 'ds000114', 'derivatives');
bids_dir = fullfile(root_dir, 'inputs', 'ds001734');
output_dir = fullfile(root_dir, 'outputs', 'ds001734', 'derivatives');

% to say which T1w file should be used as reference
opt.bidsFilterFile.t1w.ses = 'retest';
Expand All @@ -18,8 +18,8 @@

bidspm(bids_dir, output_dir, 'subject', ...
'participant_label', {'01', '02'}, ...
'action', 'preprocess', ...
'task', {'linebisection'}, ...
'action', 'smooth', ...
'task', {'MGT'}, ...
'ignore', {'unwarp', 'slicetiming'}, ...
'space', {'IXI549Space'}, ...
'options', opt);
Expand All @@ -41,7 +41,6 @@
bidspm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', {'01', '02'}, ...
'ignore', {'slicetiming'}, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'options', opt);
Expand Down
1 change: 0 additions & 1 deletion demos/openneuro/ds001168_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
bidspm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', {'01'}, ...
'ignore', {'slicetiming'}, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'keep_residuls', true);
45 changes: 45 additions & 0 deletions demos/openneuro/ds001734_run.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%
% Analysis of the NARPS dataset
%
% (C) Copyright 2022 bidspm developers

clear;
clc;

addpath(fullfile(pwd, '..', '..'));
bidspm();

% The directory where the data are located
root_dir = fileparts(mfilename('fullpath'));
bids_dir = fullfile(root_dir, 'inputs', 'ds001734');
fmriprep_dir = fullfile(root_dir, 'inputs', 'ds001734-fmriprep');
output_dir = fullfile(root_dir, 'outputs', 'ds001734', 'derivatives');

subject_label = {'001'};
task = {'MGT'};
space = {'MNI152NLin2009cAsym'};

% bidspm(fmriprep_dir, output_dir, 'subject', ...
% 'action', 'smooth', ...
% 'participant_label', subject_label, ...
% 'task', task, ...
% 'space', space, ...
% 'fwhm', 8);

%% Statistics

preproc_dir = fullfile(root_dir, 'outputs', 'ds001734', 'derivatives', 'bidspm-preproc');
model_file = fullfile(root_dir, 'models', 'model-narps_desc-U26C_smdl.json');

%% Subject level analysis

bidspm(bids_dir, output_dir, 'subject', ...
'action', 'stats', ...
'participant_label', subject_label, ...
'preproc_dir', preproc_dir, ...
'model_file', model_file, ...
'ignore', {'slice_timing'}, ...
'skip_validation', true, ...
'verbosity', 1, ...
'space', space, ...
'fwhm', 8);
Loading