-
Notifications
You must be signed in to change notification settings - Fork 119
Description
ct_scans/
scan_a/
segmentation.nii.gz
imaging.nii.gz
scan_b/
segmentation.nii.gz
imaging.nii.gz
scan_c/
segmentation.nii.gz
imaging.nii.gz
Above is the file structure of my dataset where segmentation.nii.gz and imaging.nii.gz are 3D NIFTI files with multiple slices. Also, I'm using code resembling the piece below to load the dataset.
interface = NIFTI_interface(channels=1, classes=2)
data_path = r".\ct_scans"
data_io = Data_IO(interface, data_path)I'm especially worried about my training data loading because I had to change the slice_axis in the NIFTIslicer_interface init for the sample_data size to be correct while following this tutorial.
When I run sample = data_io.sample_loader("scan_c", load_seg=True), I get a Sample of shape (H, W, N, C). N is my number of slices and my C = 1.
I found visualize_samples but I think it may be bugged. At this line, it tries to convert the sample to grayscale, even though my num of channels is 1, which leads to an IndexError. Here are the code and error respectively.
sample = data_io.sample_loader("scan_c", load_seg=True)
visualize_samples([sample], mask_seg=True, mask_pred=False)Error:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/nwogu/OneDrive/Documents/4mLab/MIScnn-UNet/data_io.py", line 39, in <module>
visualize_samples([sample], mask_seg=True, mask_pred=False)
File "C:\Users\nwogu\AppData\Local\Programs\Python\Python39\lib\site-packages\miscnn\utils\visualizer.py", line 154, in visualize_samples
sample.img_data = normalize(sample.img_data, to_greyscale=True, normalize=True)
File "C:\Users\nwogu\AppData\Local\Programs\Python\Python39\lib\site-packages\miscnn\utils\visualizer.py", line 99, in normalize
return normalize_volume(sample, to_greyscale, normalize)
File "C:\Users\nwogu\AppData\Local\Programs\Python\Python39\lib\site-packages\miscnn\utils\visualizer.py", line 48, in normalize_volume
img[:, :, :] = vec_luminosity(img[:, :, :, 0], img[:, :, :, 1], img[:, :, :, 2])
IndexError: index 1 is out of bounds for axis 3 with size 1
I may be misusing it though, I am not sure. Please, let me know. :)
As an aside but kinda related, I tried writing my own visualize_samples but I could not find the definition of overlay_segmentation as used here.