jmtyszka / bidskit

Utility functions for working with DICOM and BIDS neuroimaging data
MIT License
61 stars 41 forks source link

Second pass error : KeyError: 'ScanningSequence' #114

Open elPreeto opened 1 year ago

elPreeto commented 1 year ago

Hi, I have been using bidskit to process scans for last couple of months. I have older version of bidskit that works as intended so I tried using the latest BIDSKIT 2022.10.13 with dcm2niix v1.0.20220720. I am getting the following error on my second pass; Organizing ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000_ColFA Traceback (most recent call last): File "/usr/local/bin/bidskit", line 33, in <module> sys.exit(load_entry_point('bidskit==2022.10.13', 'console_scripts', 'bidskit')()) File "/usr/local/lib/python3.10/dist-packages/bidskit-2022.10.13-py3.10.egg/bidskit/__main__.py", line 289, in main d2n.organize_series( File "/usr/local/lib/python3.10/dist-packages/bidskit-2022.10.13-py3.10.egg/bidskit/dcm2niix.py", line 209, in organize_series tr.purpose_handling(src_meta, File "/usr/local/lib/python3.10/dist-packages/bidskit-2022.10.13-py3.10.egg/bidskit/translate.py", line 106, in purpose_handling scan_seq = bids_meta['ScanningSequence'] KeyError: 'ScanningSequence' This is what my Protocol_Translator looks like; { "AAHead_Scout":[ "Extra", "AAHead_Scout", "UNASSIGNED" ], "AAHead_Scout_MPR_cor":[ "Extra", "AAHead_Scout_MPR_cor", "UNASSIGNED" ], "AAHead_Scout_MPR_sag":[ "Extra", "AAHead_Scout_MPR_sag", "UNASSIGNED" ], "AAHead_Scout_MPR_tra":[ "Extra", "AAHead_Scout_MPR_tra", "UNASSIGNED" ], "t1_mprage_sag_p2_iso1.0":[ "T1w10", "T1w10", "UNASSIGNED" ], "t2_spc_sag_p2_iso1.0_int":[ "T2w10", "T2w10", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_P>>A_iso2.0_ref_rev-ph":[ "Extra", "ep2d_diff_mddw_30_p2_P_A_iso2.0_ref_rev-ph", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000":[ "Extra", "ep2d_diff_mddw_30_p2_A-P_iso2.0_b1000+2000", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000_ADC":[ "Extra", "ep2d_diff_mddw_30_p2_A_P_iso2.0_b1000+2000_ADC", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000_ColFA":[ "Extra", "eep2d_diff_mddw_30_p2_A_P_iso2.0_b1000+2000_ColFA", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000_FA":[ "Extra", "ep2d_diff_mddw_30_p2_A_P_iso2.0_b1000+2000_FA", "UNASSIGNED" ], "ep2d_diff_mddw_30_p2_A>>P_iso2.0_b1000+2000_TRACEW":[ "Extra", "ep2d_diff_mddw_30_p2_A_P_iso2.0_b1000+2000_TRACEW", "UNASSIGNED" ], "ep2d_bold_iso3.5_P>>A_ref_rev-ph":[ "Extra", "ep2d_bold_iso3.5_P_A_ref_rev-ph", "UNASSIGNED" ], "ep2d_bold_iso3.5_A>>P_eyes_closed_resting":[ "fMRI", "fMRI", "UNASSIGNED" ], "t2_spc_da-fl_sag_p2_t2-ir_iso1.0":[ "FLAIR3D", "FLAIR3D", "UNASSIGNED" ], "FLAIR_tse_axial":[ "EXTRA", "FLAIR_tse_axial", "UNASSIGNED" ] }

Let me know if you need any more information. Thank you so much!

elPreeto commented 1 year ago

Updated the format of protocol_translator

elPreeto commented 1 year ago

I have narrowed the problem down to the sequence "ep2d_diff_mddw_30_p2 A>>P iso2.0 b1000+2000_ColFA" not containing "ScanningSequence" in bids_purpose. I am not sure why would that not contain that key and also don't know what would be the work around. Any suggestion would help. Thanks.

jmtyszka commented 1 year ago

Sorry for the slow response and this might be too late to be useful.Probably the first thing to do is check whether ScanningSequence is present in the JSON sidecar for this series in your work directory where dcm2niix outputs converted data. If this particular field is absent from the JSON sidecar, check whether the original DICOM files for this series (in sourcedata) have the (0018,0020) ScanningSequence tag present. dcm2niix should fill this JSON field regardless of modality (https://github.com/rordenlab/dcm2niix/blob/master/BIDS/README.md).

As a side note, the ">>" or "+" may cause issues for dcm2niix, but I haven't tested that hypothesis.