fetch_figshare_file#
- pypillometry.fetch_figshare_file(article, name, version=None, cache_dir=None, force_download=False, cache_layout='flat')[source]#
Download a file from a public figshare item, with caching.
The download is checked against the MD5 checksum that figshare provides.
- Parameters:
article (int or str) – figshare item ID, URL or DOI (see
get_figshare_files())name (
str) – name of the file in the item (seeget_figshare_files())version (
Optional[int]) – version of the item; default the latest one (or the version in the URL or DOI, if it contains one)cache_dir (
Optional[str]) – directory to store the download in; if None, a new temporary directory is usedforce_download (
bool) – if False (default), an existing local copy is reused (without contacting figshare); if True, the file is downloaded againcache_layout (
str) –"flat"(default) stores the file ascache_dir/<name>,"mirror"ascache_dir/figshare.com/<id>/<version>/<name>(latestif no version is given), so that files with the same name from different items do not share a local copy
- Return type:
- Returns:
local path of the downloaded file
Examples
>>> fname = fetch_figshare_file(28776617, "sub-001_ses-1.pypil", ... cache_dir="data") >>> d = EyeData.from_file(fname)