Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider Gaussian function for single pixel annotation #6

Open
jcohenadad opened this issue Nov 23, 2021 · 3 comments
Open

Consider Gaussian function for single pixel annotation #6

jcohenadad opened this issue Nov 23, 2021 · 3 comments

Comments

@jcohenadad
Copy link
Member

Currently, a window of 50 samples, centered around the epileptic peak, is labeled with value 1.

The problem with that, is that the model is exposed to values far away from the peak, with values 1.

A suggestion would be to, instead of using a step function, to use a Gaussian or Gamma function, centered around the peak.

We would use the SoftSeg training losses.

@mpompolas
Copy link
Member

Adjusted the brainstorm code to take that into account, with a checkbox for activating it:

image

The Gaussian weighting is applied on the time dimension only.

Just started training using this configuration file with SoftSeg based on a discussion I had with @charleygros in the past, but the discussion was about 2D, not 3D training.
@naga-karthik please take a look at it when you get a chance.

Config file

{
  "command": "train",
  "gpu_ids": [
    0
  ],
  "path_output": "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/EEG-ivado/epilepsy/distant_spikes_2_seconds_gaussian_annotation/output_Epilepsy_EEG_runs_3_gaussian_annotation1",
  "model_name": "EEG_model",
  "debugging": true,
  "object_detection_params": {
    "object_detection_path": null,
    "safety_factor": [
      1,
      1,
      1
    ]
  },
  "loader_parameters": {
    "path_data": "/home/GRAMES.POLYMTL.CA/u111358/data_nvme_u111358/EEG-ivado/epilepsy/distant_spikes_2_seconds_gaussian_annotation/data_Epilepsy_EEG_runs_3_gaussian_annotation",
    "subject_selection": {
      "n": [],
      "metadata": [],
      "value": []
    },
    "target_suffix": [
      "_saw_EST_distant"
    ],
    "roi_params": {
      "suffix": null,
      "slice_filter_roi": null
    },
    "contrast_params": {
      "training_validation": [
        "EEGarounddistantspikes"
      ],
      "testing": [
        "EEGarounddistantspikes"
      ],
      "balance": {}
    },
    "slice_filter_params": {
      "filter_empty_mask": false,
      "filter_empty_input": true
    },
    "slice_axis": "sagittal",
    "multichannel": false,
    "soft_gt": true
  },
  "split_dataset": {
    "fname_split": null,
    "random_seed": 6,
    "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": 100,
      "early_stopping_patience": 50,
      "early_stopping_epsilon": 0.001
    },
    "scheduler": {
      "initial_lr": 0.001,
      "lr_scheduler": {
        "name": "CosineAnnealingLR",
        "base_lr": 1E-5,
        "max_lr": 0.01
      }
    },
    "balance_samples": {
      "applied": false,
      "type": "gt"
    },
    "mixup_alpha": null,
    "transfer_learning": {
      "retrain_model": null,
      "retrain_fraction": 1,
      "reset": true
    }
  },
  "default_model": {
    "name": "Unet",
    "dropout_rate": 0.3,
    "bn_momentum": 0.9,
    "depth": 3,
    "final_activation": "relu"
  },
  "FiLMedUnet": {
    "applied": false,
    "metadata": "institution_id",
    "film_layers": [
      0,
      1,
      0,
      0,
      0,
      0,
      0,
      0
    ]
  },
  "Modified3DUNet": {
    "applied": true,
    "length_3D": [
      112,
      112,
      128
    ],
    "stride_3D": [
      112,
      112,
      64
    ],
    "attention": false,
    "n_filters": 8
  },
  "uncertainty": {
    "epistemic": false,
    "aleatoric": false,
    "n_it": 0
  },
  "postprocessing": {
    "remove_noise": {
      "thr": -1
    },
    "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": {
    "CenterCrop": {
      "size": [
        112,
        112,
        512
      ]
    },
    "RandomAffine": {
      "degrees": 0,
      "translate": [
        0,
        0,
        0.03
      ],
      "applied_to": [
        "im",
        "gt"
      ],
      "dataset_type": [
        "training"
      ]
    },
    "NumpyToTensor": {},
    "NormalizeInstance": {
      "applied_to": [
        "im"
      ]
    }
  },
  "brainstorm": {
    "modality": "EEG",
    "event_for_ground_truth": "saw_EST_distant",
    "annotations_time_window": [
      -0.1,
      0.3
    ],
    "resampling": 100,
    "jitter": 0,
    "soft_annotation_threshold": [],
    "bids_folder_creation_mode": "Separate each trial as different subjects",
    "sInputs": [
      "1: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial001_notch_band_resample_time.mat",
      "2: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial002_notch_band_resample_time.mat",
      "3: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial003_notch_band_resample_time.mat",
      "4: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial006_notch_band_resample_time.mat",
      "5: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial007_notch_band_resample_time.mat",
      "6: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial008_notch_band_resample_time.mat",
      "7: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial009_notch_band_resample_time.mat",
      "8: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial011_notch_band_resample_time.mat",
      "9: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial015_notch_band_resample_time.mat",
      "10: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial017_notch_band_resample_time.mat",
      "11: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial019_notch_band_resample_time.mat",
      "12: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial020_notch_band_resample_time.mat",
      "13: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial022_notch_band_resample_time.mat",
      "14: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial023_notch_band_resample_time.mat",
      "15: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial025_notch_band_resample_time.mat",
      "16: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial027_notch_band_resample_time.mat",
      "17: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial030_notch_band_resample_time.mat",
      "18: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial031_notch_band_resample_time.mat",
      "19: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial032_notch_band_resample_time.mat",
      "20: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial033_notch_band_resample_time.mat",
      "21: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial035_notch_band_resample_time.mat",
      "22: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial036_notch_band_resample_time.mat",
      "23: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial037_notch_band_resample_time.mat",
      "24: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial038_notch_band_resample_time.mat",
      "25: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial039_notch_band_resample_time.mat",
      "26: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial042_notch_band_resample_time.mat",
      "27: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial044_notch_band_resample_time.mat",
      "28: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial049_notch_band_resample_time.mat",
      "29: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial050_notch_band_resample_time.mat",
      "30: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial051_notch_band_resample_time.mat",
      "31: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial052_notch_band_resample_time.mat",
      "32: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial053_notch_band_resample_time.mat",
      "33: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial056_notch_band_resample_time.mat",
      "34: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial057_notch_band_resample_time.mat",
      "35: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial058_notch_band_resample_time.mat",
      "36: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial059_notch_band_resample_time.mat",
      "37: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial060_notch_band_resample_time.mat",
      "38: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial062_notch_band_resample_time.mat",
      "39: sub-pt0090/sub-pt0090_ses-20210722_task-rest_run-03_meg/data_around_distant_spikes_trial063_notch_band_resample_time.mat"
    ]
  }
}

@mpompolas
Copy link
Member

mpompolas commented Nov 25, 2021

First result is not very promising. Need to test with an even larger Kernel

Results

image

The slice_axis parameter was wrong in this test. Check 12

IGNORE RESULT

@jcohenadad
Copy link
Member Author

First result is not very promising. Need to test with an even larger Kernel

Are we sure that trilinear interpolation without binarization is used for data augmentation? Is this information supposed to be present in the config file? @andreanne-lemay @charleygros

tgnassou added a commit to tgnassou/MEEG-Brainstorm that referenced this issue Jun 8, 2022
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

No branches or pull requests

2 participants