Skip to content

Commit b033a50

Browse files
committed
only shuffle behavioral data
1 parent 03ae61a commit b033a50

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pythonCode/permutationTesting.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def maxT(diff_arr, nullmean=0, alpha=.05, tail=1, permutations=1000, nproc=1, pv
6767
elif tail == -1:
6868
topPercVal_maxT_inx = int(len(maxT_dist_sorted)*(alpha))
6969
maxT_thresh = maxT_dist_sorted[topPercVal_maxT_inx]
70+
elif tail == 0:
71+
topPercVal_maxT_inx = int(len(maxT_dist_sorted)*(1-alpha))
72+
maxT_thresh = maxT_dist_sorted[topPercVal_maxT_inx]
7073
# elif tail == 0:
7174
# topPercVal_maxT_inx = int(len(maxT_dist_sorted)*(alpha/2.0))
7275
# botPercVal_maxT_inx = int(len(maxT_dist_sorted)*(1-alpha/2.0))
@@ -88,10 +91,10 @@ def maxT(diff_arr, nullmean=0, alpha=.05, tail=1, permutations=1000, nproc=1, pv
8891
if tail == 1:
8992
p_fwe = 1.0 - p_fwe
9093

91-
return t, (topT_thresh,botT_thresh), p_fwe
94+
return t, maxT_thresh, p_fwe
9295

9396
else:
94-
return t, (topT_thresh,botT_thresh)
97+
return t, maxT_thresh
9598

9699

97100
def _maxTpermutation((diff_arr,nullmean,tail,seed)):
@@ -184,6 +187,9 @@ def maxR(diff_arr, behav_arr, alpha=.05, tail=0, permutations=1000, nproc=1, pva
184187
elif tail == -1:
185188
topPercVal_maxR_inx = int(len(maxR_dist_sorted)*(alpha))
186189
maxR_thresh = maxR_dist_sorted[topPercVal_maxR_inx]
190+
elif tail == 0:
191+
topPercVal_maxR_inx = int(len(maxR_dist_sorted)*(1-alpha))
192+
maxR_thresh = maxR_dist_sorted[topPercVal_maxR_inx]
187193
# elif tail == 0:
188194
# topPercVal_maxR_inx = int(len(maxR_dist_sorted)*(alpha/2.0))
189195
# botPercVal_maxR_inx = int(len(maxR_dist_sorted)*(1-alpha/2.0))
@@ -221,7 +227,7 @@ def _maxRpermutation((data_normed,behav_normed,tail,seed)):
221227
# Randomly permute behavioral data along 2nd dimension (subjects). Note: np.random.shuffle() requires transposes
222228
np.take(behav_normed,np.random.rand(behav_normed.shape[1]).argsort(),axis=1,out=behav_normed)
223229
# Randomly permute measurement data along 2nd dimension (subjects). Note: np.random.shuffle() requires transposes
224-
np.take(data_normed,np.random.rand(data_normed.shape[1]).argsort(),axis=1,out=data_normed)
230+
#np.take(data_normed,np.random.rand(data_normed.shape[1]).argsort(),axis=1,out=data_normed)
225231
# Calculating Pearson correlations in a vectorized format (increasing speed)
226232
r_values = np.mean(np.multiply(behav_normed,data_normed),axis=1)
227233

0 commit comments

Comments
 (0)