Ejemplo n.º 1
0
    ########### Set parameters ##########
    datadir = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/BPM/results/PIB_Index_log_scaled/Results_ROIs'
    roiglob = os.path.join(datadir,'ic*.nii.gz')
    roi_files = glob(roiglob)
    template = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/network_volumes/netmasks/ic_masks_4D.nii.gz'
    template_mapfile = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/network_volumes/netmasks/template_mapping.txt'
    outfile = os.path.join(datadir, 'Network_Labels_GICA30.csv')
    ####################################

    #Load template and 4D roi data
    tempdat, _ = utils.load_nii(template)
    temp_mapping = utils.load_mapping(template_mapfile)
    # Verify the shape of datasets match


    roi_labels = {}
    for roi in roi_files:
        overlap_dict = {}
        _,roi_name,_ = utils.split_filename(roi)
        roidat, _ = utils.load_nii(roi)
        assert tempdat.shape[:-1] == roidat.shape
        for j in range(tempdat.shape[3]):
            temp_mask = tempdat[:,:,:,j]
            pct_overlap = calc_pct_overlap(roidat, temp_mask)
            net_name = temp_mapping[str(j+1)].split('.')[0]
            overlap_dict[net_name] = pct_overlap
        roi_labels[roi_name] = overlap_dict

    df = pd.DataFrame(roi_labels)
    df.to_csv(outfile, header=True,index_label='Network')
Ejemplo n.º 2
0
    ########### Set parameters ##########
    datadir = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/BPM/results/PIB_Index_log_scaled/Results_ROIs'
    roiglob = os.path.join(datadir, 'ic*.nii.gz')
    roi_files = glob(roiglob)
    template = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/network_volumes/netmasks/ic_masks_4D.nii.gz'
    template_mapfile = '/home/jagust/rsfmri_ica/GIFT/GICA_d30/network_volumes/netmasks/template_mapping.txt'
    outfile = os.path.join(datadir, 'Network_Labels_GICA30.csv')
    ####################################

    #Load template and 4D roi data
    tempdat, _ = utils.load_nii(template)
    temp_mapping = utils.load_mapping(template_mapfile)
    # Verify the shape of datasets match

    roi_labels = {}
    for roi in roi_files:
        overlap_dict = {}
        _, roi_name, _ = utils.split_filename(roi)
        roidat, _ = utils.load_nii(roi)
        assert tempdat.shape[:-1] == roidat.shape
        for j in range(tempdat.shape[3]):
            temp_mask = tempdat[:, :, :, j]
            pct_overlap = calc_pct_overlap(roidat, temp_mask)
            net_name = temp_mapping[str(j + 1)].split('.')[0]
            overlap_dict[net_name] = pct_overlap
        roi_labels[roi_name] = overlap_dict

    df = pd.DataFrame(roi_labels)
    df.to_csv(outfile, header=True, index_label='Network')
Ejemplo n.º 3
0
def get_seedname(seedfile):
    _, nme, _ = utils.split_filename(seedfile)
    return nme
Ejemplo n.º 4
0
    custom_palette = sns.color_palette(["#377eb8","#4daf4a"]) 
    #ex. colors:  "#e41a1c"=red, "#377eb8"=blue, "#4daf4a"=green
    plotcols = statlist
    col_labels = ['1', '2', '3', '4', '5']
    plt_outfile_pattern = '/home/jagust/DST/FSL/results/Details/%s.svg'
    #Specify info to extract GM values
    gm_pattern = '/home/jagust/DST/FSL/functional/%s/run02/Detail_ST.feat/reg/highresGMs2standard.nii.gz'   
    ####################################################################

    #Load subject list and group info file
    with open(sublist_file,'r+') as f:
        sublist = f.read().splitlines()        
    groupinfo = pd.read_csv(groupinfo_file, sep=',')  
    
    #Set output file names
    pth, mask_name, ext = gu.split_filename(mask)
    outfile = outfile_pattern%(mask_name)       
    if plot_fig:
        plt_outfile = plt_outfile_pattern%(mask_name)
        
    #Extract GM values
    gmdict = {}
    for subj in sublist:
        print subj
        gm_infile = gm_pattern%(subj)
        subjstat = fslstats(gm_infile, mask)
        gmdict[subj] = subjstat   
    gmdict = {'GM':gmdict} 
    gmdf = pd.DataFrame.from_dict(gmdict, orient='columns')
    
    #Extract stats from functional data