# Bio-Impedance Amplifier | Bio-Z App | Executables
This repository contains compiled Rust-based software for communicating with a custom-built bio-impedance amplifier.

## Features
- Single-frequency (user selectable) and frequency-sweep measurements (predefined frequency lists)
- Real-time visualization of magnitude and phase
- Support for both 2-lead and 4-lead measurements
- Supports hardware with or without an electrode multiplexer
- Dynamic software-controlled electrode selection when using a multiplexer
- Up to 24 pins available with multiplexer support
- Data logging to `.csv` files
- Day and night display modes
- Control via on-screen buttons or keyboard shortcuts (see corresponding tab)
- Adding custom markers at specific timepoints

### Frequency-sweep measurement | Frequency lists
Selectable in Sweep-tab in GUI.
- Partial: `10k,16k,25k,40k,63k,100k,160k,200kHz`;
- Full: `100,160,250,400,630,1k,1.6k,2.5k,4k,6.3k,10k,16k,25k,40k,63k,100k,160k,200kHz`;
- KTO: `100,160,250,400,630,1k,1.6k,2.5k,4k,5k,10k,16k,25k,40k,50k,100k,160k,200kHz`.

## Installation
This software supports Windows and macOS; Linux distributions are available on request.

### Windows (.exe)

1. Run `Bio-Z App Windows.exe`.

### macOS

Additional steps are required on macOS. Otherwise, you may see a message such as
*"This app can’t be opened because it is from an unidentified developer."*
You can choose one of the following options:

#### Option 1: Use the native binary (no extension)

1. Open `Bio-Z App macOS 1`.
2. A warning will appear stating that `Bio-Z App macOS 1` cannot be opened.
3. Go to **System Settings** → **Privacy & Security**.
4. Scroll down and click **Open Anyway** under **Security**.
5. Follow the onscreen instructions.

#### Option 2: Use the application bundle (.app)

1. Open **Terminal** and navigate to this folder using `cd`.
2. Run the following command to remove the quarantine attribute:

   ```bash
   sudo xattr -cr Bio-Z\ App\ macOS\ 2.app
   ```
3. Open `Bio-Z App macOS 2`.

## `.csv` output format
### File Naming
- Output filenames are automatically adjusted.
- Files end with either:
  - `_single.csv` for single measurements
  - `_sweep.csv` for sweep measurements
- Single and sweep data are **never combined** in one output file.
- If a `.csv` file already exists, a new file is created with `_1`, `_2`, etc. appended to the filename.

### Marker Functionality
- A new feature **Add marker** is available during a measurement.
- Activating **Add marker** opens a popup:
  - Can be triggered via button or shortcut key **A**
- Entered text is saved as a **marker** in the CSV output.
- Markers can later be detected and used in data analysis.

### Time Reference
- Time values are expressed in **milliseconds (ms)**.
- Time starts from the moment the hardware is powered on or connected via USB.

### Selected lead mode and lead configuration (E0...E23)
- When logging is enabled and the **Start** button was pressed, the selected lead mode and lead configuration (see structure below) are recorded whenever a measurement is started.
- This information can be used to identify which measurement configuration was active when the **Start** button was pressed.
- When hardware without a multiplexer is used: `No_multiplexer` is logged
- When hardware with a multiplexer is used:
  - `"2(E1,23)"` indicates a 2-lead with drive/sense+ at E1 and and drive/sense- at E23
  - `"4(E1,E23,E10,E12)"` indicates a 4-lead measurement with I+ at E1, I- at E23, V+ at E10 and V- at E12

### CSV Column Structure
#### Single Measurement (`*_single.csv`)
Column number | Parameter | Description |
---|------|-------------|
1| Time (ms) | Time since hardware power-on |
2| Frequency | Measured frequency |
3| Magnitude | Signal magnitude |
4| Phase | Signal phase |
5| Marker | User-defined marker text |
6| Lead | Lead mode/config 

#### Sweep Measurement (`*_sweep.csv`)
Column number | Parameter | Description |
---|------|-------------|
1| Time (ms) | Time since hardware power-on |
2| Frequency | Measured frequency |
3| Magnitude | Signal magnitude |
4| Phase | Signal phase |
5| Index / Measurement number | Sweep index |
6| Marker | User-defined marker text |
6| Lead | Lead mode/config 


