Skip to content

ADD: let AREG read a cohort kept as one folder per patient, chosen beside the per-type layout - #89

Merged
Jules-GP merged 2 commits into
DCBIA-OrthoLab:mainfrom
Jules-GP:feat/areg-per-patient-input
Oct 27, 2026
Merged

Jules-GP merged 2 commits into
DCBIA-OrthoLab:mainfrom
Jules-GP:feat/areg-per-patient-input

Conversation

@Jules-GP

Copy link
Copy Markdown
Collaborator

Why

The three AREG engines read their two inputs as two folders, one per type: t1 and t2, or ios and cbct. Many cohorts are kept the other way round: one folder per patient holding both inputs (<patient>/T1/ and <patient>/T2/, or <patient>/IOS/ and <patient>/CBCT/). Running AREG on them meant reorganising the data by hand first.

Change

Choosing the layout

  • Each engine takes a new input_layout: "One folder per type" (the default, today's behaviour) or "One folder per patient".
  • It also takes patients, the folder of patient folders.
  • t1/t2 and ios/cbct stop being required in the signature, since a per-patient request fills neither.

Sorting the per-patient layout (sadt_areg_common.patient_folders)

  • Who a file belongs to: its patient folder, never its own name. <patient>/T1/scan.nii.gz is that patient's T1, whatever the file is called.
  • The timepoint: read from a T1//T2/ folder or from _T1/_T2 in the name. A folder and a name that disagree give no timepoint: the file is left out, not guessed at.
  • Intraoral vs CBCT: read from the file type alone, so IOS/ and CBCT/ sub-folders are optional.
  • Left out: a segmentation kept beside its scan and anything the engine does not read.
  • Where the files go: into the per-type layout, in a scratch folder beside the output folder, never inside it. The names carry the patient folder's name: <patient>_T1.nii.gz, <patient>_T1_U.vtk, <patient>_U.stl, <patient>_CBCT.nii.gz.
  • No copies: files are hard-linked, with a copy only as fallback. The scratch folder is removed when the run ends, and also when sorting is refused.
  • What follows is unchanged: pairing, the supervised tools and the output folders are exactly what a per-type request runs. Combined with FIX: name each AREG IOS-CBCT patient folder as its files do and hand back the oriented CBCT beside the meshes #88, each patient's results land in a folder named after its patient folder.
  • Refusals with a clear message: two files that would be filed under one name, no patient sub-folder at all, and, for IOS to CBCT, a patient folder name with no number (that engine matches patients on digits).

Panel

  • input_layout is drawn as two segments (ui: "segmented") above the inputs. Each segment's help shows the folder tree it expects (catalogs.LAYOUT_HELP).
  • The per-type fields show only in their layout, and patients only in its own.
  • Each is required_when its layout is chosen, so the panel does not label them "(optional)".

describe.py

  • Publishes and checks required_when exactly like visible_when; the checker is shared.
  • PAIRED axes need to be path arguments, no longer required ones, since t1/t2 are now optional.

Depends on

Still to do

The server publishes a paired batch plan on t1/t2; no client uses it today. A per-patient request fills neither axis, so a future client that splits cohorts would split nothing in that layout. Splitting by patient folder there is a follow-up.

Tests

  • New tests:
    • common/tests/test_patient_folders.py (12): timepoint and jaw reading, sorting, refusals, the scratch folder.
    • test_patient_folders.py in each engine: IOS-CBCT registers a per-patient cohort end to end (side by side and with IOS//CBCT/), and the T1/T2 engines receive the patient's two timepoints.
    • The layout-condition test now checks every condition's values, not only automation's.
  • AREG_CBCT 169, AREG_IOS 89, AREG_IOSCBCT 223, common 184 passed.
  • scripts/tests: 100 passed. test_module_level_heavy_import_is_reported_as_such also fails on main.
  • Checked by hand in Slicer against a local server serving this branch.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Jules-GP
Jules-GP merged commit fb1f73d into DCBIA-OrthoLab:main Oct 27, 2026
22 checks passed
@Jules-GP
Jules-GP deleted the feat/areg-per-patient-input branch October 27, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants