Skip to content

Getting your data into Buzlab format

Brendon Watson edited this page Apr 14, 2017 · 4 revisions

We use .mat-based metadata and we will ask that this metadata be put in by the user before other functions are able to act on the data in a fully-compatible manner.

Data is assumed to be organized into session folders. Typically a session is a recording during one working day, say for 2-11 hours. Each session folder has a name /basename/ and files in it will have names such as basename.dat, basename.xml, basename.SessionMetadata.mat. The session folder's full path is called basepath. Basepath is the default input for buzcode functions and again, is assumed to always end with a directory called basename.

One point here for lab users is that this does not necessarily use .xml data as a primary input. That is because .xml files made in neuroscope or ndmanager are often filled with errors (ie amplification). Rather this goes to the intan info.rhd or the amplipex .meta files to get the recording parameters directly from the recording itself, which should be more reliable than the .xml. Rather this creates an .xml reflecting the user input here so that all information will be synchronized.

We have two levels of initial Metadata organization we have decided to start with - Animal and Session.

Animalname.AnimalMetadata.mat can be created at any time including before any recordings are made and it includes things like surgical notes, probes implanted, viruses used, etc. A Animalname.AnimalMetadata.mat file is created in this process and saved somewhere, commonly this might be in a directory containing all data for that animal (in which might also be found data for each recording session, typically a session is a recording during one working day).

Basename.SessionMetadata.mat can be created only after a recording is made and it includes things like turns on each drive since surgery, badchannels, badshanks, behavioral information, .dat file names sizes and durations, etc. A Basename.SessionMetadata.mat file is created in this process and saved somewhere, commonly this might be in a directory containing all data for that animal (in which might also be found data for each recording session,).

This platform should work across Linux/Windows or Mac and should work particularly well with either Intan or Amplipex data, but can and will be modified to work with other systems.

Typical organizations created by recording systems: Intan: ...etc/BasepathWhereLastDirectoryIsBasename/ timestamped_folderfordat1/ amplifier.dat ...etc/BasepathWhereLastDirectoryIsBasename/ timestamped_folderfordat2/ amplifier.dat ...

Amplipex ...etc/BasepathWhereLastDirectoryIsBasename/ basename01.dat ...etc/BasepathWhereLastDirectoryIsBasename/ basename02.dat ...

BASIC SCHEME FOR CREATING METADATA .m files (text files) are created, which when run will create .mat files.
The .mat file is where the important metadata is stored. The .m files have two sections, 1) a generally upper part where users will input text and numbers to specify things like locations of targets "CA1", Features to extract per waveform for clustering (4) etc and 2) an automated part that takes the user-entered info and other info to generate other stored values (ie file sizes, probe maps etc).
To change metadata once it's been made, just re-open the .m file, change the values you want changed and re-run it.

TO CREATE AN ANIMAL METADATA FILE There are 3 levels of functions you can call in MATLAB to manipulate and create AnimalMetadata, each makes a bit more of an assumption than the last.

  • bz_EditAnimalMetadata - Opens up an animal metadata .m file in the matlab text editor so it can be manually edited and run. Creates this .m file from defaults if it doesn't exist yet.
  • bz_RunAnimalMetadata - (Creates and) opens and then allows user to trigger an auto-run the .m file to create the .mat without further steps
  • bz_PreprocessExtracellEphysAnimal.m - Executes bz_RunAnimalMetadata then also makes an .xml file. Basically, assumes you are recording new ephys data.

TO CREATE A SESSION METADATA FILE There are 3 levels of functions you can call in MATLAB to manipulate and create SessionMetadata, each makes a bit more of an assumption than the last.

  • bz_EditSessionMetadata - Opens up an session metadata .m file in the matlab text editor so it can be manually edited and run. Creates this .m file from defaults if it doesn't exist yet.
  • bz_RunSessionMetadata - (Creates and) opens and then allows user to trigger an auto-run the .m file to create the .mat without further steps
  • bz_PreprocessExtracellEphysSession.m - Executes bz_RunSessionMetadata, makes an .xml file, concatenates .dat files together and makes a .lfp file from the concatenated .dat. Basically, assumes you are recording new ephys data.