sct-pipeline / contrast-agnostic-softseg-spinalcord

Contrast-agnostic spinal cord segmentation project with softseg
MIT License
4 stars 3 forks source link

Config.json file to use on the first contrast agnostic training #6

Closed mpompolas closed 11 months ago

mpompolas commented 3 years ago

Training will take place on sct-testing-large and UK-biobank.

Config file:

{
    "command": "train",
    "gpu_ids": [
        0
    ],
    "path_output": "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/ivado-project/Datasets/logs/all_training",
    "model_name": "contrast_agnostic",
    "debugging": true,
    "object_detection_params": {
        "object_detection_path": null,
        "safety_factor": [
            1.0,
            1.0,
            1.0
        ],
    },
    "loader_parameters": {
        "path_data": [
            "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/ivado-project/Datasets/sct-testing-large",
            "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/ivado-project/Datasets/uk-biobank-processed"
        ],
        "subject_selection": {
            "n": [],
            "metadata": [],
            "value": []
        },
        "target_suffix": [
            "_seg-manual"
        ],
        "extensions": [],
        "roi_params": {
            "suffix": null,
            "slice_filter_roi": null
        },
        "contrast_params": {
            "training_validation": [
                "T1w",
                "T2w",
                "T2star"
            ],
            "testing": [
                "T1w",
                "T2w",
                "T2star"
            ],
            "balance": {}
        },
        "slice_filter_params": {
            "filter_empty_mask": false,
            "filter_empty_input": true
        },
        "slice_axis": "axial",
        "multichannel": false,
        "soft_gt": true
    },
    "split_dataset": {
        "fname_split": "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/ivado-project/Datasets/split_datasets_converted.joblib",
        "random_seed": 3599,
        "center_test": [],
        "method": "per_patient",
        "balance": null,
        "train_fraction": 0.6,
        "test_fraction": 0.2
    },
    "training_parameters": {
        "batch_size": 8,
        "loss": {
            "name": "AdapWingLoss",
            "theta": 0.5,
            "alpha": 2.1,
            "epsilon": 1,
            "omega": 8
        },
        "training_time": {
            "num_epochs": 50,
            "early_stopping_patience": 50,
            "early_stopping_epsilon": 0.001
        },
        "scheduler": {
            "initial_lr": 0.001,
            "lr_scheduler": {
                "name": "CosineAnnealingLR",
                "base_lr": 1e-05,
                "max_lr": 0.01
            }
        },
        "balance_samples": {
            "applied": false,
            "type": "gt"
        },
        "mixup_alpha": null,
        "transfer_learning": {
            "retrain_model": null,
            "retrain_fraction": 1.0,
            "reset": true
        }
    },
    "default_model": {
        "name": "Unet",
        "dropout_rate": 0.3,
        "bn_momentum": 0.9,
        "depth": 2,
        "is_2d": true,
        "relu": true
    },
    "uncertainty": {
        "epistemic": false,
        "aleatoric": false,
        "n_it": 0
    },
    "postprocessing": {
        "remove_noise": {
            "thr": -1
        },
        "keep_largest": {},
        "binarize_prediction": {
            "thr": 0.5
        },
        "uncertainty": {
            "thr": -1,
            "suffix": "_unc-vox.nii.gz"
        },
        "fill_holes": {},
        "remove_small": {
            "unit": "vox",
            "thr": 3
        }
    },
    "evaluation_parameters": {
        "target_size": {
            "unit": "vox",
            "thr": [
                20,
                100
            ]
        },
        "overlap": {
            "unit": "vox",
            "thr": 3
        }
    },
    "transformation": {
        "Resample": {
            "wspace": 0.50,
            "hspace": 0.50,
            "dspace": 1
        },
        "CenterCrop": {
            "size": [
                128,
                128
            ]
        },
        "RandomAffine": {
            "degrees": 5,
            "scale": [
                0.1,
                0.1
            ],
            "translate": [
                0.03,
                0.03
            ],
            "applied_to": [
                "im",
                "gt"
            ],
            "dataset_type": [
                "training"
            ]
        },
        "ElasticTransform": {
            "alpha_range": [
                28.0,
                30.0
            ],
            "sigma_range": [
                3.5,
                4.5
            ],
            "p": 0.1,
            "applied_to": [
                "im",
                "gt"
            ],
            "dataset_type": [
                "training"
            ]
        },
        "NumpyToTensor": {},
        "NormalizeInstance": {
            "applied_to": [
                "im"
            ]
        }
    },
    "FiLMedUnet": {
        "applied": false,
        "metadata": "institution_id",
        "film_layers": [
            0,
            1,
            0,
            0,
            0,
            0,
            0,
            0
        ]
    },
    "Modified3DUNet": {
        "applied": false,
        "length_3D": [
            128,
            128,
            16
        ],
        "stride_3D": [
            128,
            128,
            16
        ],
        "attention": false,
        "n_filters": 8
    }
}

For the training part we will have CenterCrop.

For the testing, we will change to ROICrop with centerline.

Any comments @charleygros ?

charleygros commented 3 years ago
  1. Increase the contrast coverage:
            "training_validation": [
                "T1w",
                "T2w",
                "T2star"
            ],

I'm pretty sure that sct_testing-large include other suffixes.

  1. Could you please document somewhere how you did the split? strategy?
        "fname_split": "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/ivado-project/Datasets/split_datasets_converted.joblib",
  1. Decrease Patience to 10
            "early_stopping_patience": 50,
  1. Reminder for later: we will need to modify the postprocessing and evaluation_parameters

  2. Increase Affine DA, eg degrees to 20 and translate to 0.1

        "RandomAffine": {
            "degrees": 5,
            "scale": [
                0.1,
                0.1
            ],
            "translate": [
                0.03,
                0.03
            ],
            "applied_to": [
                "im",
                "gt"
            ],
            "dataset_type": [
                "training"
            ]
        },
  1. Run the script run_visualisation before starting the training on few images and share screenshots in this issue. It will help us to assess the relevance of the transformation params, eg CropSize params and the strenght of the ElasticTransform.
uzaymacar commented 2 years ago

Reminder for later: we will need to modify the postprocessing and evaluation_parameters

Hey @charleygros, I am training SoftSeg models using @mpompolas's config + your suggestions. I was wondering what else needs to be changed in the config for postprocessing and evaluation params. Thanks!

charleygros commented 2 years ago

Hey @charleygros, I am training SoftSeg models using @mpompolas's config + your suggestions. I was wondering what else needs to be changed in the config for postprocessing and evaluation params. Thanks!

Oh yea so, here my suggestion for these two chunks:

    "postprocessing": {},
    "evaluation_parameters": {},

yea :-) For the SC segmentation task, the remove noise, the target size etc is not so relevant. I think at this stage we don't want to add fancy postprocessing steps. Especially: no thresholding!

naga-karthik commented 11 months ago

closing as we're not using config files or ivadomed