from load_data import get_jc_hardi, get_test_mask, get_test_wm_mask, get_test_hardi
from show_streamlines import show_streamlines
from conn_mat import connectivity_matrix

from dipy.io.pickles import save_pickle, load_pickle

from time import time

threshold = 0.75
from dipy.data import get_sphere
sphere = get_sphere('symmetric724')
dname = 'SNR20/'

if __name__ == '__main__':
    data, affine, gtab = get_test_hardi(snr=20, denoised=0)    
    mask = get_test_mask()
    tenmodel = TensorModel(gtab)
    tenfit = tenmodel.fit(data, mask)
    FA = fractional_anisotropy(tenfit.evals)
    FA[np.isnan(FA)] = 0
    nib.save(nib.Nifti1Image(FA.astype('float32'), affine), 
             'FA.nii.gz')
    
    for i in range(27) :
        print 'White matter bundle: ', i
        wm_mask = get_test_wm_mask(i)
        print(FA[wm_mask].max())
        indicesAniso = np.where(np.logical_and(FA > threshold, wm_mask))  

        print '    Response function'
예제 #2
0
#     nib.save(nib.Nifti1Image(FA, affine),  'training-data_DWIS_hardi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_FA.nii.gz')
#     nib.save(nib.Nifti1Image(RGB, affine), 'training-data_DWIS_hardi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_RGB.nii.gz')


    

snr_list = [10, 20, 30]
denoised_list = [1]

# Testing data
for snr, denoised in [(snr, denoised) for snr in snr_list for denoised in denoised_list]:

    print "Current file : dti snr = " +  str(snr) + ' denoising = ' + str(denoised)
    data, affine, gtab = load_data.get_test_dti(snr=snr, denoised=denoised)
    FA, RGB = FA_RGB(data, gtab)
    nib.save(nib.Nifti1Image(FA, affine),  'DWIS_dti-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_FA.nii.gz')
    nib.save(nib.Nifti1Image(RGB, affine), 'DWIS_dti-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_RGB.nii.gz')


    print "Current file : dsi snr = " +  str(snr) + ' denoising = ' + str(denoised)
    data, affine, gtab = load_data.get_test_dsi(snr=snr, denoised=denoised)
    FA, RGB = FA_RGB(data, gtab)
    nib.save(nib.Nifti1Image(FA, affine),  'DWIS_dsi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_FA.nii.gz')
    nib.save(nib.Nifti1Image(RGB, affine), 'DWIS_dsi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_RGB.nii.gz')


    print "Current file : hardi snr = " +  str(snr) + ' denoising = ' + str(denoised)
    data, affine, gtab = load_data.get_test_hardi(snr=snr, denoised=denoised)
    FA, RGB = FA_RGB(data, gtab)
    nib.save(nib.Nifti1Image(FA, affine),  'DWIS_hardi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_FA.nii.gz')
    nib.save(nib.Nifti1Image(RGB, affine), 'DWIS_hardi-scheme_SNR-' + str(snr) + '_denoising_' + str(denoised) + '_RGB.nii.gz')