ibllib.oneibl.registration

Functions

get_lab

Get lab from a session path using the subject name.

get_local_data_repository

Get local data repo name from Globus client.

register_dataset

Registers a set of files belonging to a session only on the server.

register_session_raw_data

Registers all files corresponding to raw data files to Alyx.

rename_files_compatibility

Classes

IBLRegistrationClient

Object that keeps the ONE instance and provides method to create sessions and register data.

register_dataset(file_list, one=None, exists=False, versions=None, **kwargs)[source]

Registers a set of files belonging to a session only on the server.

Parameters:
  • file_list (list, str, pathlib.Path) – A filepath (or list thereof) of ALF datasets to register to Alyx.

  • one (one.api.OneAlyx) – An instance of ONE.

  • exists (bool) – Whether files exist in the repository. May be set to False when registering files before copying to the repository.

  • versions (str, list of str) – Optional version tags, defaults to the current ibllib version.

  • kwargs – Optional keyword arguments for one.registration.RegistrationClient.register_files.

Returns:

A list of newly created Alyx dataset records or the registration data if dry.

Return type:

list of dicts, dict

Notes

  • If a repository is passed, server_only will be set to True.

register_session_raw_data(session_path, one=None, overwrite=False, **kwargs)[source]

Registers all files corresponding to raw data files to Alyx. It will select files that match Alyx registration patterns.

Parameters:
  • session_path (str, pathlib.Path) – The local session path.

  • one (one.api.OneAlyx) – An instance of ONE.

  • overwrite (bool) – If set to True, will patch the datasets. It will take very long. If set to False (default) will skip all already registered data.

  • **kwargs – Optional keyword arguments for one.registration.RegistrationClient.register_files.

Returns:

  • list of pathlib.Path – A list of raw dataset paths.

  • list of dicts, dict – A list of newly created Alyx dataset records or the registration data if dry.

class IBLRegistrationClient(one=None)[source]

Bases: RegistrationClient

Object that keeps the ONE instance and provides method to create sessions and register data.

register_session(ses_path, file_list=True, projects=None, procedures=None)[source]

Register an IBL Bpod session in Alyx.

Parameters:
  • ses_path (str, pathlib.Path) – The local session path.

  • file_list (bool, list) – An optional list of file paths to register. If True, all valid files within the session folder are registered. If False, no files are registered.

  • projects (str, list) – The project(s) to which the experiment belongs (optional).

  • procedures (str, list) – An optional list of procedures, e.g. ‘Behavior training/tasks’.

Returns:

An Alyx session record.

Return type:

dict

Notes

For a list of available projects: >>> sorted(proj[‘name’] for proj in one.alyx.rest(‘projects’, ‘list’)) For a list of available procedures: >>> sorted(proc[‘name’] for proc in one.alyx.rest(‘procedures’, ‘list’))

find_files(session_path)[source]

Similar to base class method but further filters by name and extension.

In addition to finding files that match Excludes files whose extension is in EXCLUDED_EXTENSIONS, or that don’t match the patterns in REGISTRATION_GLOB_PATTERNS.

Parameters:

session_path (str, pathlib.Path) – The session path to search.

Yields:

pathlib.Path – File paths that match the dataset type patterns in Alyx and registration glob patterns.

rename_files_compatibility(ses_path, version_tag)[source]
get_local_data_repository(ac)[source]

Get local data repo name from Globus client.

Parameters:

ac (one.webclient.AlyxClient) – An AlyxClient instance for querying data repositories.

Returns:

The (first) data repository associated with the local Globus endpoint ID.

Return type:

str

get_lab(session_path, alyx=None)[source]

Get lab from a session path using the subject name.

On local lab servers, the lab name is not in the ALF path and the globus endpoint ID may be associated with multiple labs, so lab name is fetched from the subjects endpoint.

Parameters:
  • session_path (str, pathlib.Path) – The session path from which to determine the lab name.

  • alyx (one.webclient.AlyxClient) – An AlyxClient instance for querying data repositories.

Returns:

The lab name associated with the session path subject.

Return type:

str