Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fixed resizing for wavelet filtering (resizing was scrambling image) #346

Merged
merged 2 commits into from
Feb 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions radiomics/imageoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,9 @@ def _swt3(inputImage, wavelet='coif1', level=1, start_level=0, axes=(2, 1, 0)):
raise ValueError('Expected 3D data array')

original_shape = matrix.shape
adjusted_shape = tuple([dim + 1 if dim % 2 != 0 else dim for dim in original_shape])
padding = tuple([(0, 1 if dim % 2 != 0 else 0) for dim in original_shape])
data = matrix.copy()
data.resize(adjusted_shape, refcheck=False)
data = numpy.pad(data, padding, 'constant')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, should change boudnary mode to wrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if not isinstance(wavelet, pywt.Wavelet):
wavelet = pywt.Wavelet(wavelet)
Expand All @@ -764,14 +764,14 @@ def _swt3(inputImage, wavelet='coif1', level=1, start_level=0, axes=(2, 1, 0)):
dec_im = {}
for decName, decImage in six.iteritems(dec):
decTemp = decImage.copy()
decTemp = numpy.resize(decTemp, original_shape)
decTemp = decTemp[[slice(None, -1 if dim % 2 != 0 else None) for dim in original_shape]]
sitkImage = sitk.GetImageFromArray(decTemp)
sitkImage.CopyInformation(inputImage)
dec_im[str(decName).replace('a', 'L').replace('d', 'H')] = sitkImage

ret.append(dec_im)

data = numpy.resize(data, original_shape)
data = data[[slice(None, -1 if dim % 2 != 0 else None) for dim in original_shape]]
approximation = sitk.GetImageFromArray(data)
approximation.CopyInformation(inputImage)

Expand Down