From 9e0fb69faab7f79e34053aa8ea10d58042a245cf Mon Sep 17 00:00:00 2001 From: "K.Filippopolitis" <56073635+KFilippopolitis@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:24:28 +0200 Subject: [PATCH 001/223] Fix/experiment studio empty datasets and cv metrics (#2) * docs: remove jupyter references from README * feat: Replace the generic distribution graph with a dedicated histogram component, update CSV and PDF export services, and add warnings for empty datasets in the statistic analysis panel. * feat: Implement tabbed filtering for 'My Experiments' and 'Shared' experiments and exclude 'all datasets' for numerical variables in statistic analysis. * feat: Display a message prompting variable selection when group histogram data is present but no variable is chosen. * feat(experiment-studio): share and reposition data exclusion warnings Lift data-exclusion warnings into shared ExperimentStudioService state so they can be shown across the studio flow. Render the warning inline between Descriptive Statistics and Algorithm sections with a softer style, and keep dismiss support. Update warning copy to state exclusions apply to descriptive statistics and any experiment execution, and adjust descriptive-panel spec mocks. * fix(experiment-studio): improve empty dataset handling and CV error metrics - Updated Linear Regression CV renderer to correctly parse error metric arrays [mean, std]. - Added `excludedDatasetsSignal` to ExperimentStudioService to ensure datasets excluded due to empty variables are omitted from algorithm execution requests. - Refined Data Exclusion Warning message to better explain Federated Learning complete-cases requirements, clarifying that records with missing values are dropped during preprocessing. - Modified the Descriptive Statistics panel to still show excluded datasets in the Variables/Model tables while displaying the exclusion warnings. - Added a clarifying note to the Model tab's descriptive text explaining N/A value exclusion. * feat(ui): optimize experiment studio layout for responsive scaling - Set explicit 55/45 grid split for the variables panel and histogram to ensure stable scaling across viewport sizes. - Re-anchored the sidebar to a fixed 16px left position to prevent inward drifting and overlap over main content on ultra-wide screens. - Updated the sidebar collapse breakpoint from 1440px to 1650px. - Reduced global page padding to 16px to maximize horizontal canvas space. - Added dynamic `.studio-main.sidebar-collapsed` padding adjustments so the main workspace aggressively reclaims horizontal space when the sidebar shrinks, instead of leaving empty padding. - Added `min-width: 0` constraints to grid children to prevent responsive blowouts. * feat: Introduce regression line charts for single-predictor linear and logistic models, update chart registry, and improve algorithm input type display. --- AGENTS.md | 2 +- README.md | 21 +-- src/app/models/algorithm-results.model.ts | 4 +- .../models/algorithm-visualization-guide.md | 7 +- .../algorithm-panel.component.ts | 36 ++++- .../experiment-studio.component.css | 104 ++++++++++++- .../experiment-studio.component.html | 23 ++- .../experiment-studio.component.ts | 8 +- .../statistic-analysis-panel.component.html | 15 +- ...statistic-analysis-panel.component.spec.ts | 6 +- .../statistic-analysis-panel.component.ts | 62 +++++++- .../histogram-graph.component.css} | 4 +- .../histogram-graph.component.html} | 4 +- .../histogram-graph.component.ts} | 8 +- .../variables-panel.component.css | 36 ++--- .../variables-panel.component.html | 43 +++--- .../variables-panel.component.ts | 51 ++++--- .../auto-renderer/algorithm-table-registry.ts | 17 ++- .../visualisations/charts/chart-registry.ts | 14 +- .../charts/renderers/regression-line-chart.ts | 138 ++++++++++++++++++ .../experiment-list.component.css | 66 +++++---- .../experiment-list.component.html | 24 +-- .../experiment-list.component.ts | 5 +- .../pages/shared/footer/footer.component.ts | 6 +- .../services/algorithm-rules.service.spec.ts | 2 + src/app/services/algorithm-rules.service.ts | 26 +++- src/app/services/csv-export.service.ts | 2 +- src/app/services/experiment-studio.service.ts | 29 +++- .../services/experiments-dashboard.service.ts | 1 + src/app/services/pdf-export.service.ts | 6 +- 30 files changed, 589 insertions(+), 181 deletions(-) rename src/app/pages/experiment-studio/variables-panel/{distribution-graph/distribution-graph.component.css => histogram-graph/histogram-graph.component.css} (87%) rename src/app/pages/experiment-studio/variables-panel/{distribution-graph/distribution-graph.component.html => histogram-graph/histogram-graph.component.html} (56%) rename src/app/pages/experiment-studio/variables-panel/{distribution-graph/distribution-graph.component.ts => histogram-graph/histogram-graph.component.ts} (62%) create mode 100644 src/app/pages/experiment-studio/visualisations/charts/renderers/regression-line-chart.ts diff --git a/AGENTS.md b/AGENTS.md index f4843b929..8b571d671 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -78,7 +78,7 @@ Use this as a fast orientation to the codebase. - `models/`: frontend/backend DTOs and interfaces (user, algorithms, experiments, filters, data-models). - `core/`: algorithm mapping and constants. - `pages/experiment-studio/`: - - `variables-panel/`: model/dataset selection, search, variable actions, filters UI, distribution graph. + - `variables-panel/`: model/dataset selection, search, variable actions, filters UI, histogram - `algorithm-panel/`: algorithm selection/configuration, run/save-as, result rendering. - `statistic-analysis-panel/`: descriptive stats/model tables/charts. - `visualisations/`: chart registry/builders, histogram, auto-renderer, bubble chart. diff --git a/README.md b/README.md index ae031569e..91bfbeada 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Medical Informatics Platform (MIP) - Platform UI -The Platform UI for the Medical Informatics Platform (MIP). An Angular 21 standalone frontend application for composing, running, and analyzing data science experiments, featuring algorithmic configurations and JupyterHub integration. It integrates with a backend over `/services` (proxied in dev) and uses Keycloak for robust OAuth2 authentication. +The Platform UI for the Medical Informatics Platform (MIP). An Angular 21 standalone frontend application for composing, running, and analyzing data science experiments, featuring algorithmic configurations. It integrates with a backend over `/services` (proxied in dev) and uses Keycloak for robust OAuth2 authentication. ## Highlights - **Experiment Studio** (`src/app/pages/experiment-studio`): select data models/datasets, pick variables and filters (QueryBuilder), configure algorithms, run jobs, view charts/tables. @@ -10,14 +10,13 @@ The Platform UI for the Medical Informatics Platform (MIP). An Angular 21 standa ## Requirements - Node 20+ and npm 10+ - Backend reachable at `http://localhost:8080/services` (adjustable in proxy/Docker env). -- JupyterHub reachable behind the frontend at `/notebook/` (note the trailing slash). - Keycloak endpoints exposed at `/services/oauth2/authorization/keycloak` and `/services/logout`. ## Quick Start (dev) 1) Install dependencies: `npm ci` 2) Start dev server with proxy: `npm start` - Serves at `http://localhost:4200/` - - Proxies `/services` to `http://localhost:8080` and `/notebook/` to your notebook server via `src/proxy.conf.json` + - Proxies `/services` to `http://localhost:8080` via `src/proxy.conf.json` 3) Ensure backend is running and you can authenticate with Keycloak. ## Scripts @@ -56,15 +55,9 @@ See `src/app/core/algorithm-result-enum-mapper.md` for detailed mapping behavior - `src/app/pages/account-page/` – basic profile view. - `src/app/pages/shared/` – header/footer/navbar/accordion/spinner utilities. - `src/styles.css` – global styles and QueryBuilder theming; assets in `src/assets/`. -- `Dockerfile` / `nginx.conf.template` – container build and runtime proxy (`PLATFORM_BACKEND_SERVER`, `PLATFORM_BACKEND_CONTEXT`, `NOTEBOOK_ENABLED`, `JUPYTER_SERVER`, `JUPYTER_CONTEXT` envs). +- `Dockerfile` / `nginx.conf.template` – container build and runtime proxy (`PLATFORM_BACKEND_SERVER`, `PLATFORM_BACKEND_CONTEXT` envs). + -## Notebook Page (`/notebook`) -- Frontend opens JupyterHub via same-origin path `/notebook` (runtime configurable in `window.__env.JUPYTER_CONTEXT_PATH`). -- Notebook auth/session is handled by JupyterHub + OIDC (no frontend token injection). -- Runtime frontend env knobs: - - `NOTEBOOK_ENABLED` (default `0`; when `0`, `/notebook` route does not match) - - `JUPYTER_CONTEXT_PATH` (default `/notebook`) - - `JUPYTER_LANDING_PATH` (default `/hub/spawn`) ## Docker Build and serve with nginx: @@ -73,13 +66,9 @@ docker build -t fl-platform . docker run \ -e PLATFORM_BACKEND_SERVER=platform-backend-service:8080 \ -e PLATFORM_BACKEND_CONTEXT=services \ - -e NOTEBOOK_ENABLED=1 \ - -e JUPYTER_SERVER=jupyterhub:8000 \ - -e JUPYTER_CONTEXT=jupyter \ - -e JUPYTER_LANDING_PATH=/hub/spawn \ -p 80:80 fl-platform ``` -Nginx always proxies `/${PLATFORM_BACKEND_CONTEXT}/` to the backend. Notebook proxying under `/${JUPYTER_CONTEXT}/` is active only when `NOTEBOOK_ENABLED=1`. +Nginx always proxies `/${PLATFORM_BACKEND_CONTEXT}/` to the backend. ## Testing - Unit: `npm test` (Karma). diff --git a/src/app/models/algorithm-results.model.ts b/src/app/models/algorithm-results.model.ts index 16590b6b5..1bee2fc30 100644 --- a/src/app/models/algorithm-results.model.ts +++ b/src/app/models/algorithm-results.model.ts @@ -132,10 +132,10 @@ export interface LinearRegressionCVResult { f_stat: BasicStats; } -export interface BasicStats { +export type BasicStats = { mean: number; std: number; -} +} | number[]; export interface SVMResult { title: string; diff --git a/src/app/models/algorithm-visualization-guide.md b/src/app/models/algorithm-visualization-guide.md index 9561e2e7b..3c0fc5c3e 100644 --- a/src/app/models/algorithm-visualization-guide.md +++ b/src/app/models/algorithm-visualization-guide.md @@ -13,7 +13,6 @@ This document describes what the frontend currently renders for each algorithm a ### ANOVA One-Way (`anova_oneway`) - Charts: - - ANOVA Sum of Squares bar chart. - Mean plot with confidence intervals. - Tables: - ANOVA summary table. @@ -22,7 +21,7 @@ This document describes what the frontend currently renders for each algorithm a ### ANOVA Two-Way (`anova_twoway`) - Charts: - - Sum of Squares bar chart across terms. + - None (table only). - Tables: - Two-way ANOVA table (term, sum sq, df, F, p-value). @@ -39,7 +38,7 @@ Notes: ### Linear Regression (`linear_regression`) - Charts: - - Forest plot for coefficients with 95% CI. + - Regression line chart (single-predictor models only). - Tables: - Coefficients table. - Model summary table (R², adjusted R², AIC/BIC, etc.). @@ -56,7 +55,7 @@ Notes: ### Logistic Regression (`logistic_regression`) - Charts: - - Forest plot for coefficients with 95% CI. + - Logistic regression curve (single-predictor models only). - Tables: - Coefficients table. - Model summary table. diff --git a/src/app/pages/experiment-studio/algorithm-panel/algorithm-panel.component.ts b/src/app/pages/experiment-studio/algorithm-panel/algorithm-panel.component.ts index 22ede16c9..02b714c8e 100644 --- a/src/app/pages/experiment-studio/algorithm-panel/algorithm-panel.component.ts +++ b/src/app/pages/experiment-studio/algorithm-panel/algorithm-panel.component.ts @@ -12,6 +12,7 @@ import { ResultsPdfExportService } from '../../../services/export-results-pdf.se import { ErrorService } from '../../../services/error.service'; import { AuthService } from '../../../services/auth.service'; import { SpinnerComponent } from '../../shared/spinner/spinner.component'; +import { VariableTypes } from '../../../core/constants/algorithm.constants'; @Component({ @@ -828,6 +829,35 @@ export class AlgorithmPanelComponent { return null; } + private normalizeRequirementDisplayType(type: unknown): string | null { + const normalized = String(type ?? '').trim().toLowerCase(); + if (!normalized) return null; + + switch (normalized) { + case VariableTypes.TEXT: + case 'polynominal': + case 'ordinal': + return VariableTypes.NOMINAL; + case VariableTypes.INTEGER: + return VariableTypes.INT; + default: + return normalized; + } + } + + private formatRequirementTypes(types: unknown): string[] | null { + if (!Array.isArray(types) || types.length === 0) { + return null; + } + + const normalized = types + .map((type) => this.normalizeRequirementDisplayType(type)) + .filter((type): type is string => !!type); + + const unique = Array.from(new Set(normalized)); + return unique.length ? unique : null; + } + getRoleRequirement(field: any, label: string): string | null { if (!field) return null; @@ -841,13 +871,11 @@ export class AlgorithmPanelComponent { count = '1+'; } - const types = Array.isArray(field.types) && field.types.length - ? field.types.join(',') - : null; + const types = this.formatRequirementTypes(field.types); const parts = [`${label}: ${count}`]; if (types) { - parts.push(`types: ${types}`); + parts.push(`types: ${types.join(',')}`); } return parts.join(' • '); diff --git a/src/app/pages/experiment-studio/experiment-studio.component.css b/src/app/pages/experiment-studio/experiment-studio.component.css index 6dfe74ff1..65311a7f6 100644 --- a/src/app/pages/experiment-studio/experiment-studio.component.css +++ b/src/app/pages/experiment-studio/experiment-studio.component.css @@ -5,7 +5,7 @@ /* Page wrapper */ .experiment-studio-page { - padding: 32px; + padding: 32px 16px; position: relative; background: radial-gradient(circle at 50% 0%, #f8fafc 0%, #f1f5f9 100%); /* Organic Tech Slate */ @@ -41,7 +41,7 @@ .studio-sidenav { position: fixed; top: 80px; - left: max(16px, calc(50% - 700px - 240px)); + left: 16px; width: 210px; height: fit-content; display: flex; @@ -60,11 +60,44 @@ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); } +/* Base Collapsed Styles (Shared between auto-collapse and manual toggle) */ +.studio-sidenav.is-collapsed { + width: 72px !important; + left: 16px !important; + padding: 16px 0 !important; + gap: 20px !important; + align-items: center !important; +} + +.studio-sidenav.is-collapsed .studio-rail-context-title, +.studio-sidenav.is-collapsed .studio-rail-section-title, +.studio-sidenav.is-collapsed .studio-rail-label, +.studio-sidenav.is-collapsed .studio-rail-context-text, +.studio-sidenav.is-collapsed .studio-rail-item::after { + display: none !important; +} + +.studio-sidenav.is-collapsed .studio-rail-context-link, +.studio-sidenav.is-collapsed .studio-rail-item { + justify-content: center !important; + padding: 12px !important; + width: 44px; + height: 44px; + border-radius: 12px; + margin: 0 auto; + transform: none !important; +} + +.studio-sidenav.is-collapsed .studio-rail-icon { + font-size: 1.1rem !important; + margin: 0 !important; +} + /* Tier 2: Medium Screens (Laptops) - Fixed Icon Rail */ -@media (min-width: 1201px) and (max-width: 1440px) { +@media (min-width: 1201px) and (max-width: 1650px) { .studio-sidenav { width: 72px !important; - left: max(16px, calc(50% - 700px - 100px)) !important; + left: 16px !important; padding: 16px 0 !important; gap: 20px !important; align-items: center !important; @@ -328,6 +361,18 @@ box-shadow: 0 8px 18px rgba(127, 29, 29, 0.12); } +.section-warning-banner { + display: flex; + justify-content: space-between; + align-items: flex-start; + gap: 10px; + background: #fffdf6; + border: 1px solid #f1e3b1; + color: #68510f; + border-radius: 12px; + padding: 12px 14px; +} + .global-error-banner .banner-content { display: flex; align-items: center; @@ -335,6 +380,36 @@ font-weight: 600; } +.section-warning-banner .banner-content { + display: flex; + align-items: flex-start; + gap: 8px; +} + +.section-warning-banner .fa-exclamation-triangle { + margin-top: 2px; + color: #ad7d00; +} + +.warning-content { + display: flex; + flex-direction: column; + gap: 6px; +} + +.warning-title { + font-weight: 700; +} + +.warning-content ul { + margin: 0; + padding-left: 18px; +} + +.warning-content li { + margin: 2px 0; +} + .banner-close { border: none; background: transparent; @@ -353,6 +428,11 @@ outline: none; } +.section-warning-banner .banner-close:hover, +.section-warning-banner .banner-close:focus-visible { + background: rgba(107, 78, 0, 0.08); +} + /* Header */ .studio-float-back { position: sticky; @@ -399,13 +479,17 @@ gap: 24px; width: 100%; margin: 0; - padding-left: 220px; + padding-left: 240px; /* Synchronized sidebar offset */ transition: all 0.25s ease; min-width: 0; /* Critical for grid item scaling */ } +.studio-main.sidebar-collapsed { + padding-left: 88px; +} + /* Section wrapper around panels */ .studio-section { max-width: 100%; @@ -466,6 +550,10 @@ /* MIP Blue */ } +.studio-section--warning { + margin-top: -6px; +} + /* Global full-page overlay loader */ .global-overlay-loader { position: fixed; @@ -525,6 +613,10 @@ border-radius: 0px; padding: 6px 4px; } + + .studio-section--warning { + margin-top: 0; + } } /* STUDIO CONTEXT RIBBON */ @@ -740,4 +832,4 @@ color: #94a3b8; box-shadow: none; cursor: not-allowed; -} +} \ No newline at end of file diff --git a/src/app/pages/experiment-studio/experiment-studio.component.html b/src/app/pages/experiment-studio/experiment-studio.component.html index 6603b5875..036df4b87 100644 --- a/src/app/pages/experiment-studio/experiment-studio.component.html +++ b/src/app/pages/experiment-studio/experiment-studio.component.html @@ -11,8 +11,6 @@ } - -