def test_relative_rmse(): """ Test the calculation of relative RMSE from two model objects While you're at it, test the SphereModel class as well. """ Model1 = SphereModel(data_path+'small_dwi.nii.gz', data_path + 'dwi.bvecs', data_path + 'dwi.bvals',) Model2 = SphereModel(data_path+'small_dwi.nii.gz', data_path + 'dwi.bvecs', data_path + 'dwi.bvals',) # Since we have exactly the same data in both models, the rmse between them # is going to be 0 everywhere, which means that the relative rmse is # infinite... npt.assert_equal(ozm.relative_rmse(Model1, Model2), np.inf * np.ones(Model1.shape[:-1]))
help='Bvals file (FSL format)') parser.add_argument('out_file', action='store', metavar='File', help='Output file name (.nii.gz)') parser.add_argument('--mask_file', action='store', metavar='File', help='Mask file (only the voxels within the binary mask will be analyzed (.nii.gz; default: analyze all) ', default=None) params = parser.parse_args() if __name__ == "__main__": Model1 = dti.TensorModel(params.dwi_file1, params.bvecs_file1, params.bvals_file1, mask=params.mask_file, params_file='temp') Model2 = dti.TensorModel(params.dwi_file2, params.bvecs_file2, params.bvals_file2, mask=params.mask_file, params_file='temp') # Do it and save: nib.Nifti1Image(ana.relative_rmse(Model1, Model2), Model1.affine).to_filename(params.out_file)