Description:
qunex
does not import bids dataset in the right order, and it makes difficult to match single-band reference (sbref) image to the right one.
For example, this is the BIDS dataset that qunex
does not import in the right order:
sub-10
├── anat
│ ├── sub-10_T1w.json
│ ├── sub-10_T1w.nii.gz
│ ├── sub-10_T2w.json
│ └── sub-10_T2w.nii.gz
├── fmap
│ ├── sub-10_acq-pre_dir-AP_run-01_epi.json
│ ├── sub-10_acq-pre_dir-AP_run-01_epi.nii.gz
│ ├── sub-10_acq-pre_dir-PA_run-02_epi.json
│ └── sub-10_acq-pre_dir-PA_run-02_epi.nii.gz
├── func
│ ├── sub-10_task-new_dir-AP_run-01_bold.json
│ ├── sub-10_task-new_dir-AP_run-01_bold.nii.gz
│ ├── sub-10_task-new_dir-AP_run-01_sbref.json
│ ├── sub-10_task-new_dir-AP_run-01_sbref.nii.gz
│ ├── sub-10_task-new_dir-AP_run-01_events.tsv
│ ├── sub-10_task-new_dir-AP_run-02_bold.json
│ ├── sub-10_task-new_dir-AP_run-02_bold.nii.gz
│ ├── sub-10_task-new_dir-AP_run-02_sbref.json
│ ├── sub-10_task-new_dir-AP_run-02_sbref.nii.gz
│ ├── sub-10_task-new_dir-AP_run-02_events.tsv
│ ├── sub-10_task-rest_dir-AP_run-01_bold.json
│ ├── sub-10_task-rest_dir-AP_run-01_bold.nii.gz
│ ├── sub-10_task-rest_dir-AP_run-01_sbref.json
│ ├── sub-10_task-rest_dir-AP_run-01_sbref.nii.gz
│ ├── sub-10_task-rest_dir-AP_run-01_events.tsv
│ ├── sub-10_task-rest_dir-PA_run-02_bold.json
│ ├── sub-10_task-rest_dir-PA_run-02_bold.nii.gz
│ ├── sub-10_task-rest_dir-PA_run-02_sbref.json
│ ├── sub-10_task-rest_dir-PA_run-02_sbref.nii.gz
│ └── sub-10_task-rest_dir-PA_run-02_events.tsv
└── sub-10_scans.tsv
I have imported the session using the following command:
qunex_container import_bids \
--sessionsfolder="${WORK_DIR}/${STUDY_NAME}/sessions" \
--inbox="${RAW_DATA}" \
--action="link" \
--archive="leave" \
--overwrite=yes \
--container="${QUNEX_CONTAINER}"
This is the result mapping in session.txt
:
# Generated by QuNex 0.94.11 on 2022-10-17_09.17.48.737047
#
session: 10
subject: 10
bids: /data/ihsl_hcp/sessions/10/bids
raw_data: /data/ihsl_hcp/sessions/10/nii
hcp: /data/ihsl_hcp/sessions/10/hcp
1: T1w
2: T2w
3: epi dir-AP acq-pre run-01
4: epi dir-PA acq-pre run-02
5: sbref new run-01
6: bold new run-01
7: bold new run-02
8: sbref new run-02
9: sbref rest run-01
10: bold rest run-01
11: sbref rest run-02
12: bold rest run-02
I tried to modify the run order with the hcp_mapping.txt
file shown below:
T1w => T1w
T2w => T2w
epi dir-AP acq-pre run-01 => SE-FM-AP
epi dir-PA acq-pre run-02 => SE-FM-PA
sbref IL run-01 => boldref:task: bold_num(1)
bold IL run-01 => bold:task: bold_num(1)
sbref IL run-02 => boldref:task: bold_num(2)
bold IL run-02 => bold:task: bold_num(2)
sbref rest run-01 => boldref:rest:phenc(AP): bold_num(3)
bold rest run-01 => bold:rest:phenc(AP): bold_num(3)
sbref rest run-02 => boldref:rest:phenc(PA): bold_num(4)
bold rest run-02 => bold:rest:phenc(PA): bold_num(4)
But the resulting session_hcp.txt
file does not generate what I want:
# Generated by QuNex 0.94.11 on 2022-10-17_09.19.08.208254
#
session: 10
subject: 10
bids: /data/ihsl_hcp/sessions/10/bids
raw_data: /data/ihsl_hcp/sessions/10/nii
hcp: /data/ihsl_hcp/sessions/10/hcp
hcpready: true
1 :T1w :T1w: se(1)
2 :T2w :T2w: se(1)
3 :SE-FM-AP :epi dir-AP acq-pre run-01: se(1)
4 :SE-FM-PA :epi dir-PA acq-pre run-02: se(1)
5 :boldref1:task :sbref IL run-01: se(1): bold_num(1)
6 :bold1:task :bold IL run-01: se(1): bold_num(1)
7 :bold2:task :bold IL run-02: se(1): bold_num(2)
8 :boldref5:task :sbref IL run-02: se(1): bold_num(2)
9 :boldref3:rest :sbref rest run-01: se(1): bold_num(3): phenc(AP)
10 :bold3:rest :bold rest run-01: se(1): bold_num(3): phenc(AP)
11 :boldref4:rest :sbref rest run-02: se(1): bold_num(4): phenc(PA)
12 :bold4:rest :bold rest run-02: se(1): bold_num(4): phenc(PA)
You can see that image 8 is tagged as boldref5
rather than expected boldref2
.
I guess that this may be because of how import_bids
import files.
In line 508-511 of bids.py
, I found that file list is generated using os.walk
:
for path, dirs, files in os.walk(candidate):
for file in files:
sourceFiles.append(os.path.join(path, file))
It has been known that os.walk
can iterate files in a random order, so this may be the root of the problem.
Conclusion:
In short,
-
import_bids
import files in a random order (likely due to howos.walk
works) - It is not possible to manually match sbref files using
bold_num
parameter - Also, I found manual ordering does not work when there exists multiple pairs of field maps (using se(*) parameters).