Пример #1
0
def testEmptyArchiveAppend(validBidsI, imageMetadata, tmpdir):
    # Create in root with no BIDS-I, then append to make non-empty archive
    datasetRoot = Path(tmpdir, testEmptyArchiveAppend.__name__)
    archive = BidsArchive(datasetRoot)
    archive._appendIncremental(validBidsI)

    assert not archive.isEmpty()
    assert archiveHasMetadata(archive, imageMetadata)
    assert appendDataMatches(archive, validBidsI)
    assert isValidBidsArchive(datasetRoot)
Пример #2
0
def testAppendNoOverwriteDatasetMetadata(tmpdir, validBidsI):
    rootPath = Path(tmpdir, "new-dataset")
    archive = BidsArchive(rootPath)

    EXPECTED_README = "The readme we expect"
    validBidsI.readme = EXPECTED_README
    archive._appendIncremental(validBidsI)

    NEW_README = "The readme we don't expect"
    validBidsI.readme = NEW_README
    validBidsI.setMetadataField('subject', 'newSubject')
    archive._appendIncremental(validBidsI)

    with open(os.path.join(rootPath, 'README')) as readme:
        readmeText = readme.readlines()
        assert len(readmeText) == 1
        assert readmeText[0] == EXPECTED_README
Пример #3
0
def testGetEvents(validBidsI, imageMetadata, tmpdir):
    archive = BidsArchive(tmpdir)
    archive._appendIncremental(validBidsI)

    # Get the events from the archive as a pandas data frame
    events = archive.getEvents()[0].get_df()
    events = correctEventsFileDatatypes(events)
    assert events is not None

    # Check the required columns are present in the events file data frame
    for column in DEFAULT_EVENTS_HEADERS:
        assert column in events.columns

    # Check the columns are of the proper types
    for column, dtype in BIDS_EVENT_COL_TO_DTYPE.items():
        if column in events.columns:
            assert events[column].dtype == dtype