Closed muschellij2 closed 1 month ago
This error is due to:
target_dims = (512*2, 512*2, 64)
ct = pad_image(ct, target_dims)
from https://github.com/MASILab/tbi_ct_lesion_segmentation/blob/master/utils/patch_ops.py#L287, which calls https://github.com/MASILab/tbi_ct_lesion_segmentation/blob/master/utils/pad.py#L3.
We have registered our data to the MNI template:
>>> ct.shape
(184, 224, 184)
which now causes errors. But even if we had not, we have some thin-slice CT scans which have dimensions of 512x512x100 let's say, and this will fail as well, correct?
Thank you for bringing this to our attention. The pad_image()
function has now been generalized to pad appropriately for arbitrary image sizes, where new images are padded to dimensions of the nearest greatest multiple of 2^4 (required for utilization of the U-net).
https://github.com/MASILab/tbi_ct_lesion_segmentation/blob/master/utils/pad.py
We have the data in a standard space (184, 224, 184). Trying the update, I get:
*** PREPROCESSSING ***
100%|███████████████████████████████████████████| 21/21 [00:02<00:00, 9.83it/s]
Total number of lesion patches = 361384.0
Allowed total number of patches = 10000
0%| | 0/10 [00:00<?, ?it/s
Traceback (most recent call last):
File "train.py", line 119, in <module>
num_channels=num_channels)
File "/scratch/users/jmusche1@jhu.edu/pitch_run/tbi_ct_lesion_segmentation/utils/patch_ops.py", line 297, in CreatePatchesForTraining
CTPatches[indices[cur_idx], :, :, :] = ct_patch
ValueError: could not broadcast input array from shape (78,128,1) into shape (128,128,1)
This appears to be an issue with the patch collection at edges of CT slices.
I've tried a quick fix, please let me know whether this addresses the problem.
For reference, the fix is at: https://github.com/MASILab/tbi_ct_lesion_segmentation/blob/master/utils/patch_ops.py#L225 where images are padded out further to allow for patches to be gathered from edges of slices.
Can't share the data right now, but running into
ValueError: ((420, 420), (400, 400), (-60, -60)) cannot contain negative values.
, when trying on our data: