skliff13 / CT_RegSegm

Segmentation of lungs in 3D Computed Tomography (CT) scans via non-rigid image registration
23 stars 0 forks source link

Two issues in use #1

Open whisney opened 3 years ago

whisney commented 3 years ago

For most images, the code can execute normally, but it will report errors for some images.

  1. For almost all images with the slice thickness of 10mm in my dataset, it will report errors. I found that the layer thickness of the image is regulated to 1.5-3 mm in https://github.com/skliff13/CT_RegSegm/blob/32956deeb5a541524e0e86adda8b8f3488c11ad5/regsegm_utils.py#L89, but the case that the slice thickness of the input image is greater than 6 mm is not considered. So, I added the following code, and the problem was solved:

    while voxel_dimensions[2] > 3: new_size = (img.shape[0], img.shape[1], img.shape[2] * 2) img = imresize(img, new_size, order=0) voxel_dimensions[2] /= 2

  2. There is another issue that I can't solve. The shape of result.raw and mov doesn't match. Errors are reported as follows:

    Traceback (most recent call last): File "run_regsegm.py", line 23, in rs.process_file(path) File "/home/zyw/pulmonary_tuberculosis/CT_RegSegm-master/ct_reg_segmentor.py", line 111, in process_file moved_mask = reg.register3d(moving, fixed, mask, self.reg_dir) File "/home/zyw/pulmonary_tuberculosis/CT_RegSegm-master/regsegm_utils.py", line 69, in register3d moved_mask = read_mhd_simple(out_dir + '/result', mov.shape) File "/home/zyw/pulmonary_tuberculosis/CT_RegSegm-master/regsegm_utils.py", line 37, in read_mhd_simple arr = np.reshape(arr, shape[::-1]) File "<__array_function__ internals>", line 6, in reshape File "/home/zyw/zywenvi/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 299, in reshape return _wrapfunc(a, 'reshape', newshape, order=order) File "/home/zyw/zywenvi/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 58, in _wrapfunc return bound(*args, **kwds) ValueError: cannot reshape array of size 2719744 into shape (128,128,128)

skliff13 commented 3 years ago

Thanks for the report. I need to say that this code was originally written in MATLAB and later transferred to Python with lots of redundant pieces of code. Frankly speaking, all this code needs massive re-writing. Not sure whether I will find time for this before the segmentation method implemented here gets utterly outdated.