Example #1
0
def test_rsquared():
    ii = ozm.rsquared(TM1, TM2)

    # Test for regression:
    npt.assert_almost_equal(ii,
    np.array([[[ 0.41738295,  0.5686638 ,  0.66632678,  0.66796424],
        [ 0.55782746,  0.52997752,  0.65248008,  0.79295422]],

       [[ 0.49519897,  0.52195252,  0.70362685,  0.62545745],
        [ 0.43410031,  0.56910023,  0.76395852,  0.73071651]],

       [[ 0.50371373,  0.56810418,  0.53169063,  0.60985997],
        [ 0.53667339,  0.69261167,  0.70018453,  0.63229423]]]))
                    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.rsquared(Model1, Model2),
                    Model1.affine).to_filename(params.out_file)

                    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.rsquared(Model1, Model2),
                    Model1.affine).to_filename(params.out_file)