simcortexpp 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. simcortexpp/__init__.py +0 -0
  2. simcortexpp/cli/__init__.py +0 -0
  3. simcortexpp/cli/main.py +81 -0
  4. simcortexpp/configs/__init__.py +0 -0
  5. simcortexpp/configs/deform/__init__.py +0 -0
  6. simcortexpp/configs/deform/eval.yaml +34 -0
  7. simcortexpp/configs/deform/inference.yaml +60 -0
  8. simcortexpp/configs/deform/train.yaml +98 -0
  9. simcortexpp/configs/initsurf/__init__.py +0 -0
  10. simcortexpp/configs/initsurf/generate.yaml +50 -0
  11. simcortexpp/configs/seg/__init__.py +0 -0
  12. simcortexpp/configs/seg/eval.yaml +31 -0
  13. simcortexpp/configs/seg/inference.yaml +35 -0
  14. simcortexpp/configs/seg/train.yaml +42 -0
  15. simcortexpp/deform/__init__.py +0 -0
  16. simcortexpp/deform/data/__init__.py +0 -0
  17. simcortexpp/deform/data/dataloader.py +268 -0
  18. simcortexpp/deform/eval.py +347 -0
  19. simcortexpp/deform/inference.py +244 -0
  20. simcortexpp/deform/models/__init__.py +0 -0
  21. simcortexpp/deform/models/surfdeform.py +356 -0
  22. simcortexpp/deform/train.py +1173 -0
  23. simcortexpp/deform/utils/__init__.py +0 -0
  24. simcortexpp/deform/utils/coords.py +90 -0
  25. simcortexpp/initsurf/__init__.py +0 -0
  26. simcortexpp/initsurf/generate.py +354 -0
  27. simcortexpp/initsurf/paths.py +19 -0
  28. simcortexpp/preproc/__init__.py +0 -0
  29. simcortexpp/preproc/fs_to_mni.py +696 -0
  30. simcortexpp/seg/__init__.py +0 -0
  31. simcortexpp/seg/data/__init__.py +0 -0
  32. simcortexpp/seg/data/dataloader.py +328 -0
  33. simcortexpp/seg/eval.py +248 -0
  34. simcortexpp/seg/inference.py +291 -0
  35. simcortexpp/seg/models/__init__.py +0 -0
  36. simcortexpp/seg/models/unet.py +63 -0
  37. simcortexpp/seg/train.py +432 -0
  38. simcortexpp/utils/__init__.py +0 -0
  39. simcortexpp/utils/tca.py +298 -0
  40. simcortexpp-0.1.0.dist-info/METADATA +334 -0
  41. simcortexpp-0.1.0.dist-info/RECORD +44 -0
  42. simcortexpp-0.1.0.dist-info/WHEEL +5 -0
  43. simcortexpp-0.1.0.dist-info/entry_points.txt +2 -0
  44. simcortexpp-0.1.0.dist-info/top_level.txt +1 -0
File without changes
File without changes
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ import subprocess
5
+ import typer
6
+ from typing import List
7
+
8
+ from simcortexpp.preproc.fs_to_mni import app as fs_to_mni_app
9
+ from simcortexpp.initsurf.generate import main as initsurf_generate
10
+
11
+
12
+ app = typer.Typer(help="SimCortexPP (SCPP) CLI")
13
+
14
+ def run_module(module: str, overrides: List[str], torchrun: bool = False, nproc: int = 1) -> int:
15
+ if torchrun:
16
+ cmd = ["torchrun", f"--nproc_per_node={nproc}", "-m", module]
17
+ else:
18
+ cmd = [sys.executable, "-m", module]
19
+ cmd += (overrides or [])
20
+ return subprocess.call(cmd)
21
+
22
+ # Preprocessing
23
+ app.add_typer(fs_to_mni_app, name="fs-to-mni", help="FreeSurfer -> MNI preprocessing")
24
+
25
+ # Segmentation group
26
+ seg_app = typer.Typer(help="Segmentation (3D U-Net) stage")
27
+ app.add_typer(seg_app, name="seg")
28
+
29
+ initsurf_app = typer.Typer(help="Initial surface generation (from seg predictions)")
30
+
31
+ @seg_app.command("train")
32
+ def seg_train(
33
+ overrides: List[str] = typer.Argument(None, help="Hydra overrides"),
34
+ torchrun: bool = typer.Option(False, "--torchrun", help="Launch training with torchrun for DDP"),
35
+ nproc_per_node: int = typer.Option(1, "--nproc-per-node", help="GPUs per node for torchrun"),
36
+ ):
37
+ code = run_module("simcortexpp.seg.train", overrides or [], torchrun=torchrun, nproc=nproc_per_node)
38
+ raise typer.Exit(code)
39
+
40
+ @seg_app.command("infer")
41
+ def seg_infer(overrides: List[str] = typer.Argument(None, help="Hydra overrides")):
42
+ code = run_module("simcortexpp.seg.inference", overrides or [])
43
+ raise typer.Exit(code)
44
+
45
+ @seg_app.command("eval")
46
+ def seg_eval(overrides: List[str] = typer.Argument(None, help="Hydra overrides")):
47
+ code = run_module("simcortexpp.seg.eval", overrides or [])
48
+ raise typer.Exit(code)
49
+
50
+ @initsurf_app.command("generate")
51
+ def initsurf_generate_cmd(overrides: List[str] = typer.Argument(None, help="Hydra overrides")):
52
+ code = run_module("simcortexpp.initsurf.generate", overrides or [])
53
+ raise typer.Exit(code)
54
+
55
+ app.add_typer(initsurf_app, name="initsurf")
56
+
57
+ # --- add near seg_app / initsurf_app ---
58
+ deform_app = typer.Typer(help="Stage 4 — Deformation: train / infer / eval")
59
+ app.add_typer(deform_app, name="deform")
60
+
61
+ @deform_app.command("train")
62
+ def deform_train(
63
+ overrides: List[str] = typer.Argument(None, help="Hydra overrides"),
64
+ torchrun: bool = typer.Option(False, "--torchrun", help="Launch training with torchrun for DDP"),
65
+ nproc_per_node: int = typer.Option(1, "--nproc-per-node", help="GPUs per node for torchrun"),
66
+ ):
67
+ code = run_module("simcortexpp.deform.train", overrides or [], torchrun=torchrun, nproc=nproc_per_node)
68
+ raise typer.Exit(code)
69
+
70
+ @deform_app.command("infer")
71
+ def deform_infer(overrides: List[str] = typer.Argument(None, help="Hydra overrides")):
72
+ code = run_module("simcortexpp.deform.inference", overrides or [])
73
+ raise typer.Exit(code)
74
+
75
+ @deform_app.command("eval")
76
+ def deform_eval(overrides: List[str] = typer.Argument(None, help="Hydra overrides")):
77
+ code = run_module("simcortexpp.deform.eval", overrides or [])
78
+ raise typer.Exit(code)
79
+
80
+ if __name__ == "__main__":
81
+ app()
File without changes
File without changes
@@ -0,0 +1,34 @@
1
+ user_config: null
2
+
3
+ dataset:
4
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
5
+ split_name: test
6
+ session_label: "01"
7
+ space: "MNI152"
8
+
9
+ # Stage 1 roots (GT surfaces)
10
+ roots:
11
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
12
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
13
+
14
+ outputs:
15
+ # Stage 4 prediction roots (deformed surfaces)
16
+ pred_roots:
17
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-deform-0.1
18
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-deform-0.1
19
+
20
+ out_dir: /project/hippocampus/common/kaveh/workspace/scpp-runs/deform/exp01_hcpya+oasis1/eval_test
21
+
22
+ eval:
23
+ pred_desc: "deform" # matches inference naming: desc-deform
24
+ device: "cuda:0"
25
+ n_chamfer: 150000
26
+ n_assd_hd: 150000
27
+ log_level: "INFO"
28
+
29
+ hydra:
30
+ run:
31
+ dir: ${outputs.out_dir}
32
+ output_subdir: null
33
+ job:
34
+ chdir: false
@@ -0,0 +1,60 @@
1
+ user_config: null
2
+
3
+ dataset:
4
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
5
+ split_name: test
6
+ session_label: "01"
7
+ space: "MNI152"
8
+
9
+ # Where T1 + GT FS surfaces live (Stage 1 outputs)
10
+ roots:
11
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
12
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
13
+
14
+ # Where init surfaces + ribbon_prob live (Stage 3 outputs)
15
+ initsurf_roots:
16
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-initsurf-0.1
17
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-initsurf-0.1
18
+
19
+ surface_name: ["lh_pial", "lh_white", "rh_pial", "rh_white"]
20
+
21
+ prob_clip_min: 0.0
22
+ prob_clip_max: 1.0
23
+ prob_gamma: 1.0
24
+ add_prob_grad: false
25
+
26
+ inference:
27
+ device: "cuda:0"
28
+ batch_size: 1
29
+ num_workers: 2
30
+ log_level: "INFO"
31
+ overwrite: true
32
+
33
+ model:
34
+ ckpt_path: /project/hippocampus/common/kaveh/workspace/scpp-runs/deform/exp01_hcpya+oasis1/checkpoints/deform_best_rmse.pth
35
+ strict_load: true
36
+
37
+ c_in: 2
38
+ sigma: 1
39
+ n_steps: 8
40
+ inshape: [184, 224, 184]
41
+ c_hid: [8, 16, 32, 64, 128, 128]
42
+
43
+ geom_ratio: 0.5
44
+ geom_depth: 6
45
+ gn_groups: 8
46
+ gate_init: -3.0
47
+
48
+ outputs:
49
+ out_roots:
50
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-deform-0.1
51
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-deform-0.1
52
+
53
+ log_dir: /project/hippocampus/common/kaveh/workspace/scpp-runs/deform/exp01_hcpya+oasis1/logs_infer_test
54
+
55
+ hydra:
56
+ run:
57
+ dir: ${outputs.log_dir}
58
+ output_subdir: null
59
+ job:
60
+ chdir: false
@@ -0,0 +1,98 @@
1
+ user_config: null
2
+
3
+ dataset:
4
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
5
+ train_split_name: train
6
+ val_split_name: val
7
+
8
+ session_label: "01"
9
+ space: "MNI152"
10
+
11
+ roots:
12
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
13
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
14
+
15
+ initsurf_roots:
16
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-initsurf-0.1
17
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-initsurf-0.1
18
+
19
+ surface_name: ["lh_pial", "lh_white", "rh_pial", "rh_white"]
20
+
21
+ prob_clip_min: 0.0
22
+ prob_clip_max: 1.0
23
+ prob_gamma: 1.0
24
+ add_prob_grad: false
25
+
26
+ aug_prob: 0.30
27
+ aug_rot_range_deg: 5.0
28
+ aug_scale_range: 0.03
29
+ aug_trans_range_mm: 2.0
30
+
31
+ trainer:
32
+ seed: 2025
33
+ img_batch_size: 1
34
+ grad_accum_steps: 4
35
+ num_epochs: 500
36
+ validation_interval: 5
37
+ collision_interval: 50
38
+
39
+ learning_rate: 1.0e-4
40
+ weight_decay: 5.0e-5
41
+
42
+ points_per_image: 150000
43
+ val_points_per_image: 100000
44
+ num_workers: 4
45
+ log_level: INFO
46
+ mesh_chunk: 4
47
+ grad_clip_norm: 1.0
48
+
49
+ scheduler_patience: 2
50
+ scheduler_factor: 0.5
51
+ scheduler_min_lr: 1.0e-6
52
+ scheduler_threshold_mm: 0.0
53
+ scheduler_threshold_mode: rel
54
+ scheduler_cooldown: 0
55
+
56
+ early_stop_patience: 12
57
+ early_stop_min_delta_mm: 0.0003
58
+
59
+ model:
60
+ sigma: 1
61
+ n_steps: 8
62
+ inshape: [184, 224, 184]
63
+ c_hid: [8, 16, 32, 64, 128, 128]
64
+ c_in: 2
65
+
66
+ geom_ratio: 0.5
67
+ geom_depth: 6
68
+ gn_groups: 8
69
+ gate_init: -3.0
70
+
71
+ init_ckpt: ""
72
+ init_strict: true
73
+
74
+ objective:
75
+ chamfer_weight: 1.0
76
+ edge_loss_weight: 0.3
77
+ normal_weight: 0.3
78
+ reg_warmup_epochs: 10
79
+
80
+ hd_weight: 5.0
81
+ hd_p: 0.01
82
+ hd_lambda_mm: 0.6
83
+ hd_points: 60000
84
+
85
+ pial_lr_hd_weight: 0.5
86
+ pial_lr_hd_p: 0.001
87
+ pial_lr_hd_lambda_mm: 0.6
88
+ pial_lr_hd_points: 25000
89
+
90
+ outputs:
91
+ root: /project/hippocampus/common/kaveh/workspace/scpp-runs/deform/exp01_hcpya+oasis1
92
+
93
+ hydra:
94
+ run:
95
+ dir: ${outputs.root}
96
+ output_subdir: null
97
+ job:
98
+ chdir: false
File without changes
@@ -0,0 +1,50 @@
1
+ dataset:
2
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
3
+ split_name: all
4
+ session_label: "01"
5
+ space: "MNI152"
6
+
7
+ # Preproc roots (where preprocessed T1 lives)
8
+ roots:
9
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
10
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
11
+
12
+
13
+ # Segmentation roots (where seg9_dseg lives)
14
+ seg_roots:
15
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-seg-0.1
16
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-seg-0.1
17
+
18
+ outputs:
19
+ out_roots:
20
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-initsurf-0.1
21
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-initsurf-0.1
22
+ log_dir: /project/hippocampus/common/kaveh/workspace/scpp-runs/initsurf/exp01_hcpya+oasis1/logs_generate
23
+
24
+ params:
25
+ gap_size: 1
26
+
27
+ sdf_sigma: 0.5
28
+ topo_threshold: 16.0
29
+ n_smooth: 2
30
+
31
+ wm_thickness: 1.0
32
+ wm_start_level: -0.2
33
+ wm_step: -0.08
34
+ wm_min_level: -5.0
35
+ wm_max_iters: 120
36
+
37
+ pial_start_level: 0.1
38
+ pial_step: 0.05
39
+ pial_max_level: 5.0
40
+ pial_max_iters: 120
41
+ pial_shrink_step: 0.05
42
+ pial_shrink_max_iters: 80
43
+
44
+
45
+ hydra:
46
+ run:
47
+ dir: ${outputs.log_dir}
48
+ output_subdir: null
49
+ job:
50
+ chdir: false
File without changes
@@ -0,0 +1,31 @@
1
+ dataset:
2
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
3
+ split_name: test
4
+ session_label: "01"
5
+ space: MNI152
6
+
7
+ roots:
8
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
9
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
10
+
11
+ evaluation:
12
+ num_classes: 9
13
+ exclude_background: true
14
+ nsd_tolerance_vox: 1.0
15
+ spacing: [1.0, 1.0, 1.0]
16
+
17
+ outputs:
18
+ pred_roots:
19
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-seg-0.1
20
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-seg-0.1
21
+
22
+ log_dir: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1/logs_eval_test
23
+ eval_csv: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1/metrics_test.csv
24
+ eval_xlsx: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1/metrics_test.xlsx
25
+
26
+ hydra:
27
+ run:
28
+ dir: ${outputs.log_dir}
29
+ output_subdir: null
30
+ job:
31
+ chdir: false
@@ -0,0 +1,35 @@
1
+ dataset:
2
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
3
+ split_name: test
4
+ session_label: "01"
5
+ space: "MNI152"
6
+ pad_mult: 16
7
+
8
+ roots:
9
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
10
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
11
+
12
+ trainer:
13
+ device: cuda:0
14
+ batch_size: 2
15
+ num_workers: 4
16
+
17
+ model:
18
+ in_channels: 1
19
+ out_channels: 9
20
+ ckpt_path: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1/checkpoints/seg_best_dice.pt
21
+
22
+ outputs:
23
+ out_roots:
24
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-seg-0.1
25
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-seg-0.1
26
+
27
+ log_dir: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1/logs_infer_test
28
+
29
+
30
+ hydra:
31
+ run:
32
+ dir: ${outputs.log_dir}
33
+ output_subdir: null
34
+ job:
35
+ chdir: false
@@ -0,0 +1,42 @@
1
+ dataset:
2
+ split_file: /project/hippocampus/common/kaveh/workspace/datasets/splits/dataset_split.csv
3
+
4
+ roots:
5
+ HCP_YA: /project/hippocampus/common/kaveh/workspace/datasets/hcpya-u100/derivatives/scpp-preproc-0.1
6
+ OASIS1: /project/hippocampus/common/kaveh/workspace/datasets/oasis-1/derivatives/scpp-preproc-0.1
7
+
8
+ train_split: train
9
+ val_split: val
10
+ session_label: "01"
11
+ space: "MNI152"
12
+ pad_mult: 16
13
+ augment: true
14
+
15
+
16
+ trainer:
17
+ device: cuda:0
18
+ num_epochs: 500
19
+ learning_rate: 1e-4
20
+ batch_size: 6
21
+ num_workers: 4
22
+ validation_interval: 15
23
+ dice_weight: 1.0
24
+ use_ddp: true
25
+ data_parallel: false
26
+
27
+ model:
28
+ in_channels: 1
29
+ out_channels: 9
30
+
31
+ outputs:
32
+ root: /project/hippocampus/common/kaveh/workspace/scpp-runs/seg/exp01_hcpya+oasis1
33
+ log_dir: ${outputs.root}/logs_train
34
+ ckpt_dir: ${outputs.root}/checkpoints
35
+
36
+
37
+ hydra:
38
+ run:
39
+ dir: ${outputs.log_dir}
40
+ output_subdir: null
41
+ job:
42
+ chdir: false
File without changes
File without changes