def testAsSingleIncremental(oneImageBidsI): run = BidsRun() assert run.asSingleIncremental() is None NUM_APPENDS = 5 for i in range(NUM_APPENDS): run.appendIncremental(oneImageBidsI) oldImage = oneImageBidsI.image imageData = getNiftiData(oldImage) newDataShape = imageData.shape[:3] + (NUM_APPENDS, ) newData = np.zeros(newDataShape, dtype=imageData.dtype) for i in range(NUM_APPENDS): newData[..., i] = imageData[..., 0] newImage = oldImage.__class__(newData, oldImage.affine, oldImage.header) consolidatedBidsI = BidsIncremental(newImage, oneImageBidsI.getImageMetadata()) assert run.asSingleIncremental() == consolidatedBidsI
def appendBidsRun(self, run: BidsRun) -> None: """ Append a BIDS Run to this archive. Args: run: Run to append to the archvie. Examples: >>> archive1 = BidsArchive('/tmp/dataset1') >>> archive2 = BidsArchive('/tmp/dataset2') >>> archive1.getRuns() [1, 2] >>> archive2.getRuns() [1] >>> run2 = archive1.getBidsRun(subject='01', task='test', run=2) >>> archive2.appendBidsRun(run2) >>> archive2.getRuns() [1, 2] """ if run.numIncrementals() == 0: return self._appendIncremental(run.asSingleIncremental())