spatialtopology / spacetop-prep

code for transferring data and preprocessing
MIT License
0 stars 3 forks source link

[DUP] sub-0040_ses-02_task-narratives_acq-mb8_run-04 #15

Closed jungheejung closed 2 months ago

jungheejung commented 2 years ago

TODO

fmriprep output

                ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json
                        Evidence: sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json
                ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.nii.gz
                        Evidence: sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.nii.gz

scannotes

Narratives: On Run 4, the scanner crashed with an error that Terry had not seen before. Had to save data and reboot the system.

jungheejung commented 5 months ago

@yarikoptic Same here, This is a scan where the DUP is longer (and expected size) compared to the BOLD data Based on the scannotes, the scanner rebooted. I wonder if this mismatch has to do with the scanner reboot?

Is there anything we can check to make sure the DUP is the correct file and that we need to salvage it? Maybe looking at the time acquired would help? or perhaps that's already the logic of Heudiconv. What do you think?

yarikoptic commented 5 months ago

similar case to

besides no data loss here:

❯ for f in ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold*json; do echo $f; jq .AcquisitionTime $f; done
./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json
"13:54:39.842500"
./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold.json
"13:19:5.550000"
[bids@rolando A003842] > for f in 0*/; do dcmdump +P 0008,0032  $f/0000011.dcm | sed -e 's,\[,,g' -e 's, *#.*,,g' | sort -n -k 4 | tr '\n' ' '; echo  "$f"; done | sort -n -k 3
(0008,0032) TM 124658.965000] 001-anat-scout_ses-02/
(0008,0032) TM 124658.965000] 002-anat-scout_ses-02_MPR_sag/
(0008,0032) TM 124658.965000] 003-anat-scout_ses-02_MPR_cor/
(0008,0032) TM 124658.965000] 004-anat-scout_ses-02_MPR_tra/
(0008,0032) TM 124809.855000] 005-fmap-epi_dir-ap_acq-mb8_run-01/
(0008,0032) TM 124833.372500] 006-fmap-epi_dir-pa_acq-mb8_run-01/
(0008,0032) TM 125115.362500] 007-func_run-01_task-narratives_acq-ap-mb8_SBRef/
(0008,0032) TM 125122.262500] 008-func_run-01_task-narratives_acq-ap-mb8/
(0008,0032) TM 125913.717500] 009-func_run-02_task-narratives_acq-ap-mb8_SBRef/
(0008,0032) TM 125920.617500] 010-func_run-02_task-narratives_acq-ap-mb8/
(0008,0032) TM 130816.435000] 011-func_run-03_task-narratives_acq-ap-mb8_SBRef/
(0008,0032) TM 130823.335000] 012-func_run-03_task-narratives_acq-ap-mb8/
(0008,0032) TM 131858.650000] 013-func_run-04_task-narratives_acq-ap-mb8_SBRef/
(0008,0032) TM 131905.550000] 014-func_run-04_task-narratives_acq-ap-mb8/
(0008,0032) TM 135200.842500] 005-fmap-epi_dir-ap_acq-mb8_run-01a/
(0008,0032) TM 135224.372500] 006-fmap-epi_dir-pa_acq-mb8_run-01a/
(0008,0032) TM 135432.942500] 007-func_run-04_task-narratives_acq-ap-mb8_SBRef/
(0008,0032) TM 135439.842500] 008-func_run-04_task-narratives_acq-ap-mb8/
(0008,0032) TM 140516.902500] 009-func_run-01_task-faces_acq-ap-mb8_SBRef/
(0008,0032) TM 140523.802500] 010-func_run-01_task-faces_acq-ap-mb8/
(0008,0032) TM 141248.587500] 011-func_run-02_task-faces_acq-ap-mb8_SBRef/
(0008,0032) TM 141255.487500] 012-func_run-02_task-faces_acq-ap-mb8/
(0008,0032) TM 142023.070000] 013-func_run-03_task-faces_acq-ap-mb8_SBRef/
(0008,0032) TM 142029.970000] 014-func_run-03_task-faces_acq-ap-mb8/
(0008,0032) TM 142756.015000] 015-anat-scout_ses-02/
(0008,0032) TM 142756.015000] 016-anat-scout_ses-02_MPR_sag/
(0008,0032) TM 142756.015000] 017-anat-scout_ses-02_MPR_cor/
(0008,0032) TM 142756.015000] 018-anat-scout_ses-02_MPR_tra/
(0008,0032) TM 142847.422500] 019-fmap-epi_dir-ap_acq-mb8_run-02/
(0008,0032) TM 142911.395000] 020-fmap-epi_dir-pa_acq-mb8_run-02/
(0008,0032) TM 143021.592500] 021-func_run-01_task-alignvideo_acq-ap-mb8_SBRef/
(0008,0032) TM 143028.492500] 022-func_run-01_task-alignvideo_acq-ap-mb8/
(0008,0032) TM 143714.597500] 023-func_run-02_task-alignvideo_acq-ap-mb8_SBRef/
(0008,0032) TM 143721.497500] 024-func_run-02_task-alignvideo_acq-ap-mb8/
(0008,0032) TM 145148.642500] 025-func_run-03_task-alignvideo_acq-ap-mb8_SBRef/
(0008,0032) TM 145155.542500] 026-func_run-03_task-alignvideo_acq-ap-mb8/
(0008,0032) TM 150101.085000] 027-func_run-04_task-alignvideo_acq-ap-mb8_SBRef/
(0008,0032) TM 150107.985000] 028-func_run-04_task-alignvideo_acq-ap-mb8/

but there is a new oddity with _epi1 and _epi2 suffixes given while no _run-01a among fieldmaps -- may be heudiconv or reproin was "too smart" to handle that ... indeed -- based on sequence index and name it groupped them together:

  "5-fmap-epi_dir-ap_acq-mb8_run-01": [
    "/inbox/DICOM/2021/07/20/A003842/005-fmap-epi_dir-ap_acq-mb8_run-01/0000011.dcm",
    "/inbox/DICOM/2021/07/20/A003842/005-fmap-epi_dir-ap_acq-mb8_run-01/0000021.dcm",
    "/inbox/DICOM/2021/07/20/A003842/005-fmap-epi_dir-ap_acq-mb8_run-01a/0000011.dcm",
    "/inbox/DICOM/2021/07/20/A003842/005-fmap-epi_dir-ap_acq-mb8_run-01a/0000021.dcm"
  ],

to give to dcm2niix....

we have done renames after creating a helper script and calling smth like

datalad run -m "Rename fmaps for dir-pa fmaps for sub-0040/ses-02" bash -c 'for f in *_dir-pa_run-02_epi.* ; do ../../../code/rename_file "$f" "${{f/_run-02_epi/_run-03_epi}}"; done; for f in *_dir-pa_run-01_epi1.* ; do ../../../code/rename_file "$f" "${{f/_run-01_epi1/_run-02_epi}}"; done; for f in *_dir-pa_run-01_epi2.* ; do ../../../code/rename_file "$f" "${{f/_run-01_epi2/_run-01_epi}}"; done;'
jungheejung commented 4 months ago

Issue is due to using scan squence numbers instead of scan time. If scanner crashes, using sequence numbers are prone to error. https://github.com/nipy/heudiconv/issues/740

jungheejung commented 2 months ago

DUP is primary. delete all others.

        * ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold.json: BOLDJSON_TR (384) does not match expected TR (1156).
        * ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json: DUPJSON_TR (1156) matches expected TR (1156).
        * ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json: DUPJSON_TR (1156) is not smaller than BOLDJSON_TR (384).
        * ./sub-0040/ses-02/func/sub-0040_ses-02_task-narratives_acq-mb8_run-04_bold__dup-01.json: DUPJSON (50079) is acquired later than BOLDJSON (47945).