The Scan order table in the QQC report checks the series order compared to the template dataset. This table is created by qqc.qqc.dicom.check_order_of_series.
You can try using the function by running the lines below in python
export PYTHONPATH=/data/predict1/home/kcho/software/qqc:${PYTHONPATH}
ipython
from pathlib import Path
from qqc.dicom_files import get_dicom_files_walk
from qqc.qqc.json import jsons_from_bids_to_df
from qqc.qqc.dicom import check_order_of_series
input_dir = Path('/data/predict1/data_from_nda/MRI_ROOT/sourcedata/SI03540/ses-XXXXXXX')
df_full_input = get_dicom_files_walk(input_dir, quick_scan=True)
template_dir = Path('/data/predict1/data_from_nda/MRI_ROOT/rawdata/sub-SI00726/ses-XXXXXX')
df_full_std = jsons_from_bids_to_df(template_dir).drop_duplicates()
order_check_df = check_order_of_series(df_full_input, df_full_std)
order_check_df
However, when a series gets repeated due to an issue in the initial scan, the order of series will be shifted by one and will not match the standard template anymore.
input_dir2 = Path('/data/predict1/data_from_nda/MRI_ROOT/sourcedata/SI07530/ses-2023XXXXX')
df_full_input2 = get_dicom_files_walk(input_dir2, quick_scan=True)
order_check_df2 = check_order_of_series(df_full_input2, df_full_std)
order_check_df2
series_num series_order_target series_order series_num_target order_diff
Summary Fail
0 1.0 Localizer Localizer 1.0 Pass
1 2.0 AAHScout AAHScout 2.0 Pass
2 3.0 AAHScout_MPR_sag AAHScout_MPR_sag 3.0 Pass
3 4.0 AAHScout_MPR_cor AAHScout_MPR_cor 4.0 Pass
4 5.0 AAHScout_MPR_tra AAHScout_MPR_tra 5.0 Pass
5 6.0 Localizer_aligned Localizer_aligned 6.0 Pass
6 7.0 DistortionMap_AP DistortionMap_AP 7.0 Pass
7 8.0 DistortionMap_PA DistortionMap_PA 8.0 Pass
8 9.0 T1w_MPR_ND T1w_MPR_ND 9.0 Pass
9 10.0 T1w_MPR T1w_MPR 10.0 Pass
10 11.0 T2w_SPC_ND T2w_SPC_ND 11.0 Pass
11 12.0 T2w_SPC T2w_SPC 12.0 Pass
12 13.0 DistortionMap_AP DistortionMap_AP 13.0 Pass
13 15.0 DistortionMap_PA DistortionMap_PA 14.0 Pass
14 17.0 rfMRI_REST_AP_SBRef rfMRI_REST_AP_SBRef 15.0 Pass
15 19.0 rfMRI_REST_AP rfMRI_REST_AP_SBRef 16.0 Fail
16 21.0 rfMRI_REST_PA_SBRef rfMRI_REST_AP 17.0 Fail
17 23.0 rfMRI_REST_PA rfMRI_REST_PA_SBRef 18.0 Fail
18 25.0 dMRI_b0_AP_SBRef rfMRI_REST_PA 19.0 Fail
19 27.0 dMRI_b0_AP dMRI_b0_AP_SBRef 20.0 Fail
20 29.0 dMRI_dir176_PA_SBRef dMRI_b0_AP 21.0 Fail
21 31.0 dMRI_dir176_PA dMRI_dir176_PA_SBRef 22.0 Fail
22 33.0 dMRI_b0_AP_SBRef dMRI_dir176_PA 25.0 Fail
23 35.0 dMRI_b0_AP dMRI_b0_AP_SBRef 26.0 Fail
24 37.0 DistortionMap_AP dMRI_b0_AP 27.0 Fail
25 39.0 DistortionMap_PA DistortionMap_AP 28.0 Fail
26 41.0 rfMRI_REST_AP_SBRef DistortionMap_PA 29.0 Fail
27 43.0 rfMRI_REST_AP rfMRI_REST_AP_SBRef 30.0 Fail
28 45.0 rfMRI_REST_PA_SBRef rfMRI_REST_AP 31.0 Fail
29 47.0 rfMRI_REST_PA rfMRI_REST_PA_SBRef 32.0 Fail
30 49.0 NaN rfMRI_REST_PA NaN Fail
We need a function that
- takes in
order_check_df (pd.DataFrame)
- and replaces
Fail into Pass if just extra series were added to series_order column.
- maybe map out which series occurs before each series in the
series_order_target column, and check if this mapping applies to each row in the series_order column?
The
Scan ordertable in the QQC report checks the series order compared to the template dataset. This table is created byqqc.qqc.dicom.check_order_of_series.You can try using the function by running the lines below in python
However, when a series gets repeated due to an issue in the initial scan, the order of series will be shifted by one and will not match the standard template anymore.
We need a function that
order_check_df(pd.DataFrame)FailintoPassif just extra series were added toseries_ordercolumn.series_order_targetcolumn, and check if this mapping applies to each row in theseries_ordercolumn?