rtCommon.openNeuro

An interface to access OpenNeuro data and metadata. It can download and cache OpenNeuro data for playback.

Module Contents

Classes

OpenNeuroCache

class rtCommon.openNeuro.OpenNeuroCache(cachePath='/tmp/openneuro/')
getCachePath(self)
getS3Client(self)

Returns an s3 client in order to reuse the same s3 client without always creating a new one. Not thread safe currently.

getDatasetList(self, refresh=False)

Returns a list of all datasets available in OpenNeuro S3 storage. See https://openneuro.org/public/datasets for datasets info. Alternate method to access from a command line call: [aws s3 –no-sign-request ls s3://openneuro.org/]

isValidAccessionNumber(self, dsAccessionNum)
getSubjectList(self, dsAccessionNum)

Returns a list of all the subjects in a dataset

Parameters

dsAccessionNum – accession number of dataset to lookup

Returns

list of subjects in that dataset

getDescription(self, dsAccessionNum)

Returns the dataset description file as a python dictionary

getReadme(self, dsAccessionNum)

Return the contents of the dataset README file. Downloads toplevel dataset files if needed.

getArchivePath(self, dsAccessionNum)

Returns the directory path to the cached dataset files

downloadData(self, dsAccessionNum, downloadWholeDataset=False, **entities)

This command will sync the specified portion of the dataset to the cache directory. Note: if only the accessionNum is supplied then it will just sync the top-level files. Sync doesn’t re-download files that are already present in the directory. Consider using –delete which removes local cache files no longer on the remote.

Parameters
  • dsAccessionNum – accession number of the dataset to download data for.

  • downloadWholeDataset – boolean, if true all files in the dataset will be downloaded.

  • entities – BIDS entities (subject, session, task, run, suffix) that define the particular subject/run of the data to download.

Returns

Path to the directory containing the downloaded dataset data.