Пример #1
0
def data(num):
    """ Run a single subjects data. """

    sdir = subdir(num)
    roi_names = [
            "wartaskAB_Right Accumbens_str2.nii.gz",
            "wartaskAB_Right Accumbens.nii.gz",
            "wartaskAB_Right Caudate.nii.gz"]
 
    # --
    # Get that Ss data and trial information.
    sdata = get_behave_data(num)
    sdata.update(get_similarity_data(num))
    sdata.update(get_rl_data(num))
    
    trials = get_trials_combined()
    durations = get_durations()

    # --
    # Go!
    roi_results = []
    for name in roi_names:
        print(name)
        spath = os.path.join(sdir, name)
    
        # Init this roi's models
        roiglm = fmri.catreward.roi.base.Catreward(
                1.5, spath, trials, durations, sdata)
        
        # Get, reformat (extract), and store the results.
        roi_results.append(roiglm.run(name))

    return roi_results
Пример #2
0
def meandata(num):
    """ Run a single subjects data, drawing the BOLD data
    from the /bold dir text files. """

    sdir = subdir(num)
    roi_names = [
            "wartaskAB_Right Accumbens_str2_bold.txt",
            "wartaskAB_Right Accumbens_bold.txt",
            "wartaskAB_Right Caudate_bold.txt"]
 
    # --
    # Get that Ss data and trial information.
    sdata = get_behave_data(num)
    sdata.update(get_similarity_data(num))
    sdata.update(get_rl_data(num))
 
    trials = get_trials()
    durations = get_durations()

    # --
    # Go!
    roi_results = []
    for name in roi_names:
        print(name)
        spath = os.path.join(sdir, 'bold', name)
    
        # Init this roi's models
        roiglm = fmri.catreward.roi.exps.base.CatMean(
                1.5, spath, trials, durations, sdata)

        # Get, reformat (extract), and store the results.
        roi_results.append(roiglm.run(name))

    return roi_results
Пример #3
0
    def __init__(self):

        try: Exp.__init__(self)
        except AttributeError: pass
        
        durations = get_durations()
        tmp_trials = get_trials()

        self.TR = 1.5
        self.ISI = 1.5
        self.trials = roi.timing.dtime(tmp_trials, durations, None, 0)
Пример #4
0
def run(num, roi_class_name, trials_name):
    """ For subject <num>, run all models for all ROIs.

    Note: Must be run from the parent folder of all the fMRI datasets."""

    sdir = subdir(num)
    roi_class_path = roi_class_name.split('.')
    txt_classes = ['CatMean', 'Nobox', 'CatMeanFir', 'Subtime']
    if roi_class_name == 'Catreward':
        roi_names = get_roi_names(kind='nii')
    elif roi_class_name in txt_classes:
        roi_names = get_roi_names(kind='txt')
        sdir = os.path.join(sdir, 'bold')
            ## Swich to the bold dir too
    else:
        raise ValueError("Could not find suitable ROI names.")

    # --
    # Get that Ss data and trial information.
    sdata = get_behave_data(num)
    sdata.update(get_similarity_data(num))
    sdata.update(get_rl_data(num))

    durations = get_durations()
    trials = None
    if trials_name == 'get_trials':
        trials = get_trials()
    elif trials_name == 'get_trials_combined':
        trials = get_trials_combined()
    else:
        raise ValueError("trials_name was unkown.")

    # --
    # Go!
    results = []
    for name in roi_names:
        print(name)
        spath = os.path.join(sdir, name)
    
        # Init this roi's models
        Roiclass = getattr(bclasses, roi_class_name)
        roiglm = Roiclass(1.5, spath, trials, durations, sdata)

        # Get, reformat (extract), and store the results.
        # And del it to keep memory reasonable
        results.append(roiglm.run(name))

    return results
Пример #5
0
def sim():
    """ Test by simulation. """

    # --
    # Get that Ss data and trial information.
    trials = get_trials()
    durations = get_durations()
    sdata = None

    sim = Simtest().run('1')

    roiglm = roi.base.Roi(1.5, '', trials, durations, sdata)

    # Create data for the model
    roiglm.bold = sim['model_01']['bold']
    roiglm.create_hrf('mean_fir', {'window_size':30})
#    roiglm.create_hrf('double_gamma')
    roiglm.create_dm()

    # Get, reformat (extract), and store the results.
    return roiglm.run('simulate')
Пример #6
0
def main(num, roi_names, roi_class_name):
    """ The main worker for run3.py.

    <num> is a valid subject number code (101-118)
    <roi_names> is the names of the rois you wish to analyze
    <roi_class_name> is the name of the fmri.catreward.roi.exps.base 
    class you want to use for the experiment. 
    
    This script saves each Ss data to seperate files, returning nothing. """

    # --
    # Get that Ss data and trial information.
    trials = get_trials_combined()
    durations = get_durations()

    sdata = get_behave_data(num)
    sdata.update(get_similarity_data(num))
    sdata.update(get_rl_data(num))
    sdata.update(get_cumrewards(num))
        ## Add all data to sdata, a dict

    # --
    # The fMRI data is located at:
    sdir = subdir(num)
    
    # --
    results = []
    for name in roi_names:
        print(name)
        spath = os.path.join(sdir, 'bold', name)
    
        # Init this roi's models
        Roiclass = getattr(bclasses, roi_class_name)
        roiglm = Roiclass(1.5, spath, trials, durations, sdata)

        # Get, reformat (extract), and store the results.
        # And del it to keep memory reasonable
        results.append(roiglm.run(name))

    return results