oneibl.one

Functions

Listable

ONE

parse_id

Ensures the input experiment identifier is an experiment UUID string :param method: An ONE method whose second arg is an experiment id :return: A wrapper function that parses the id to the expected string

Classes

OneAbstract

OneAlyx

OneOffline

Listable(t)[source]
parse_id(method)[source]

Ensures the input experiment identifier is an experiment UUID string :param method: An ONE method whose second arg is an experiment id :return: A wrapper function that parses the id to the expected string

class OneAbstract(username=None, password=None, base_url=None, cache_dir=None, silent=None)[source]

Bases: abc.ABC

path_from_eid(eid: str) → Optional[Union[pathlib.Path, Sequence[pathlib.Path]]][source]

From an experiment id or a list of experiment ids, gets the local cache path :param eid: eid (UUID) or list of UUIDs :return: eid or list of eids

eid_from_path(path_obj)[source]

From a local path, gets the experiment id :param path_obj: local path or list of local paths :return: eid or list of eids

abstract load(**kwargs)[source]
abstract list(**kwargs)[source]
abstract search(**kwargs)[source]
ONE(offline=False, **kwargs)[source]
class OneOffline(username=None, password=None, base_url=None, cache_dir=None, silent=None)[source]

Bases: oneibl.one.OneAbstract

load(eid, **kwargs)[source]
list(**kwargs)[source]
search(**kwargs)[source]
class OneAlyx(**kwargs)[source]

Bases: oneibl.one.OneAbstract

property alyx
help(dataset_type=None)[source]
list(eid: Optional[Union[str, pathlib.Path, uuid.UUID]] = None, details=False) → Union[List, Dict[str, str]][source]

From a Session ID, queries Alyx database for datasets related to a session.

Parameters
  • eid (bool) – Experiment session uuid str

  • details – If false returns a list of path, otherwise returns the REST dictionary

Returns

list of strings or dict of lists if details is True

Return type

list, dict

load(eid, dataset_types=None, dclass_output=False, dry_run=False, cache_dir=None, download_only=False, clobber=False, offline=False, keep_uuid=False)[source]

From a Session ID and dataset types, queries Alyx database, downloads the data from Globus, and loads into numpy array.

Parameters
  • eid (str) – Experiment ID, for IBL this is the UUID of the Session as per Alyx database. Could be a full Alyx URL: ‘http://localhost:8000/sessions/698361f6-b7d0-447d-a25d-42afdef7a0da’ or only the UUID: ‘698361f6-b7d0-447d-a25d-42afdef7a0da’. Can also be a list of the above for multiple eids.

  • dataset_types (list) – [None]: Alyx dataset types to be returned.

  • dclass_output (bool If None or an empty dataset_type is specified, the output will be a dictionary by default.) – [False]: forces the output as dataclass to provide context.

  • cache_dir (str) – temporarly overrides the cache_dir from the parameter file

  • download_only (bool) – do not attempt to load data in memory, just download the files

  • clobber (bool) – force downloading even if files exists locally

  • keep_uuid (bool) – keeps the UUID at the end of the filename (defaults to False)

Returns

List of numpy arrays matching the size of dataset_types parameter, OR a dataclass containing arrays and context data.

Return type

list, dict, dataclass SessionDataInfo

load_dataset(eid: Union[str, pathlib.Path, uuid.UUID], dataset: str, collection: Optional[str] = None, download_only: bool = False) → Any[source]

Load a single dataset from a Session ID and a dataset type.

Parameters

eid – Experiment session identifier; may be a UUID, URL, experiment reference string

details dict or Path :param dataset: The ALF dataset to load. Supports asterisks as wildcards. :param collection: The collection to which the object belongs, e.g. ‘alf/probe01’. For IBL this is the relative path of the file from the session root. Supports asterisks as wildcards. :param download_only: When true the data are downloaded and the file path is returned :return: dataset or a Path object if download_only is true

Examples

intervals = one.load_dataset(eid, ‘_ibl_trials.intervals.npy’) intervals = one.load_dataset(eid, ‘trials.intervals’) filepath = one.load_dataset(eid ‘_ibl_trials.intervals.npy’, download_only=True) spikes = one.load_dataset(eid ‘spikes.times.npy’, collection=’alf/probe01’)

load_object(eid: Union[str, pathlib.Path, uuid.UUID], obj: str, collection: Optional[str] = 'alf', download_only: bool = False, **kwargs) → Union[alf.io.AlfBunch, List[pathlib.Path]][source]

Load all attributes of an ALF object from a Session ID and an object name.

Parameters

eid – Experiment session identifier; may be a UUID, URL, experiment reference string

details dict or Path :param obj: The ALF object to load. Supports asterisks as wildcards. :param collection: The collection to which the object belongs, e.g. ‘alf/probe01’. Supports asterisks as wildcards. :param download_only: When true the data are downloaded and the file paths are returned :param kwargs: Optional filters for the ALF objects, including namespace and timescale :return: An ALF bunch or if download_only is True, a list of Paths objects

Examples: load_object(eid, ‘*moves’) load_object(eid, ‘trials’) load_object(eid, ‘spikes’, collection=’*probe01’)

to_eid(id: Union[str, pathlib.Path, uuid.UUID, dict, Sequence[Union[str, pathlib.Path, uuid.UUID, dict]]] = None, cache_dir: Optional[Union[str, pathlib.Path]] = None) → Union[str, Sequence[str]][source]
search(details=False, limit=None, **kwargs)[source]
Applies a filter to the sessions (eid) table and returns a list of json dictionaries

corresponding to sessions.

For a list of search terms, use the methods

>>> one.search_terms()
Parameters
  • dataset_types (list of str) – list of dataset_types

  • date_range (list) – list of 2 strings or list of 2 dates that define the range

  • details (bool) – default False, returns also the session details as per the REST response

  • lab (list or str) – a str or list of lab names

  • limit (int List of possible search terms) – default None, limits results (if pagination enabled on server)

  • location (str) – a str or list of lab location (as per Alyx definition) name Note: this corresponds to the specific rig, not the lab geographical location per se

  • number (str or int) – number of session to be returned; will take the first n sessions found

  • / performance_gte (performance_lte) – search only for sessions whose performance is

less equal or greater equal than a pre-defined threshold as a percentage (0-100) :type performance_gte: float

Parameters
  • subjects (list or str) – a list of subjects nickname

  • task_protocol (str) – a str or list of task protocol name (can be partial, i.e. any task protocol containing that str will be found)

  • users (list or str) – a list of users

Returns

list of eids, if details is True, also returns a list of json dictionaries, each entry corresponding to a matching session

Return type

list, list

download_datasets(dsets, **kwargs)[source]

Download several datsets through a list of alyx REST dictionaries :param dset: list of dataset dictionaries from an Alyx REST query OR list of URL strings :return: local file path

download_dataset(dset, cache_dir=None, **kwargs)[source]

Download a dataset from an alyx REST dictionary :param dset: single dataset dictionary from an Alyx REST query OR URL string :param cache_dir (optional): root directory to save the data in (home/downloads by default) :return: local file path

static search_terms()[source]

Returns possible search terms to be used in the one.search method.

Returns

a tuple containing possible search terms:

Return type

tuple

static keywords()[source]

Returns possible keywords to be used in the one.list method

Returns

a tuple containing possible search terms:

Return type

tuple

static setup()[source]

Interactive command tool that populates parameter file for ONE IBL.

path_from_eid(eid: str, use_cache: bool = True) → Union[pathlib.Path, Sequence[pathlib.Path]][source]

From an experiment id or a list of experiment ids, gets the local cache path :param eid: eid (UUID) or list of UUIDs :param use_cache: if set to False, will force database connection :return: eid or list of eids

eid_from_path(path_obj: Union[str, pathlib.Path], use_cache: bool = True) → Union[pathlib.Path, Sequence[pathlib.Path]][source]

From a local path, gets the experiment id :param path_obj: local path or list of local paths :param use_cache: if set to False, will force database connection :return: eid or list of eids

url_from_path(filepath)[source]

Given a local file path, returns the URL of the remote file. :param filepath: A local file path :return: A URL string

datasets_from_type(eid, dataset_type, full=False)[source]

Get list of datasets belonging to a given dataset type for a given session :param eid: Experiment session identifier; may be a UUID, URL, experiment reference string details dict or Path :param dataset_type: A dataset type, e.g. camera.times :param full: If True, a dictionary of details is returned for each dataset :return: A list of datasets belonging to that session’s dataset type

get_details(eid: str, full: bool = False)[source]

Returns details of eid like from one.search, optional return full session details.

download_raw_partial(url_cbin, url_ch, first_chunk=0, last_chunk=0)[source]