TEA indicators, EEG section in governance

This commit is contained in:
Roberto Treviño
2026-11-26 07:06:52 -06:00
parent 53a6393cb2
commit 471ed3a18c
23 changed files with 614 additions and 20 deletions
+35 -7
View File
@@ -9,6 +9,7 @@ import { RouterLink } from '@angular/router';
import { Api } from '../api/api';
import { ApiConfiguration } from '../api/api-configuration';
import { addClinicalValidation } from '../api/fn/models/add-clinical-validation';
import { analyze } from '../api/fn/models/analyze';
import { models } from '../api/fn/models/models';
import { promote } from '../api/fn/models/promote';
import { readReport$Json } from '../api/fn/models/read-report-json';
@@ -16,6 +17,8 @@ import { score } from '../api/fn/models/score';
import { train } from '../api/fn/models/train';
import { versions } from '../api/fn/models/versions';
import { domains } from '../api/fn/operations/domains';
import { studies } from '../api/fn/eeg/studies';
import { study } from '../api/fn/eeg/study';
import { runStatus } from '../api/fn/runs/run-status';
import type { Domain } from '../api/models/domain';
import type { Version } from '../api/models/version';
@@ -78,6 +81,23 @@ export class Gobernanza {
const found = this.report.value();
return found ? interpretabilityFigures(found as Record<string, unknown>) : [];
});
/** TEA: its EEGs and their analysis. */
protected readonly eegs = resource({
params: () => (this.domain() === 'tea' ? this.refreshed() + 1 : undefined),
loader: () => this.api.invoke(studies),
});
protected readonly eeg = signal<string | undefined>(undefined);
protected readonly eegMetrics = resource({
params: () => this.eeg(),
loader: ({ params }) => this.api.invoke(study, { eeg_id: params }),
});
protected readonly metricNames: Record<string, string> = {
posterior_rhythm: 'Ritmo posterior (Hz)',
spindles_n2: 'Husos de sueño N2 (por min)',
spindles_n3: 'Husos de sueño N3 (por min)',
paroxysmal_spikes: 'Picos paroxísticos (por min)',
anteroposterior_gradient: 'Gradiente anteroposterior',
};
protected readonly asOf = signal('');
protected readonly run = signal<{ kind: string; status: string } | undefined>(undefined);
protected readonly message = signal('');
@@ -115,13 +135,12 @@ export class Gobernanza {
}
}
protected async start(kind: 'train' | 'score'): Promise<void> {
const domain = this.domain() as Domain;
const { run_id } =
kind === 'train'
? await this.api.invoke(train, { domain, body: this.asOf() ? { as_of: this.asOf() } : {} })
: await this.api.invoke(score, { domain });
const label = kind === 'train' ? 'Entrenamiento' : 'Cálculo de riesgos';
protected async analyzeEegs(): Promise<void> {
const { run_id } = await this.api.invoke(analyze, { domain: this.domain() as Domain });
await this.follow(run_id, 'Análisis de EEG');
}
private async follow(run_id: string, label: string): Promise<void> {
for (;;) {
const status = (await this.api.invoke(runStatus, { run_id }))['status'] as string;
this.run.set({ kind: label, status });
@@ -130,4 +149,13 @@ export class Gobernanza {
}
this.refreshed.update((n) => n + 1);
}
protected async start(kind: 'train' | 'score'): Promise<void> {
const domain = this.domain() as Domain;
const { run_id } =
kind === 'train'
? await this.api.invoke(train, { domain, body: this.asOf() ? { as_of: this.asOf() } : {} })
: await this.api.invoke(score, { domain });
await this.follow(run_id, kind === 'train' ? 'Entrenamiento' : 'Cálculo de riesgos');
}
}