This project adapts the SpatialConfiguration-Net and the Adaptive Wing Loss to detect 32 cardiac landmarks in 3D echocardiography images and then reconstructs 7 cross-section views of the heart based on the predicted landmark locations.
conda env create -f env.yaml
conda activate comp4801
- Place raw
jsonannotations inrodata/raw/json/. - Place raw
nrrdimages intodata/raw/nrrd/.
The directory tree should be like this:
cardiac-scn
├─ data
│ └─ raw
│ ├─ json
│ │ ├─ 2021-09-17-annotations
│ │ │ ├─ PWHOR191529000T_17Sep2021_BPCZ8ERS_3DQ.json
│ │ │ ├─ PWHOR191529000T_17Sep2021_BPCZ8ESW_3DQ.json
│ │ │ └─ ...
│ │ ├─ 2021-09-20-annotations
│ │ │ └─ ...
│ │ └─ ...
│ └─ nrrd
│ ├─ 2021-09-17-3d-nrrd
│ │ ├─ PWHOR191529000T_17Sep2021_BPCZ8ERS_3DQ.seq.nrrd
│ │ ├─ PWHOR191529000T_17Sep2021_BPCZ8ESW_3DQ.seq.nrrd
│ │ └─ ...
│ ├─ 2021-09-20-3d-nrrd
│ │ └─ ...
│ └─ ...
└─ ...
-
Parse all raw
jsonannotations intocsvfiles.python _parse_raw.py- The results will be saved in
data/meta/4d_ijk/$VIEW/.
- The results will be saved in
-
Preprocess data (extract 3D from 4D and resize); generate groundtruth heatmaps (place Gaussian excitations); split the dataset into training, validation, and testing sets.
python _preprocess.py --views $VIEW python _generate_truth.py --views $VIEW python _split.py --views $VIEW --test "TEST.txt"where
$VIEWis a list of cross-section view abbreviations separated by,, e.g.,VIEW="A2C,A4C,SAXA,SAXB,ALAX,SAXMV,SAXM".TEST.txtis a list of fixed test filenames.- This process may take a while. Recommended to process one view at a time.
- The processed data will be saved in
data/nrrd/$VIEW/; the groundtruth heatmaps will be saved indata/truth/$VIEW/; the dataset meta will be saved indata/meta/train/$VIEW/,data/meta/val/$VIEW/,data/meta/train_val/$VIEW/, anddata/meta/test/$VIEW/.
Train with gpu-interactive.
python train.py --config $CFG
$CFGis the config file. Example config files are provided inconfigs/.- Checkpoints will be saved in
pths/$VIEW/; logs will be saved inlogs/$VIEW/.
Calculate the Euclidean distance between the predicted and groundtruth landmark locations.
python evaluate.py --view $VIEW --pth_path $CKPT
$VIEWis the view abbreviation.$CKPTis the path to thepthfile.- The results will be saved in
evaluation/$VIEW/.
- For A2C, A4C, ALAX, use the general SVD method.
python recover.py --view $VIEW --pth_path $CKPT - For SAXA, jointly use SAXA's, SAXM's and SAXMV's landmarks to predict the normal.
python recover_saxa.py --view "SAXA" --saxa_pth_path $SAXA_CKPT --saxm_pth_path $SAXM_CKPT --saxmv_pth_path $SAXMV_CKPT - For SAXB, ignore PV-tip when fitting the plane.
python recover_saxb.py --view "SAXB" --pth_path $SAXB_CKPT - For SAXM, SAXMV, either use the general SVD method,
or jointly use SAXA's, SAXM's and SAXMV's landmarks to predict the normal.
python recover.py --view $VIEW --pth_path $CKPTpython recover_saxa.py --view $VIEW --saxa_pth_path $SAXA_CKPT --saxm_pth_path $SAXM_CKPT --saxmv_pth_path $SAXMV_CKPT- The results will be saved in
results/$VIEW/. fit.csvrecords the predicted centroid and normal vector of the cross-section plane.err.csvrecords the distances from predicted landmarks to the predicted cross-section plane.images/contains visualizations of the cross-section views.
- The results will be saved in