Skip to content

Commit

Permalink
Hack for loading radiological volumes with uint8 data range
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouget committed Feb 16, 2024
1 parent 6ed0d4a commit fed761a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ def input_file_category_disambiguation(input_filename: str) -> str:
image_type = image.GetPixelIDTypeAsString()
array = sitk.GetArrayFromImage(image)

# @TODO. Have encountered FLAIR images with integer values in [0, 255], from DICOM conversion, which will be
# failed associated as annotations...
if len(np.unique(array)) > 255 or np.max(array) > 255 or np.min(array) < -1:
category = "MRI"
# If the input radiological volume has values within [0, 255] only. Empirical solution for now, since less than
# 10 classes are usually handle at any given time.
elif len(np.unique(array)) >= 25:

This comment has been minimized.

Copy link
@andreped

andreped Jun 1, 2024

Member

@dbouget Where did you get 25 from? Typo? Did you mean 255?

This comment has been minimized.

Copy link
@andreped

andreped Jun 1, 2024

Member

This also sounds like this condition could just be merged with the statement above as a separate or condition?

This comment has been minimized.

Copy link
@dbouget

dbouget Jun 3, 2024

Author Collaborator

It's not a typo, some FLAIR images have integer values in the range [0, 255] and they were assigned as labels and not MR scans, though I picked 25 randomly and it will work so long as we don't deal with more than 25 classes....
Could likely be merged into a single if statement yes!

category = "MRI"
else:
category = "Annotation"
return category
Expand Down

0 comments on commit fed761a

Please sign in to comment.