TEA indicators, EEG section in governance
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
</mat-form-field>
|
||||
<button mat-flat-button type="button" (click)="start('train')">Entrenar</button>
|
||||
<button mat-stroked-button type="button" (click)="start('score')">Calcular riesgos</button>
|
||||
@if (domain() === 'tea') {
|
||||
<button mat-stroked-button type="button" (click)="analyzeEegs()">Analizar EEG</button>
|
||||
}
|
||||
@if (run(); as r) {
|
||||
<span class="muted" role="status">{{ r.kind }}: {{ r.status }}</span>
|
||||
}
|
||||
@@ -113,4 +116,64 @@
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (domain() === 'tea') {
|
||||
<div class="card model">
|
||||
<h2>Electroencefalogramas</h2>
|
||||
<table class="plain eegs">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fecha</th>
|
||||
<th>Registro</th>
|
||||
<th>Análisis</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (e of eegs.value() ?? []; track e.id) {
|
||||
<tr>
|
||||
<td>
|
||||
<button mat-button type="button" (click)="eeg.set(e.id)">{{ e.study_date }}</button>
|
||||
</td>
|
||||
<td>{{ e.lab_record_id ?? '—' }}</td>
|
||||
<td>
|
||||
{{ !e.analysed ? 'Sin analizar' : e.valid ? 'Válido' : 'No válido' }}
|
||||
{{ e.level ? '(' + e.level + ')' : '' }}
|
||||
</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="3" class="muted">Sin EEG cargados.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (eegMetrics.value(); as m) {
|
||||
<h3>EEG {{ m.id }} · {{ m.age_months ?? '—' }} meses</h3>
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Métrica</th>
|
||||
<th>Valor</th>
|
||||
<th>z</th>
|
||||
<th>Curva</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (x of m.metrics; track x.code) {
|
||||
<tr>
|
||||
<td>{{ metricNames[x.code] ?? x.code }}</td>
|
||||
<td class="num">{{ x.value | number: '1.2-2' }}</td>
|
||||
<td class="num">{{ x.z === null ? '—' : (x.z | number: '1.2-2') }}</td>
|
||||
<td>{{ x.model ?? 'sin curva en producción' }}</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="4" class="muted">Sin métricas (EEG no válido).</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user