Package: arfx
arfxis a family of commandline tools for copying sampled data in
and out of ARF containers. ARF (https://github.com/melizalab/arf) is an
open, portable file format for storing behavioral and neural data, based
onHDF5.installationpipinstallarfxor from source:pythonsetup.pyinstallusageThe general syntax isarfx operation [options] files. The syntax is
similar totar. Operations are as follows:-A:copy data from one container to another-c:create a new container-r:append data to the container-t:list contents of the container-x:extract entries from the container-d:delete entries from the containerOptions specify the target ARF file, verbosity, automatic naming
schemes, and any metadata to be stored in the entry.-f FILE:use ARF file FILE-v:verbose output-n NAME:name entries sequentially, using NAME as the base-a ANIMAL:specify the animal-e EXPERIMENTER:specify the experimenter-p PROTOCOL:specify the protocol-s HZ:specify the sampling rate of the data, in Hz-T DATATYPE:specify the type of data-u:do not compress data in the arf file-P:when deleting entries, do not repackinput filesarfxcan read sampled data frompcm,wave,npyandmdafiles. Support for additional file formats can be added as
plugins (see 4).When adding data to an ARF container (-cand-rmodes), the
input files are specified on the command line, and added in the order
given. By default, entries are given the same name as the input file,
minus the extension; however, if the input file has more than one entry,
they are given an additional numerical extension. To override this, the-nflag can be used to specify the base name; all entries are given
sequential names based on this.The-n,-a,-e,-p,-s,-Toptions are used to store information
about the data being added to the file. The DATATYPE argument can be the
numerical code or enumeration code (runarfx--help-datatypesfor a
list), and indicates the type of data in the entries. All of the entries
created in a single run of arfx are given these values. The-uoption tells arfx not to compress the data, which can speed up I/O
operations slightly.Currently only one sampled dataset per entry is supported. Clearly this
does not encompass many use cases, butarfxis intended as a simple
tool. More specialized import procedures can be easily written in Python
using thearflibrary.output filesThe entries to be extracted (in-xmode) can be specified by name.
If no names are specified, all the entries are extracted. All sampled
datasets in each entry are extracted as separate channels, because they
may have different sampling rates. Event datasets are not extracted.By default the output files will be inwaveformat and will have
names with the formatentry_channel.wav. The-nargument can be
used to customize the names and file format of the output files. The
argument must be a template in the format defined by thepython string
module.
Supported field names includeentry,channel, andindex, as
well as the names of any HDF5 attributes stored on the entry or channel.
The extension of the output template is used to determine the file
format. Currently onlywaveis supported, but additional formats may
be supplied as plugins (see 4).The metadata options are ignored when extracting files; any metadata
present in the ARF container that is also supported by the target
container is copied.other operationsAs withtar, the-toperation will list the contents of the
archive. Each entry/channel is listed on a separate line in path
notation.The-Aflag is used to copy the contents of one ARF file to another.
The entries are copied without modification from the source ARF file(s)
to the target container.The-d(delete) operation uses the same syntax as the extract
operation, but instead of extracting the entries, they are deleted.
Because of limitations in the underlying HDF5 library, this does not
free up the space, so the file is repacked unless the-Poption is
set.The-U(update) operation can be used to add or update attributes of
entries, and to rename entries (if the-nflag is set).The--write-attroperation can be used to store the contents of text
files in top-level attributes. The attributes have the nameuser_<filename>. The--read-attroperation can be used to read
out those attributes. This is useful when data collection programs
generate log or settings files that you want to store in the ARF file.other utilitiesThis package comes with a few additional scripts that do fairly specific
operations.arfx-splitThis script is used to reorganize very large recordings, possibly
contained in multiple files, into manageable chunks. Each new entry is
given an updated timestamp and attributes from the source entries.
Currently, no effort is made to splice data across entries or files.
This may result in some short entries. Only sampled datasets are
processed.arfx-collect-sampledThis script is used to export data into a flat binary structure. It
collects sampled data across channels and entries into a single 2-D
array. The output can be stored in a multichannel wav file or in a raw
binarydatformat (N samples by M channels), which is used by a wide
variety of spike-sorting tools.extending arfxAdditional formats for reading and writing can be added using the Python
setuptools plugin system. Plugins must be registered in thearfx.ioentry point group, with a name corresponding to the extension of the
file format handled by the plugin.An arfx IO plugin is a class with the following required methods:__init__(path, mode, **attributes): Opens the file atpath. Themodeargument specifies whether the file is opened for reading
(r), writing (w), or appending (a). Must throw anIOErrorif the file does not exist or cannot be created, and aValueErrorif the specified value formodeis not supported. The
additionalattributesarguments specify metadata to be stored in the
file when created.arfxwill pass all attributes of the channel and
entry (e.g.,channels,sampling_rate,units, anddatatype) when opening a file for writing. This method may issue aValueErrorif the caller fails to set a required attribute, or
attempts to set an attribute inconsistent with the data format.
Unsupported attributes should be ignored.read(): Reads the contents of the opened file and returns the data
in a format suitable for storage in an ARF file. Specifically, it must
be an acceptable type for thearf.entry.add_data()method (seehttps://github.com/melizalab/arffor documentation).write(data): Writes data to the file. Must issue anIOErrorif
the file is opened in the wrong mode, andTypeErrorif the data
format is not correct for the file format.timestamp: A readable property giving the time point of the data.
The value may be a scalar indicating the number of seconds since the
epoch, or a two-element sequence giving the number of seconds and
microseconds since the epoch. If this property is writable it will be
set byarfxwhen writing data.sampling_rate: A property indicating the sampling rate of the data
in the file (or current entry), in units of Hz.The class may also define the following methods and properties. If any
property is not defined, it is assumed to have the default value defined
below.nentries: A readable property indicating the number of entries in
the file. Default value is 1.entry: A readable and writable integer-valued property corresponding
to the index of the currently active entry in the file. Active means
that theread()andwrite()methods will affect only that entry.
Default is 0, andarfxwill not attempt to change the property ifnentriesis 1.version informationarfxuses semantic versioning and is synchronized with the
major/minor version numbers of the arf package specification.