csdTBI

For Non-Coding Audience

csdStart is a MATLAB function that will take in experimental data and map out the boundaries of layer 4 in the primary visual cortex (V1).

This section provides an explanation of the text-based-interface (TBI), which provides for the same functionalities of the csdGUI; however, it is recommended to use csdGUI due to ease of use.

A specific example would be the following:

X = csdStart();

As the code is running, you will see the following in the command window.


This is purely for progress tracking purposes and is relevant for code optimization so it will not be relevant in your case.

At some point, the function will output a figure that resembles the following.

This is an output of all 300 grids in a 15 by 20 orientation that are analogous to the grids displayed on the TV screen during an experiment. You will need to look for the grid that has congregated patches of color in the center. The red is due to a voltage sink (decrease in voltage, polarization) because this is where depolarization happens in the neurons and polarization happens in the extracellular matrix, which is what the electrode channels contact. In this case, the grid at column 9 and row 1 shows the traits of the desired grid.

The function will then prompt for you to input the x and y coordinates of the grid. The x and y coordinates are defined with the origin as the top-left corner with all x and y values positive. Following this, the function will continue running and input three more figures. The three figures enable further analysis of the specific grid.

These three figures are the following:

  • Voltage Response of Electrodes: This plots the local field potentials (LFPs) for all 16 channels of the electrode.
  • CSDs for Channels: This includes the CSD plots for 14 channels. There is no 16 channels because 2 channels are used/eliminated to determine the second spatial derivative of the LFPs (definition of CSD).
  • 2D Heat Map for CSDs: This allows the determination of the upper and lower bounds of layer 4 of V1.
  • 3D Heat Map for CSDs: This is essentially the same thing as the 2D heat map, but this is displayed in 3D for visual ease in identifying the sinks and sources.

 The four figures should appear as the following:


In short, the significance of this code is great due to being able to determine the boundaries of layer 4 of V1. Not only can this eliminate the extra procedure for histology and microtome cryostat but also it may further verify the results of the histology. Also, please expect a 2-3 day total runtime with the prompt for coordinate input coming up after 1 day of runtime. If external assistance is required, please feel free to email me at dennisou2@msn.com.


For Coding Audience

The csdStart TBI utilizes the following functions:

  •        csdDataProcessing
  •        csdAllGrids
  •        csdPlot

Each of the functions will be explained in detail in the following sections.

 

csdStart

csdStart takes in the input of ‘path’ and ‘tfile’ and allows the user to determine the boundaries for layer 4 of the primary visual cortex (V1). The purpose of this function is to make things easier for the non-coding user since csdStart eliminates the need to call on multiple functions manually. Upon calling csdStart, you can either choose to use the GUI or the TBI. I personally recommend the GUI, but if you don’t like GUIs, the TBI is an appropriate alternative. Within the scope of this documentation, we will discuss only the details of TBI.

csdStart first calls on csdDataProcessing to output a relevant data cell X followed by csdAllGrids taking in X and displaying the CSDs for all 300 grids. Once the user has selected the corresponding grid and inputted the coordinates in the command window, four figures will show up.

 These four figures are the following:

  •        Voltage Response of Electrodes: This plots the local field potentials (LFPs) for all channels of the electrode.
  •        CSDs for Channels: This includes the CSD plots for channels. There is two lesser plots than number of channels because 2 channels are used/eliminated to determine the second spatial derivative of the LFPs (definition of CSD).
  •        2D Heat Map for CSDs: This allows the determination of the upper and lower bounds of layer 4 of V1.
  •        3D Heat Map for CSDs: This is essentially the same thing as the 2D heat map, but this is displayed in 3D for visual ease in identifying the sinks and sources.

Through these four figures, it will be easy to determine the boundaries of layer 4 and also take a closer look at the signals corresponding to the specified grid.

The syntax of CSDmapping is the following:

X = csdStart()

Because there are no parameters, a specific example would be the same as the syntax above.


csdDataProcessing

csdDataProcessing takes in the input of path and tfile and outputs a cell, X, that includes the local field potential (LFP) values of the next 100 ms (100 ms is user defined and can be easily changed along with all other parameters) following each trigger stimulus for all triggers of all grids of the channels. Cell X has 16 rows and 300 columns. The 16 rows correspond to the 16 channels of the electrode and the 300 columns correspond to the 300 grids on the TV screen. The number of channels and grids will vary, but for demonstration purposes, we will assume 16 channels and 300 grids. Furthermore, each element of the cell contains LFP values in the dimensions of (# of trigger stimuli for specific grid) rows by (# of data points recorded in 100ms) columns. The reason for using a cell as the outermost data storage format is because the individual elements have differing dimensions and an array is not able to accommodate for this. The purpose of creating this function is to avoid pulling out relevant data from the raw data files multiple times since doing so takes a lot of time.

csdDataProcesing first takes in the trigger stimuli timestamps via GetSGStimTriggers.m (part of vhlabtools) for all 300 grids from the stimtimes.txt file located in the experimental data folder and inputs all this data into an array A. It is assumed that the ending time of this trial run will be lesser than 1.2 times of the latest trigger time of grid 1. This end-time-boundary is defined as max_T. readvhlvdatafile will take in the LFP values for all 16 channels from the vlhvanaloginput.vld file and input it into an array LFP. This large LFP array is then filtered via the Savitzky-Golay algorithm to eliminate the 60-cycle noise caused by the nature of the AC source.

The LFP values of the next 100ms following all stimulus timestamps are then downsampled via fastread and are inputted into the cell X, which becomes the output of super2.m. The reason to down-sample the data is so that cell X can be stored within RAM. Most importantly, the time discrepancy between labview and spike2 are taken into account in the vhlv_sync2spike2 function. To find the time discrepancy the function subtracts the shift time from the Spike2 timeframe in order to be synchronized with the Labview timeframe.

The syntax of super2 is the following:

X = csdDataProcessing(path, tfile, header, data, tbefore, tafter, channels, transition, i_initial, rows, columns)

A specific example would be the following:

X = csdDataProcessing(‘/Users/dennisou/Desktop’,  ’t00001’,’vhlvanaloginput.vlh’, ‘vhlvanaloginput.vld’, 50, 100, 16, 0, 1, 15, 20)


csdAllGrids

csdAllGrids takes in the input of cell X outputted by csdDataProcessing and outputs the CSD for all 300 grids in the 15 by 20 orientation previously mentioned. The purpose of utilizing this function is to locate the corresponding grid. This also allows for us to bypass the heatmap step since CSD provides for more accuracy as opposed to averaged LFPs.

Specifically, csdAllGrids calls on helper function csdCalculate to individually perform CSD on all 300 grids. csdCalculate will take in all LFP data for a designated grid and perform CSD for all 16 channels resulting in an output array of CSD for each of the 14 channels vs. time. The reason that 16 channels have been reduced to 14 channels is that the definition of CSD is the second spatial derivative of the LFP. With each derivative taken, one channel gets eliminated. Therefore, with CSD taken, 2 channels get eliminated resulting in 2 less than 16 which is 14.

csdAllGrids then plots out all the CSD data for all 300 grids on a MATLAB figure. Each subplot in this figure contains the CSD of each corresponding grid location on the TV screen used for training. Each subplot displays CSD data in the axes of channel/depth vs time. A large patch of red should represent a current sink. The reason behind this is because as V1 neurons get stimulated, they depolarize, which in turn causes the extracellular matrix (ECM) to polarize. Since the electrode is present in the ECM, channels in layer 4 should receive a summation of charge loss due to group depolarization of nearby cells. This largest current sink happens in channels in layer 4 because this is the layer of V1 that takes in inputs from the LGN.

The syntax of extreme_csd is the following:

csdAllGrids(X, rows, columns, delta, channel_order, start_time, path, tfile)

A specific example would be the following:

csdAllGrids(X, 15, 20, 50, [9 8 10 7 13 4 12 5 15 2 16 1 14 3 11 6], 0, ‘/Users/dennisou/Desktop’,  ’t00001’)

This means that the cell output from csdDataProcessing is X, while the grids are oriented in a 15 by 20 format on the TV screen used for training experiments. The order of the channels from top to bottom (shallow to deep) are [9 8 10 7 13 4 12 5 15 2 16 1 14 3 11 6] with 50um spacing while accounting for the LFP signals starting at 0ms from the onset of stim triggers.

 

csdPlot

Before running csdPlot, csdCalculate for a specific grid location must be run first for a designated grid. csdPlot takes in the outputs of csdCalculate, which are L, H, and I. L contains the averaged LFP data for the 100ms following each trigger time. This is a 16 by 31 array where 16 is the number of channels and 31 is the number of data points in 100ms sampled with a 25000 Hz rate and down sampled by a factor of 83. H contains the CSD for 14 channels. It is a 14 by 31 array where 14 is the number of channels and 31 is the number of data points within 100ms. The reason that there are only 14 channels rather than 16 channels was explained earlier. I is the same as H but with a row and column of zeroes appended to the last row and column. Because pcolor interpolates between data points, adding zeroes will prevent the elimination of the last row and column. The pcolor_normalize function takes care of this.

These three arrays will result in three figures plotted. The first figure, which uses L, will display the averaged LFP values vs. time for each of the 16 channels. The second figure, which uses H, will display the CSD results displayed in a 14-channel vs. time plot. Each subplot represents a channel. The third figure, which uses I, will display the CSD in a 3D plot where red represents high values and blue represents low values. The x-coordinates represent time while the y-coordinates represent channel/depth and the z-coordinates represent CSD values in the units of V/m2. 

The syntax of csdPlot is the following:

plotCSD(L,H,I,channel_order,start_time,delta) with superCSD having the syntax [L,H,I] = superCSD(X, gridloc, delta, channel_order, sync_channel_position, above_sync, below_sync)

A specific example would be the following:

csdPlot(L,H,I, [9 8 10 7 13 4 12 5 15 2 16 1 14 3 11 6], 0, 50) with superCSD having the syntax [L,H,I] = superCSD(X, 217, 50, [9 8 10 7 13 4 12 5 15 2 16 1 14 3 11 6], 11, 2, 1)

It will usually be tedious to count the grids, so you may replace gridloc with the helper function coordinates_to_grid(x, y, rows). A specific example would be [L,H,I] = csdPlot(X, coordinates_to_grid(15,7,15)) which is equivalent to [L,H,I] = superCSD(X,217). When determining the x and y values, the origin is in the top left corner with values increasing as one moves to the bottom right.


If there are further questions, please refer to the internal comments in the m-files of each function. Please feel free to email me at dennisou2@msn.com for further questions.

Comments