Listing Alyx Filenames

An ALyx Filename (ALF) is any file whose path matches a specific pattern. We will use the following file structure as an example:

├─ 2021-06-30/
│  ├─ 001/
│  │  ├─ alf/
│  │  │  ├─ probe00/
│  │  │  │  ├─ spikes.clusters.npy
│  │  │  │  ├─ spikes.times.npy
│  │  │  ├─ probe01/
│  │  │  │  ├─ #2021-07-05#/
│  │  │  │  │  ├─ spikes.clusters.npy
│  │  │  │  │  ├─ spikes.times.npy
│  │  │  │  ├─ spikes.clusters.npy
│  │  │  │  ├─ spikes.times.npy
│  │  ├─ probes.description.json

Let’s create some files and generate an ONE cache table:

from tempfile import TemporaryDirectory
from pathlib import Path
from one.alf.cache import make_parquet_db

files = [

temp_dir = TemporaryDirectory()  # Create a temporary directory in which to place Alyx files
for file in files:
    file_path = Path(  # Create full path
    file_path.parent.mkdir(parents=True, exist_ok=True)  # Create directories
    file_path.touch()  # Create empty file

make_parquet_db(  # Generate cache tables

The full spec is available in the one.alf.spec module:

import one.alf.spec as alf_spec
from one.api import ONE

one = ONE(

A valid ALF path includes the following parts (those in brackets are optional):


Details of each part can be obtained through the one.alf.spec.describe function:


An optional folder to group data by modality, device, etc.  This is necessary when a session
contains multiple measurements of the same type, from example spike times from multiple probes.
Label examples include "probe00", "raw_video_data".

When using One.load_object an object is passed to the method for loading. Other specifiers such as attributes, collection and revision may be passed.

To list all the files in ‘subject/2021-06-01/001’


To list all datasets in the ‘alf/probe01’ collection

[ ]:
one.list_datasets('subject/2021-06-01/001', collection='alf/probe01')

To list all datasets not in a collection

one.list_datasets('subject/2021-06-01/001', collection='')

To list all revisions for a given session

revisions = one.list_revisions('subject/2021-06-01/001')
[x or None for x in revisions]
[None, '2021-07-05']

To list all collections for a given session

collections = one.list_collections('subject/2021-06-01/001')
[x or None for x in collections]
[None, 'alf/probe00', 'alf/probe01']

To load the ‘spikes’ object from the ‘alf/probe00’ collection

spikes = one.load_object('subject/2021-06-01/001', 'spikes', collection='alf/probe00')

To load the ‘spikes’ object from the ‘alf/probe01’ collection, and the last revision before or on July 1st

spikes = one.load_object('subject/2021-06-01/001', 'spikes',
                         collection='alf/probe01', revision='2021-07-01')

To load ‘spikes.times’ from collection ‘alf/probe00’

spike_times = one.load_dataset('subject/2021-06-01/001', 'spikes.times.npy',

Click here for more information on the ALF specification. Click here for information on creating and validating new dataset types.