Skip to content

RebeFrederick/NeuroEchemAnalysis_Gamry_MATLAB

Repository files navigation

NeuroEchemAnalysis_Gamry_MATLAB

Code base for processing and analysis of electrochemical measurement data for neural interface devices using MATLAB.
For use with Gamry potentiostats and Gamry Framework software (.dta file types).
Last Updated: 2025-JUL-10 by Rebecca Frederick



FILE DESCRIPTIONS

MATLAB Version: R2025a

Main File: "main_DTA_batch_process.m"

  • Reads all Gamry .dta files within a folder.
  • Runs "DTA_read" function to create & save an organized MATLAB data structure for each .dta file.
  • Runs "DTA_calc" function to append the structure with calculated values depending on measurement type.
  • Runs "DTA_summaries" function to add .csv and .mat files with all |Z|, CSC, and OCP values labeled with date, wafer ID, device ID, animal ID (or electrolyte type), electrode ID, and test ID.
  • Runs "DTA_combined_struct" function to combine all .dta file data structures into one combined MATLAB data structure.
  • Runs "DTA_plots" function to create basic visualizations of data within the folder.
    • Open Circuit Potential values for each electrode and average +/- standard deviation of all electrodes.
    • Impedance Magnitude values for each electrode and average +/- standard deviation of all electrodes.
    • Charge Storage Capacity values for each electrode and average +/- standard deviation of all electrodes.
    • Impedance Spectra, subplots of magnitude and phase, with all electrodes' data overlayed.
    • Cyclic Voltammograms, subplots of each scan rate, with all electrodes' data overlayed.
    • Cyclic Voltammograms, subplots of each scan rate and subplots of voltage vs. time and current vs. time, with all electrodes' data overlayed.

Functions & Run Order:

  1. DTA_read.m Output File Format
  2. DTA_calc.m Output File Format
  3. DTA_summaries.m Output File Format
  4. DTA_combined_struct.m Output File Format
  5. DTA_plots.m Output File Format

Follow-On File: "DTA_master_struct.m"

  • Combines multiple data structures generated by DTA_combined_struct into one 'master' data structure.
  • Assumes "combinedDTA_Struct.mat" files are located within two levels of subfolders.
    • Main Folder (input)
      • Study Groups Folders
        • Device/Day Folders > "MATLAB_Output" Folder > "Summaries_Outputs" Folder


USER INSTRUCTIONS

  1. Open "Deku_NeuroEng_EchemAnalysis_MATLAB" Folder in your MATLAB Directory.
    ~ ~ OR ~ ~
    Open MATLAB to your default directory.
    Add the "EchemAnalysis_MATLAB" Folder and Subfolders to your MATLAB directory.
  2. Open the function file for reading .dta files: "DTA_read.m"
  3. Edit the filename convention for labeling data (Lines 78 and 81-86).
    All fields must have a definition, either pulled from the filename or explicitely defined (as a string).
    • date (Default Format: YYYYMMDD)
    • wafer (Any String, must not start with a number!)
    • device (Any String, must not start with a number!)
    • animal (ID/Name, or Electrolyte ID)
    • electrode (Default Format: E00)
    • test (Letter Increment: A, B, C, ..., Y, Z, ZA, ZB, ..., ZZ, ZZA, ...)
  4. Open the main data analysis file: "DTA_batch_process.m"
  5. Run _main_DTA_batch_process.m
  6. At the first prompt, select the folder that contains your .dta raw data files.
    If your files are in subfolders, the analysis will not run on any files in those subfolders, it will only run on files in the main folder you selected.
  7. At the second prompt, select the folder where you want to save all output files.
    Recommended: Create a folder within your raw data folder named "MainFolder_Analysis".
  8. Wait for MATLAB to finish processing your files.
  9. At the third prompt, enter your desired values for calculations:
    • Frequency (in Hz) for pulling impedance magnitude data.
      Default is 1 kHz.
    • Electrode Geometric Surface Area (GSA, in um^2).
      Default is 2000 um^2.
    • CV curve number (as whole integer) to use for Charge Storage Capacity calculations.
      Default is curve #3.
    • Percentage (as whole integer) of data to use for calculating average open circuit potential (OCP) value.
      Default is last 10% of total measurement time.
  10. Wait for MATLAB to finish processing your files.
  11. Check that the output files are saved in your selected folder and contain the data, summaries, and plots (in progress) you selected in the user prompts.
  12. Repeat for any additional folders of .dta files you would like to process.


OUTPUT FILE DESCRIPTIONS

Individual File (.mat) Structures (Raw Data & Calculated Values):

  • The output will be .mat files with the same filenames as each of the .dta files
    in the folder(s) you selected for processing.
  • Each .mat file contains a structure variable called "DTA_read_output"
  • Each structure contains the same information in the same format:
Structure Level Data Type Description
DTA_read_output.filename character name of original .dta file
DTA_read_output.testType character 'EIS' or 'CV' or 'OCP'
DTA_read_output.testDate character date from original .dta file
DTA_read_output.testTime character time from original .dta file
DTA_read_output.notes array text notes (if any) from original .dta file
DTA_read_output.ocpcurve
cols=time,voltage
array OCP raw data
empty if .dta file is not an OCP measurement
DTA_read_output.cvcurve
cols=time,Vf,Im;
rows=curve#
array CV raw data for all curves
empty if .dta file is not a CV measurement
DTA_read_output.eis structure EIS raw data
empty if .dta file is not an EIS measurement
  ...eis.fstart character starting frequency value for measurement
  ...eis.ffinal character ending frequency value for measurement
  ...eis.ppd character number of data points per decade
  ...eis.time cell time values for each data point
  ...eis.freq cell frequency values for each data point
  ...eis.Zreal cell real portion of impedance values for each data point
  ...eis.Zimag cell imaginary portion of impedance values for each data point
  ...eis.Zmod cell impedance modulus values for each data point
  ...eis.Zph cell impedance phase values for each data point
DTA_read_output.settings array stores settings from CVs needed for CSC
  ...settings.scanrate character scan rate of CV measurement, in mV/sec.
  ...settings.stepsize character step size for each voltage step, in mV, default is 10mV.

Structure Level Added by "DTA_calc.m" Function:

Structure Level Data Type Description
DTA_read_output.Calculated cell array stores values calculated by DTA_process.m
   If OCP... 1x2 cell {1,1} 'Avg_OCP'   {1,2} number in V
   If EIS... 2x2 cell {1,1} 'Freq'   {1,2} number in Hz
{2,1} '|Z|'       {2,2} number in ohm
   If CV... 7x2 cell {1,1} 'CSCc'     {1,2} number in mC/cm^2
{2,1} 'CSCa'     {2,2} number in mC/cm^2
{3,1} 'CSCh'     {3,2} number in mC/cm^2
{4,1} 'Qc'         {4,2} number in nC
{5,1} 'Qa'         {5,2} number in nC
{6,1} 'Qh'         {6,2} number in nC
{7,1} 'CVslope' {7,2} number in A/V

Summary (.csv) Files

Within One Folder:

OCP Data Summary

Columns = Date, Wafer ID, Device ID, Animal ID, Electrode ID, Test ID, OCP (V)

EIS Data Summary

Columns = Date, Wafer ID, Device ID, Animal ID, Electrode ID, Test ID, Frequency (Hz), Impedance (ohm)

CV Data Summary

Columns = Date, Wafer ID, Device ID, Animal ID, Electrode ID, Test ID, Scan Rate (mV/s), CSCc (mC/cm^2), CSCa (mC/cm^2), CSCh (mC/cm^2)


Master Data Structure

Pulls Names from Filename. Defined in "DTA_read" function.
Level 1: Structure Name = "masterDTA"
Level 2: Fieldnames = Wafer ID(s)
Level 3: Fieldnames = Device ID(s)
Level 4: Fieldnames = Electrode ID(s)
Level 5: Fieldnames = Animal ID(s)
Level 6: Fieldnames = Date(s)
Level 7: Fieldnames = TestType ("OCP", "EIS", or "CV")

Structure Level: 7-TestType Data Type Description
...   .OCP
      testID char Letter ID for Measurement
      rawdata 1x1 struct Contains Raw Data in 3 Fields: time, Vf, Vach
      calcdata 1x2 cell Same as DTA_read_output.Calculated for OCP
...   .EIS
      testID char Letter ID for Measurement
      rawdata 1x1 struct Contains Raw Data in 9 Fields:
fstart, ffinal, ppd, time, freq, Zreal, Zimag, Zmod, Zph
      calcdata 2x2 cell Same as DTA_read_output.Calculated for EIS
...   .CV
    ...   Fieldnames = Scan Rate 1x1 struct
            testID char Letter ID for Measurement
            rawdata 1x1 struct Contains Raw Data in 3 Fields: time, Vf, Im
            calcdata 7x2 cell Same as DTA_read_output.Calculated for CV

Plots

Within One Folder:

OCP Data

Creates scatter plot with OCP value for each electrode, as well as the average and standard deviation of all electrodes.

EIS Data

Creates scatter plot of impedance magnitude at the user-selected frequency (during DTA_calc function, default = 1 kHz) for each electrode, as well as the average and standard deviation of all electrodes.
Creats one figure with two subplots, one for impedance magnitude vs. frequency and one for phase vs. frequency, with data from each electrode (pulled from file names) overlayed within the same subplot.

CV Data

Creates scatter plot of cathodal and anodal charge storage capacity calculated from the user-selected curve number (during DTA_calc function, default = curve 3) for each electrode, as well as the average and standard deviation of all electrodes.
Creats two figures with two subplots. The first figure has one subplot for each scan rate, with data from each electrode (pulled from file names) overlayed within the same subplot. The second figure has two subplots for each scan rate, one for the applied voltage vs. time and one for the measured current vs. time, with data from each electrode (pulled from file names) overlayed within the same subplot.



END OF READ ME



About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages