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

Ultrasound Deidentification - Pixel Masking Failure #165

Closed
wetzelj opened this issue Nov 17, 2020 · 4 comments
Closed

Ultrasound Deidentification - Pixel Masking Failure #165

wetzelj opened this issue Nov 17, 2020 · 4 comments

Comments

@wetzelj
Copy link
Contributor

wetzelj commented Nov 17, 2020

When deidentifying an ultrasound, an error was encountered when the ultrasound study contained single image RGB stills as well as RGB cine clips. When the study encountered one of these single-image stills, an exception occurred:

Exception: operands could not be broadcast together with shapes (768,768,1024) (768,1024,3)

This issue appears to be due to an error with clean.py line 223. Since the original shape of the image in this scenario is (X, Y, channel), when using the numpy.tile() function to "stack" the mask into all channels, the mask is incorrectly stacked to a shape of (X, X, Y)

I'm not 100% sure what the correct fix should be for this. If self.original.shape == 4, we have a RGB cine clip - the logic works appropriately. If self.original.shape == 2 we have a single-frame greyscale image - again, the logic works appropriately. However, if self.original.shape == 3, it appears that we are in an ambiguous state. From the comment on line 222, it appears that the intent - as coded - was that in this state we expected to have a greyscale cine clip - which would have the shape of (frames, X, Y). In my error case, however, the file being deidentified, was not a greyscale cine clip, but was instead a single-frame RGB image with the shape (X, Y, channel).

Instead of relying on the shape to indicate the action to take here, I wonder if we should look to the (0028,0002) SamplesPerPixel and (0028,0008) NumberOfFrames tags to determine how to appropriately build the 3 dimensional mask. I'd appreciate other thoughts on this. This is the first I've really had to dig into Ultrasounds.

@vsoch
Copy link
Member

vsoch commented Nov 17, 2020

Oh interesting, I didn't know about the single frame RGB image. Looking at SamplesPerPixel it notes that:

For monochrome (gray scale) and palette color images, the number of planes is 1. For RGB and other three vector color models, the value of this Attribute is 3.

So would you want to add a check under original.shape == 3 to have different logic depending on this field? If you want to open a PR with this suggested change, it would be great - we want to also have a test case (with a de-identified image) that makes sure it continues to work.

@wetzelj
Copy link
Contributor Author

wetzelj commented Nov 17, 2020

Sounds good. I'll get started on something. It may take me a bit to get the sample image for upload created and approved.

@wetzelj
Copy link
Contributor Author

wetzelj commented Nov 18, 2020

If you'd like to take a look at what will be coming, it's committed here. I'm still waiting for a greyscale cine clip to test with and still waiting for images that I can contribute to the project. Once I have these, I'll commit and open the pull request.

vsoch pushed a commit that referenced this issue Dec 1, 2020
* Correcting issue with deidentifying pixels on RGB images
* Correcting issue with deidentifying pixels on cine clips
Corrected bugs with "all" keyword.  Added additional test methods.
* Adding ultrasound test images, handle compressed test images

Adding new images to test the variant dimensions that can be encountered when deidentifying pixel data.  Introduced the ability to handle zipped test files to bypass the github 100Mb file size limit for the RGB cine clip.  Renamed the test file for the pixel dimension tests.
@wetzelj
Copy link
Contributor Author

wetzelj commented Dec 7, 2020

Fixed with #166

@wetzelj wetzelj closed this as completed Dec 7, 2020
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