User Tools

Site Tools


analysis:nsb2017:week2

Differences

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

Link to this comparison view

Next revision
Previous revision
analysis:nsb2017:week2 [2017/07/02 16:30]
mvdm created
analysis:nsb2017:week2 [2023/04/13 12:20] (current)
Line 1: Line 1:
-~~DISCUSSION~~+~~DISCUSSION:off~~
  
 ===== Module 2: Introduction to neural data types, file formats and preprocessing ===== ===== Module 2: Introduction to neural data types, file formats and preprocessing =====
Line 108: Line 108:
 If at some point you want to construct a ''​tsd''​ variable yourself, you can do ''​help tsd''​ to see how. The ''​tsd()''​ function is a //​constructor//​ for variables of type ''​tsd''​. ''​LoadCSC()''​ calls this function to create an empty ''​tsd''​ template, and then fills it with data loaded from ''​.ncs''​ files; you can check if the result meets the specification by calling ''​CheckTSD()''​. If at some point you want to construct a ''​tsd''​ variable yourself, you can do ''​help tsd''​ to see how. The ''​tsd()''​ function is a //​constructor//​ for variables of type ''​tsd''​. ''​LoadCSC()''​ calls this function to create an empty ''​tsd''​ template, and then fills it with data loaded from ''​.ncs''​ files; you can check if the result meets the specification by calling ''​CheckTSD()''​.
  
-There are a number of functions that work with ''​tsd''​ data: some of these can be found in the tsd [[https://​github.com/​mvdm/​neuraldata-w16/​tree/​master/​shared/​datatypes/​tsd | folder]] in the %%GitHub%% repository. Two other important ones you will meet in this module are ''​restrict()''​ and ''​getd()''​ (which also work on other data types, below).+There are a number of functions that work with ''​tsd''​ data: some of these can be found in the tsd [[https://​github.com/​mvdm/​nsb2017/​tree/​master/​shared/​datatypes/​tsd | folder]] in the %%GitHub%% repository. Two other important ones you will meet in this module are ''​restrict()''​ and ''​getd()''​ (which also work on other data types, below).
  
 ==== Timestamp (TS) data-type ==== ==== Timestamp (TS) data-type ====
Line 188: Line 188:
 ☛ How many spikes did the second neuron emit in this session? ☛ How many spikes did the second neuron emit in this session?
  
-As with ''​tsd''​ data above, you can call the ts constructor ''​ts()''​ to start with a template that you can then fill with data if you want to build your own. The ts [[https://​github.com/​mvdm/​neuraldata-w16/​tree/​master/​shared/​datatypes/​ts | folder]] on %%GitHub%% contains some other utility functions that work with timestamp data.+As with ''​tsd''​ data above, you can call the ts constructor ''​ts()''​ to start with a template that you can then fill with data if you want to build your own. The ts [[https://​github.com/​mvdm/​nsb2017/​tree/​master/​shared/​datatypes/​ts | folder]] on %%GitHub%% contains some other utility functions that work with timestamp data. 
 ==== Interval (IV) data-type ==== ==== Interval (IV) data-type ====
  
Line 350: Line 351:
  
 Notice how each file is named: all start with ''​R042-2013-08-18''​ followed by a suffix indicating the file type and (if necessary) an identifier. Applying this naming scheme consistently is a key part of good data management because it enables provenance tracking -- which cells from what animal, what session, and what condition are contributing to each plot, et cetera. The **rename** steps in the above schematic are an important first step. Notice how each file is named: all start with ''​R042-2013-08-18''​ followed by a suffix indicating the file type and (if necessary) an identifier. Applying this naming scheme consistently is a key part of good data management because it enables provenance tracking -- which cells from what animal, what session, and what condition are contributing to each plot, et cetera. The **rename** steps in the above schematic are an important first step.
-===== Using the low-level data loading functions ===== 
  
-Neuralynx supplies a set of functions that load the raw data into MATLAB (included in your %%GitHub%% clone). We will use these one by one in the following subsections. A common theme is that all of these functions will output a ''​Timestamps''​ variable, indicating when each data sample or event occurred. Data acquisition systems need to solve the engineering challenge of aligning many different kinds of signals (video, neural activity, events) on a common timebase, so that relationships between them can be analyzed. These ''​Timestamps''​ are what ties the different data files together. By default, Neuralynx ​data loaders ​return timestamps in microseconds (us).+===== Using the wrapped ​data loaders ​=====
  
 Before getting started, create a folder with today'​s date in your [[analysis:​nsb2016:​week1|project folder]], and create a new file in it named ''​sandbox.m''​. These sandbox files are not meant to be re-used or committed to %%GitHub%% -- as the name indicates, they are just a temporary file that is easier to work with compared to typing everything directly into the MATLAB Command Window. ​ Before getting started, create a folder with today'​s date in your [[analysis:​nsb2016:​week1|project folder]], and create a new file in it named ''​sandbox.m''​. These sandbox files are not meant to be re-used or committed to %%GitHub%% -- as the name indicates, they are just a temporary file that is easier to work with compared to typing everything directly into the MATLAB Command Window. ​
Line 359: Line 359:
  
 All instructions that follow should be pasted into a [[http://​blogs.mathworks.com/​videos/​2011/​07/​26/​starting-in-matlab-cell-mode-scripts/​|cell]] in this sandbox file and executed from there (Ctrl-Enter when a cell is selected), unless they are prefaced with ''>>''​ to indicate the Command Prompt. All instructions that follow should be pasted into a [[http://​blogs.mathworks.com/​videos/​2011/​07/​26/​starting-in-matlab-cell-mode-scripts/​|cell]] in this sandbox file and executed from there (Ctrl-Enter when a cell is selected), unless they are prefaced with ''>>''​ to indicate the Command Prompt.
- 
-===== Using the wrapped data loaders ===== 
  
 The vandermeerlab code base contains "​wrappers"​ of data loading functions that return the data in the data types discussed above. You will notice that each loading function, discussed below, takes in a ''​cfg''​ ("​configuration"​) variable, which is used to specify parameters and options such as the filenames to be loaded. This use of ''​cfg''​ variables is shared by many other vandermeerlab data analysis functions (as well as those in the %%FieldTrip%% toolbox), and is highly encouraged when you start writing your own code: it encourages well-organized code and enables provenance tracking, two principles of [[analysis:​nsb2015:​week0|good programming practice]]. The vandermeerlab code base contains "​wrappers"​ of data loading functions that return the data in the data types discussed above. You will notice that each loading function, discussed below, takes in a ''​cfg''​ ("​configuration"​) variable, which is used to specify parameters and options such as the filenames to be loaded. This use of ''​cfg''​ variables is shared by many other vandermeerlab data analysis functions (as well as those in the %%FieldTrip%% toolbox), and is highly encouraged when you start writing your own code: it encourages well-organized code and enables provenance tracking, two principles of [[analysis:​nsb2015:​week0|good programming practice]].
Line 474: Line 472:
 As you can see, this loaded spike data from 67 neurons. The ''​usr''​ field by default contains the tetrode number from which each spike train was recorded; this behavior can be disabled by setting ''​cfg.getTTnumbers = 0''​. If you wish to load *._t files (containing spikes from neurons of questionable cluster quality), do ''​cfg.load_questionable_cells = 1;''​. See the function documentation for further options. As you can see, this loaded spike data from 67 neurons. The ''​usr''​ field by default contains the tetrode number from which each spike train was recorded; this behavior can be disabled by setting ''​cfg.getTTnumbers = 0''​. If you wish to load *._t files (containing spikes from neurons of questionable cluster quality), do ''​cfg.load_questionable_cells = 1;''​. See the function documentation for further options.
  
-==== Using the low-level data loading functions ====+===== Using the low-level data loading functions ====
 + 
 +Neuralynx supplies a set of functions that load the raw data into MATLAB (included in your %%GitHub%% clone). We will use these one by one in the following subsections. A common theme is that all of these functions will output a ''​Timestamps''​ variable, indicating when each data sample or event occurred. Data acquisition systems need to solve the engineering challenge of aligning many different kinds of signals (video, neural activity, events) on a common timebase, so that relationships between them can be analyzed. These ''​Timestamps''​ are what ties the different data files together. By default, Neuralynx data loaders return timestamps in microseconds (us).
  
-In some cases, it is important to test exactly what is in the raw data files you are loading. For that purpose, it is easier not to have to deal with the wrapper functions. Below are some commonly used data loading functions as provided by Neuralynx.+Why use these functions instead of the wrappers? It is often important to test exactly what is in the raw data files you are loading, especially when there is missing or corrupt data, or it is unclear what processing the wrappers may be doing. For that purpose, it is easier not to have to deal with the wrapper functions.
  
-=== Position data (*.nvt) loading ===+==== Position data (*.nvt) loading ​====
  
 The low-level loading function for video data is ''​Nlx2MatVT''​. Deploy it as follows: The low-level loading function for video data is ''​Nlx2MatVT''​. Deploy it as follows:
Line 566: Line 566:
 This concludes the introduction to Neuralynx video data. The other outputs of ''​Nlx2MatVT''​ are not used for typical analyses. This concludes the introduction to Neuralynx video data. The other outputs of ''​Nlx2MatVT''​ are not used for typical analyses.
  
-=== LFP data file (*.Ncs) loading ===+==== LFP data file (*.Ncs) loading ​====
  
 The Neuralynx loader for Ncs files is ''​Nlx2MatCSC''​. Use it thusly: The Neuralynx loader for Ncs files is ''​Nlx2MatCSC''​. Use it thusly:
Line 636: Line 636:
 Aha, the ''​-ADBitVolts''​ entry gives us the conversion from the raw data to volts. Another reason to wrap this lowlevel function into something that does the conversion for us! As you can see, the header contains some other information,​ which will be discussed in more detail in later modules. Aha, the ''​-ADBitVolts''​ entry gives us the conversion from the raw data to volts. Another reason to wrap this lowlevel function into something that does the conversion for us! As you can see, the header contains some other information,​ which will be discussed in more detail in later modules.
  
-=== Event file (*.Nev) loading ===+==== Event file (*.Nev) loading ​====
  
 ''​*.Nev''​ (**N**euralynx **Ev**ent) files contain timestamps of various task events. Use as follows: ''​*.Nev''​ (**N**euralynx **Ev**ent) files contain timestamps of various task events. Use as follows:
Line 749: Line 749:
  
 NOTE: if you are on a Mac, you might get an error related to the ''​nearest_idx3''​ function; you can fix that for now by changing this to ''​nearest_idx''​ in the ''​PlotTSDfromIV''​ function. NOTE: if you are on a Mac, you might get an error related to the ''​nearest_idx3''​ function; you can fix that for now by changing this to ''​nearest_idx''​ in the ''​PlotTSDfromIV''​ function.
 +
analysis/nsb2017/week2.1499027432.txt.gz · Last modified: 2018/07/07 10:19 (external edit)