Closed tashrifbillah closed 4 years ago
Proposed solution 1:
use spm_bspline with order=1 (linear interpolation):
# resample the mask ---------------------------------------------------------------
inPrefix= lowResMaskPath.split('.')[0]
savemat(inPrefix+'_sp.mat', {'sp_high':sp_high,'sp_low':sp_low, 'imgDim':lowResImg.shape[:3], 'sOrder':1})
highResMask= resize_spm(lowResMask, lowResMaskPath.split('.')[0])
Most of the difference is gone, while some is observed in the skull region, again on the last slice along the Z axis.
Double checked
Proposed solution 2:
Use reflect
mode with scipy interpolation:
highResMask= resize(lowResMask.astype('float'), (sx, sy, sz), order= 1, mode= 'reflect')
There is more difference than that of spm_bspline. Difference is observed along all axes.
Proposed solution 3:
Use symmetric
mode with scipy interpolation:
highResMask= resize(lowResMask.astype('float'), (sx, sy, sz), order= 1, mode= 'symmetric')
Same difference as that of reflect
mode.
Guess: the difference in reflect
and symmetric
modes are stemming from morphological operation performed in Python.
Decision: accept spm_bspline(order=1)
as the suitable interpolation technique for mask interpolation.
The following commit implemented the above decision:
https://github.com/pnlbwh/dMRIharmonization/commit/7b106d4a9fce0863ed75c1aafc8ddc1d7e777eb8
@tashrifbillah will merge the pull request soon. Keeping it stand by for a day in case we want to make more changes:
Merged PR #30 into spm-bspline
branch.
Issue marked for closing
Resampled mask in Python is zero on the last slice along Z axis
Experiment performed on the following images
Suheyla MATLAB
Tashrif Python
This zero slice makes subsequent L0 and FA features zero on that particular slicer.
@suheyla2 and @yrathi believe this error accounts for the remaining difference between MATLAB and PYTHON. @tashrifbillah argued that the anomaly is same for all cases and all sites. @yrathi refuted, the zero slice triggers mis-registration between two cases where one is affected by this anomaly and the other is not. @suheyla2 observed this anomaly in some cases where rounding during grid creation affects resampling.
In particular, scipy
resize
package is used to peform mask resampling in Pythonhttps://github.com/pnlbwh/dMRIharmonization/blob/spm-bspline/lib/resampling.py#L106
On the other hand, MATLAB uses interp3 function:
https://github.com/pnlbwh/harmonization/blob/master/Utilities/harmonizationFunctions/resampleData.m#L25
Possible solution:
Other than looking for equivalent resampling option in Python (according to our experiment before, there is none), we better use MATLAB executable for mask resampling as well. Just include the mask resampling code segment in https://github.com/pnlbwh/dMRIharmonization/blob/spm-bspline/lib/spm_bspline_exec/bspline.m
cc: @sbouix