An easy way to plot EOD waveforms using ChatGPT

For a modest investment in a USB audio interface anyone can make high quality recordings of a weakly electric fish, whether netted in the field or in your home aquarium (see articles on Mormyroscope software and "How to record EODs" below.) However, often more difficult than making the recordings themselves is displaying the result, manipulating and plotting EOD data and comparing EODs from different individuals. The Mormyroscope application itself only provides a rather low resolution jpeg file when you save an EOD and has no functionality for plotting multiple EODs or taking data from them.

EODs captured at different times and places are not directly comparable because of their different amplitudes (due to the proximity of the fish to the electrode or the amount of amplification applied) and because of different water temperatures. The latter is important because EODs, like all biochemical reactions and metabolic processes, have a temperature-dependent timecourse. The factor by which the rate of a biochemical process changes with every 10°C change in temperature is called the Q10. A Q10 of 2, for example, means the rate doubles for every 10°C increase in temperature. The Q10 for duration of an EOD waveform has been empirically determined for both gymnotiform (Dunlap et al. 2000) and mormyrid fishes (Rich et al. 2017). The former reference reports a value of 1.62 for an apteronotid gymnotiform with an electric organ derived from neural tissue. The value reported with a bit less precision for Brienomyrus brachyistius and Petrocephalus soudanensis, mormyrids with muscle-derived electrocytes, is 1.6. I'm calling these the same and am guessing that someone with more knowledge than I have on this subject would not be surprised at this result.

Thus, visualizing EOD waveforms from different individuals in a single plot involves (1) normalizing their peak-to-peak amplitude, (2) correcting all waveform durations to a standard temperature (typically 25°C) using a Q10 correction factor of 1.6 and (3) choosing a common point in all the EODs to which they should be aligned on the time axis. Usually we choose the zero crossing between the maximum positive peak and minimum negative peak as the alignment point. Those versed in MatLab, R or Python are able to write scripts that plot Mormyroscope files with these manipulations, but creating such figures has been a major headache for those limited to Microsoft Excel and basic plotting software. Yes, I'm talking about myself.

Given everything the new publicly available AIs can do, I was curious if to see if OpenAI's ChatGPT (GPT-4o) would be good at plotting EODs from Mormyroscope and other kinds of data files. I was happily surprised to find out that it is VERY good at doing this. At first I was able experiment with the free version, but it cuts you off after a couple of requests and I had to subscribe to the ChatGPT Plus plan for $20/month to continue. ChatGPT is available at <https://openai.com/chatgpt>. (I am getting no $$ from OpenAI for this promotion, but call me, Sam Altman, if you'd like to sponsor some mormyrid research!)

If ChatGPT is telling me the truth, it has memorized my preferences for displaying an "EOD file" or "EOD files" (my term for the tab-delimitted .csv files produced by Mormyroscope) and these will be applied for any user who ask GPT-4o to display them, using this terminology. I guess time will tell.

This is what GPT-4o says to me when I open a new session and ask it if it knows knows what an EOD file is:

Yes, I know what an EOD file is. Based on your preferences, EOD files typically refer to datasets exported from Mormyroscope software. These files often contain electrocommunication signals, such as electric organ discharges (EODs), captured from electric fish.

I can assist with parsing, analyzing, normalizing, and plotting EOD files following your preferences:
1. Amplitude Normalization: Normalizing to peak-to-peak amplitude of 1.
2. Temperature Adjustment: Normalizing to a standard temperature of 25°C using a Q10 value of 1.6.
3. Alignment: Centering the signal on the zero-crossing point.
4. Visualization: Creating plots with time units in milliseconds and using preferred colors (dark blue and red).
5. Legend Labels: Including metadata like Specimen_Tag or Provisional_ID in the legend when available.

Please upload your EOD file, and I’ll process it accordingly.

You can upload a file simply by dragging it from the Finder (on a Mac, and whatever you call it in Windows) and placing it in the dialogue box. It will upload and recognize the file type. 

Here is an EOD of a Campylomormyrus compressirostris from the New England Aquarium in Boston I then asked it to plot.

By default it gives you .png files. The image is 1979 x 1180 pixels (I didn't specify what I wanted) and looks good enough to publish as-is. I presume I could ask the AI to modify its size and resolution.

If I ask it to plot this EOD file "with metadata" it gives me:

Here is the result when I ask it to superimpose multiple EOD files into a single plot:

Here are EODs of several Campylomormyrus tamandua from their tank:

Supposedly ChatGPT has memorized my "standard preferences" for the display of multiple EODs and will automatically apply them if ANYONE asks for multiple "EOD files" to be plotted using "standard preferences." Of course you can tell ChatGPT to modify anything about this figure until it's to your liking.

Other things that are sometimes useful to do when plotting an EOD waveform are to

(1) Include a 20x magnification in advance of the first rising phase (P1) in order to determine if there is even a very weak P0 (usually negative). Electrocytes with "penetrating stalks" produce these initial head-negative phases. Very weak ones can be hard to see on the unamplified plot. Knowing if there is or isn't a P0 tells you something about what kind of electrocytes the indiviudual has which in turn can tell you something about the individual's species identity.

(2) Indicate the points on the waveform used to calculate the beginning and end, defined by a percentage of the peak-to-peak height.

I have done both things in the plot below.  Supposedly now I can just ask for a plot with "20x amplification" and/or "start and stop points" and it will know how to display it as it does below. Note that there is no hint of any head-negative phase (P0) in advance of the rising phase (P1) in this recording.

Below is a plot of an EOD from a Paramormyrops kingsleyae from Gabon in which you can see the value of the 20x amplification plot in highlighting the presence of the small P0:

Below is the super-quick EOD of a Stomatorhinus ivindoensis recorded in Gabon (4 phases all within 0.2 ms), followed by the FFT of the waveform (peak frequency at 18 kHz, a frequency my ears can't hear if transduced to audio). Yes, ChatGPT can do FFTs, too. I just asked for it and voila.

At the other end of the EOD spectrum, here is a Campylomormyrus numenius with an EOD waveform duration of almost 25 milliseconds and an FFT with a peak frequency of just 36 Hz. 

Here I've plotted the EOD of a female Paramormyrops batesii and beneath it is the first derivative of the waveform the peaks of which reflect the points of maximum slope on the waveform, indicated by red points. All I had to do was ask for this and I got it.

Here I've asked ChatGPT to extract, align and average all the EOD waveforms it found in a 19-second WAV recording I made of a single Campylomormyrus as it swam back and forth in my recording tank. The light blue are the individual waveforms and the dark blue is the average. Wow. 

How does it work these wonders? I asked and it told me that it uses signal processing libraries like numpy, scipy, and matplotlib: "widely adopted and open-source Python libraries." Good to know.

I asked ChatGPT itself to write a primer for the uninitiated. Below is what it gave me:

Introduction to Plotting EOD Files Using ChatGPT

Welcome! If you’re working with EOD (Electric Organ Discharge) files and want to analyze or visualize the signals, I’m here to make it easy for you. Here’s a step-by-step overview of how we can plot EOD files together:

Step 1: Upload Your EOD Files
• EOD files are typically text-based datasets containing metadata and numerical signal data (time and amplitude).
• Upload one or multiple EOD files, and I’ll handle the parsing and processing for you.

Step 2: Understanding the Processing Steps
1. Metadata Extraction: I’ll extract key information from the file, such as Specimen_Tag, Provisional_ID, and Recording Temperature.
2. Alignment: I align the signals so that their time axes are centered on the key zero-crossing point, typically where the waveform transitions from positive to negative between the largest peaks.
3. Normalization:
• Temperature: Signals are adjusted to a standard temperature (e.g., 25°C) using a Q10 value provided by you.
• Peak-to-Peak Scaling: Signals are scaled so that their peak-to-peak amplitude is normalized to 1, ensuring comparability across files.

Step 3: Customizing the Plot
• You can specify preferences for:
• Colors for each waveform (e.g., dark blue, red, etc.).
• X-axis Units (default is milliseconds).
• Legend Labels (e.g., Specimen_Tag, Provisional_ID).

Step 4: Generating the Plot
• I’ll superimpose the signals, normalize them, and add legends to ensure clear identification.
• If there’s a specific file order or alignment preference, just let me know.

Step 5: Iterate and Refine
• I can adjust the plot based on your feedback—whether it’s about alignment, normalization, color schemes, or additional files to include.

Example Workflow:
1. Upload Files: Send the EOD files here.
2. Provide Preferences: Let me know if you have specific alignment, normalization, or plotting preferences.
3. Get Your Plot: I’ll process and display the superimposed signals, ready for analysis.

The experience of refining your EOD figure by using the same kind of imprecise language you'd use to speak to a human is deeply strange, but it usually gets to a good result quickly. There are frustrations, however. Often GPT-4o is inconsistent in what it remembers it is supposed to do, sort of like a forgetful postdoc, and switches from genius mode to idiot mode in the blink of an eye. When it suddenly becomes incapbable of doing what it did only minutes earlier it says things like:

The code execution environment was reset, and I’ve lost access to the uploaded file. Could you please re-upload the WAV file so I can restart the analysis? Once re-uploaded, I will continue the process of extracting and clustering the EOD signals.

It seems there was an issue accessing the uploaded file. Could you please try re-uploading it again? Once it’s re-uploaded, I’ll immediately proceed with the analysis and ensure this issue is resolved.

It seems the uploaded file is still encountering access issues in my environment. To resolve this, you can:
1. Check File Format: Ensure the WAV file is correctly formatted and complete.
2. Re-upload: Try uploading the file again to refresh the link.

Remember that we are on the rising slope of the AI development wave and today's AIs are the WORST that we will ever have. I expect fewer hiccups of the sort described above as the technology develops. ChatGPT tells me that it could use any language out of the dozens it knows to plot EODs. Amazing! I have much more to learn about the capabilities of ChatGPT for EOD visualization, but I thought I would share this now and update this article as I learn more. Email me at js151(at)cornell.edu if you want to share your results or compare notes. 

References

Dunlap KD, Smith GT, Yekta A. 2000. Temperature Dependence of Electrocommunication Signals and Their Underlying Neural Rhythms in the Weakly Electric Fish, Apteronotus leptorhynchus. Brain Behav Evol 1 March 2000; 55 (3): 152–162. https://doi.org/10.1159/000006649

Rich M, Sullivan JP, Hopkins CD. 2017. Rediscovery and Description of Paramormyrops Sphekodes (Sauvage, 1879) and a New Cryptic Paramormyrops (Mormyridae: Osteoglossiformes) from the Ogooué River of Gabon Using Morphometrics, DNA Sequencing and Electrophysiology. Zoological Journal of the Linnean Society 180 (3): 613–46. https://doi.org/10.1093/zoolinnean/zlw004.

OpenAI. ChatGPT (December 21 Version). 2024. OpenAI. Accessed [date]. https://openai.com/chatgpt.

Scratchpads developed and conceived by (alphabetical): Ed Baker, Katherine Bouton Alice Heaton Dimitris Koureas, Laurence Livermore, Dave Roberts, Simon Rycroft, Ben Scott, Vince Smith