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

Create protocol for manual lesion segmentation #73

Open
jcohenadad opened this issue Jan 18, 2024 · 16 comments
Open

Create protocol for manual lesion segmentation #73

jcohenadad opened this issue Jan 18, 2024 · 16 comments
Assignees

Comments

@plbenveniste plbenveniste self-assigned this Jan 18, 2024
@plbenveniste
Copy link
Collaborator

plbenveniste commented Jan 25, 2024

@cspino and I are working on manual correction of MS lesion in the spinal cord predicted by the model (refer to ACTRIMS abstract). So far, the proposed method is the following :

  • Download SCT
  • Clone manual correction repository
  • Download segmentation predictions : from `duke/projects/canproco/2023_11_08_lesion_seg_models_and_results/M12_inference/inference_results_Dataset555_nnUNet222_fold2_2d_BIDS``
  • Download the config file (looks like the following):

FILES_LESION:

  • sub-cal056_ses-M12_STIR.nii.gz
  • sub-cal072_ses-M12_STIR.nii.gz
  • sub-edm011_ses-M12_PSIR.nii.gz
  • sub-edm013_ses-M12_PSIR.nii.gz
  • sub-mon001_ses-M12_PSIR.nii.gz
  • sub-mon004_ses-M12_PSIR.nii.gz
  • sub-tor006_ses-M12_PSIR.nii.gz
  • sub-tor007_ses-M12_PSIR.nii.gz
  • sub-van005_ses-M12_PSIR.nii.gz
  • sub-van010_ses-M12_PSIR.nii.gz
  • Create a virtual environment :

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

  • Run the following command for manual correction :
  • python manual_correction.py -path-img <INPUT_PATH> -config <CONFIG_FILE> -path-label <LABEL_PATH> -suffix-files-lesion _lesion-manual

However, we identified certains things to do beforehand:

  • Copy predictions to CanProCo branch
  • Create a json file for each file with generated by "Generated by 2D nnUNet model available at duke/projects/canproco/2023_11_08_lesion_seg_models_and_results/nnunet_region-based_(SC+lesion)_training_on_STIR_and_inverted_PSIR_data/nnUNet_results/Dataset222_RegionBasedLesionSeg/nnUNetTrainer__nnUNetPlans__2d model used in ACTRIMS 2024 abstract"
  • Modify manual_correction script to change Fsleyes parameters : such as the intensity parameters depending on the contrast
  • Manually correct images

@jcohenadad Could you give me feedback on the json file data for the automatically segmented lesions

@valosekj
Copy link
Member

valosekj commented Jan 25, 2024

Great summary! 👍🏻

For SCI derivatives (segmented using the SCISeg model and then manually corrected), I use the following jSON sidecar:

{
    "GeneratedBy": [
        {
            "Name": "SCISeg nnUNet3D",
            "Version": "Dataset183_tSCI3SitesALPhase2Seed710",
            "Date": "2024-01-16"
        },
        {
            "Author": "Jan Valosek",
            "Note": "Manually corrected",
            "Date": "2024-01-18 10:42:24"
        }
    ]
}

Or, if a mask is created completely manually, I use:

{
    "GeneratedBy": [
        {
            "Author": "Jan Valosek",
            "Date": "2024-01-18 10:42:24"
        }
    ]
}

Unfortunately, manual-correction.py supports only the second JSON option. I usually write a simple loop to add info about a model to the JSON sidecar. UPDATE - an issue opened: spinalcordtoolbox/manual-correction#75

Also see our intranet convention here.

@valosekj
Copy link
Member

valosekj commented Jan 25, 2024

Modify manual_correction script to change Fsleyes parameters : such as the intensity parameters depending on the contrast

This is already supported; see the -fsleyes-dr flag here.

@plbenveniste
Copy link
Collaborator

In our case, what do you think of ?

{
    "GeneratedBy": [
        {
            "Name": "nnunet_region-based_(SC+lesion)_training_on_STIR_and_inverted_PSIR_data nnUNet2D",
            "Version": "Dataset222_RegionBasedLesionSeg",
            "Date": "2024-01-16"
        },
        {
            "Author": "Pierre-Louis Benveniste",
            "Note": "Manually corrected",
            "Date": "2024-01-18 10:42:24"
        }
    ]
}

@jcohenadad
Copy link
Member Author

jcohenadad commented Jan 25, 2024

"Name": "nnunet_region-based_(SC+lesion)_training_on_STIR_and_inverted_PSIR_data nnUNet2D" --> ideally it should point to the actual model (eg: URL to the model hosted on the assets of a published release on github). Or maybe the version should point to the versioned model... i don't know what's best. But in any case we need a link, otherwise in 5 years another student might give the same name to the model, and then we have a conflict

"Note": "Manually corrected", --> i don't think this field is necessary

@plbenveniste
Copy link
Collaborator

Release done ! Format of json files will be :

{
    "GeneratedBy": [
        {
            "Name": "2D nnUNet model stored at https://github.com/ivadomed/canproco/releases/tag/r20240125",
            "Version": "2D region-based nnUNet fold 2",
            "Date": "2024-01-16"
        },
        {
            "Author": "Pierre-Louis Benveniste",
            "Date": "2024-01-18 10:42:24"
        }
    ]
}

@jcohenadad
Copy link
Member Author

Great! I have a comment about naming the model #74

Also, putting the version URL under "Name" defeats the purpose of the field "Version".

How about instead putting the name of the model (ie: the packaged ZIP file, like model_ms_seg_sc-lesion_regionBased.zip) under "Name", and the URL to the release under "Version"?

@valosekj
Copy link
Member

"Note": "Manually corrected", --> i don't think this field is necessary

I used this because, in some cases, the automatic seg was okay and needed no corrections. To distinguish this, I used:

    "Note": "Visually verified",

or, if manual correction was required:

    "Note": "Manually corrected",

@jcohenadad
Copy link
Member Author

 "Note": "Visually verified",

I agree, this is a good idea. We should probably add this information in our intranet so as to standardize our terminology @NathanMolinier

BTW: Does your manual_correction script automatically identifies if there was a modification in the segmentation, and then applies either "Visually verified" or "Manually corrected"?

@valosekj
Copy link
Member

valosekj commented Jan 26, 2024

BTW: Does your manual_correction script automatically identifies if there was a modification in the segmentation, and then applies either "Visually verified" or "Manually corrected"?

Yes! The script tracks the modification times of a file to distinguish if the file was just opened or actually modified.

@plbenveniste
Copy link
Collaborator

  • The model name was updated in the release.
  • Segmentations were added to branch plb/m12_lesion_seg and pushed to git-annex
  • Json files were created for each predicted segmentation

The json files have the following format :

{
        "GeneratedBy": [
            {
                "Name": "2D nnUNet model model_ms_seg_sc-lesion_regionBased.zip",
                "Version": "https://github.com/ivadomed/canproco/releases/tag/r20240125",
                "Date": "2024-01-26"
            }
        ]
    }

@NathanMolinier
Copy link

NathanMolinier commented Jan 26, 2024

"Note": "Visually verified",

I agree, this is a good idea. We should probably add this information in our intranet so as to standardize our terminology @NathanMolinier

BTW: Does your manual_correction script automatically identifies if there was a modification in the segmentation, and then applies either "Visually verified" or "Manually corrected"?

Regarding this point, I discussed with @valosekj and I think that we should stick to our standards and use the field "Name" instead of "Note". For more information about this please check this comment in manual correction.

Manual correction script needs to be updated for sure regarding json sidecars. Also few JSON sidecar examples are presented in our new convention.

@NathanMolinier
Copy link

NathanMolinier commented Jan 26, 2024

The field "SpatialReference": "orig" should also be added @plbenveniste

@plbenveniste
Copy link
Collaborator

Great idea @NathanMolinier ! However, because of consistency, I suggest adding this field to the entire dataset and not just to these specific segmentations. An issue was created #75

@NathanMolinier
Copy link

Yes indeed ! All the json sidecars should have this "SpatialReference" 👍

@valosekj
Copy link
Member

Regarding the "SpatialReference", you could test manual-correction PR #76, which now adds "SpatialReference" automatically.

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

4 participants