-
Notifications
You must be signed in to change notification settings - Fork 16
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
[FEAT]: BAMF nnUNet Breast MR Model #82
base: main
Are you sure you want to change the base?
Conversation
@LennyN95 , it looks like MHubIO only support nnUNet-v1 models at the moment? I am referring to this code here: https://github.com/MHubAI/mhubio/blob/main/mhubio/modules/runner/NNUnetRunner.py#L21 The breast segmentation model was trained on nNUNet-v2. Let me know how to proceed with this. cc. @vanossj |
Hi @rahul99, this sounds like an interesting model and another great addition to the MHub model repository!
|
{
"ContentCreatorName": "BAMFHealth^AI",
"ClinicalTrialSeriesID": "Session1",
"ClinicalTrialTimePointID": "1",
"SeriesDescription": "AIMI breast-tumor AI segmentation",
"SeriesNumber": "300",
"InstanceNumber": "1",
"BodyPartExamined": "BREAST",
"segmentAttributes": [
[
{
"labelID": 1,
"SegmentDescription": "Breast",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Breast-Tumor-MRI",
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "123037004",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Anatomical Structure"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "76752008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Breast"
},
"recommendedDisplayRGBValue": [56, 125, 255]
},
{
"labelID": 2,
"SegmentDescription": "Fibroglandular Tissue",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Breast-Tumor-MRI",
"AnatomicRegionSequence": {
"CodeValue": "76752008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Breast"
},
"AnatomicRegionModifierSequence": {
"CodeValue": "51440002",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Right and left"
},
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "C35869",
"CodingSchemeDesignator": "NCIt",
"CodeMeaning": "Radiologic Finding"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "C114467",
"CodingSchemeDesignator": "NCIt",
"CodeMeaning": "Breast Fibroglandular Tissue"
},
"recommendedDisplayRGBValue": [128, 174, 128]
},
{
"labelID": 3,
"SegmentDescription": "Structural Tumor",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Breast-Tumor-MRI",
"AnatomicRegionSequence": {
"CodeValue": "76752008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Breast"
},
"AnatomicRegionModifierSequence": {
"CodeValue": "51440002",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Right and left"
},
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "49755003",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Morphologically Altered Structure"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "4147007",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Mass"
},
"recommendedDisplayRGBValue": [144, 238, 144]
}
]
],
"ContentLabel": "SEGMENTATION",
"ContentDescription": "Image segmentation",
"ClinicalTrialCoordinatingCenterName": "dcmqi"
} |
@LennyN95 , Hey Leo, I have posted the json containing code for ROIs above. Please have a look and let me know if I missed something. I have also added NNUnetRunnerV2. Its an easy extension of the NNUnetRunner that you wrote so beautifully. Its a slightly different PR as it contains two models so there might be something I probably missed. Please review and let me know :) |
@rahul99, this looks great so far! I noticed that you use |
we can switch it to neoplasm |
@LennyN95 , since we did not have the ROI entries in SegDB, I was testing the container by specifying other ROIs that are available in SegDB. Since the process outputs three ROIs and I see that entry for The flow worked great when I passed three random ROIs that are available in SegDB (Except I think refreshing the base image might solve this? |
@LennyN95 , a small query on the NNUnetRunner as well. In this line: Comment says add symlink to input dir, but we add symlink to output dir. Also, I don't think that's needed? We have already organised the data into appropriate folder structure and nnunet predict function does not use it. Let me know what your thoughts are on this? |
@LennyN95 , Hey Leo, do you have any updates on the SegDB entries for Breast and FGT? |
Hey @rahul99, I was looking into this and found that it'd be good to discuss briefly with @dclunie if available at PW. In the meanwhile, I added an option to specify custom triplets and segments in the config file that will be available as SegDB ID's at runtime. You can either register custom triplets and custom segments in your runner module class (outside of the class definition) or define them in the config file as explained here. Note, that custom triplets and segments should mainly be used to simplify development and to accommodate the time until a segdb update propagates into a new base image. However, in special cases where we won't add a segment to our universal SegDB this is a transparent way to define custom segments. |
I am not in Boston for PW41 but am available online; FYI, since the subject of codes for FGT came up, see DICOM CP 2226 (currently out for ballot). |
@LennyN95 since you introduced that capability of registering custom triplets, it might be good to add some basic validation checks. Coding scheme designator must come from the list in the standard: https://dicom.nema.org/medical/dicom/current/output/chtml/part16/chapter_8.html, or must start with the "99" prefix. |
Good point @fedorov. The default is indeed 99segdb, is hardxoding the list and validating against it a valuable solution? I assume this doesn't change frequently if at all? |
I believe the recommendation is to have all caps, so it would be 99SEGDB. But private coding scheme should be absolutely last resort!
Yes, they don't. But a basic check (ie if it does not start from 99 it must come from the defined list) would prevent someone from using, for example, an invalid value "LUNGMASK" for coding scheme designator. |
@fedorov I implemented it all uppercase, see https://github.com/MHubAI/SegDB/blob/6b2db45ecdc711c5dee93990b73594ccd6a77d9a/segdb/classes/Triplet.py#L63C105-L63C112 ;) Just to make clear, I asked if this changes frequently to get an idea if hardcoding the list to check against is a valuable solution, I assume yes then. This is a simple check we can easily include! Note that in general, this is more thought to be used during development to have a quick placeholder and then to be resolved during the review process. |
@rahul99, lets switch the FGT code to SCT 1342375003. That way we can keep codes in snowmed as much as possible. so change metadata for label 2 to: {
"labelID": 2,
"SegmentDescription": "Fibroglandular Tissue",
"SegmentAlgorithmType": "AUTOMATIC",
"SegmentAlgorithmName": "BAMF-Breast-Tumor-MRI",
"AnatomicRegionSequence": {
"CodeValue": "76752008",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Breast"
},
"AnatomicRegionModifierSequence": {
"CodeValue": "51440002",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Right and left"
},
"SegmentedPropertyCategoryCodeSequence": {
"CodeValue": "123037004",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Anatomical Structure"
},
"SegmentedPropertyTypeCodeSequence": {
"CodeValue": "1342375003",
"CodingSchemeDesignator": "SCT",
"CodeMeaning": "Structure of fibroglandular tissue of breast"
},
"recommendedDisplayRGBValue": [128, 174, 128]
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category: C_RADIOLOGIC_FINDING
should change too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run mhub.update inside of your image (during development) or re-build with the latest base image docker pull mhubai/base
.
@LennyN95 , thanks for making breast related entries available on SegDB. I've rolled back the config :) On standby if any more changes required. Thanks! |
I have made the change. Thanks for educating me on this as well. :) |
@LennyN95 , following your comment on the other PR, I have uploaded the output segmentation file above. Thanks! |
/test sample:
idc_version: 17.0
data:
- SeriesInstanceUID: 1.3.6.1.4.1.14519.5.2.1.57828200249886597927204318690632931889
aws_url: s3://idc-open-data/bf0fc92d-e708-468c-af90-0c02329f636d/*
path: dicom
reference:
url: https://www.dropbox.com/scl/fi/o2b26zrb20e080rcc0z5d/bamf_nnunet_mr_breast.zip?rlkey=8m434go1u7zthemx0w245pors&st=wetbolof&dl=0 |
Please note, we updated our base image. All mhub dependencies are now installed in a virtual environment under We also simplified our test routine. Sample and reference data now have to be uploaded to Zenodo and provided in a mhub.tom file at the project root. The process how to create and provide these sample data is explained in the updated testing phase article of our documentation. Under doi.org/10.5281/zenodo.13785615 we provide sample data as a reference. |
@rahul99 thx for adapting to the new test routine! To make the test pass, you can reference the download link to the zip file (https://zenodo.org/records/13843612/files/bamf_nnunet_mr_breast.test.zip?download=1). |
@LennyN95 , thanks for pointing it out. Let me know if you need more information from us. Looking forward to getting this PR over the line |
/test sample:
idc_version: 17.0
data:
- SeriesInstanceUID: 1.3.6.1.4.1.14519.5.2.1.57828200249886597927204318690632931889
aws_url: s3://idc-open-data/bf0fc92d-e708-468c-af90-0c02329f636d/*
path: dicom
reference:
url: https://zenodo.org/records/13843612/files/bamf_nnunet_mr_breast.test.zip?download=1 |
@LennyN95 , just circling back to see if you have an update for us. Thanks! |
Since this model relies on NNUnet V2, I paused the submission process until MIC-DKFZ/nnUNet#2556 is resolved. This will lead to an improved UX for MHub models and we're actively working on this now. Let me know if you are running against any deadlines and feel free to share your opinion / feedback in the related issue. Thx @rahul99! |
No description provided.