Ejemplo n.º 1
0
def test_parse_bids_filename_with_full_path():
    ident = scanid.parse_bids_filename(
        "/some/folder/sub-CMH0001_ses-01_run-1_T1w.nii.gz")
    assert ident.subject == 'CMH0001'
    assert ident.session == '01'
    assert ident.run == '1'
    assert ident.suffix == 'T1w'
Ejemplo n.º 2
0
def test_optional_entities_dont_get_parsed_as_suffix():
    optional_entities = "sub-CMH0001_ses-01_{}_T1w.nii.gz"
    for entity in ['run', 'acq', 'ce', 'rec', 'echo', 'ce', 'mod', 'task']:
        optional_field = '{}-11'.format(entity)
        bids_name = optional_entities.format(optional_field)
        parsed = scanid.parse_bids_filename(bids_name)
        assert optional_field not in parsed.suffix
Ejemplo n.º 3
0
def test_parse_bids_filename_without_ext():
    ident = scanid.parse_bids_filename(
        "/some/folder/sub-CMH0001_ses-02_run-3_T1w")
    assert ident.subject == 'CMH0001'
    assert ident.session == '02'
    assert ident.run == '3'
    assert ident.suffix == 'T1w'
Ejemplo n.º 4
0
def test_bids_file_correctly_parses_when_all_task_entities_given():
    task_bids = "sub-CMH0001_ses-01_task-abcd_acq-efgh_" + \
                "rec-ijkl_run-1_echo-11_imi"

    parsed = scanid.parse_bids_filename(task_bids)
    assert str(parsed) == task_bids
Ejemplo n.º 5
0
def test_bids_file_correctly_parses_when_all_anat_entities_given():
    anat_bids = "sub-CMH0001_ses-01_acq-abcd_ce-efgh_rec-ijkl_" + \
                "run-1_mod-mnop_somesuffix"

    parsed = scanid.parse_bids_filename(anat_bids)
    assert str(parsed) == anat_bids
Ejemplo n.º 6
0
def test_bids_file_equals_itself_with_path_and_ext():
    bids_name = "sub-CMH0001_ses-01_run-1_T1w"
    bids_full_path = "/some/folder/somewhere/{}.nii.gz".format(bids_name)
    ident = scanid.parse_bids_filename(bids_name)
    assert ident == bids_full_path
Ejemplo n.º 7
0
def test_bids_file_equals_string_of_itself_minus_run():
    bids_name = "sub-CMH0001_ses-01_run-1_T1w"
    ident = scanid.parse_bids_filename(bids_name)
    assert ident == bids_name.replace("run-1_", "")
Ejemplo n.º 8
0
def test_bids_file_equals_string_of_itself():
    bids_name = "sub-CMH0001_ses-01_run-1_T1w"
    ident = scanid.parse_bids_filename(bids_name)
    assert ident == bids_name
Ejemplo n.º 9
0
def test_empty_entity_name_and_label_does_not_get_set_as_suffix():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("sub-CMH_ses-01_-_T1w.nii.gz")
Ejemplo n.º 10
0
def test_unknown_entity_does_not_get_set_as_suffix():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("sub-CMH_ses-01_new-FIELD_T1w.nii.gz")
Ejemplo n.º 11
0
def test_parse_bids_filename_missing_suffix_and_run():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("sub-CMH0001_ses-01.nii.gz")
Ejemplo n.º 12
0
def test_parse_bids_filename_malformed_session():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("sub-CMH0001_ses-_run-1_T1w")
Ejemplo n.º 13
0
def test_parse_bids_filename_missing_subject():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("ses-01_run-1_T1w")
Ejemplo n.º 14
0
def test_parse_bids_filename_without_run():
    scanid.parse_bids_filename("sub-CMH0001_ses-01_T1w.nii.gz")
Ejemplo n.º 15
0
def test_bids_file_correctly_parses_when_all_fmap_entities_given():
    fmap_bids = "sub-CMH0001_ses-01_acq-abcd_dir-efgh_run-1_fmap"

    parsed = scanid.parse_bids_filename(fmap_bids)
    assert str(parsed) == fmap_bids
Ejemplo n.º 16
0
def test_bids_file_raises_exception_when_wrong_entities_used_for_fmap():
    with pytest.raises(scanid.ParseException):
        scanid.parse_bids_filename("sub-CMH0001_ses-01_dir-somedir_"
                                   "rec-somefield_run-1_T1w.nii.gz")
Ejemplo n.º 17
0
def test_bids_file_handles_prelapse_session_strings():
    prelapse_file = "sub-BRG33006_ses-01R_run-1_something"

    parsed = scanid.parse_bids_filename(prelapse_file)
    assert str(parsed) == prelapse_file
Ejemplo n.º 18
0
def test_parse_bids_filename():
    ident = scanid.parse_bids_filename("sub-CMH0001_ses-01_run-1_T1w.nii.gz")
    assert ident.subject == 'CMH0001'
    assert ident.session == '01'
    assert ident.run == '1'
    assert ident.suffix == 'T1w'