예제 #1
0
def TBV_value_extractor(TBVip,voi,ctr,outdir,basename):
    
    """
    This function extracts the tvalues from data loaded in TBV and save them
    as binary files. 
    Up to this date there is no possibility to extract the beta values.

    Parameters
    ----------
    TBVip : string
        IP index to access the TBV processed data. When TBV is running on the
        same machine please use 'localhost'
    voi : integer
        A value ranging from 0 to infinite. It indicates the index of the ROI
        used in analysis.
    ctr : integer
        A value ranging from 0 to infinite. It indicates the index of the 
        contrast of interest. The contrast can be defined manually using a .ctr
        file or it can be defined automatically by TBV. Usually the contrast
        '0' corresponds to the map 'first predictors vs. baseline'.
    outdir : string
        The directory for the output files.
    basename : string
        Basename for the outputs.

    Returns
    -------
    None.

    """


    TBV = tbvnetworkinterface.TbvNetworkInterface(TBVip,55555)    
    
                   
    if TBV.get_current_time_point()[0] == TBV.get_expected_nr_of_time_points()[0]: 
        print('Extracting t-values...')
         
    #coordinates of voxels of the roi
        coord_roi_voxels = np.array(TBV.get_all_coords_of_voxels_of_roi(voi)[0])
        
        tvals = np.array([TBV.get_map_value_of_voxel(voi,coord)[0] 
                        for coord in coord_roi_voxels]).reshape(-1,1)

      
        output_tval = np.concatenate((coord_roi_voxels,tvals),axis=1)
            
        print('Saving t-vals data...')
        with open(os.path.join(outdir,basename+'_voi'+str(voi)+'.tvals'), 'w') as outfile:
            np.savetxt(outfile, output_tval)
        
        print('Everything have been estimated! Goodbye!')
예제 #2
0
#load properties in the just created rtRSAObj
#the config.json file can be created by using one of the class method
#the file si wirtten after the estimation of the RS
rtRSAObj.load(sub_json_file)

print('rtRSA ready!\n')
print('Nr of voxels: ', +len(rtRSAObj.func_coords))
print('Base stimuli name:')
print(rtRSAObj.conditions)

#%%############################################################################
#                               TBV  interface settings                       #
###############################################################################

#create an instance to access TBV via network plugin
TBV = tbvnetworkinterface.TbvNetworkInterface('localhost', 55555)

win = visual.Window(fullscr=False,
                    color='gray',
                    screen=0,
                    size=(1024, 768),
                    colorSpace='rgb255')

#creation of the cue for the image
image = visual.ImageStim(win,
                         image=None,
                         mask=None,
                         units='pix',
                         pos=(0.0, 0.0),
                         size=600,
                         ori=0.0,