ONE basic commands

There are four main ONE methods that can be used to search for and download data. Here we provide an introduction to these commands using some simple example implementations. Before proceeding make sure that you have installed the IBL python environment and set up your ONE credentials

1. Importing ONE

To use ONE, we must first import the module and instantiate the ONE class. This can be done using the following commands

[1]:
from oneibl.one import ONE
one = ONE()
Connected to https://alyx.internationalbrainlab.org as mayo

Note

If you are trying to connect through your personal IP address you may recieve the following error

ConnectionError: Can't connect to https://alyx.internationalbrainlab.org.
IP addresses are filtered on IBL database servers.
Are you connecting from an IBL participating institution ?

If so, make sure you VPN into an IBL institution network

2. Searching for data

Each experimental session is identified by a unique string known as an experiment ID (eID). To search for experiments, we can use the one.search command. This will return a list of eIDs that match the search criterion.

The possible searchable fields can be listed using the method

[2]:
one.search_terms()
Out[2]:
['dataset_types',
 'date_range',
 'lab',
 'location',
 'number',
 'performance_gte',
 'performance_lte',
 'project',
 'subject',
 'task_protocol',
 'users']

Let’s search for the experiments performed with the subject KS022 on the 10 December 2019

[3]:
eid = one.search(subject='KS022', date_range=['2019-12-10', '2019-12-10'])[0]
print(f"experiment ID = {eid}")
experiment ID = a3df91c8-52a6-4afa-957b-3479a7d0897c

To get more information about the returned sessions, we can add in a details flag

[4]:
eids, ses_info = one.search(subject='KS022', date_range=['2019-12-10', '2019-12-10'], details=True)
eid = eids[0]

from ibllib.misc import pprint
pprint(ses_info[0])
{
    "subject": "KS022",
    "start_time": "2019-12-10T14:40:57.879000",
    "number": 1,
    "lab": "cortexlab",
    "project": "carandiniharris_midbrain_ibl",
    "url": "https://alyx.internationalbrainlab.org/sessions/a3df91c8-52a6-4afa-957b-3479a7d0897c",
    "task_protocol": "_iblrig_tasks_ephysChoiceWorld6.1.3",
    "local_path": "C:\\Users\\Mayo\\Downloads\\FlatIron\\cortexlab\\Subjects\\KS022\\2019-12-10\\001"
}

3. Listing available data

Once the eID of the session of interest is known, we can list the available datasets using the one.list command

[5]:
one.list(eid)
Out[5]:
['_iblrig_codeFiles.raw',
 '_iblrig_taskSettings.raw',
 'trials.response_times',
 'clusters.channels',
 'spikes.depths',
 '_spikeglx_sync.times',
 'spikes.depths',
 'clusters.amps',
 'trials.goCueTrigger_times',
 'clusters.waveforms',
 'channels.localCoordinates',
 'ephysData.raw.sync',
 '_iblrig_encoderTrialInfo.raw',
 '_phy_spikes_subset.waveforms',
 '_spikeglx_sync.channels',
 'clusters.waveformsChannels',
 'ephysData.raw.meta',
 'wheel.position',
 'trials.stimOn_times',
 'trials.probabilityLeft',
 'templates.amps',
 'camera.times',
 'probes.trajectory',
 'spikes.clusters',
 'channels.localCoordinates',
 '_iblqc_ephysSpectralDensity.freqs',
 'templates.waveforms',
 'probes.description',
 'trials.goCue_times',
 'clusters.uuids',
 '_iblqc_ephysTimeRms.rms',
 'ephysData.raw.ch',
 '_iblqc_ephysSpectralDensity.freqs',
 'ephysData.raw.ap',
 '_iblqc_ephysSpectralDensity.freqs',
 'templates.waveformsChannels',
 'ephysData.raw.meta',
 'ephysData.raw.meta',
 '_iblrig_Camera.timestamps',
 'ephysData.raw.meta',
 '_iblrig_Camera.raw',
 'trials.itiDuration',
 'camera.times',
 'clusters.waveformsChannels',
 '_iblqc_ephysTimeRms.timestamps',
 'clusters.depths',
 '_iblqc_ephysTimeRms.timestamps',
 '_phy_spikes_subset.spikes',
 '_iblrig_Camera.raw',
 'trials.stimOff_times',
 'spikes.times',
 'clusters.uuids',
 'ephysData.raw.ap',
 'ephysData.raw.meta',
 'wheelMoves.intervals',
 'templates.waveformsChannels',
 '_iblqc_ephysTimeRms.timestamps',
 '_iblqc_ephysTimeRms.rms',
 '_iblqc_ephysTimeRms.timestamps',
 '_iblrig_encoderEvents.raw',
 'spikes.templates',
 'ephysData.raw.sync',
 'clusters.waveforms',
 '_iblrig_Camera.timestamps',
 'trials.contrastLeft',
 '_spikeglx_sync.channels',
 'spikes.amps',
 'ephysData.raw.nidq',
 '_spikeglx_sync.channels',
 'trials.feedback_times',
 '_phy_spikes_subset.waveforms',
 'ephysData.raw.ch',
 '_spikeglx_sync.times',
 '_iblqc_ephysTimeRms.rms',
 'spikes.times',
 '_spikeglx_sync.polarities',
 'spikes.samples',
 'clusters.peakToTrough',
 'spikes.amps',
 'templates.amps',
 'spikes.samples',
 'ephysData.raw.ch',
 '_spikeglx_sync.times',
 'camera.dlc',
 'camera.dlc',
 'trials.firstMovement_times',
 'trials.feedbackType',
 'clusters.metrics',
 'trials.intervals',
 'ephysData.raw.wiring',
 'channels.rawInd',
 'ephysData.raw.ch',
 '_iblqc_ephysTimeRms.rms',
 'wheelMoves.peakAmplitude',
 'trials.choice',
 '_phy_spikes_subset.spikes',
 'templates.waveforms',
 'camera.times',
 '_phy_spikes_subset.channels',
 'ephysData.raw.ch',
 '_iblrig_Camera.raw',
 'ephysData.raw.lf',
 'channels.rawInd',
 'wheel.timestamps',
 '_spikeglx_sync.polarities',
 '_iblrig_ambientSensorData.raw',
 '_iblqc_ephysSpectralDensity.power',
 'clusters.channels',
 '_iblqc_ephysSpectralDensity.power',
 'clusters.metrics',
 'wheel.timestamps',
 '_spikeglx_sync.polarities',
 'trials.intervals',
 'spikes.templates',
 'clusters.amps',
 'ephysData.raw.wiring',
 '_iblqc_ephysSpectralDensity.power',
 'trials.rewardVolume',
 'kilosort.whitening_matrix',
 'ephysData.raw.wiring',
 '_iblqc_ephysSpectralDensity.power',
 'clusters.peakToTrough',
 'ephysData.raw.timestamps',
 'kilosort.whitening_matrix',
 '_iblqc_ephysSpectralDensity.freqs',
 '_iblrig_Camera.timestamps',
 '_phy_spikes_subset.channels',
 'ephysData.raw.lf',
 'ephysData.raw.timestamps',
 '_iblrig_taskData.raw',
 'clusters.depths',
 'trials.contrastRight',
 'spikes.clusters',
 '_iblrig_encoderPositions.raw']

We can set the details flag to True to return more information about each dataset

[6]:
data_details = one.list(eid, details=True)
data_details[0]
Out[6]:
[]

4. Loading data

Once we have information about the session eID and the list of available dataset types we can use the one.load function to download the data from FlatIron. Let’s download the clusters.amps and clusters.depths datasets

[7]:
dataset_types = ['clusters.amps', 'clusters.depths']
amps0, depths0, amps1, depths1 = one.load(eid, dataset_types=dataset_types)

Note

Loading clusters.amps and clusters.depths returned four variables. This is because there is electrophysiology data for two different probes for this session.

To find out more details about what is being downloaded we can return a data class that contains information about each of the downloaded datasets. This can be added by setting the dclass_output argument to True.

[8]:
data = one.load(eid, dataset_types=dataset_types, dclass_output=True)

We have access to the following information

[9]:
data.__dict__.keys()
Out[9]:
dict_keys(['dataset_type', 'dataset_id', 'local_path', 'eid', 'url', 'data', 'hash', 'file_size'])

For example if we look at the local_path we will see that the data has come from two different probes, probe00 and probe01

[10]:
data.local_path
Out[10]:
[WindowsPath('C:/Users/Mayo/Downloads/FlatIron/cortexlab/Subjects/KS022/2019-12-10/001/alf/probe01/clusters.depths.npy'),
 WindowsPath('C:/Users/Mayo/Downloads/FlatIron/cortexlab/Subjects/KS022/2019-12-10/001/alf/probe01/clusters.amps.npy'),
 WindowsPath('C:/Users/Mayo/Downloads/FlatIron/cortexlab/Subjects/KS022/2019-12-10/001/alf/probe00/clusters.amps.npy'),
 WindowsPath('C:/Users/Mayo/Downloads/FlatIron/cortexlab/Subjects/KS022/2019-12-10/001/alf/probe00/clusters.depths.npy')]

Tip

To find out more information about the ONE functions and the arguments that can be parsed we can use the help command. For example we can type

[11]:
help(one.load)
Help on method load in module oneibl.one:

load(eid, dataset_types=None, dclass_output=False, dry_run=False, cache_dir=None, download_only=False, clobber=False, offline=False, keep_uuid=False) method of oneibl.one.OneAlyx instance
    From a Session ID and dataset types, queries Alyx database, downloads the data
    from Globus, and loads into numpy array.

    :param eid: 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.
    :type eid: str
    :param dataset_types: [None]: Alyx dataset types to be returned.
    :type dataset_types: list
    :param dclass_output: [False]: forces the output as dataclass to provide context.
    :type dclass_output: bool
     If None or an empty dataset_type is specified, the output will be a dictionary by default.
    :param cache_dir: temporarly overrides the cache_dir from the parameter file
    :type cache_dir: str
    :param download_only: do not attempt to load data in memory, just download the files
    :type download_only: bool
    :param clobber: force downloading even if files exists locally
    :type clobber: bool
    :param keep_uuid: keeps the UUID at the end of the filename (defaults to False)
    :type keep_uuid: bool

    :return: List of numpy arrays matching the size of dataset_types parameter, OR
     a dataclass containing arrays and context data.
    :rtype: list, dict, dataclass SessionDataInfo