{"id":18500070,"url":"https://github.com/chriski777/nstanalysis","last_synced_at":"2026-01-29T18:40:49.963Z","repository":{"id":168033707,"uuid":"94806113","full_name":"chriski777/NSTAnalysis","owner":"chriski777","description":"Neural Spike Train Analysis","archived":false,"fork":false,"pushed_at":"2017-08-07T08:07:08.000Z","size":157,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T21:44:38.734Z","etag":null,"topics":["computational-neuroscience","scatterplot-visualization","spike-trains"],"latest_commit_sha":null,"homepage":"","language":"Matlab","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chriski777.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-19T18:04:18.000Z","updated_at":"2025-02-08T07:32:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd6a0c00-e00e-4d49-af01-7ce34aba8b58","html_url":"https://github.com/chriski777/NSTAnalysis","commit_stats":null,"previous_names":["chriski777/nstanalysis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chriski777/NSTAnalysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriski777%2FNSTAnalysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriski777%2FNSTAnalysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriski777%2FNSTAnalysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriski777%2FNSTAnalysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chriski777","download_url":"https://codeload.github.com/chriski777/NSTAnalysis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriski777%2FNSTAnalysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28882273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T16:41:59.663Z","status":"ssl_error","status_checked_at":"2026-01-29T16:39:39.641Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-neuroscience","scatterplot-visualization","spike-trains"],"created_at":"2024-11-06T13:48:23.502Z","updated_at":"2026-01-29T18:40:49.927Z","avatar_url":"https://github.com/chriski777.png","language":"Matlab","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NST Analysis\nNeural Spike Train Analysis. Allows one to import sorted Plexon files and perform a series of statistical analyses on neuronal discharge data through batch processing. \n\n## Table of Contents  \n* [Calculation Types](#calcHeader)\n* [SetUp Directories](#setHeader)\n* [Prerequisite TODO](#preReqHeader)\n* [Performing Calculations](#perfCalcHeader)\n  * [Master Function](#masterHeader)\n* [Visualization Functions](#visHeader)\n  * [Rastor Plot](#rastorHeader)\n  * [Cell ISI/Autocorrelogram](#cellISIHeader)\n  * [Spike Density Function](#sdfHeader)\n  * [2D ScatterPlot](#scatterTwoHeader)\n  * [3D ScatterPlot](#scatterThreeHeader)\n    * [ScatterPlot3d](#scatterThreeDHeader)\n    * [allScatterPlot3d](#scatterallThreeDHeader)\n* [Classification](#classHeader)  \n  \n\u003ca name=\"calcHeader\"/\u003e\n\n### Calculation Types\n* Calculations/Types of Analyses one can perform include: \n  * Measures of Central Tendency of ISI distribution: Standard deviation and Mean\n  * Mean FR \n  * CV \n  * CV2 (Nawrot et al., 2008)\n  * Approximate Entropy (Pincus 1991)\n  * dApEn (Darin, Soares, Wichmann 2006)\n  * Raster Plot Visualization\n  * Autocorrelogram Visualization\n  * 2-D ScatterPlot Visualization\n  * 3-D ScatterPlot Visualization\n  * Double Exponential (DExp) Fit of Autocorrelograms\n  * ISI Histogram Visualization\n  * ISI Converter \n  * Kurtosis\n  * Pearson's moment coefficient of Skewness\n  * Fano Factor (Darin, Soares, Wichmann 2006), (Eden \u0026 Kramer 2010)\n  * Non-parametric skew of ISI distribution\n  * Pearson mode Skew \n  * Spike Density Function \n    * Movement-specific Spike Density Function\n  * StatAv \n* Coming Soon\n  * Hurst Exponent\n  \n\u003ca name=\"setHeader\"/\u003e  \n\n### Setup Directories\nClone/download this repository and make sure to add all these folders to the current path in Matlab. Open_data.m, detecMove.m, and loadMoveFile are files that were created by a lab member Tim Whalen. I made edits to these files to make them compatible with the other files in this repository. These files are only included in this repo as they are needed to load the sorted neuron spike trains from Plexon. \n\n![screen shot 2017-08-06 at 6 01 51 pm](https://user-images.githubusercontent.com/10649054/29008821-fc7f414e-7ad1-11e7-8d51-ce0e8ce61f20.png)\nSelect the \"Add with Subfolders\" option and add the directory that contains the .PL2 files you would like to examine. \n\n\u003ca name=\"preReqHeader\"/\u003e  \n\n### Prerequisite To-Do List\n* Know how many classes of in-vivo data you would like to examine. This depends on the number of conditions you would like to study: Acute, Gradual, Alpha-Syn, etc. If you just want results for a given dataset, just use one condition.\n* Make sure the condition you want is included in the switch cases of the dataInitializer.m file. \n\n![screen shot 2017-08-06 at 6 28 01 pm](https://user-images.githubusercontent.com/10649054/29009110-2a0fcd06-7ad5-11e7-9928-866e23321688.png)\n\n* Also include the condition in the master.m. Make sure to delete the condtions that are not being used from the typeNames array and the corresponding elseif statement. Add elseif statements for your condition and add the condition into the typeNames array. \n\n![screen shot 2017-08-06 at 7 44 18 pm](https://user-images.githubusercontent.com/10649054/29010466-575ac8dc-7ae0-11e7-9481-94de3ea8fcb6.png)\n\n\n   * Currently, there are eight cases (Acute, Alpha-Syn, Gradual, Gradual 35%, Gradual 65%, Naive, Unilateral Depleted, Unilateral Intact) in the dataInitializer.m file. **It is important that you delete the cases along with the files and animalcodes. You will encounter an error unless you have the files listed in the dataInitializer.m file.**\n\n   * To add cases, follow this format: \n     ```\n     case 'CONDITION_NAME'\n         input.files = {\n             %1 From animal one\n             'FILENAMEUNITONESorttt.pl2;'\n             'FILENAMEUNITTWOSorttt.pl2;'  \n\n             %2 From animal two\n             'FILENAMEUNITONESorttt.pl2;'\n             'FILENAMEUNITTWOSorttt.pl2;'       \n             'FILENAMEUNITTHREESorttt.pl2;'   \n             };\n         input.animalcodes = [1 1 2 2 2];\n         data = open_data(input);\n     ```\n    *  **Please follow the naming convention of naming a PL2 file as 'fileNameAWsorttt-01.pl2'.**\n    * Keep in mind your animalcodes should correspond to the number of files you add. \n    \n* Create an excel file named 'custClassification.xlsx'. Create a separate sheet for each condition/case you have in dataInitializer.m. \n![screen shot 2017-08-06 at 7 19 26 pm](https://user-images.githubusercontent.com/10649054/29009943-879e6f16-7adc-11e7-9c5e-346423b1d7d2.png)\n\nFollow this format and define four columns that contain **conditionFileName, conditionSPKC, conditionUnit, conditionRegularIrregularBurst'**. The SpKC and unit information can be found via NeuroExplorer. Make sure to have a row in the excel sheet for each file you add in dataInitializer. If the class is unknown, simply put 'No Class'. Once you set the dataInitializer and custClassificaiton file up, you should be good to go. \n\n\u003ca name=\"perfCalcHeader\"/\u003e  \n\n### Performing Calculations\n\n\u003ca name=\"masterHeader\"/\u003e  \n\n#### Master\nThe master Function will be the most important function you will use in batch processing a certain analysis script.\nThe master function takes in three parameters:\n* Handle of function you would like to apply (String). Functions are limited to functions in the Functions directory.\n* The conditions you would like to apply (String). Conditions are 'FULL' (Applies to all conditions) , and the strings of the conditions you have defined: 'Acute', 'Alpha-Syn', etc. \n* Third parameter: Will be updated in the future. Just use 0 for now. \n```\n%To calculate the statAv parameter for all conditions you have defined, put this command in the command window of Matlab\nmaster('statAv', 'FULL', 0)\n\n%To calculate the AppEntropy parameter for a condition 'condition_name' you have defined, put this command in the command window of Matlab:\n\nmaster('AppEntropy', 'condition_name', 0)\n\n```\nThis will create a results folder along with the results for each condition. \nPlease refer to the function scripts to read about what they exactly calculate. \nThe following functions can be used as function handles: \n* 'AppEntropy'\n* 'CV'\n* 'CV2'\n* 'ISIKurtosis'\n* 'allstdISI'\n* 'cellbycellISIAutos'\n* 'dApEn' (only compatible once you calculate AppEntropy and shuffledApEn)\n* 'classISIHists'\n* 'spikedensityfunction'\n* 'expFitAutos'\n* 'expFitResults'\n* 'fanoFactor'\n* 'meanFR'\n* 'meanISI'\n* 'nonParametricSkew'\n* 'pearsonModeSkew'\n* 'pearsonSecSkew'\n* 'sampleSkew'\n* 'shuffledApEn'\n* 'statAv'\n* 'rasterPlot'\n\nParameters for these function handles can be adjusted in the mapper.m file. \n\n\u003ca name=\"visHeader\"/\u003e \n\n### Visualizations\n\n\u003ca name=\"rastorHeader\"/\u003e \n\n#### RasterPlot\nRasterplot is a visualization function that can be used through the master function. \n```\nmaster('rasterPlot', 'condition_name', 0)\n```\nYou should get a rasterPlot for each spike train in your file.\n![screen shot 2017-08-06 at 9 31 40 pm](https://user-images.githubusercontent.com/10649054/29012433-4a7d5aa2-7af0-11e7-93b4-ecc858bbf7ec.png)\n\n\u003ca name=\"cellISIHeader\"/\u003e \n\n#### CellByCellISIAutos\nCellbycellISIAutos is a visualization script that can also be used through the master function. \n```\nmaster('cellbycellISIAutos', 'condition_name', 0)\n```\nEach row of a figure will have an ISI and autocorrelogram corresponding to a single spike train.\n![screen shot 2017-08-06 at 9 35 19 pm](https://user-images.githubusercontent.com/10649054/29012443-68600574-7af0-11e7-9fba-dcaae9b9916e.png)\n\nEmpty subplots indicate that the given spike train did not fire above the threshold firing rate. The threshold firing rate can be changed in the cellbycellISIAutos.m script. \n\n\u003ca name=\"sdfHeader\"/\u003e \n\n#### SpikeDensityFunction\nSpikeDensityFunction is a visualization script that can be used through the master function. It will show the spike density function results over multiple periods of movement. \n\nYou can adjust the time before movement onSet(line 31) and after movement onSet (line 32) in the spikedensityFunction.m file. \n```\nmaster('spikeDensityFunction', 'condition_name', 0)\n```\n\n![screen shot 2017-08-06 at 9 47 51 pm](https://user-images.githubusercontent.com/10649054/29012521-06236404-7af1-11e7-9a38-390db753b009.png)\nThe first 3 subplots show that there are no movements/ lack of movement periods that fit the minimum time length. The last subplot shows different movement phases along with their spike density. \n\n\u003ca name=\"scatterTwoHeader\"/\u003e \n\n#### 2D ScatterPlot\nScatterPlot allows you to produce a 2 dimensional scatterPlot that plots the results of one function against the results of another. Keep in mind, the ScatterPlot **does NOT** apply the functions to the datasets. Rather, it reads the results and then plots the data points in the 2 feature parameter space. **Make sure to call the master function for the features first to get their results.**\n\nThe scatterPlot function is not used via the master function. \nIt takes in 3 input parameters:\n* First Function handle (String)\n* Second Function handle (String)\n* Type of Conditions You'd like to examine (String) : 'FULL' creates scatterplots for ALL conditions.\n\nFormat of scatterPlot command:\n```\nscatterPlot('function_one', 'function_two', 'Type')\n```\n\n![screen shot 2017-08-06 at 10 51 07 pm](https://user-images.githubusercontent.com/10649054/29014392-a396c292-7afd-11e7-9507-40bcdf448abf.png)\n\nThe plot above is produced when the statement \n```\nscatterPlot('sampleSkew', 'fanoFactor', 'FULL')\n```\nis put in the command window. \n\n![screen shot 2017-08-06 at 10 51 33 pm](https://user-images.githubusercontent.com/10649054/29014381-9815ee16-7afd-11e7-9dc7-903c19c87cf2.png)\n\nThe plot above is produced when the statement\n```\nscatterPlot('sampleSkew', 'fanoFactor', 'Naive')\n```\nis put in the command window. \n\n\u003ca name=\"scatterThreeHeader\"/\u003e\n\n#### 3D ScatterPlot Visualization\n\n\u003ca name=\"scatterThreeDHeader\"/\u003e\n\n##### ScatterPlot3D\nScatterPlot3D allows you to produce a 3 dimensional scatterPlot that plots a series of data points in a 3D feature space. Keep in mind, the ScatterPlot3D **does NOT** apply the functions to the datasets. Rather, it reads the results and then plots the data points in the 3 feature parameter space. **Make sure to call the master function for the features first to get their results.**\n\nThe scatterPlot3d function is not used via the master function. \nIt takes in 3 input parameters:\n* First Function handle (String)\n* Second Function handle (String)\n* Third Function handle (String)\n\n```\nscatterPlot3d('function_one', 'function_two', 'function_three')\n```\n\n![screen shot 2017-08-06 at 11 20 45 pm](https://user-images.githubusercontent.com/10649054/29014465-f4ac2bc2-7afd-11e7-9053-4956ceea3f6d.png)\n\nA figure like the one above is produced for EACH of the conditions if the command:\n```\nscatterPlot3d('fanoFactor', 'sampleSkew', 'expFitResults')\n```\nis used.\n\n![screen shot 2017-08-06 at 11 23 16 pm](https://user-images.githubusercontent.com/10649054/29014559-7727dc0e-7afe-11e7-803c-c72a54359afb.png)\n\nPress the button covered by the blue rectangle to rotate the 3D plot. Pressing the red rectangle will allow you to click on a certain data point and see its corresponding x,y,z values along with its fileName and SPKC unit. \n\n![screen shot 2017-08-06 at 11 26 31 pm](https://user-images.githubusercontent.com/10649054/29014636-e276f3e6-7afe-11e7-86ac-912883eb3c41.png)\n\nWith the dataTip cursor, you can select a point and see something similar to what is shown above: \n\n\u003ca name=\"scatterallThreeDHeader\"/\u003e\n\n##### allscatterPlot3d\nallscatterPlot3D plots **all** datapoints for **all conditions** in the **SAME** figure. Allscatterplot3d is useful in analyzing cumulative data (Similarities of features in Regular/Irregular/Burst neurons among ALL conditions). \n\nThis function takes 4 input parameters: \n* First Function handle (String)\n* Second Function handle (String)\n* Third Function handle (String)\n* Extra Functions cell (Cell)\n\nThe extra Functions cell should contain function handles that you'd like to see included in the dataTip. **The extra Functions you use must also have their results already calculated (Must have used master function for extra functions)**.  If you don't have any extra results you would like to see, just use an empty cell. AllScatterPlot3D also prints to the console the neurons classified as 'No Class'. \n\n```\ndataTipCell = {'extFunction1',..., 'extFunctionN'};\nallscatterPlot3d('function_one', 'function_two', 'function_three', dataTipCell)\n```\n![screen shot 2017-08-07 at 12 16 13 am](https://user-images.githubusercontent.com/10649054/29016081-bb10049e-7b05-11e7-9fcd-0342f7ac4807.png)\n\nThe following 3D plot is made when you type in the following commands:\n```\ndataTipCell = {'CV'};\nallscatterPlot3d('sampleSkew', 'fanoFactor', 'expFitResults', dataTipCell)\n```\n\n\u003ca name=\"classHeader\"/\u003e\n\n### Using the Classifcation Scheme\nThis classification scheme employs the fanoFactor, sampleSkew, and doubleExpFit values to assign a neuron 1 of 4 possible types: No Class, Regular, Irregular, or Burst. **IMPORTANT:** To use this classification scheme, please make sure that you have calculated the results for the three parameters through the master function. \n\n#### reCustClassify\nThis function reads in the results of the three functions you want to use to reclassify the data. Based on the results of the three functions, the neurons will be classified by the criteria they meet. These threshold values can be adjusted in the reCustClassify.m script. \n\nreCustClassify has three input parameters: \n* First Function handle (String)\n* Second Function handle (String)\n* Third Function handle (String)\n\n```\nreCustClassify('function_one', 'function_two', 'function_three')\n```\n\nTo use the classification scheme, you want to focus on the fanoFactor, sampleSkew, and expFitResults results. Thus, use this command:\n```\nreCustClassify('fanoFactor', 'sampleSkew', 'expFitResults')\n```\n![screen shot 2017-08-07 at 12 52 30 am](https://user-images.githubusercontent.com/10649054/29017214-bfcfa99e-7b0a-11e7-9316-aacf308e2354.png)\n\nThis command will produce n (the number of conditions there are) condition_name results.csv files in your current directory.\nIf you open any one of those files, they will have four columns: FileName, SPKC, Unit, Class. \nImport each of these files into the 'custClassification.xlsx' file. Each condition should have their own sheet in the excel file. \n * Go to Data \u003e From Text (In Get External Data Section)\nSelect Delimited data type. Set the delimiters to be only commas when you import the .csv files. Press finish to import your newly classified data. \n\n![screen shot 2017-08-07 at 1 01 45 am](https://user-images.githubusercontent.com/10649054/29017577-47dcc726-7b0c-11e7-9eff-5888bf00772f.png)\n\n**IMPORTANT** Run the master function for all your functions again so that the classes for each neuron will be updated. \n\nYou may notice that some neurons are unclassified if your threshold values are not generalizable. You can fix this by creating broader threshold values or by manually inspecting the ISI histograms/Autocorrelograms of the 'No Class' neurons. Once you assign the class through visual inspection to each 'No Class' neuron, manually change the 'No Class' values in the 'custClassification.xlsx' to the values determined by visual inspection. Make sure to run the master function for all your functions again so that your classes will be updated. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriski777%2Fnstanalysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriski777%2Fnstanalysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriski777%2Fnstanalysis/lists"}