Exemple #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)
Exemple #2
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()
    assert events is not None

    # Check the required columns are present in the events file data frame
    for column in ['onset', 'duration', 'response_time']:
        assert column in events.columns
Exemple #3
0
def doRuns(cfg, bidsInterface, subjInterface, webInterface):
    """
    Process a run of a bids dataset. The subject and run configuration
    values will be supplied by the cfg parameter.
    Args:
        cfg: configurations parsed from the project toml config file
        bidsInterface: client interface to bids data
        webInterface: client interface to user web page
    Returns: no return value
    """
    subject = cfg.subjectName
    run = cfg.runNum[0]
    entities = {
        'subject': subject,
        'run': run,
        'suffix': 'bold',
        'datatype': 'func'
    }
    webInterface.clearRunPlot(run)
    if cfg.writeBidsArchive is True:
        # Create a new bids archive from the incrementals
        bidsArchivePath = os.path.join(tmpDir,
                                       'bids_archive_' + uuid.uuid4().hex)
        print(f'BIDS Archive will be written to {bidsArchivePath}')
        newArchive = BidsArchive(bidsArchivePath)
    # Initialize the bids stream
    streamId = bidsInterface.initOpenNeuroStream(cfg.dsAccessionNumber,
                                                 **entities)
    numVols = bidsInterface.getNumVolumes(streamId)
    for idx in range(numVols):
        bidsIncremental = bidsInterface.getIncremental(streamId, idx)
        if cfg.writeBidsArchive is True:
            newArchive.appendIncremental(bidsIncremental)
        imageData = bidsIncremental.imageData
        avg_niftiData = numpy.mean(imageData)
        print("| average activation value for TR %d is %f" %
              (idx, avg_niftiData))
        webInterface.plotDataPoint(run, idx, float(avg_niftiData))