-
Notifications
You must be signed in to change notification settings - Fork 147
169 | 4 MetaData and PreprocessCT refactored, grt123 processing adopted #170
169 | 4 MetaData and PreprocessCT refactored, grt123 processing adopted #170
Conversation
@@ -288,23 +242,17 @@ def predict(image_itk, nodule_list, model_path="src/algorithms/classify/assets/g | |||
|
|||
if torch.cuda.is_available(): | |||
casenet = torch.nn.DataParallel(casenet).cuda() | |||
# else: | |||
# else: |
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'm not sure if the indentation level is now correct?
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.
Thanks :)
1c51d07
to
92addb1
Compare
@@ -21,10 +21,12 @@ def mm2voxel(coord, origin=0., spacing=1.): | |||
origin = scipy.ndimage._ni_support._normalize_sequence(origin, len(coord)) | |||
spacing = scipy.ndimage._ni_support._normalize_sequence(spacing, len(coord)) | |||
coord = np.ceil(coord - np.array(origin)) / np.array(spacing) | |||
print(coord) |
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.
Committed by accident?
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.
Yep
import numpy as np | ||
import scipy.ndimage | ||
from src.preprocess import load_ct | ||
|
||
|
||
class Params: | ||
"""Params for CT data preprocessing. | ||
"""Params for CT data pre-processing. |
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.
Please try and make these sorts of changes in a separate commit in future.. much easier to review :)
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.
Ok, thank you for the review :)
@@ -52,61 +59,81 @@ def __init__(self, hu_transform=False, clip_lower=None, clip_upper=None, | |||
raise ValueError('The min_max_normalize should be bool or int') | |||
self.min_max_normalize = min_max_normalize | |||
|
|||
if not isinstance(scale, (int, float)) and (scale is not None): | |||
raise ValueError('The scale should be float or int') |
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.
TypeError
would seem more suitable here.
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.
Indeed it is.
|
||
class PreprocessCT: | ||
if dtype not in np.typeDict.keys() and (dtype is not None): | ||
raise ValueError('The dtype should be one of appropriate np.dtype') |
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.
(ditto)
prediction/src/tests/test_load_ct.py
Outdated
assert all([m_axis == o_axis for m_axis, o_axis in zipped]) | ||
|
||
meta = load_ct.load_ct(metaimage_path, voxel=False) | ||
spacing = list(reversed(meta.GetSpacing())) | ||
spacing = meta.GetSpacing()[::-1] |
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.
Hm? :)
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.
The SimpleITK
reads CT scan array from MetaImages in zyx
order, methods like GetSpacing | GetOrigin return values in xyz
order, though.
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.
Can you add this as a comment in the code? :)
14543c3
to
389824f
Compare
self.stride = 4 | ||
self.filling_value = 160 | ||
|
||
def __call__(self, imgs, target): |
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.
Kinda gross to abuse dunderscore call. I'm assuming this code is from elsewhere?
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.
Yes, this code had been taken from the edited version of the original SimpleCrop class. I've put unchanged functions into test_grt123_preprocess.py
in order to ensure absolute interchangeability.
389824f
to
1acd7c7
Compare
Thanks! |
Refactored classes
PreprocessCT
andMetaData
. Preprocessing of grt123 algorithm has been replaced by them.Description
PreprocessCT
is now a subclass ofParams
, both are documented along withMetaData
.Correct me if I've mistaken, but there is a bug in the processing part of the grt123 prediction algorithm adoptation:
spacing
will became redundant after re-sampling.nod_location
should also take into account both theorigin
of the CT scan andnew_spacing = [1, 1, 1]
and therefore shal looks likeNeglection of the
origin
andnew_spacing
leads to estimation of a complitely different CT part.SimpleCrop
requiresnp.pad
to be applied on each patch independently for the same CT scan.The aforementioned bugs were corrected along with the adoptation of grt123 preprocessing via
preprocess_ct.py
Reference to official issue
This addresses #169 and partially covers #4
How Has This Been Tested?
For the
grt123_preprocess
, all tests lie intest_grt123_preprocess
and are written in order to ensure fully interchangeability.CLA