Add tensoflow dataset_from_dicom_filesnames#29
Add tensoflow dataset_from_dicom_filesnames#29blowekamp wants to merge 1 commit intoSimpleITK:mainfrom
Conversation
Add method to create a Tensorflow Dataset flow from a list of filenames readable by SimpleITK.
zivy
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.