示例#1
0
def create_prob_seg_iteration3(template_grays,templates,image,naming):
        base='/data/henry10-w/jjuwono/bayesion_masks_'+naming
        a=nb.load(image)
        adat_raw=a.get_data()
        adat=quantile_transform(a.get_data())
        print(adat.dtype)
        #input()
        distributions_raw=[]
        distributions=[]
        fgs=[]
        data_dict={}
        for i in template_grays:
            print(c.get_ms(os.path.basename(i)),i)
            data_dict[c.get_ms(os.path.basename(i))]=i

        for i in templates:
            temp=nb.load(i).get_data()
            temp=quantile_transform(temp)
            print('here')
            try:
                z=z_score(temp)
            except:
                print(sys.exc_info())
                continue
            try:
                print(data_dict[c.get_ms(os.path.basename(i))],i)
                fg=nb.load(data_dict[c.get_ms(os.path.basename(i))]).get_data()
            except:
                print(sys.exc_info())
                continue
            distributions.append(z)
            fgs.append(fg)
        
        return fgs,distributions,a,adat,adat_raw
示例#2
0
def create_prob_seg_iteration3(template_grays, templates, image, file_handl):
    a = nb.load(image)
    adat_raw = a.get_data()
    adat = quantile_transform(a.get_data())
    #print(adat.dtype)
    #input()
    distributions_raw = []
    distributions = []
    fgs = []
    data_dict = {}
    for i in template_grays:
        #print(c.get_ms(os.path.basename(i)),i)
        data_dict[c.get_ms(os.path.basename(i))] = i

    for i in templates:
        temp = nb.load(i).get_data()
        temp = quantile_transform(temp)
        #print('here')
        try:
            z = z_score(temp)
        except:
            print(sys.exc_info())
            file_handl.write(str(sys.exc_info()) + '\n')
            continue
        try:
            #print(data_dict[c.get_ms(os.path.basename(i))],i)
            fg = nb.load(data_dict[c.get_ms(os.path.basename(i))]).get_data()
        except:
            print(sys.exc_info())
            file_handl.write(str(sys.exc_info()) + '\n')
            continue
        distributions.append(z)
        fgs.append(fg)
    return fgs, distributions, a, adat, adat_raw
示例#3
0
                print(sys.exc_info())
                continue
            distributions.append(z)
            fgs.append(fg)
        
        return fgs,distributions,a,adat,adat_raw

prefix='test_retest_PSIR'
#glob for images to segment#
glob_path=glob('/data/henry8/nico/SC_ATROPHY_RAP/*/*/*/*C2*/ms*only_cord.nii.gz')+glob('/data/henry8/nico/SC_ATROPHY_RAP/*/*/*/*C2*/vol*only_cord.nii.gz')
glob_path=glob('/data/henry8/nico/SC_ATROPHY_RAP/*/SKYRA/PSIR/C23_retest/*only_cord.nii.gz')
errors=[]
pass_on=[]
for static in glob_path:
    if 'retest' in static:
        mse_static=c.get_ms(static)+'PSIR_retest'+scanner(static)
    else:
        mse_static=c.get_ms(static)+'PSIR_'+scanner(static)

    try:
        os.remove('/data/henry4/jjuwono/data/henry4/jjuwono/'+prefix+'/'+mse_static+'/warped/synslice_avggmsegs.nii.gz')
    except:
        pass
    if os.path.isdir('/data/henry4/jjuwono/new_GM_method/'+mse_static):
        continue
    output_path='/data/henry4/jjuwono/data/henry4/jjuwono/'+prefix+'/'+mse_static+'/'
    files=sorted(glob('/data/henry6/esha/Data/Interp_10/Current_Data/sharpened/*'))
    files2=sorted(glob('/data/henry6/esha/Data/Masks_interp10/butterfly/all/*'))
    pth='/data/henry6/esha/Data/Interp_10/Current_Data/sharpened/'
    pth2='/data/henry6/esha/Data/Masks_interp10/butterfly/all/'
    dim=2