-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add tensoflow dataset_from_dicom_filesnames #29
base: main
Are you sure you want to change the base?
Conversation
Add method to create a Tensorflow Dataset flow from a list of filenames readable by SimpleITK.
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.
Really like it, especially the lazy loading via map and the _sitk_read_image
function.
|
||
|
||
def _sitk_read_image( | ||
filename: tf.string, image_path=None, encoding="utf-8", channels=3 |
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.
image_path
- possibly rename to image_dir_path
?
""" | ||
|
||
image = sitk.RescaleIntensity(image, outputMinimum=0.0, outputMaximum=255.0) | ||
image = sitk.Cast(image, sitk.sitkUInt8) |
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.
I think these two rows should be removed (rescale+cast). The DICOM images can be color.
if image.GetDimension() == 3 and image.GetSize()[2] == 1: | ||
image = image[:, :, 0] | ||
|
||
if image.GetDimension() == 2: |
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.
This should probably also allow for 3D images.
if image_path: | ||
str_fn = str(Path(image_path) / str_fn) | ||
|
||
image = sitk.ReadImage(str_fn, sitk.sitkFloat32) |
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.
Set the IO to GDCM? This is so that it matches the intent of dataset_from_dicom_filenames
. Or just change that function name to dataset_from_filenames
?
Please describe the expected behavior and features at a higher level and not at the if statements. This code is a not terrible specific to "DICOM" except the conversion of 3D of 1 slice to 2D. Adding support for "series" would be an additional feature more specific for 3D DICOM series. This was originally written for support for 2D chest x-ray images. |
The code indeed is not DICOM specific. I think a more general interface makes sense. A function No need to support 3D images as series of files. Users should convert a series to a single 3D image prior to training as the read operation is much faster (will be very slow if all volumes are represented by series of images). |
Add method to create a Tensorflow Dataset flow from a list of filenames readable by SimpleITK.