-
Notifications
You must be signed in to change notification settings - Fork 113
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
fix: 🐛 IDC1346, properly detect binary segmentations declared as fractional #309
base: master
Are you sure you want to change the base?
Conversation
b94f07f
to
5c0bce6
Compare
@Punzo thanks for digging into this 👍 Do we know what the segmentations are supposed to look like for this dataset? From what I see the first image might be correct but the second looks odd. My guess is that the submitters to TCIA had labelmaps and decided it was easier to put them in a single segment and call it fractional rather than going through the process to make bitplanes. The images are described here but it's hard to tell how that would map to what we see here. They say "Derived objects from the DWI and DCE acquisitions are included for the convenience of the user. Some of these are not strictly DICOM compliant and may not be readable by all DICOM software packages." So I'm not sure what we should expect. Regarding the tests, yes, there's a PR to fix that: #308 following conversation here: #303 |
I am afraid we do not! Very unfortunately, David Newitt at UCSF, who did this conversion using in-house matlab code (I believe), retired, and there isn't anyone to ask for clarifications about those segmentations. These are the collections where FRACTIONAL is encountered: ispy2, qiba_ct_1c, breast_mri_nact_pilot, acrin_6698, ispy1. All except the QIBA one come from David Newitt / UCSF, from what I know :-( I can generate sample URLs for image+segmentation pairs from each of the collections mentioned, if this helps. But this becomes complete guesswork... Maybe indeed we should shelve support of those collections until we have FRACTIONAL support implemented. |
not sure, but the second segmentation is defined as a mask, so maybe is the mask used in the seg and why is so ackward. Please let me know if I should take any other action.
Nice! |
Up to you, but even with proper support, the shape of the segmentation will not change respect the one in my second screenshot (only the edges will be "smoothed" with proper support). In the conversion to binary, I just have essentially taken the pixels with highest value (48) and put their value to 1 (and 0 to all others pixels). So the shape of seg would not change. See https://github.com/dcmjs-org/dcmjs/pull/309/files#diff-077798721d0df020ee8184a2f54d4459dba916e19c86ac0f0aecc4e6ea80bf2fR1274-R1303 |
Given this discussion that's what I would vote for. |
Ok then for the second segmentation, i will just remove the code that does the thresholding and I will reput the warning that fractional segs are not supported. The first seg will be loaded as a binary. |
Done in 4736ff1 @pieper @fedorov. Please let me know if I need to address anything else. As soon as this will be merged, I will update OHIF. |
P.S.: if you meant that we should just not support the full collection, I will leave to you to close this PR. |
@fedorov should we close this? |
I feel bad about discarding all the work you have done, but I agree with Steve - implementing custom rules based on assumptions can be dangerous. Let me also discuss this with @dclunie before we finalize the decision and close this PR. |
For the sake of completeness, this dataset is from the collection documented here: https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=50135447#501354470d1c0b53772a4fba8580e8b19f65069b Specifically, there is Analysis mask files description. However, conventions described in this document do not seem to be followed in the sample investigated here. |
I looked at one of these, and even though it does not appear to follow the exact description mentioned, it does look suspiciously like a bit mask with various combinations bits from 0x00 through 0x20 set: % dchist -h ACRIN-6698-102212/04-04-2002-102212T0-ACRIN-6698ISPY2MRIT0-82630/61900.000000-ISPY2\ VOLSER\ uni-lateral\ cropped\ Analysis\ Mask-08921/1-1.dcm [0] 42423 p=0.00809155 e=0.0562311 cum=0.0562311 This is obviously not a valid use of a DICOM SEG object if that is indeed the case (nor is what is described in the document). But potentially something that could be split into separate binary segmentations if someone wanted to bother. I don't think we (IDC) should expect any viewer to support such an invalid object though, regardless. |
Found a private data element within the SEG object that describes the mask: (0x0117,0x10d3) LO Mask Legend VR= VL=<0x0088> <00000001 ( 1) : PE threshold\00000010 ( 2) : other SER filter\00010000 (16) : automatic background threshold\00100000 (32) : manual VOI > |
Thank you for investigating @dclunie
Agreed, let's close this as an issue but perhaps add a link to this discussion someplace. Do we have something like release notes or a "known issues" document to collect links to discussions like this? |
Perhaps we should put in a TCIA HelpDesk request to correct the invalid SEG objects? In that, we could document the problem and suggest a solution. |
this fix OHIF/Viewers#1346.
https://viewer.imaging.datacommons.cancer.gov/viewer/1.3.6.1.4.1.14519.5.2.1.7695.4164.330974290504454152904316943429
has two segmentations:
1)
this one was actually a binary seg (but the DICOM multiframe.SegmentationType is set to fractional). The seg array values are [0,1] (note: the multiframe.MaximumFractionalValue is 255).
There was already a check for this case (binary seg, but defiined as fractional), but the check was checking if the array values were either [0,multiframe.MaximumFractionalValue]. Now I changed in a way that it will check if the values are [0, firstNonZeroValue]. In this case the seg will be loaded as a normal binary.
here the seg has various values in the array (something like: [0, 12, 33, 48]). For this case, I added a flag (default to true) for converting the seg into a binary one. The conversion is done with a simple thresholding where I use the maximum value found in the array (multiframe.MaximumFractionalValue does not look be reliable number, at least for IDC datasets) and I multiply it for a thesholdingParameter (80% in default).
@pieper can you please review? thanks!