Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"crates/elf-mcp",
"crates/elf-run",
"crates/elf-keys",
"crates/elf-tui",
]
resolver = "2"

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ The exported JSON now bundles the run manifest/filter metadata (if you loaded a

---

## TUI dashboard

```bash
cargo run -p elf-tui
```

`elf-tui` mirrors the GUI tabs in a terminal-only flow powered by `ratatui`. Use the left/right arrows (or `1`–`3`) to pick tabs, `Tab` to edit fields, and `Enter` to run the ECG → HRV pipeline or load a run bundle for manifest/event summaries.

---

## Validation & testing

- `cargo test` covers `elf-lib` metrics, CLI regression suites (`pipeline.rs`, `pupil.rs`, etc.), and the dataset validator.
Expand Down
31 changes: 29 additions & 2 deletions crates/elf-run/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,25 @@ fn manifest_records_jitter() {
assert_eq!(bundle.manifest.isi_jitter_ms, Some(100.0));
}

#[derive(Serialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct EventRow {
pub onset: f64,
pub duration: f64,
pub trial: usize,
pub block: usize,
pub event_type: String,
pub stim_id: String,
#[serde(default)]
pub condition: String,
#[serde(default)]
pub resp_key: Option<String>,
#[serde(default)]
pub resp_rt: Option<f64>,
#[serde(default)]
pub value: Option<String>,
}

#[derive(Serialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RunManifest {
pub sub: String,
pub ses: String,
Expand Down Expand Up @@ -402,6 +406,29 @@ pub fn write_manifest(path: &Path, manifest: &RunManifest) -> Result<()> {
Ok(())
}

pub fn read_manifest(path: &Path) -> Result<RunManifest> {
let file =
fs::File::open(path).with_context(|| format!("opening manifest {}", path.display()))?;
let manifest = serde_json::from_reader::<_, RunManifest>(file)
.with_context(|| format!("parsing manifest {}", path.display()))?;
Ok(manifest)
}

pub fn read_events_tsv(path: &Path) -> Result<Vec<EventRow>> {
let mut reader = ReaderBuilder::new()
.delimiter(b'\t')
.trim(Trim::All)
.has_headers(true)
.from_path(path)
.with_context(|| format!("opening events {}", path.display()))?;
let mut events = Vec::new();
for row in reader.deserialize::<EventRow>() {
let parsed = row.with_context(|| format!("parsing events in {}", path.display()))?;
events.push(parsed);
}
Ok(events)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
16 changes: 16 additions & 0 deletions crates/elf-tui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "elf-tui"
version = "0.1.0"
edition = "2021"
authors = ["ELF Contributors"]
license = "MIT OR Apache-2.0"

[dependencies]
anyhow = { workspace = true }
crossterm = "0.27"
ratatui = "0.26"
elf-lib = { path = "../elf-lib" }
elf-run = { path = "../elf-run" }
csv = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Loading
Loading