Eavesdropping on the brain at sea: development of a surface‑mounted system to detect weak electrophysiological signals from wild animals

Despite rapid advances in sensor development and technological miniaturization, it remains challenging to non‑ invasively record small‑amplitude electrophysiological signals from an animal in its natural environment. Many advances in ecophysiology and biologging have arisen through sleep studies, which rely on detecting small signals over multiple days and minimal disruption of natural animal behavior. This paper describes the development of a surface‑mounted system that has allowed novel electrophysiological recordings of sleep in wild marine mammals. We discuss our iterative design process by providing sensor‑comparison data, detailed technical illustrations, and material recommendations. We describe the system’s performance over multiple days in 12 freely moving northern elephant seals ( Mirounga angustirostris ) sleeping on land and in water in captivity and the wild. We leverage advances in signal processing by applying independent components analysis and inertial motion sensor calibrations to maximize signal quality across large (> 10 gigabyte), multi‑day datasets. Our study adds to the suite of biologging tools available to scientists seeking to understand the physiology and behavior of wild animals in the context in which they evolved.

neurophysiological underpinning of animal behavior in the wild.
Recent efforts to record sleep in the wild coincide with significant advances in sensor technology and miniaturization [4,5,[10][11][12]. Electrophysiological sleep recordings rely on detecting small changes in brain activity (several orders of magnitude smaller than typical heart signals) and benefit from multiple-day recordings of freely behaving animals in the wild. Sleep studies rely on the use of electroencephalogram (EEG) to record changes in brain activity from "large amplitude" (~ 75 μV peak-to-peak amplitude in humans) slow-wave sleep (SWS: 0.5-4 Hz) to small-amplitude, high-frequency activity during waking or rapid-eye-movement (REM) sleep. Sleep states are distinguished from one another using EEG (brain) activity, electrooculogram (eye) activity, electromyogram (muscle) activity, accelerometry, and heart rate variability [13].
In addition to promoting technological advancement, studying sleep in the wild contributes to our knowledge of its function and evolution, with implications for conservation and comparative medicine [14][15][16]. Across the animal kingdom, sleep provides critical restorative functions from energy conservation, immune function, metabolism, memory, and learning [14,17]. Sleep quota differences between captive and wild settings highlight the importance of quantifying in situ sleep patterns [4,11]. In situ multi-generational sleep recordings have demonstrated that hereditary sleep adaptations can improve reproductive success [12]. Marine mammal sleep studies suggest that unihemispheric sleep may provide similar homeostatic functions as REM sleep through the apparent lack of REM sleep in cetaceans and lack of REM rebound in fur seals [18,19]. Wild marine mammal sleep studies can further investigate extreme forms of sleep to shed light on sleep phenology, evolution, and pathology.

Methods
We developed a system for long-term electrophysiological recordings in wild, free-swimming northern elephant seals, Mirounga angustirostris, in two phases. During Phase 1, we recorded EEG from anesthetized northern elephant seal pups housed in a rehabilitation facility (The Marine Mammal Center, TMMC-Sausalito, CA) ( Table 1) (N = 11). In Phase 2, we developed a portable EEG datalogger to record sleep in freely moving juvenile northern elephant seals (N = 12). We recorded EEG from freely moving seals (2a) in the controlled lab environment at Long Marine Lab (University of California Santa Cruz) and (2b) on the beach at Año Nuevo State Park (California, USA). This iterative design process allowed us to test and compare electrode performance (Phase 1) and then apply these results to develop our portable device (Phase 2). All animal procedures were approved at the federal and institutional levels under National Marine Fisheries Permits #19108, #23188, and #18786 (TMMC), and by the Institutional Animal Care and Use Committee (IACUC) of the University of California Santa Cruz (Costd1709 and Costd2009-2) and The Marine Mammal Center (TMMC #2019-2). All animals were sedated for tag placement following standard protocols [1,33,34,46,47]. Briefly, an induction injection of intramuscular Telazol ® [tiletamine and zolazepam] (1 mg/kg) was maintained with doses of Telazol/ketamine/valium as needed.

Phase 1: stationary recordings
We tested and refined electrode configuration during stationary EEG recordings with 11 anesthetized northern elephant seal weanlings (weaned pups ~ 3-4 months old) undergoing rehabilitation at TMMC (Table 1). Each recording lasted less than an hour and coincided with routine veterinary procedures. Of the 11 anesthetized seals, we performed 2 EEG recordings during veterinarian-ordered euthanasia (Euthasol ® [pentobarbital sodium and phenytoin sodium]) due to congenital defects independent of the study. Animals were to be euthanized regardless of the study. These recordings provided an opportunistic assessment of brain wave attenuation and demonstrated that surface electrodes detected brain activity.

Stationary recordings: instrumentation and data collection
We tested several surface-mounted electrode types: (1) soft-dry electrodes (DRYODE ™ by IDUN Technologies); (2) dry electrodes (SoftPulse ™ by Dätwyler), and (3) goldcup electrodes (Genuine GRASS ® ). We measured 9 differential electrophysiological channels ( were placed approximately 5 cm posterior to the outer canthus, EMG electrodes were placed above the nuchal muscles, ECG electrodes were placed on either side of the body near the fore flippers, and ground electrodes were placed on the forehead between the supraorbital vibrissae ( Fig. 3). This electrode configuration closely matched montages used for implanted polysomnography in other pinnipeds [21,28,30,45]. We trimmed the fur and attached all electrodes to clean skin using conductive paste and kinesiology tape. We recorded EEG with a stationary amplifier (PowerLab ™ ) (#1-11) ( Table 1), and tested multiple electrode types and configurations to optimize signal detection. We collected and visualized data in LabChart (ADInstruments ™ ).  [46,47]. Shortly after transport, we anesthetized and instrumented the seals with the portable EEG datalogger (see "Instrument Attachment"). We released the seals into a dry enclosure (6.1 m × 3.0 m) for at least 48 h after sedation. The animals were then released into a seawater pool (4.9 m × 3.0 m × 1.4 m (water volume 21 m 3 ) with an adjoining haul-out area (1.2 m × 3.0 m). After an acclimatization period of 30 min to 2 days, the seals learned to exit the pool and freely transitioned between the two media. If needed, seals were sedated to modify instrument attachments. We removed instrumentation during a final sedation and transported seals back to Año Nuevo State Park.

2b: Wild deployments-Año Nuevo State Park (ANO)
We anesthetized and instrumented six seals at Año Nuevo State Park (#17-22: 3 weanlings [~ 75 days old] and 3 juveniles [14 or 24 months old]) ( Table 1). Instruments were recovered after 3-5 days in the wild. Seals were instrumented during the molt haulout when animals of all age classes were present at the colony, before most newly weaned pups had departed to sea on their first foraging trip.

Portable datalogger instrumentation
We recorded 9 differential electrophysiological signals (with 21 independent electrodes and wires), pressure, illumination, temperature, 3D accelerometer, 3D gyroscope, and 3D magnetic compass using the Neurologger3 (©2016 Evolocus LLC). Electrophysiological signals were recorded with a differential amplifier (no common reference was used). We created a portable, waterproof, and ruggedized housing for the Neurologger3 to withstand the hydrostatic pressure when the elephant seal dove (up to 2000 m of seawater; pressure equivalent of 200 atmospheres or ~ 3000 psi as below). The housing had external sensor ports to record pressure and illumination and to display recording status via a small LED. The logger transmitted snapshots of electrophysiological data via Bluetooth.
We created a housing for the device that accounted for: (1) a transparent wall for viewing the illumination sensor and LED status; (2) the pressure sensor (KELLER 4LD) machined between an internal lip and external retaining wall or clip; (3) attenuation of Bluetooth signals by aluminum housing material, and (4) a bulkhead for 21 electrical wires exiting the housing, each of which is a potential conduit for water.
Across three design iterations, we developed a housing and frontend (headcap and patches) to satisfy these requirements (see Additional file 2: Table S2 for a full comparison of the three versions [V1, V2, and V3]). A robust SubConn ® Micro Circular 21-pin underwater connector was selected to transmit electrophysiological signals into the housing. The final housing (V3) was an aluminum cylinder with one rounded end and a threaded cap at the other side that integrated pressure and illumination sensors, an acrylic window, and the SubConn ® Micro Circular 21-pin underwater connector ( Fig. 2 and Additional file 2: Table S2). The acrylic window allowed light detection by the illumination sensor, visualization of the LED status, and reception of Bluetooth signals to verify signal quality.

Headcap and patch design
We designed the EEG headcap and patches by embedding electrodes between two layers of neoprene (Fig. 3A).  The most effective configuration embedded electrodes between an outer layer of durable, flexible neoprene rubber (3 mm thick, 40A durometer; Part No. 1370N54 McMaster Carr) with a second, inner layer of thin neoprene sponge foam (3 mm thick; multiple brands including Lazy Dog Warehouse) to hold electrodes in place against the skin (see Additional file 2: Table S2 for more detail on previous iterations). This design facilitated the reuse of the equipment by preventing tearing in the upper neoprene layer. We fixed the electrodes into place between the two layers of neoprene using a silicone room-temperature-vulcanizing (RTV) adhesive (Permatex ® Automotive Adhesive Sealant; Item No. 80765 ACE ® Hardware) to protect the wires and maintain wire configuration across deployments. The sealant created a robust mechanical bond to abraded neoprene rubber, a chemical bond to silicone-insulated electrode sheathing, and no bond to the neoprene cement (added after the full cure time of the silicone RTV) that peeled off easily upon each retrieval of the instrument.
Precautions to minimize water intrusion included sealing wire exit points and footprints for the headcap and patches. We routed electrode wires through custom 3D-printed molds (Fig. 3C) potted with a two-part Epoxies ® urethane (Part No.: ). An extra layer of neoprene foam was required on either side of the rigid mold to better conform to the curve of the head. To further prevent water intrusion at depth, we created a chemical bond at the top of the 3D mold to avoid slow water intrusion along the wire and into the 3D mold. Genuine Grass reusable goldcup electrodes with "no-tangle" silicone wire insulation were spliced to a Technomed reusable goldcup electrode's thermoplastic polyurethane (TPU) wire (Technomed wire Part No.: TE/C12-934) to achieve a chemical bond between the TPU electrode wire and urethane potting compound. We prevented water intrusion to this splice joint through several sequential layers: (a) standard heat-shrink; (b) ScotchKote ™ ; (c) marinegrade heat-shrink; (d) ScotchKote ™ ; (e) marine-grade heat-shrink; (f ) urethane potting compound (mentioned earlier), and (g) silicone RTV Permatex ® Adhesive Sealant (only on the silicone-insulated inner end) (Fig. 3C). The abraded marine-grade heat-shrink created a chemical bond with the potting compound. We repeated this process for each patch, using smaller 3D molds for the 1-and 2-wire outputs from EMG and ECG patches. For creating waterproofed electrode patches, we recommend carefully waterproofing the bottom lip of the patch and creating a chemical bond at the wire's exit point.
Earlier iterations had water intrusion issues that the final design resolved. Patches remained completely watertight during two 5-day deployments using this method, as evidenced by the persistence of conductive paste under the electrode and water-contact indicator tape placed adjacent to the electrode. In all cases, V3 resulted in a nearly waterproof seal where any water intrusion was minimal and slow, such that signal quality remained adequate for sleep stage characterization throughout the recording (see "Signal quality analysis").
We surrounded cable bundles with ultra-lightweight braided microfilament 316L stainless steel shielding material, heat-shrink, liquid electrical tape, and nylon braided sheathing (Fig. 3A). Electrode cables were soldered to the leads of a 21-pin underwater connector which routed the electrical signals into the portable datalogger (Fig. 3A). Solder joints were staggered to maximize space efficiency and strength, covered in heat-shrink, potted in polyurethane; a final large-diameter marinegrade heat-shrink tubing minimized water intrusion at mechanically vulnerable connections. Use of a threaded locking sleeve reduced the risk of the connector becoming disconnected during the experiment.

Instrument attachment
Once animals were immobilized, we trimmed the fur and cleaned the skin with alcohol or acetone at electrode attachment sites. We used conductive paste Ten20 ™ (Weaver and Company) to promote signal conduction and adhesion. Neoprene adhesive (Aquaseal ™ ) was applied onto the headcap, patches, and the animal's skin. Several minutes later, we applied a second layer of adhesive. We attached small cable bridges to the fur in several places to minimize cable tension and entanglement potential, with Velcro ® cable organizers attached with neoprene adhesive (Fig. 3).
The datalogger was wrapped in Tesa ® tape and attached to a flexible nylon mesh with stainless steel zip ties. The flexible nylon mesh was epoxied to the animal's fur, consistent with established practices for external attachment of animal telemetry tags (Horning et al. 2019) (Fig. 3B). For each design iteration, combined instrumentation did not exceed 10% of the animal's cross-sectional area and 2% of the animal's body mass (2.31% cross-sectional area and 0.87% of body mass). When time allowed, we verified datalogger signal quality by examining 20-s raw-signal snapshots via Bluetooth.
After the recording, we removed the datalogger by disconnecting the zip ties from the nylon mesh. We separated the top layer of neoprene rubber from the bottom layer of neoprene foam, removing all electrodes and wires from the animal. The animal molted off the nylon mesh and any residual neoprene foam in its next molt.

Data processing
A total of 1072 h (45 days) of electrophysiological data were collected from the 12 animals in Phase 2 of this study, of which 464 h (19.3 days) were from free-moving animals at Long Marine Lab, and 608 h (25.3 days) were from free-moving animals at Año Nuevo Reserve. In addition, one animal instrumented at Año Nuevo Reserve spent 44 h (1.9 days) at sea.
The Neurologger3 sampled electrophysiological data at 500 Hz and inertial motion and environmental sensors at approximately 36 Hz (250/7 = 35.7142857 Hz). We down-sampled inertial motion data to 25 Hz using the 'resample' function in MATLAB to obtain an integer sampling frequency. Binary data were stored on a 200 GB microSD card in the Neurologger3, processed using a custom MATLAB script (Neurologger Converter & Visualizer © Evolocus LLC), and then converted into .MAT (MATLAB file) and .EDF (European Data Format) formats.
ECG artifacts were sometimes present in EEG channels when animals entered the water, complicating visual and quantitative scoring methods. To minimize ECG artifacts and enable visual and quantitative EEG scoring, we applied the "runica" Independent Component Analysis function in the open-source EEGLAB v2020.0 toolbox in MATLAB. Independent Component Analysis (ICA) is now standard practice in EEG signal processing and refers to a collection of unsupervised learning algorithms that decompose multivariate signals into maximally independent components (ICs) [48]. We trained the ICA algorithm with a subset of electrophysiological data collected from animals while stationary underwater. This training data (training data durations: median-12 min; minimum-5.5 min; maximum-20.2 min) was selected as a representative section where movement artifacts were minimal, and SWS, REM, and heart rate artifacts were present. We visualized ICA weights for manual review. If the heart rate decomposed separately from EEG signals into at most 2 or 3 ICs, these ICA weights were selected and applied across the entire recording for that animal.
We compared spectral density profiles and the ability to discriminate between SWS and REM across (A) the raw signal, (B) the independent component (IC) that maximally expresses brain activity, and (C) the raw signals pruned with ICs that minimally express brain activity (e.g., heart signals or electrical noise). We determined the maximal brain IC visually by selecting the IC that (1) allowed visual and quantitative discrimination between SWS and REM and (2) was generated by one of four EEG electrode locations in 2D topographic maps. We always kept the intact ECG channel (without ECG IC(s) removed) and the IC that maximally expressed heart activity for heart rate analysis. We determined the maximal heart IC by locating the highest amplitude ECG signal generated by the posterior location in 2D topographic maps. Because the ECG waveform was often separated into two or more ICs, the ECG channel often yielded the cleanest heart rate signal.
Inertial motion sensor data were calibrated and processed using the Customized Animal Tracking Systems (CATS) toolbox in MATLAB to measure overall dynamic body acceleration, pitch, roll, and heading [49]. We applied rotation matrices and spherical calibrations for each animal to transform the tag's reference frame to that of the animal and account for differences in attachment orientation.
We combined raw electrophysiological data (500 Hz), electrophysiological data pruned with ICA, ICs (which maximally expressed brain and heart activity), and processed motion and environmental sensor data (25 Hz) into a single EDF file using the writeeeg function in EEGLAB. We then inspected the resulting file in Lab-Chart (©ADInstruments). Instantaneous heart rate was calculated using the cyclic measurement peak detection algorithm in LabChart ® , with ECG peak detection parameters consistent with those used for large mammals, exceeding a minimum of 2 standard deviations with a QRS width of 60 ms across normalized 4-s windows.

Qualitative signal analysis
To prepare the raw data for visual sleep scoring, we bandpass filtered electrophysiological signals according to the standard outlined in the American Academy of Sleep Medicine sleep scoring manual [50]: EEG/EOG: 0.3-30 Hz; EMG: 10-100 Hz; ECG: 0.3-75 Hz. We visualized signals using standard temporal and voltage scales (100 µV for EEG/EOG, 40 µV for EMG, 2 mV for ECG, [− 1.5,1.5] G-forces (g) for accelerometer data). Spectrograms were visualized for two (L & R) of the best EEG channels and the maximal brain IC using fast Fourier transform (FFT) using a Hann (cosine-bell) window with a sample size of 1024 points and 50% overlap, examining spectral power from ~ 20-40 dB for frequencies between 0 and 15 Hz.
Guidelines for visual sleep scoring were based on those set for other marine mammals [21,43,45]. We scored sleep according to the following sleep states in 30-s epochs: Active Waking (AW), Quiet Waking (QW), Drowsiness (DW), Slow-Wave Sleep (SWS), Rapid-eye Movement Sleep (REM) (Fig. 4). Sleep scoring criteria is as follows, with additional scoring criteria and interscorer reliability in Kendall-Bar et al. (thesis in prep): (1) Quiet Waking (QW, Fig. 4D)-low-voltage, highfrequency background EEG activity (> 50% epoch duration), occasional movement or eye blink artifacts (occupying < 50% of the epoch duration), and accelerometer traces demonstrating only subtle breathing or motion (i.e., slowly rolling, grooming, or body repositioning). (2) Active Waking (AW, Fig. 4E)-gross movement artifacts in all electrophysiological channels for > 50% of the duration of the 30-s epoch, accompanied by movement in the accelerometer (more activity than behaviors described above for QW).  Fig. 4C) when low-voltage, high-frequency EEG activity coincided with an increase in heart rate variability (HRV: see HRV criteria below) for > 50% of the 30-s epoch, consistent with previous sleep studies of walruses during sleep apneas [13].
The peak-to-peak amplitude of slow waves varied slightly between recordings and recording location (land v. water). On land, SWS amplitude typically reached or exceeded 75 µV (a standard threshold for humans). Delta spectral power was > 2-fold greater during sleep than during neighboring periods of quiet waking or rapid-eye-movement sleep (except with extensive water intrusion-see Signal quality analysis). SWS occurred independently of breathing and always involved symmetrical high amplitude activity in each hemisphere, low muscle activity in the EMG channels, and no visible eye activity in the EOG channels. We subdivided SWS into two stages for quantitative analysis: SWS1 and SWS2. High-amplitude slow-wave sleep (SWS2) was scored when slow waves reached their maximal amplitude (compared to neighboring sleep cycles). In contrast, lowamplitude slow-wave sleep (SWS1) was a transitional state scored when slow waves exceeded the amplitude of EEG activity during waking by at least 1.5X and were not maximal in amplitude compared with neighboring sleep cycles.
We used very-low frequency heart rate variability (HRV) power (total power between 0 and 0.005 Hz; 8 K FFT Hann (cosine-bell) window with 50% overlap) to subdivide low-amplitude, high-frequency EEG periods following slow-wave sleep high HRV (high-certainty REM) versus low HRV (putative REM). Both high HRV and low HRV REM episodes coincided with behavioral Fig. 4 Sleep categorization methods. Sleep stages were distinguished from distinct characteristics of the EEG spectrogram, z-axis gyroscope (for breath detection), and heart rate. Spectral power varied across stages from A slow (10 s) oscillations between slow waves and waking during Drowsiness (DW); B highest amplitude low-frequency activity during SWS (exemplified by hot colors in low frequencies [0.5-4 Hz] of the spectrogram); C lowest amplitude high-frequency activity during REM (exemplified by dark colors in the spectrogram), and D low-amplitude high-frequency activity during quiet waking (QW), and E motion artifacts during active waking (AW). We differentiated between periods of REM with F low heart rate variability (HRV) and G high HRV (independent of changes in respiratory state-apnea [not breathing] and eupnea [breathing consistently]). We demonstrate HRV patterns due to G respiration, H independent of respiration, and I due to both respiration and movement artifacts (due to short-duration inaccuracies in automated peak detection). During active waking, motion artifacts could be caused by large breaths or active forward movement ('galumphing' on land or swimming in water) characteristics of REM such as closed eyes, motionlessness, occasional muscle and whisker twitches, occasional whole-body jerks, and rapid eye movements. However, we conservatively restricted the quantitative signal analysis (next section) to high HRV REM episodes.
Although surface-mounted EOG sensors reliably detected eye blinks, we only occasionally detected eye movements (more subtle than eye blinks) during REM. As such, we did not rely on EOG for scoring REM. Muscle activity (measured with EMG on the neck) during REM was sometimes lower than during SWS but usually remained unchanged if EMG activity was already low in SWS. The subtle changes in EMG may result from our reduced ability to detect fine-scale changes in muscle tone using non-invasive surface electrodes and the fact that the seals typically sleep with their head outstretched on the ground.

Quantitative signal quality analysis
Of several techniques employed to assess signal quality in lab-based experiments, many are not feasible for field experiments with wild animals. For example, our device cannot measure impedance, a measure of effective resistance of the tissues overlying the skull often involved in signal quality assessments [78]. Others, such as alphaband power due to the Berger effect [82] or theta-band power during REM, are only possible if these signals are detected from the occipital lobe or hippocampus, outside the scope of our frontoparietal EEG montage. Consequently, we examined delta spectral power (δ) during SWS divided by delta spectral power during REM (SWS δ/REM δ) to measure signal quality over time. Although sleep signal amplitude may vary across animals and age classes, changes in delta power over time can be used to determine the reliability of a novel recording technique over long, multi-day recordings [78]. As in previous studies, we applied subject-specific linear regression models and group-specific linear mixed-effects models to assess the impact of age (< 1, < 2, and < 3 years old), recording location (land v. water), and design iteration (V1, V2, and V3). The data were analyzed in JMP ® Software (Cary, NC) [51] and R [80] and visualized using ggplot2 [81].
We selected one EEG channel per animal (out of 9 channels: 4 raw EEG, 4 EEG pruned with ICA, and one maximal brain IC) with the fewest motion artifacts for quantitative signal quality analyses. Delta spectral power (0.5-4 Hz) was calculated for the best EEG channel for 30-s epochs of SWS2 and REM. Spectral power analyses were performed with a Fast Fourier Transform (FFT) using a Hann (cosine-bell) data window with 50% overlap.

Phase 1a: electrode types
We found that Genuine Grass reusable goldcup electrodes and Ten20 ™ (Weaver and Company) conductive paste produced the most reliable recordings. In addition to allowing continuous signal conduction, conductive paste helped attach electrodes during stationary recordings without adhesive. Among the dry electrode options we tested, each one introduced "popping" artifacts indicating interrupted contact with the skin (Fig. 5). When we tested soft-dry electrodes and flat dry electrodes, we found that the flexible polymer optimized for smooth, human skin did not make good contact with the rough skin of the elephant seals.
We tested a few goldcup electrode alternatives, which performed similarly, but varied greatly in their ability to resist corrosion over time (i.e., Genuine Grass electrodes outperformed Technomed). When we directly compared goldcup and needle electrodes (similar to those used in the past to record sleep in elephant seals - [27,28]), we detected auditory cortical responses of similar amplitude and time course (see Additional file 5). However, goldcup electrodes were more susceptible to electrical noise in high-noise lab environments (50-60 Hz).

Phase 1b: electrode configurations
Preliminary stationary recordings at TMMC and Long Marine Lab enabled determination of the ideal electrode configurations for detecting heart (ECG), brain (EEG), muscle (EMG), and eye (EOG) activity. Using a referential montage, we recorded the highest amplitude slow waves with electrodes placed apart > 5 cm (peakto-peak slow-wave amplitude >2-fold greater than using a differential montage; Fig. 6). However, these larger signals were subject to larger artifacts, and the loss of a single reliable reference electrode occasionally resulted in the loss of any usable signals. Based on this, a differential montage across electrodes placed no more than 5 cm apart was used for the remainder of our recordings. In addition, by placing electrodes closer together, we decreased the necessary size of the footprint. A differential montage (as opposed to a referential montage referenced to a single electrode) allowed us to continue recordings after losing single EEG signals. We found that placing a differential EOG electrode pair approximately 2 cm posterior from the outer canthus more selectively detected eye activity than if the reference electrode was placed near the ground electrodes on the forehead. We recorded peak-to-peak ECG amplitudes more than twice as large when using an asymmetrical differential montage (anterior to one fore-flipper, posterior to the other) compared to symmetrical placement anterior to the foreflippers (Fig. 6).

Raw signal quality
We recorded reliable electroencephalogram (EEG) and electrocardiogram (ECG) signals in several different settings (Fig. 7). Overall, we could extract heart rate peaks at all times, whether the animal was moving or not, and reliably detected changes in EEG activity whenever the animal was calm, on land and in water. Here, we present examples of raw signals recorded in these different settings and highlight the ability to discriminate between Signal quality comparison across several surface-mounted electrodes. This recording demonstrates brain wave attenuation during euthanasia and the superior signal quality of A genuine GRASS ® goldcup electrodes; B DATWYLER SoftPulse ™ flat dry; C dry brush electrodes; D soft-dry DRYODE ™ electrodes. Snap-on surface-mounted electrodes with conductive gel and adhesive reliably detected E muscle activity (EMG) and F heart rate (ECG) attenuation. (Note, the veterinarian-ordered euthanasia was related to congenital defects and unrelated to this study.) , and electrocardiogram (ECG) electrodes. B, C EEG traces during SWS in Seal #4 demonstrate higher peak-to-peak amplitude of slow waves using the referential montage than recorded simultaneously with a differential montage (green line) (189 µV v. 73 µV). D, E Heart signals derived from the symmetrical anterior placement of both ECG leads (Seal #14) are more than twice as large as heart signals derived from contralateral placement (dark blue line) of ECG leads (Seal #12) low-frequency (0.5-4 Hz) and high-amplitude (> 50 µV peak-to-peak amplitude) EEG signals during SWS, compared to the high-frequency and low-amplitude signals observed during REM sleep (Fig. 7). These excerpts also show high heart-rate variability characteristic of REM sleep. We include 1-min raw signal data excerpts for each setting in our open-source data repository [52].

Heart rate (ECG) raw signals
We recorded reliable heart rate signals even while the seal was actively galumphing (moving forward on land) or swimming (Fig. 7). For most recordings, we could locate heartbeats using automated peak-detection using standard settings, consistent with the "large dog" preset using ADInstruments' LabChart software (QRS width = 60 ms, normalized across a 4-s window, with a minimum detection period of 180 ms). However, when motion was vigorous, and we did not use shielding or heat-shrink to reinforce ECG wires, the peaks were not adequately recognized by automated software, although still distinguishable to the human eye ( Fig. 8;4A and B).

Brain activity (EEG) raw signals
As is typical for sleep studies, we could not record artifact-free EEG signals during vigorous motion. Indeed, when animals were sleeping while drifting at sea, occasional full-body twitches or flipper strokes would temporarily interrupt clean signal quality. However, we Fig. 7 Raw signal quality across recording locations. 10-s electroencephalogram (EEG) and electrocardiogram (ECG) data excerpts shown with uniform scaling (EEG 5× magnified compared to ECG) across plots for comparison of signal quality across active behaviors, i.e., galumphing or swimming) and distinct sleep states, i.e., slow-wave sleep (SWS) and rapid-eye-movement sleep (REM)). We show usable ECG in red (automated peak-detection possible), usable EEG in blue (no movement artifacts-visual and quantitative sleep state analysis possible with unprocessed raw signals), and unusable EEG in gray. We detected heart rate, but not sleep state, while the animal was active on land (1A) and in water (2A, 3A, and 4A). We were able to detect sleep state (difference between SWS and REM) when the animal was calm, whether that was on land (1B, C), stationary in water (2B, C), or drifting at the surface (3D, E) recorded clean signals when the animal was still or calm, grooming or repositioning. One obstacle to recording clean EEG signals was contamination by larger ECG signals that usually appeared as soon as the electrodes became wet (Fig. 8;1A, B). ECG artifacts in EEG channels were present in 6 out of 12 deployments, especially in early designs where water intrusion was significant. Even in these cases, we could visually discriminate between Fig. 8 Signal quality challenges and solutions. 10-s sequences of ECG and EEG with consistent scaling across plots (EEG 20× magnified compared to EEG). Vertical gray lines represented automated peak detection results. 1A, B EEG signals with heart rate (HR) artifacts caused by water intrusion, resolved in later iterations that minimized water intrusion (1C, D). 2A, B VHF transmitter pings obscured ECG peak detection and EEG recordings on land but not in water (2C, D). 3A, B EEG and ECG signals obscured by satellite pings. 3C, D We replaced ~ 5 s of data surrounding the ping with data before or after the ping. Manual ping removal facilitated quantitative analysis by improving automated peak detection but can locally interrupt fine-scale patterns such as irregular heartbeats (visible in 3B but not 3D). 4A, B Wires reinforced by shielding and heat-shrink tubing outperformed insulated electrode wires covered with liquid electrical tape SWS and REM sleep. Regardless, artifacts complicated visual analysis and made quantitative analysis impossible. With our final headcap and patch design, we minimized water intrusion and recorded clean EEG signals with minimal heart rate artifacts. In two recordings, the electrodes stayed dry for the duration of the experiment (verified by water-contact indicator tape and the persistence of conductive paste), despite the animal moving in and out of water for 5 days. However, even in cases where there was some water intrusion, efforts to minimize it seemed to improve signals by helping prevent the flow of saltwater over and between electrodes.

Electrical contamination
Electrical recordings amidst other telemetered and transmitting devices presented significant signal detection challenges. Using the standard programming for VHF animal tracking tags, 200 ms pulses are transmitted at 148-149 MHz every 1.7 s. Since these signals fall well beyond the sampling frequency of our device, noise from a tag such as this collapsed broadly into a mixture of low-frequency and high-frequency noise ( Fig. 8;2A, B). We recommend configuring a custom VHF transmitter to delay transmission until the end of the experiment to minimize this interference ( Fig. 8;2C, D). Similarly, satellite tag transmissions briefly interrupted signals detected by the tag, but at a lower transmission frequency (once per 92 s) ( Fig. 8;3A, B). It was possible to remove these large anomalies using methods previously applied to remove ECG artifacts from EMG data [82], similar to manual artifact-removal methods for ECG artifact removal in cetacean EEG papers [41] (Fig. 8;3C, D).

Signal processing to improve sleep detection
We maximized signal quality using ICA to isolate both contaminating signals (ECG) and signals of interest (EEG). In most cases, our raw signals were improved by the removal of heart rate artifacts via ICA, which facilitated both visual and quantitative scoring (Fig. 9).
After running ICA on a subset of our data while the animal was stationary in the water, we applied those weights to entire recordings and inspected the resulting ICs. In all cases, we were able to identify ICs that maximally expressed contaminating artifacts (e.g., IC1, IC2, and IC9 in Fig. 10B) and one IC that maximally expressed brain activity (e.g., IC5 in Fig. 10B). The maximal heart ICs were identified visually as containing recognizable ECG components (e.g., IC1 & IC2 in Fig. 10B) and confirmed in topographic maps ( Fig. 10A and C). Any identifiable contaminating electrical signals were removed Fig. 9 A Three spectrograms (90-min duration) show the progressive improvement in signal quality for visual discrimination between SWS and REM (designated in the top hypnogram) between the raw EEG signal and the pruned EEG signal contaminating ICs removed, and the IC that maximally expressed brain activity. 1-min waveforms from SWS (B) and REM (C) show progressively improved signal quality from Raw EEG (purple), Pruned EEG (blue), and the ICs that maximally expressed brain activity (green) (constant frequency; e.g., IC9 in Fig. 10B). We visually identified the IC that maximally expressed brain activity (IC5) as the one with distinct slow waves during SWS and low-voltage activity during REM. Maximal brain components were then confirmed with topographic maps relating to the four EEG electrodes (Fig. 10D).

Signal quality analysis
We examined delta (δ) spectral power differences between SWS and REM over several days to examine the effects of design iteration, age (from 0 to 1, 1 to 2, and 2 to 3 years old), and recording location (land versus water) (Figs. 11 and 12; Additional file 3).
Signal quality across locations. Overall, signal quality was lower in water than on land (Δ SWS δ/REM δ = 3.427 ± 0.5121; p < 0.0001*; Fig. 11C), but that difference varied between versions (p = 0.0026*; Fig. 12). Signal quality was significantly lower in water than on land for V1 (p = 0.0012*) and V2 (p < 0.0001*), but we were able to minimize the impact of water intrusion on signal quality by V3 (p = 0.9753) (Fig. 11C, D). Signal quality across time (by version). Some of the adjustments made between V1 and V2 to make the frontend lighter and more streamlined decreased signal stability through water intrusion and the lack of wire reinforcement or shielding. The final version recovered signal quality through improved waterproofing and wire fortification. In a mixed-effects model of signal quality over time (individual as a random effect), we found that neither V1 nor V3 resulted in signal degradation over time (V1: slope = − 1.807 ± 1.682 p = 0.3951; V3: slope = − 0.7695 ± 0.5053 p = 0.1486) (Fig. 11A). Signal quality across ages. We found no significant difference in signal quality between oldest (2-3 years old) and youngest (0-1 year old) animals when on land and Fig. 10 A, C, D Topographic maps with spherical interpolation (EEGLAB) show each IC's spatial weights based on the relative spatial orientation of sensors on the seal (EEG above cortex, EMG on neck, and ECG near pectoral flippers). Each diagram represents a single IC where red or dark blue (opposite polarity) represents strong spatial weights for each electrode location. IC1 and 2 are opposite polarity components of the heart signal from rear heart rate sensors, while EEG electrode locations above the brain generate IC5. B ICs over time, showing the ECG waveform in IC1 & 2 and slow-wave sleep in IC5 signal quality was independent of water intrusion (Δ SWS δ/REM δ = 6.6931 ± 2.812; p = 0.1646; Additional files 3 and 4). See additional files for raw and processed data and analyses (Additional files 6,7,8,9,10,11,12).

Discussion
In Phase 1 of our study, we found the electrode type and configuration that performed best in our experiments: a differential montage of Genuine Grass goldcup electrodes attached with a conductive paste. The differential montage outperformed the single reference electrode because the shorter inter-electrode distance helped to minimize noise. We then created and tested a robust, portable system in Phase 2. Our logger housing design enabled the use of up to 21 independent electrical signals (separate wires) and the detection of pressure, illumination, LED, and Bluetooth signals from the exterior of the housing. We found that small acrylic windows allowed adequate signal transmission despite the housing's aluminum wall. Ultimately, we designed a system using electrically shielded and reinforced wires combining polyurethane and silicone potting materials to minimize water intrusion, expedite patch removal, and facilitate patch renewal and reattachment.
We reliably identified SWS on land and in water. In general, signals were smaller in water than on land. We were able to record EEG signals of similar amplitude and timecourse to previous sleep studies with northern elephant seals (> 50 μV peak-to-peak amplitude during SWS and < 50 μV peak-to-peak amplitude during QW/ REM) [33]. The effects of animal age and tissue thickness were difficult to tease apart statistically due in part to our iterative design process. Despite typically smaller amplitude slow waves in water and in older animals, we were able to distinguish between SWS and REM in older animals using our final design iteration, even during rest behavior in our most challenging recording environment (drifting through seawater in the wild). This leads us to believe that careful waterproofing and attachment could allow recordings with free-ranging adult animals. Based on the initial pilot studies at the rehabilitation facility, we also expect to obtain reliable EEG signals in other pinnipeds, potentially allowing clinical seizure detection in California sea lions (Zalophus californianus). It is difficult to predict the success of surface-mounted sensors for continuous EEG recordings for animals with smooth skin and thicker blubber layers such as cetaceans. However, improvements in suction cups, sensor technology, and signal processing have allowed short-term EEG recordings, in-water auditory evoked potential recordings, and artifact removal in bottlenose dolphins [41,53]. If suction cups can adequately exclude water and minimize lateral movement, longer-term surface EEG recordings of cetacean sleep may be possible [41].
Using ICA we successfully removed heart artifacts to identify an IC that best expressed brain activity. This IC was often most reliable for sleep scoring and maintained the spectral properties of sleep states. A primary concern in signal processing is whether the methods remove essential features of the signal of interest along with contaminating artifacts. In our case, it was critical to examine the spectral features of the IC that we identified as maximally expressing brain activity to ensure that this IC was sufficient for identifying sleep stages. When we compared the power spectrum of the raw EEG, pruned EEG, and the maximal brain IC, we observed that the power density spectrum of the IC during SWS (bottom-most bold line; Fig. 13A) closely resembled the power density spectrum of raw signals during SWS in the absence of any heart rate artifacts (bottom lines in Fig. 13B). This suggests that the maximal brain IC preserves the spectral features of SWS. Likewise, the power density spectrum of the raw EEG signal in the presence of artifacts (top-most line; Fig. 13A) closely resembles the raw electrocardiogram signal (top-most line, Fig. 13B), suggesting that the contaminating signals removed via pruning with ICA are primarily generated by the heart.
We found that ICA was less useful where heart artifacts were minimal or very transient. In deployments with little to no heart rate artifact, the raw EEG signals could yield more reliable signals (in terms of SWS δ/REM δ over time) than the maximal brain IC. Due to changing Fig. 12 Effect of water submersion on signal quality. Lollipop plots showing delta spectral power of slow-wave sleep (SWS) connected to subsequent delta during REM, colored according to recording location (land in red and water in blue). Plots are aligned such that the first and last sleep cycles of each recording are aligned. Smaller lines after initial water submersion show the resulting decrease in signal quality, which is minimized in later iterations of the tag conditions in natural experiments, artifacts may be present at different intensities throughout the recording. Increased water intrusion may increase the amplitude of contaminating ECG artifact over time. In theory, ICA identifies orthogonal components that are stable over time, but this can be challenging in practice where the polarity, signal morphology, and amplitude of the contaminating signal may change depending on water intrusion amount and the animal's orientation (affecting relative sensor orientation). In these cases, it was important that we examined the maximal brain IC (relatively stable over time) in addition to pruned signals that are affected by transient artifacts. Further studies could investigate the utility of allowing ICA weights to vary over time, minimizing signal alteration when artifacts are minimal.
During vigorous stroking in water or galumphing on land, EEG signals mirrored gyroscope signals, suggesting that we may be able to apply ICA with these motion sensors to recover signal quality during motion. Differences Fig. 13 Power spectral density plots pre-and post-ICA. A Power spectral density plot for 1 min of slow-wave sleep (SWS) and 1 min of rapid-eye-movement sleep (REM) (see Fig. 11 for raw waveforms) with significant heart rate artifacts in the electroencephalogram (EEG). The plot compares spectral power over frequency for raw EEG (violet), EEG pruned with ICA (blue), and the IC that maximally expressed brain activity (green) for both SWS (bold upper line) and REM (thin lower line). This demonstrates the greater discriminatory power between SWS and REM in the delta frequency range in EEG signals processed with ICA (shaded areas). B Power spectral density (PSD) plot for 1 min of SWS where there was no significant heart rate artifact in the EEG, demonstrating the spectral features of the raw electrocardiogram (ECG) signal, apparent in the raw EEG signal in 13A. In addition, left and right raw EEG signals show that the spectral features of SWS are primarily preserved in the maximal brain IC, shown in 13A. Note the different horizontal and vertical scales of A and B in sampling frequencies could be adjusted for (motion sensors upsampled and smoothed) and used as additional channel inputs for ICA to identify and isolate an orthogonal movement component. Further studies can build on our use of ICA to maximize and recover signal quality in the wild environment.
We reliably recorded heart rate on land and in water during motion and at rest in the seals; the highest quality signals were obtained with shielded wires that were reinforced with heat-shrink tubing. Although we could detect larger-scale eye blink detections in the electrooculogram (EOG), we could not reliably detect smaller amplitude eye deflections during REM sleep that are readily picked up from electrodes implanted into the eye orbit [42]. Similarly, our surface-mounted electromyography (EMG) electrodes only occasionally demonstrated a difference in muscle tone between SWS and REM sleep, suggesting a lower sensitivity than previous studies using invasive EMG to distinguish REM sleep in elephant seals [27,28]. As in previous sleep apnea studies in walruses [13], we could reliably identify REM using low-frequency heart rate variability.
There were additional considerations when pairing the sleep-recording device with typical animal tracking tags. The typical transmission frequency for a VHF animal tracking tag is less than 2 s, not long enough for the electrophysiological signals to return to baseline after an interruption of high-frequency noise collapsed into the 500 Hz recording frequency of the logger. Our custom VHF tag was programmed to remain off for 5 days after being activated, and then would ping at a frequency of only once per minute, allowing us to record reliable electrophysiological signals between each ping. In addition, because we needed to place the sleep-recording device on the top of the head, the Argos transmitter was placed further back on the body, where it seldom exited the water to provide location coordinates. Future research can focus on creating a smaller, integrated, potted unit mounted on the head to maximize high quality location data.
Future studies can reduce the size and impact of the datalogger housing by potting the device in epoxy. Our design prioritized SD-card recovery and datalogger adjustment at this early prototyping stage. Creating a smaller, streamlined version of this device that focuses on recording only EEG and heart rate, both necessary for discrimination between SWS and REM based on our results may be one solution. This refinement would reduce the headcap's footprint by prioritizing EEG over less critical EOG sensors. For sleep studies of bilaterally sleeping phocids, a single reliable EEG and ECG pair (and additional ground electrode) could be adequate for sleep characterization. However, we recommend recording at least four independent channels to increase the likelihood of continuous sleep state characterization. In addition, the number of independent components available for signal processing is proportional to the number of channels. A higher number of channels facilitates isolating contaminating artifacts from signals of interest. For unihemispheric sleeping cetaceans, sirenians, and fur seals [59][60][61][62][63][64][65], additional EEG channels are required to characterize independent changes in each hemisphere.
Due to the large size, expense, and limited availability of underwater connectors with more than 21 pins, we were limited to recording 10 differential electrophysiological signals. We chose to record 9 signals (4 EEG, 2 EMG, 2 EOG, 1 ECG) with 3 redundant ground electrodes (to take advantage of all available connector pins). If a differential montage or underwater connector is not required, it would be possible to record up to 32 independent signals using the same Neurologger3 to improve spatial resolution. While this number is still far below the quantity recommended for source estimation in humans (minimum of 128 channels recommended) [54], higher density arrays (even < 32 channels) could provide helpful information in the assessment of auditory evoked potentials in free-moving cetaceans or epilepsy in California sea lions [41,55].
Our study builds on advances in animal biotelemetry and technological miniaturization to allow the first recordings of marine mammal sleep in the wild. EEG recordings are necessary to distinguish between SWS, and REM sleep, each of which provides distinct restorative functions to the brain and body. Our EEG device enabled sleep state categorization for wild northern elephant seals across their sleeping habitats. Future studies can use these methods to examine sleep patterns across individuals, ontogeny, and habitats to establish activity budgets and total sleep time for a large, highly mobile mesopredator. Total sleep time can be used to investigate the ties between sleep, ecology, cognition, and body size, furthering our understanding of wild animal resting behavior and the function and evolution of mammalian sleep [56,57].
The development of this new instrumentation is particularly timely due to changing patterns in the phenology of sleep and stress from increasing anthropogenic stressors [79]. Ecophysiological studies of sleep and heart rate shed light on the evolution and physiological underpinnings of natural behavior and the effect of anthropogenic disturbance on wildlife [2,7,8,11,12]. By further developing these methods, we can more accurately assess the natural physiology and behavior of wild animals and quantify its disruption in response to human activities.

Conclusions
Our study provided a new, non-invasive electrophysiological method to record sleep in wild marine mammals. We built a custom headcap that minimized water intrusion to allow successful EEG discrimination between SWS and REM sleep with captive and wild animals, on land and in water, stationary and drifting through seawater. Over subsequent design iterations, we were able to minimize water intrusion and the resulting signal quality loss (δ power SWS/δ power REM), such that the majority of sleep cycles remained above a quantitative threshold (SWS twofold higher than REM) throughout multi-day recordings. ECG signals provided reliable heart rate measurements whether animals were moving or calm and captured largescale low-frequency heart rate variability that distinguished REM from quiet waking. We describe signal quality challenges and solutions, including ICA, to facilitate visual and quantitative sleep scoring. Our study builds on technological advances and provides detailed recommendations to guide scientists in creating new tools to investigate sleep and heart rate in wild animals.