User Tools

Site Tools


analysis:adrlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
analysis:adrlab [2013/04/26 12:00]
mvdm
analysis:adrlab [2013/08/09 13:24]
aacarey [Basic data loading]
Line 1: Line 1:
 +===== Overview of data files =====
 +
 +A promoted (i.e. pre-processed,​ annotated, and approved) data folder consists of most of the following files:
 +
 +   * *.Ncs files: continuously sampled data, "local field potentials"​
 +   * (*.ntt files: raw tetrode files, these are generally not included)
 +   * *.Nev file: raw Events file
 +   * *.Nvt file: video tracking file (usually zipped)
 +
 +The above are raw data files stored by Neuralynx. The following files are the result of preprocessing and annotation:
 +
 +   * *.t files: spike times for one putative neuron (output from MClust)
 +   * *.clusters: cluster information (output from MClust, you will generally not need this)
 +   * *wv.mat and *%%ClusterQual%%.mat files: waveforms and cluster quality metrics
 +   * *Metadata.mat file: structured task-related information such as locations of feeders, times of rewards, etc. (not included in all sessions)
 +   * *%%ExpKeys%%.m file: basic information about this recording session, such as task, start time, end time, etc. (note this is a .m file, so needs to be run rather than loaded as you would a .mat file)
 +   * *vt.mat file: pre-processed video tracking data
 +
 +Note the naming convention for the above files: all files are identified by the RYYYY-MM-DD string in the filename, and recording files are further named with the tetrode number.
 +
 +===== Basic data loading =====
 +
 +The below will only work if you have grabbed the vandermeerlab code base and added it to your MATLAB path ([[computing:​matlabsetup|instructions]]). If you are using a Mac, you will need to get the data loading files from Neuralynx and add them to the relevant folders (you'​ll know where when you get errors upon trying to load something).
 +
 +First, change your current (working) folder to the recording session of interest.
 +
 +Spike time series from a single cluster (putative neuron) are stored in a *.t file. These files are generated by MClust after the spike sorting process is complete.
 +
 +To load all spike trains in a folder:
 +
 +<code matlab>
 +>> S = LoadSpikes(FindFiles('​*.t'​));​
 +</​code>​
 +
 +this gives a cell array S with one cell for each spike train, stored in a ts object:
 +
 +<code matlab>
 +>> plot(Data(S{1}),​0,'​.k'​);​ % crude plot
 +</​code>​
 +
 +This plots the spike times of the first cluster. A ts object is a custom (not built in into MATLAB) object with a number of methods (functions):​ the most useful are Data (get the spike times stored in it) and Restrict (restrict the spike times to specific times).
 +
 +To load and plot a CSC file:
 +
 +<code matlab>
 +>> csc = LoadCSC(FindFile('​*CSC1a.Ncs'​),'​ConvertToS',​1);​
 +>> plot(Range(csc),​Data(csc));​
 +</​code>​
 +
 +Note that %%LoadCSC%% returns a tsd object ("​timestamped data") which consists of matching arrays of times and data. As with ts objects, Range() returns the times, but now there is also Data() which returns the data.
 +
 +Be aware that this time series can be restricted to the time the rat was actually freely moving and engaged in behavior; use the %%ExpKeys%% file and the Restrict function explained below to do this.
 +
 +To access the position data, first load the *vt.mat file (which contains the x and y tsd objects) and then do:
 +
 +<code matlab>
 +x_data = Data(Vt.x);
 +y_data = Data(Vt.y);
 +plot(x_data,​y_data,'​.'​);​ % notice this has some extra tracking data outside of the track
 +</​code>​
 +
 +We will now use the %%ExpKeys%% file and Restrict to only include data when the rat was actually on the track:
 +
 +<code matlab>
 +run(FindFile('​*keys.m'​));​ % load experimental metadata; notice this is a script so we can run it
 +x = Restrict(Vt.x,​ExpKeys.TimeOnTrack,​ExpKeys.TimeOffTrack);​ % only include data from when rat was on track
 +y = Restrict(Vt.y,​ExpKeys.TimeOnTrack,​ExpKeys.TimeOffTrack);​
 +plot(Data(x),​Data(y),'​.'​);​ % looks better now
 +</​code>​
 +
 +
 ====== Description of the Multiple-T task ====== ====== Description of the Multiple-T task ======
  
Line 5: Line 76:
  
 ====== Metadata ====== ====== Metadata ======
 +
 +This is example of a Metadata struct, taken from session ZXXX
  
 <code matlab> <code matlab>
Line 20: Line 93:
          ​Linpath:​ [1x1 struct]          ​Linpath:​ [1x1 struct]
 </​code>​ </​code>​
- 
analysis/adrlab.txt ยท Last modified: 2018/07/07 10:19 (external edit)