Tools for preprocessing DICOM metadata imported using `dicomtools.core` into in a `pandas.DataFrame` in preparation for training RandomForest classifier to predict series type.
row = {'SeriesDescription': 'ax t1 +c', 'ContrastBolusAgent': 'Gadavist'}
row1 = {'SeriesDescription': 'ax t1', 'ContrastBolusAgent': np.nan}
row2 = {'SeriesDescription': 'ax t1', 'ContrastBolusAgent': 'Gadavist'} # example of discordant SD
row3 = {'SeriesDescription': 'AX T1 POST', 'ContrastBolusAgent': np.nan} # also discordant
assert detect_contrast(row) == 1
assert detect_contrast(row1) == 0
assert detect_contrast(row2) == 1
assert detect_contrast(row3) == 1
assert rm_extra_info('ax t1 <mpr>') == 'ax t1'
assert rm_extra_info('adc (mm^2/s)') == 'adc'
assert rm_extra_info('ax t1 [date]') == 'ax t1'
def test_find_seq(sd, targ): assert _find_seq(sd) == targ
test_find_seq('ax t1 +c', 't1')
test_find_seq('ax t1 flair +c', 't1')
test_find_seq('ax t2 +c', 't2')
test_find_seq('ax t2 flair', 'flair')
test_find_seq('ax t2 gre', 'swi')
test_find_seq('ax swi', 'swi')
test_find_seq('ax susc', 'swi')
test_find_seq('adc', 'adc')
test_find_seq('eadc', 'other')
test_find_seq('ax dwi', 'dwi')
test_find_seq('ax diffusion', 'dwi')
test_find_seq('ax spgr +c', 'spgr')
test_find_seq('localizer', 'loc')
assert _extract_label('ax t1 +c') == 't1'
assert _extract_label('ax t1 +c [date]') == 't1'
assert _extract_label('<MPR Thick Range>') == 'unknown'