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
Next revision Both sides next revision
getting_started:neuralynx_fcdc [2010/02/16 16:24]
194.95.136.75
getting_started:neuralynx_fcdc [2017/08/17 11:21] (current)
127.0.0.1 external edit
Line 1: Line 1:
 {{tag>​neuralynx lfp dataformat}} {{tag>​neuralynx lfp dataformat}}
  
-====== Getting started with the Neuralynx data recorded at the FCDC  ​======+====== Getting started with the Neuralynx data recorded at the Donders Institute ​ ​======
  
 ===== Introduction ===== ===== Introduction =====
Line 9: Line 9:
 ===== Background ===== ===== Background =====
  
-At the FCDC, we record brain activity using an ECoG electrode grid with 252 electrodes. The signal is amplified by a factor of 20 using a headstage amplifier (Headstage 32V-G20, Plexon Inc., Dallas, TX, USA), and subsequently low-pass filtered at 8 kHz and digitized at ~32 kHz sampling frequency using a Neuralynx amplifier (Digital Lynx, 256 channels, Neuralynx Tucson, AZ, USA). +At the Donders Institute, we record brain activity using an ECoG electrode grid with 252 electrodes. The signal is amplified by a factor of 20 using a headstage amplifier (Headstage 32V-G20, Plexon Inc., Dallas, TX, USA), and subsequently low-pass filtered at 8 kHz and digitized at ~32 kHz sampling frequency using a Neuralynx amplifier (Digital Lynx, 256 channels, Neuralynx Tucson, AZ, USA). 
  
 To deal with the tremendous amounts of data recorded each session (approximately 1.5 Gb/min), we develop a recording procedure that allows us to: To deal with the tremendous amounts of data recorded each session (approximately 1.5 Gb/min), we develop a recording procedure that allows us to:
   - Ensure the correct recording and storage of a particular session (using the *.nrd Neuralynx dataformat).   - Ensure the correct recording and storage of a particular session (using the *.nrd Neuralynx dataformat).
-  - Use a format that allows us to keep long-term storages copies of the original datasets (using the **[[reference:​spikesplitting]]** function to split the original file and store as a //.sdma// file format). +  - Use a format that allows us to keep long-term storages copies of the original datasets (using the **[[reference:​ft_spikesplitting]]** function to split the original file and store as a //.sdma// file format). 
-  - Obtain a 1 kHz downsampled working copy of the LFP data that can be conveniently used by the **[[reference:​preprocessing]]** and other FieldTrip functions. ​+  - Obtain a 1 kHz downsampled working copy of the LFP data that can be conveniently used by the **[[reference:​ft_preprocessing]]** and other FieldTrip functions. ​
   - Obtain a 1 kHz downsampled estimate of the multi-unit activity (MUA).   - Obtain a 1 kHz downsampled estimate of the multi-unit activity (MUA).
   - Eventually obtain an estimate of single-unit activity (SUA), depending on the electrode grid configuration.   - Eventually obtain an estimate of single-unit activity (SUA), depending on the electrode grid configuration.
  
-The downsampling of the original 32 kHz data into the LFP and MUA data is done using the **[[reference:​spikedownsample]]** function.+The downsampling of the original 32 kHz data into the LFP and MUA data is done using the **[[reference:​ft_spikedownsample]]** function.
  
 Here, we will briefly explain how we use FieldTrip to obtain these representations of the data. In addition, we will describe some basic preprocessing steps (i.e., relabeling channels and using a montage configuration to re-reference the data). To known more about the characteristics of the fileformats used in our recording and analysis setup, please check **[[dataformat:​spike|Spike and LFP dataformats]]** for a description of Neuralynx and Plexon data formats supported by FieldTrip. For general information about getting started with Plexon and Neuralynx using FieldTrip, please refer to the getting started with **[[getting_started:​neuralynx]]** and **[[getting_started:​plexon]]** sections. Here, we will briefly explain how we use FieldTrip to obtain these representations of the data. In addition, we will describe some basic preprocessing steps (i.e., relabeling channels and using a montage configuration to re-reference the data). To known more about the characteristics of the fileformats used in our recording and analysis setup, please check **[[dataformat:​spike|Spike and LFP dataformats]]** for a description of Neuralynx and Plexon data formats supported by FieldTrip. For general information about getting started with Plexon and Neuralynx using FieldTrip, please refer to the getting started with **[[getting_started:​neuralynx]]** and **[[getting_started:​plexon]]** sections.
Line 30: Line 30:
 ==== Data splitting ==== ==== Data splitting ====
  
-The Neuralynx acquisition system provides the data in a format containing the raw data directly after A/D conversion. During each recorded session, the *.nrd file is written directly to an external Lacie RAID-0 hard disk that is connected by firewire 800. The *.nrd datafiles contain a 16kB ascii header, followed by the multiplexed 32-bit channel-level data (see also [[getting_started:​neuralynx|this]] page). The huge size of these multiplexed files (>100 Gb per 45 minute session) precludes them for efficient post-processing. Using the FieldTrip ​ **[[reference:​spikesplitting]]** function, we split the *.nrd file into seperate files for each channel, containing exactly the same 32-bit information. These file are written into a single directory which usually has the extension *.sdma, since it contains the "splitted ​dma" channels. We refer to this directory as the output dataset, whereas the *.nrd file is the input dataset.+The Neuralynx acquisition system provides the data in a format containing the raw data directly after A/D conversion. During each recorded session, the *.nrd file is written directly to an external Lacie RAID-0 hard disk that is connected by firewire 800. The *.nrd datafiles contain a 16kB ascii header, followed by the multiplexed 32-bit channel-level data (see also [[getting_started:​neuralynx|this]] page). The huge size of these multiplexed files (>100 Gb per 45 minute session) precludes them for efficient post-processing. Using the FieldTrip ​ **[[reference:​ft_spikesplitting]]** function, we split the *.nrd file into seperate files for each channel, containing exactly the same 32-bit information. These files are written into a single directory which usually has the extension *.sdma, since it contains the "split dma" channels. We refer to this directory as the output dataset, whereas the *.nrd file is the input dataset.
  
 An example of the configuration for spikesplitting is provided below: An example of the configuration for spikesplitting is provided below:
Line 41: Line 41:
 cfg.format ​ = '​int32'; ​ cfg.format ​ = '​int32'; ​
 cfg.channel = '​all';​ cfg.channel = '​all';​
-cfg         ​= ​spikesplitting(cfg);+cfg         ​= ​ft_spikesplitting(cfg);
 </​code> ​ </​code> ​
  
 It is also important to note that:  It is also important to note that: 
   * The information extracted from a single *.nrd file also contains the timestamps, trigger and event information (see below for details). ​   * The information extracted from a single *.nrd file also contains the timestamps, trigger and event information (see below for details). ​
-  * The new version of Neuralynx software also reserve ​an initial segment of the recorded file to write a header. The Fieldtrip ​function **[[reference:​spikesplitting]]** could extract this information and write it in a *.txt file in the dataset directory. According to Neuralynx, this header will be operative in future releases.+  * The new version of Neuralynx software also reserves ​an initial segment of the recorded file to write a header. The FieldTrip ​function **[[reference:​ft_spikesplitting]]** could extract this information and write it in a *.txt file in the dataset directory. According to Neuralynx, this header will be operative in future releases.
   * The *.sdma dataset format is used as our back up copy and long-term storage. After creating two backup copies, the original *.nrd file is erased.   * The *.sdma dataset format is used as our back up copy and long-term storage. After creating two backup copies, the original *.nrd file is erased.
   * For the same reason, the data is kept as close as possible to the original recorded file. We do not apply further preprocessing during this step.   * For the same reason, the data is kept as close as possible to the original recorded file. We do not apply further preprocessing during this step.
Line 52: Line 52:
 ==== Data downsampling ==== ==== Data downsampling ====
  
-The **[[reference:​spikedownsample]]** function preprocesses and downsamples the LFP data sampled at 32 KHz to 1 kHz. The LFP data at 1 kHz can subsequently be analyzed.+The **[[reference:​ft_spikedownsample]]** function preprocesses and downsamples the LFP data sampled at 32 KHz to 1 kHz. The LFP data at 1 kHz can subsequently be analyzed.
  
-An example of the configuration for spikedownsample ​is provided below:+An example of the configuration for **[[reference:​ft_spikedownsample]]** ​is provided below:
  
   cfg             = [];   cfg             = [];
Line 76: Line 76:
     cfg.preproc.lpfiltdir ​ = '​twopass';​     cfg.preproc.lpfiltdir ​ = '​twopass';​
     cfg.preproc.precision ​ = '​double';​     cfg.preproc.precision ​ = '​double';​
-    cfg = spikedownsample(cfg); ​   ​+    cfg = ft_spikedownsample(cfg); ​   ​
  
-By using the option **format** in the configuration structure, we can choose the file format to which the downsampled LFP data will be written. FieldTrip can write file dataset in several formats (see **[[reference:​write_data]]**). We use the Plexon *.nex format which provides us the best compromise between data read/write speed and storage capacity. To get more details about the  Plexon dataformats,​ please see the [[getting_started:​plexon|getting started with Plexon data]] section. The output dataset directory for the LFP data uses the suffix //_ds//.+By using the option **format** in the configuration structure, we can choose the file format to which the downsampled LFP data will be written. FieldTrip can write the file dataset in several formats (see **[[reference:​ft_write_data]]**). We use the Plexon *.nex format which provides us the best compromise between data read/write speed and storage capacity. To get more details about the  Plexon dataformats,​ please see the [[getting_started:​plexon|getting started with Plexon data]] section. The output dataset directory for the LFP data uses the suffix //_ds//.
  
-The raw *.nrd file and the splitted ​DMA files contains AD values that are not scaled in uV and require an additional factor of 64x. In addition, our acquisition system includes a Plexon headstage with an additional amplification of 20x. Thus, in our case the calibration should be specified as 1/(64*20).+The raw *.nrd file and the split DMA files contains AD values that are not scaled in uV and require an additional factor of 64x. In addition, our acquisition system includes a Plexon headstage with an additional amplification of 20x. Thus, in our case the calibration should be specified as 1/(64*20).
  
 ==== Dealing with timestamps ==== ==== Dealing with timestamps ====
Line 88: Line 88:
 In contrast, the timestamp clock in the Plexon acquisition hardware ticks at the native sampling frequency of 40kHz, meaning that subsequent samples in a Plexon file are 40000/​Fsample timestamps apart. In a channel that is sampled at 40kHz subsequent samples are one clocktick apart, in a channel that is sampled at 1kHz the subsequent samples are 40 clockticks apart. In contrast, the timestamp clock in the Plexon acquisition hardware ticks at the native sampling frequency of 40kHz, meaning that subsequent samples in a Plexon file are 40000/​Fsample timestamps apart. In a channel that is sampled at 40kHz subsequent samples are one clocktick apart, in a channel that is sampled at 1kHz the subsequent samples are 40 clockticks apart.
  
-In FieldTrip the relation between the timestamps and the samples is represented in the header. If you call **[[reference:​read_header|read_header]]** on your datafile, you'll see something like this+In FieldTrip the relation between the timestamps and the samples is represented in the header. If you call **[[reference:​ft_read_header|ft_read_header]]** on your datafile, you'll see something like this
  
-  >> hdr = read_header('​256_noev_DigitaLynx_DMA.nrd'​)+  >> hdr = ft_read_header('​256_noev_DigitaLynx_DMA.nrd'​)
   hdr =    hdr = 
               Fs: 32556               Fs: 32556
Line 105: Line 105:
 or this or this
  
-  >> hdr = read_header('​p021parall.nex'​)+  >> hdr = ft_read_header('​p021parall.nex'​)
   hdr =    hdr = 
                 nChans: 15                 nChans: 15
Line 131: Line 131:
 After spikesplitting,​ there is a *.ttl file containing the same 32kHz representation of the trigger channel as in the DMA log file. There are also two files (*.tsl and *.tsh) that represent the lowest and highest 32 bits of the 64 bit timestamp channel. The Neuralynx timestamp channel has a clock rate of 1MHz, i.e. 1e6 timestamps per second, or approximately 32 timestamps per data sample at 32kHz (1e6/​32556). ​ After spikesplitting,​ there is a *.ttl file containing the same 32kHz representation of the trigger channel as in the DMA log file. There are also two files (*.tsl and *.tsh) that represent the lowest and highest 32 bits of the 64 bit timestamp channel. The Neuralynx timestamp channel has a clock rate of 1MHz, i.e. 1e6 timestamps per second, or approximately 32 timestamps per data sample at 32kHz (1e6/​32556). ​
  
-After spikedownsampling,​ the continuous sampled LFP channels are not represented at 32kHz any more, but typically at 1000 Hz. That means that the samples at which the triggers occur in the *.ttl channel cannot directly be mapped onto the samples in the LFP channels. The method to link the original triggers to the downsampled data is by means of the timestamps. The **[[:​reference:​spikedownsample]]** function has the option //​cfg.timestampdefinition//​ which can be //'​orig'//​ or //'​sample'//​. If you specify it as //​cfg.timestampdefinition='​sample'//,​ the timestamps in the downsampled LFP channels will correspond to the original samples, i.e. there will be 32566 timestamps per second in the downsampled data. The fist downsampled sample will be at timestamp 17, because the first 32 original samples are all compressed into the first downsampled sample. If you specify //​cfg.timestampdefinition='​orig'//,​ the downsampled LFP data will be written to disk with the original timestamp definition with 1e6 timestamps per second. +After spikedownsampling,​ the continuous sampled LFP channels are not represented at 32kHz any more, but typically at 1000 Hz. That means that the samples at which the triggers occur in the *.ttl channel cannot directly be mapped onto the samples in the LFP channels. The method to link the original triggers to the downsampled data is by means of the timestamps. The **[[:​reference:​ft_spikedownsample]]** function has the option //​cfg.timestampdefinition//​ which can be //'​orig'//​ or //'​sample'//​. If you specify it as //​cfg.timestampdefinition='​sample'//,​ the timestamps in the downsampled LFP channels will correspond to the original samples, i.e. there will be 32566 timestamps per second in the downsampled data. The first downsampled sample will be at timestamp 17, because the first 32 original samples are all compressed into the first downsampled sample. If you specify //​cfg.timestampdefinition='​orig'//,​ the downsampled LFP data will be written to disk with the original timestamp definition with 1e6 timestamps per second.
- +
- +
 ==== Data preprocessing ==== ==== Data preprocessing ====
  
-Data sessions that had been subsequently ​splitted, downsampled and stored in Plexon //.nex// format are suitable to be preprocessed for further analysis. To get a general idea of how to proceed, we recommend to read the documentation of the FieldTrip ​ **[[reference:​preprocessing]]** function and the preprocessing tutorials in the [[:​tutorial|tutorial documentation]] .\\ +Data sessions that had been subsequently ​split, downsampled and stored in Plexon //.nex// format are suitable to be preprocessed for further analysis. To get a general idea of how to proceed, we recommend to read the documentation of the FieldTrip ​ **[[reference:​ft_preprocessing]]** function and the preprocessing tutorials in the [[:​tutorial|tutorial documentation]] .\\ 
-Here, we will focused on how to read the Plexon dataset directories (//_ds//) which contains ​multiple *.nex files. A basic configuration structure is provided below:+Here, we will focused on how to read the Plexon dataset directories (//_ds//) which contain ​multiple *.nex files. A basic configuration structure is provided below:
  
 <​code>​ <​code>​
 cfg = []; cfg = [];
-cfg.dataset ​         = dataset; % "​_ds"​ dataset directory +cfg.dataset ​         = dataset; ​     % "​_ds"​ dataset directory 
-cfg.dataformat ​      = 'combined_ds'; +cfg.dataformat ​      = 'plexon_ds'; ​ % this is optional, and will be auto-detected 
-cfg.headerformat ​    = 'combined_ds'; +cfg.headerformat ​    = 'plexon_ds'; ​ % this is optional, and will be auto-detected 
-cfg = preprocessing(cfg)+cfg = ft_preprocessing(cfg)
 </​code>​ </​code>​
  
Line 158: Line 155:
        time: {[1x3001 double] ​ [1x3001 double] ​ [1x3001 double]}        time: {[1x3001 double] ​ [1x3001 double] ​ [1x3001 double]}
     fsample: 1000     fsample: 1000
 +
         cfg: [1x1 struct]         cfg: [1x1 struct]
 </​code>​ </​code>​
Line 163: Line 161:
 ==== Dealing with changing of channel labels ==== ==== Dealing with changing of channel labels ====
  
-Neuralynx uses the expression **csc** (from //c//ontinuos ​//s//ampled //​c//​hannel) in addition with a number (e.g. //010//) to label the channels. This labels are different from the names assigned to the electrodes in the electrode array. To keep consistency on the labels (this is specially ​important for plotting the channels), we apply a **montage structure** that consist ​in a matrix of correspondences that  changes the original labels by the new ones. By using the FieldTrip function **[[reference:​preprocessing]]**, with the montage as a part of the cfg option **montage**,​ channel labels ​could be modified. ​+Neuralynx uses the expression **csc** (from //c//ontinuous ​//s//ampled //​c//​hannel) in addition with a number (e.g. //010//) to label the channels. This labels are different from the names assigned to the electrodes in the electrode array. To keep consistency on the labels (this is especially ​important for plotting the channels), we apply a **montage structure** that consist ​of a matrix of correspondences that  changes the original labels by the new ones. By using the FieldTrip function **[[reference:​ft_preprocessing]]**, with the montage as a part of the cfg option **montage**,​ channel labels ​can be modified. ​
  
 All montage files for our particular experiment are available upon request.\\ An example of changing the channel labels is provided below: All montage files for our particular experiment are available upon request.\\ An example of changing the channel labels is provided below:
Line 171: Line 169:
 cfg = []; cfg = [];
 cfg.montage = montage; cfg.montage = montage;
-data = preprocessing(cfg,data);+data = ft_preprocessing(cfg,data);
 </​code>​ </​code>​
  
Line 178: Line 176:
 ==== Dealing with data re-referencing ==== ==== Dealing with data re-referencing ====
  
-Similar to what we described in the last section, re-reference of the signal to a particular electrode or electrode group could be performed using a montage structure and the FieldTrip **[[reference:​preprocessing]]** function. We implemented 2 montage structures to be used together with our datasets recording. These files are also available upon request. \\+Similar to what we described in the last section, re-reference of the signal to a particular electrode or electrode group could be performed using a montage structure and the FieldTrip **[[reference:​ft_preprocessing]]** function. We implemented 2 montage structures to be used together with our datasets recording. These files are also available upon request. \\ 
 ===== Plotting Options ===== ===== Plotting Options =====
  
Line 185: Line 184:
 ==== Dealing with layouts ==== ==== Dealing with layouts ====
  
-Datasets obtained from electrocortigraphic (ECoG) grids might be particular for each recording. Number, position and relation with anatomical number of the electrodes used in a grid might differ completely to the same parameters in another ECoG grid.  The FieldTrip function **[[reference:​prepare_layout|prepare_layout]]** allows the possibility to create a particular layout structures of a electrode grid from an image of the grid.\\ ​+Datasets obtained from electrocortigraphic (ECoG) grids might be particular for each recording. Number, position and relation with anatomical number of the electrodes used in a grid might differ completely to the same parameters in another ECoG grid.  The FieldTrip function **[[reference:​ft_prepare_layout|ft_prepare_layout]]** allows the possibility to create a particular layout structures of a electrode grid from an image of the grid.\\ ​
 In the following, we will show the layout structures that are currently used in our datasets. These layouts are avalaible upon request.\\ In the following, we will show the layout structures that are currently used in our datasets. These layouts are avalaible upon request.\\
  
-For example, a schematic layout of the 256 electrode grid might be obtained using the following the function **[[reference:​layoutplot|layoutplot]]**:+For example, a schematic layout of the 256 electrode grid might be obtained using the following the function **[[reference:​ft_layoutplot|ft_layoutplot]]**:
  
 <​code>​ <​code>​
 load kurt_layout_schematic_common load kurt_layout_schematic_common
 cfg = []; cfg = [];
-cfg.layout = layout+cfg.layout = ft_layout
-layoutplot(cfg)+ft_layoutplot(cfg)
 </​code>​ </​code>​
  
Line 200: Line 199:
 {{:​getting_started:​schematic_common3.png|}} \\ {{:​getting_started:​schematic_common3.png|}} \\
  
-An example of the same layout, containing time-frequency charts at the site of each electrode (obtaining with the FieldTrip function **[[reference:​topoplotTFR]]**) is provided below:\\+An example of the same layout, containing time-frequency charts at the site of each electrode (obtaining with the FieldTrip function **[[reference:​ft_topoplotTFR]]**) is provided below:\\
  
 {{:​getting_started:​ku_039_256elec.png?​571x367}} {{:​getting_started:​ku_039_256elec.png?​571x367}}