SHM1 = ozm.SphericalHarmonicsModel(
        dwi1,
        bvecs1,
        bvals1,
        mask=brain_mask,
        model_coeffs=csd_coeffs[0],
        response_file=response_files[0],
        #axial_diffusivity=AD1,
        #radial_diffusivity=RD1
    )

    SHM2 = ozm.SphericalHarmonicsModel(
        dwi2,
        bvecs2,
        bvals2,
        #mask = mask_array,
        mask=brain_mask,
        model_coeffs=csd_coeffs[1],
        response_file=response_files[1],
        #axial_diffusivity=AD2,
        #radial_diffusivity=RD2
    )

    rmse_file_name = '%s%s_relative_rmse_b%s.nii.gz' % (
        data_path, 'SphericalHarmonicsModel', bval)
    if not os.path.isfile(rmse_file_name):
        relative_rmse = ozm.relative_rmse(SHM1, SHM2)
        io.nii_from_volume(relative_rmse, rmse_file_name,
                           ni.load(dwi1).get_affine())
Beispiel #2
0
        mask=brain_mask)

    SphereModel1 = ozm.SphereModel(dwi1, bvecs1, bvals1, mask=brain_mask)

    SphereModel2 = ozm.SphereModel(dwi2, bvecs2, bvals2, mask=brain_mask)

    ModelFest = zip([
        TensorModel1, CanonicalTensorModel1, MultiCanonicalTensorModel1,
        SparseDeconvolutionModel1, SphereModel1,
        PointyMultiCanonicalTensorModel1, PointyCanonicalTensorModel1
    ], [
        TensorModel2, CanonicalTensorModel2, MultiCanonicalTensorModel2,
        SparseDeconvolutionModel2, SphereModel2,
        PointyMultiCanonicalTensorModel2, PointyCanonicalTensorModel2
    ], [
        'TensorModel', 'CanonicalTensorModel', 'MultiCanonicalTensorModel',
        'SparseDeconvolutionModel', 'SphereModel',
        'PointyMultiCanonicalTensorModel', 'PointyCanonicalTensorModel'
    ])

    # Compute the relative RMSE for each model:
    relative_rmse = []
    for Model1, Model2, model_name in ModelFest:
        rmse_file_name = '%s%s_relative_rmse_b%s.nii.gz' % (data_path,
                                                            model_name, bval)
        # Only do this if you have to:
        if not os.path.isfile(rmse_file_name):
            relative_rmse = ozm.relative_rmse(Model1, Model2)
            io.nii_from_volume(relative_rmse, rmse_file_name,
                               ni.load(dwi1).get_affine())
        csd_coeffs.append(d + "/" + f.split(".")[0] + "_CSD.nii.gz")
        response_files.append(d + "/" + f.split(".")[0] + "_ER.mif")

    SHM1 = ozm.SphericalHarmonicsModel(
        dwi1,
        bvecs1,
        bvals1,
        mask=brain_mask,
        model_coeffs=csd_coeffs[0],
        response_file=response_files[0],
        # axial_diffusivity=AD1,
        # radial_diffusivity=RD1
    )

    SHM2 = ozm.SphericalHarmonicsModel(
        dwi2,
        bvecs2,
        bvals2,
        # mask = mask_array,
        mask=brain_mask,
        model_coeffs=csd_coeffs[1],
        response_file=response_files[1],
        # axial_diffusivity=AD2,
        # radial_diffusivity=RD2
    )

    rmse_file_name = "%s%s_relative_rmse_b%s.nii.gz" % (data_path, "SphericalHarmonicsModel", bval)
    if not os.path.isfile(rmse_file_name):
        relative_rmse = ozm.relative_rmse(SHM1, SHM2)
        io.nii_from_volume(relative_rmse, rmse_file_name, ni.load(dwi1).get_affine())
    ModelFest = zip([TensorModel1,CanonicalTensorModel1,
                     MultiCanonicalTensorModel1,SparseDeconvolutionModel1,
                     SphereModel1,PointyMultiCanonicalTensorModel1,
                     PointyCanonicalTensorModel1],
                     [TensorModel2,CanonicalTensorModel2,
                      MultiCanonicalTensorModel2,SparseDeconvolutionModel2,
                      SphereModel2,PointyMultiCanonicalTensorModel2,
                      PointyCanonicalTensorModel2],
                     ['TensorModel', 'CanonicalTensorModel',
                      'MultiCanonicalTensorModel','SparseDeconvolutionModel',
                         'SphereModel', 'PointyMultiCanonicalTensorModel',
                         'PointyCanonicalTensorModel'
                         ])


    # Compute the relative RMSE for each model: 
    relative_rmse = []
    for Model1,Model2,model_name in ModelFest:      
        rmse_file_name = '%s%s_relative_rmse_b%s.nii.gz'%(data_path,
                                                          model_name,
                                                          bval)
        # Only do this if you have to:
        if not os.path.isfile(rmse_file_name):
            relative_rmse = ozm.relative_rmse(Model1, Model2)
            io.nii_from_volume(relative_rmse,
                               rmse_file_name,
                               ni.load(dwi1).get_affine())