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

[MAINT] reuse pybids synthetic dataset #246

Merged
merged 2 commits into from
Jan 10, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import numpy as np
import pandas as pd
import pytest
from bids.tests import get_test_data_path

from bidsmreye.quality_control import compute_displacement, compute_robust_outliers


@pytest.fixture
def pybids_test_dataset() -> Path:
return Path(get_test_data_path()) / "synthetic" / "derivatives" / "fmriprep"
def pybids_test_dataset(data_dir) -> Path:
return data_dir / "synthetic" / "derivatives" / "fmriprep"


@pytest.fixture
Expand Down
5 changes: 5 additions & 0 deletions tests/data/synthetic/T1w.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"RepetitionTime": 2.5,
"EchoTime": 0.0029,
"FlipAngle": 8
}
79 changes: 79 additions & 0 deletions tests/data/synthetic/code/create_synthetic_ds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# small bash script to create a synthetic BIDS data set

# defines where the BIDS data set will be created
start_dir=$(pwd)
raw_dir=${start_dir}/../

subject_list='01 02 03 04 05'
session_list='01'

create_raw_dwi() {

target_dir=$1
subject=$2
ses=$3

this_dir=${target_dir}/sub-${subject}/ses-${ses}/dwi

mkdir -p "${this_dir}"

suffix='_dwi'
source_image=${target_dir}/../images/4d.nii.gz
filename=${this_dir}/sub-${subject}_ses-${ses}${suffix}.nii.gz
cp "${source_image}" "${filename}"

source_bval=${start_dir}/dwi.bval
filename=${this_dir}/sub-${subject}_ses-${ses}${suffix}.bval
cp "${source_bval}" "${filename}"

source_bvec=${start_dir}/dwi.bvec
filename=${this_dir}/sub-${subject}_ses-${ses}${suffix}.bvec
cp "${source_bvec}" "${filename}"

}

create_raw_fmap() {

target_dir=$1
subject=$2
ses=$3

this_dir=${target_dir}/sub-${subject}/ses-${ses}/fmap

mkdir -p ${this_dir}

source_image=${target_dir}/../images/3d.nii.gz

fmap_suffix_list='_phasediff _magnitude1 _magnitude2'

for suffix in ${fmap_suffix_list}; do
cp "${source_image}" "${this_dir}/sub-${subject}_ses-${ses}${suffix}.nii.gz"
done

RepetitionTime=0.4
EchoTime1=00519
EchoTime2=0.00765
FlipAngle=60
template='{"FlipAngle":%f, "RepetitionTime":%f, "EchoTime1":%f, "EchoTime2":%f, "IntendedFor": ["%s", "%s"], "PhaseEncodingDirection": "j-"}'

suffix='_bold'

task_name='nback'
IntendedFor1="$(echo ses-${ses}/func/sub-${subject}_ses-${ses}_task-${task_name}_run-01${suffix}.nii.gz)"
IntendedFor2="$(echo ses-${ses}/func/sub-${subject}_ses-${ses}_task-${task_name}_run-02${suffix}.nii.gz)"
json_string=$(printf "$template" "$FlipAngle" "$RepetitionTime" "$EchoTime1" "$EchoTime2" "$IntendedFor1" "$IntendedFor2")
echo "$json_string" >${this_dir}/sub-${subject}_ses-${ses}_phasediff.json
echo "$json_string" >${this_dir}/sub-${subject}_ses-${ses}_phasediff.json

}

# RAW DATASET
for subject in ${subject_list}; do
for ses in ${session_list}; do
create_raw_dwi ${raw_dir} ${subject} ${ses}
create_raw_fmap ${raw_dir} ${subject} ${ses}
done

done
1 change: 1 addition & 0 deletions tests/data/synthetic/code/dwi.bval
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
3 changes: 3 additions & 0 deletions tests/data/synthetic/code/dwi.bvec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0 0.99955850839614 0.01954407058656 0.00294903200119 0.57941150665283 -0.22696028649807 -0.88946276903152 0.81388407945632 0.25786191225051 0.94657051563262 0.48336026072502 0.31938299536705 0.42975607514381 -0.4763910472393 -0.59470033645629 -0.59882068634033 -0.83007228374481 0.88395410776138 0.2610293328762 0.09066703915596 -0.80151742696762 0.53270918130874 -0.79953873157501 0.94853943586349 0.26080328226089 -0.04598157480359 0.20106360316276 0.76368796825408 -0.13214653730392 -0.14714884757995 0.89985853433609 -0.57571458816528 -0.35732066631317 -0.33106037974357 -0.31264066696167 -0.96581315994262 -0.95102477073669 0.43446427583694 -0.75675719976425 0.73082029819488 -0.67709231376647 0.67937570810318 -0.13976696133613 -0.72053796052932 -0.07321017235517 0.5839369893074 -0.07184987515211 -0.55975395441055 0.82137787342071 0.36826944351196 -0.19602409005165 -0.73164790868759 0.43177768588066 0.52686661481857 -0.19931995868682 0.4891959130764 0.37798687815666 -0.70318156480789 0.26638954877853 -0.01923633553087 0.02821243368089 0.54735606908798 -0.30064421892166 0.73979389667511 0.28209447860717
0 -0.02049821615219 0.98761302232742 0.52286034822464 -0.80844813585281 -0.65079009532928 -0.30648133158683 0.02310398034751 0.87089902162551 0.07609922438859 -0.81609696149826 -0.78027993440628 -0.53328257799148 -0.50823193788528 0.61257445812225 0.04065646231174 -0.53946721553802 0.02398272044956 -0.41599848866462 -0.91442102193832 0.48670825362205 0.79603910446167 0.26488894224166 -0.28364571928978 0.67999285459518 -0.03036121465265 -0.9791235923767 -0.642438352108 0.20882698893547 0.83522641658783 0.37077417969703 0.37174785137176 -0.00542591279372 -0.04497369006276 -0.27928236126899 -0.25846034288406 0.19096466898918 -0.89682209491729 0.62152820825576 0.30336225032806 -0.08724510669708 0.59735131263732 -0.82620531320571 0.31055691838264 0.72652155160903 -0.69059783220291 -0.48624488711357 -0.81753581762313 -0.42245289683342 -0.68479514122009 0.54096210002899 -0.67699402570724 0.76565784215927 0.5939724445343 -0.3681089580059 0.28870034217834 -0.87901186943054 -0.34432905912399 0.93346035480499 0.24267202615737 -0.96214282512664 -0.18922631442546 0.30678990483284 0.53955316543579 0.9575902223587
0 0.02150822617113 -0.15568755567073 -0.85241317749023 -0.10341253876686 -0.72454214096069 -0.33900585770607 -0.58056783676147 -0.41838020086288 -0.31338959932327 0.31677860021591 0.53773391246795 0.72864228487014 -0.71746206283569 -0.52065771818161 0.79985052347183 -0.14126154780387 0.46695810556411 0.8710965514183 0.39447921514511 0.34739750623703 -0.28730210661888 0.53904712200164 -0.14077690243721 -0.68526721000671 0.99848085641861 -0.02984086796641 -0.06366975605487 -0.96898341178894 0.52985268831253 -0.22974103689193 0.72825574874877 -0.93396604061126 0.94253724813461 -0.90788620710372 -0.02007177658379 -0.24307298660278 0.0833735987544 -0.20253752171993 -0.61145150661468 -0.73070788383483 0.426168769598 -0.54575622081756 -0.61998349428176 -0.6832326054573 -0.42672303318977 -0.87086367607116 -0.13531495630741 0.38323882222175 -0.62883508205413 0.81788432598114 0.0798152834177 0.47679767012596 -0.60795408487319 0.90816700458526 -0.82300633192062 -0.29062712192535 -0.62207180261611 0.24018363654613 0.96991771459579 -0.27108195424079 0.81522691249847 0.90304642915725 -0.40197896957397 -0.05868147313594
6 changes: 6 additions & 0 deletions tests/data/synthetic/dataset_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Name": "Synthetic dataset for inclusion in BIDS-examples",
"BIDSVersion": "1.0.2",
"License": "PD",
"Authors": ["Markiewicz, C. J."]
}
10 changes: 10 additions & 0 deletions tests/data/synthetic/derivatives/fmriprep/dataset_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"PipelineDescription": {
"Name": "fmriprep"
},
"Name": "synthetic",
"BIDSVersion": "1.7.1",
"License": "PD",
"Authors": ["Markiewicz, C. J."],
"DatasetType": "derivative"
}
Loading
Loading