Exemplo n.º 1
0
# aryHlfMaxCnfLw = np.percentile(aryEmpHlfMax, 0.5, axis=1)
# aryHlfMaxCnfUp = np.percentile(aryEmpHlfMax, 99.5, axis=1)

# Mean and standar error:
aryHlfMaxMne = np.mean(aryEmpHlfMax, axis=1)
aryError = np.std(aryEmpHlfMax, axis=1)

funcPltAcrDpth(
    aryHlfMaxMne,  # aryData[Condition, Depth]
    aryError,  # aryError[Con., Depth]
    varNumDpt,  # Number of depth levels (on the x-axis)
    varNumIn,  # Number of conditions (separate lines)
    varDpi,  # Resolution of the output figure
    0.0,  # Minimum of Y axis
    2.0,  # Maximum of Y axis
    False,  # Boolean: whether to convert y axis to %
    dicPthDpth.keys(),  # Labels for conditions (separate lines)
    strXlabel,  # Label on x axis
    strYlabel,  # Label on y axis
    'Response at 50% contrast',  # Figure title
    True,  # Boolean: whether to plot a legend
    (strPthOt + '_' + strFunc + '_half_max_response' + strFleTyp),
    varSizeX=2000.0,
    varSizeY=1400.0,
    # aryCnfLw=aryHlfMaxCnfLw,
    # aryCnfUp=aryHlfMaxCnfUp,
    lstVrt=list(vecPeakHlfMaxMed))
# ----------------------------------------------------------------------------

print('-Done.')
Exemplo n.º 2
0
    # SEM across subjects:
    lstHlfMaxRespSem[idxIn] = np.divide(np.std(lstHlfMaxResp[idxIn], axis=0),
                                        np.sqrt(varNumSubs))
    lstHlfMaxRespSem[idxIn] = np.array(lstHlfMaxRespSem[idxIn], ndmin=2)

# Stack the vectors for the two ROIs (V1 & V2):
aryHlfMaxRespMne = np.vstack(lstHlfMaxRespMne[:])
aryHlfMaxRespSem = np.vstack(lstHlfMaxRespSem[:])

funcPltAcrDpth(aryHlfMaxRespMne,   # aryData[Condition, Depth]
               aryHlfMaxRespSem,   # aryError[Con., Depth]
               varNumDpth,         # Number of depth levels (on the x-axis)
               varNumIn,           # Number of conditions (separate lines)
               varDpi,             # Resolution of the output figure
               0.0,                # Minimum of Y axis
               1.4,                # Maximum of Y axis
               False,              # Boolean: whether to convert y axis to %
               dicPthDpth.keys(),  # Labels for conditions (separate lines)
               strXlabel,          # Label on x axis
               strYlabel,          # Label on y axis
               'Response at half maximum contrast',  # Figure title
               True,               # Boolean: whether to plot a legend
               (strPthOt + '_half_max_response.png'))


# -----------------------------------------------------------------------------
# *** Plot contrast at half maximum response across depth

# Label for axes:
strXlabel = 'Cortical depth level (equivolume)'
strYlabel = 'Percent luminance contrast'
def funcLinRegAcrSubs(arySubDpthMns,
                      vecLinRegMdl,
                      varNumSubs,
                      varNumDpth,
                      strTitle,
                      strXlabel,
                      strLinRegYlabel,
                      varLinRegYmin,
                      varLinRegYmax,
                      varLinRegP,
                      varDpi,
                      strPltOtPre,
                      strPltOtSuf):
    """
    Calculate & plot across-subjects simple linear regression.

    A simple linear regression is model is calculated to test the dependence of
    the parameter estimates (i.e. signal change) to stimulus condition (i.e.
    luminance contrast), separately for each depth level.
    """
    # Repeat linear regression model for each subject:
    vecLinRegX = np.tile(vecLinRegMdl, varNumSubs)

    # Vectors for regression results (one regression per depth level):

    # Slope of the regression line:
    vecSlpe = np.zeros(varNumDpth)
    # Intercept of the regression line:
    vecItrcpt = np.zeros(varNumDpth)
    # Correlation coefficient:
    vecCor = np.zeros(varNumDpth)
    # p-value:
    vecP = np.zeros(varNumDpth)
    # Standard error of the estimate:
    vecStdErr = np.zeros(varNumDpth)

    # Loop through depth levels to calculate linear regression independently
    # at each depth level:
    for idxDpth in range(0, varNumDpth):

        # Get a flat array with the parameter estiamtes for each condition for
        # each subject:
        vecLinRegY = arySubDpthMns[:, :, idxDpth].flatten()

        # Fit the regression model:
        vecSlpe[idxDpth], vecItrcpt[idxDpth], vecCor[idxDpth], vecP[idxDpth], \
            vecStdErr[idxDpth] = stats.linregress(vecLinRegX, vecLinRegY)

    # File name for figure:
    strPltOt = strPltOtPre + 'acrsSubsLinReg' + strPltOtSuf

    # Create plot:
    funcPltAcrDpth(vecSlpe[None, :],    # Data to be plotted
                   vecStdErr[None, :],  # Error shading
                   varNumDpth,          # Number of depth levels
                   1,                   # Number of conditions (separate lines)
                   varDpi,              # Resolution of the output figure
                   varLinRegYmin,       # Minimum of Y axis
                   varLinRegYmax,       # Maximum of Y axis
                   False,               # Whether to convert y axis to %
                   [''],                # Labels for conditions
                   strXlabel,           # Label on x axis
                   strLinRegYlabel,     # Label on y axis
                   strTitle,            # Figure title
                   False,               # Boolean: whether to plot a legend
                   strPltOt)            # Output path for the figure
# ----------------------------------------------------------------------------
# *** Plot results

# Path for figure:
strPath = '/home/john/PhD/Tex/Tootell_1988/semiTootell1988_smth_0p2.svg'

# Plot semisaturation contrast:
funcPltAcrDpth(vecSemi,
               aryError,
               varNumLayers,
               1,
               80.0,
               0.0,
               0.5,
               True, [''],
               'Cortical depth',
               'Percent luminance contrast',
               'Semisaturation contrast',
               False,
               strPath,
               vecX=vecLayPos,
               varNumLblY=6,
               varXmin=0.0,
               varXmax=1.0)

# Path for figure:
strPath = '/home/john/PhD/Tex/Tootell_1988/hlfmaxTootell1988_smth_0p2.svg'

# Plot response at 50% contrast:
funcPltAcrDpth(vecHlfMax,
               aryError,
Exemplo n.º 5
0
# Label for axes:
strXlabel = 'Cortical depth level (equivolume)'
strYlabel = 'fMRI signal change [a.u.]'

#funcPltAcrDpth(aryEmpHlfMax[:, 0, :],  # aryData[Condition, Depth]
funcPltAcrDpth(
    aryHlfMaxMne,  # aryData[Condition, Depth]
    0,  # aryError[Con., Depth]
    varNumDpt,  # Number of depth levels (on the x-axis)
    varNumIn,  # Number of conditions (separate lines)
    varDpi,  # Resolution of the output figure
    0.0,  # Minimum of Y axis
    2.0,  # Maximum of Y axis
    False,  # Boolean: whether to convert y axis to %
    dicPthDpth.keys(),  # Labels for conditions (separate lines)
    strXlabel,  # Label on x axis
    strYlabel,  # Label on y axis
    'Response at 50% contrast',  # Figure title
    True,  # Boolean: whether to plot a legend
    (strPthOt + '_' + strFunc + '_half_max_response' + strFleTyp),
    varSizeX=2000.0,
    varSizeY=1400.0,
    aryCnfLw=aryHlfMaxCnfLw,
    aryCnfUp=aryHlfMaxCnfUp,
    lstVrt=list(vecPeakHlfMaxMed))

# ----------------------------------------------------------------------------
# *** Plot semisaturation contrast

# Label for axes:
strXlabel = 'Cortical depth level (equivolume)'
Exemplo n.º 6
0
aryPrctUp = np.array(aryPrct[1, :], ndmin=2)

# ----------------------------------------------------------------------------
# *** Plot result

# Median across subjects:
aryDpthMne = np.median(aryDpth, axis=0, keepdims=True)

# Create plot:
funcPltAcrDpth(aryDpthMne,
               None,
               varNumDpth,
               1,
               80.0,
               varYmin,
               varYmax,
               False, [''],
               strXlabel,
               strYlabel,
               strRoi.upper(),
               False,
               strPltOt,
               varSizeX=1800.0,
               varSizeY=1600.0,
               varNumLblY=5,
               varPadY=(0.1, 0.1),
               aryCnfLw=aryPrctLw,
               aryCnfUp=aryPrctUp)

# ----------------------------------------------------------------------------
Exemplo n.º 7
0
# Label for axes:
strXlabel = 'Cortical depth level (equivolume)'
strYlabel = 'fMRI signal change [a.u.]'

# Stack the vectors for the two ROIs (V1 & V2):
aryHlfMaxResp = np.vstack(lstHlfMaxResp[:])

funcPltAcrDpth(
    aryHlfMaxResp,  # aryData[Condition, Depth]
    np.zeros(np.shape(aryHlfMaxResp)),  # aryError[Con., Depth]
    varNumDpth,  # Number of depth levels (on the x-axis)
    varNumIn,  # Number of conditions (separate lines)
    varDpi,  # Resolution of the output figure
    0.0,  # Minimum of Y axis
    2.0,  # Maximum of Y axis
    False,  # Boolean: whether to convert y axis to %
    dicPthDpth.keys(),  # Labels for conditions (separate lines)
    strXlabel,  # Label on x axis
    strYlabel,  # Label on y axis
    'Response at half maximum contrast',  # Figure title
    True,  # Boolean: whether to plot a legend
    (strPthOt + '_half_max_response.png'),
    varSizeX=2000.0,
    varSizeY=1400.0)

# ----------------------------------------------------------------------------
# *** Plot semisaturation contrast

# Label for axes:
strXlabel = 'Cortical depth level (equivolume)'
strYlabel = 'Percent luminance contrast'