Skip to content

Optimize data augmentation for 3D kernel #57

@jcohenadad

Description

@jcohenadad

Useful syntax

To look at predictions with GT. Run under the data_seg_mp2rage_20221220_124553/data_processed_lesionseg folder:

for i in 017 025 058 079 082 098 103 111 114 115; do fsleyes -S sub-P${i}/anat/sub-P${i}_UNIT1 derivatives/labels/sub-P${i}/anat/sub-P${i}_UNIT1_lesion-manualHaris -cm yellow ../../model_seg_lesion_mp2rage_xxx/pred_masks/sub-P${i}_UNIT1_pred -cm red -a 50; done

TODO:

  • Use less conservative cropping during preprocessing, to avoid the 'black edge', which could limit the performance of training (ie: model would focus on edge detection).
  • Use softseg
  • Looks like only one lesion is segmented. Maybe check post-processing (keep only one object).

image

config file
{
    "command": "train",
    "gpu_ids": [4],
    "path_output": "/home/GRAMES.POLYMTL.CA/p101317/data_nvme_p101317/model_seg_lesion_mp2rage_",
    "model_name": "model_seg_lesion_mp2rage",
    "debugging": true,
    "object_detection_params": {
        "object_detection_path": null,
        "safety_factor": [1.0, 1.0, 1.0]
    },
    "wandb": {
        "wandb_api_key": "9095e2bc9e4ab445d478c9c8a81759ae908be8c6",
        "project_name": "basel-mp2rage-lesion",
        "group_name": "3D",
        "run_name": "run-1",
        "log_grads_every": 100
    },
    "loader_parameters": {
        "path_data": ["/home/GRAMES.POLYMTL.CA/p101317/data_nvme_p101317/data_seg_mp2rage_20221217_170634/data_processed_lesionseg"],
        "subject_selection": {"n": [], "metadata": [], "value": []},
        "target_suffix": ["_lesion-manualHaris"],
        "extensions": [".nii.gz"],
        "roi_params": {
            "suffix": null,
            "slice_filter_roi": null
        },
        "contrast_params": {
            "training_validation": ["UNIT1"],
            "testing": ["UNIT1"],
            "balance": {}
        },
        "slice_filter_params": {
            "filter_empty_mask": true,
            "filter_empty_input": true
        },
        "slice_axis": "axial",
        "multichannel": false,
        "soft_gt": false,
        "bids_validate": true
    },
    "split_dataset": {
        "fname_split": null,
        "random_seed": 42,
        "split_method" : "participant_id",
        "data_testing": {"data_type": null, "data_value":[]},
        "balance": null,
        "train_fraction": 0.6,
        "test_fraction": 0.2
    },
    "training_parameters": {
        "batch_size": 16,
        "loss": {
            "name": "DiceLoss"
        },
        "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-5,
                "max_lr": 1e-3
            }
        },
        "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.1,
        "final_activation": "sigmoid",
        "depth": 3
    },
    "FiLMedUnet": {
        "applied": false,
        "metadata": "contrasts",
        "film_layers": [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    "Modified3DUNet": {
        "applied": true,
        "length_3D": [32, 32, 64],
        "stride_3D": [32, 32, 64],
        "attention": false,
        "n_filters": 8
    },
    "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":
        {
            "hspace": 0.75,
            "wspace": 0.75,
            "dspace": 0.75
        },
        "CenterCrop": {
            "size": [64, 64, 128]},

        "RandomAffine": {
            "degrees": 5,
            "scale": [0.1, 0.1],
            "translate": [0.1, 0.1],
            "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"]
	},		    
	"NormalizeInstance": {"applied_to": ["im"]}
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions