def test_ris_acquisition_date_format_filter():
    with pytest.raises(TypeError):
        image1 = ri("tests/data/mri.nii.gz", "MRI", "T1", "20000123", ["x", "y", "z"], [2, 2, 2])
        image2 = ri("tests/data/mri.nii.gz", "MRI", "T2", "20000123", ["x", "y", "z"], [0.5, 0.5, 4])
        image3 = ri("tests/data/mri.nii.gz", "MRI", "T1+GAD", "20000123", ["x", "y", "z"], [1, 1, 1.5])
        image_set = ris([image1, image2, image3])
        image_set.filter_by_acquisition_date(012300)  # The integer 012300 is not a proper string format for date
    with pytest.raises(ValueError):
        image1 = ri("tests/data/mri.nii.gz", "MRI", "T1", "20000123", ["x", "y", "z"], [2, 2, 2])
        image2 = ri("tests/data/mri.nii.gz", "MRI", "T2", "20000123", ["x", "y", "z"], [0.5, 0.5, 4])
        image3 = ri("tests/data/mri.nii.gz", "MRI", "T1+GAD", "20000123", ["x", "y", "z"], [1, 1, 1.5])
        image_set = ris([image1, image2, image3])
        image_set.filter_by_acquisition_date('012300')  # 012300 is not a proper string format for date
def test_ris_good_input():
    image1 = ri("tests/data/mri.nii.gz", "MRI", "T1", "20000123", ["x", "y", "z"], [2, 2, 2])
    image2 = ri("tests/data/mri.nii.gz", "MRI", "T2", "20000123", ["x", "y", "z"], [0.5, 0.5, 4])
    image3 = ri("tests/data/mri.nii.gz", "MRI", "T1+GAD", "20000123", ["x", "y", "z"], [1, 1, 1.5])
    image_set = ris([image1, image2, image3])

    # Manually create filtered set after filtering by contrast for T2 images only
    filtered_set2 = ris([image2])

    assert image_set.radiology_images == [image1, image2, image3]
    assert image_set.filter_by_radiology_type('MRI').radiology_images == image_set.radiology_images
    assert image_set.filter_by_contrast('T2').radiology_images == filtered_set2.radiology_images
    assert image_set.filter_by_acquisition_date('20000123').radiology_images == image_set.radiology_images
def test_ris_contrast_filter():
    with pytest.raises(TypeError):
        image1 = ri("tests/data/mri.nii.gz", "MRI", "T1", "20000123", ["x", "y", "z"], [2, 2, 2])
        image2 = ri("tests/data/mri.nii.gz", "MRI", "T2", "20000123", ["x", "y", "z"], [0.5, 0.5, 4])
        image3 = ri("tests/data/mri.nii.gz", "MRI", "T1+GAD", "20000123", ["x", "y", "z"], [1, 1, 1.5])
        image_set = ris([image1, image2, image3])
        image_set.filter_by_contrast(1337)  # 1337 is not a proper contrast
def test_ris_radiology_type_filter():
    with pytest.raises(TypeError):
        image1 = ri("tests/data/mri.nii.gz", "MRI", "T1", "20000123", ["x", "y", "z"], [2, 2, 2])
        image2 = ri("tests/data/mri.nii.gz", "MRI", "T2", "20000123", ["x", "y", "z"], [0.5, 0.5, 4])
        image3 = ri("tests/data/mri.nii.gz", "MRI", "T1+GAD", "20000123", ["x", "y", "z"], [1, 1, 1.5])
        image_set = ris([image1, image2, image3])
        image_set.filter_by_radiology_type('NIRS')