Repository navigation
Adding statistical tests to ISC and ISFC - #310
Conversation
| pos_freq = np.arange(1, (D.shape[1] - 1) // 2 + 1) | ||
| neg_freq = np.arange(D.shape[1] - 1, (D.shape[1] - 1) // 2, -1) | ||
|
|
||
| shift = np.random.rand(D.shape[0], len(pos_freq), D.shape[2]) * 2 * math.pi |
There was a problem hiding this comment.
We try to avoid np.random.rand in favor of np.random.RandomState.rand, according to the Scikit-learn guidelines:
https://github.com/brainiak/brainiak/blob/master/CONTRIBUTING.rst#standards
http://scikit-learn.org/stable/developers/contributing.html#random-numbers
| D[:, :, 2] = \ | ||
| [[-0.26593192, -0.56914734, 0.28397317, 0.30276589, -0.42637472], | ||
| [-0.67598379, -0.51549055, -0.64196342, 1.60686666, 0.04127293]] | ||
| [0.04127293, -0.67598379, -0.51549055, -0.64196342, 1.60686666]] |
There was a problem hiding this comment.
Why is the reordering necessary?
There was a problem hiding this comment.
Added a comment to clarify, I wanted to create a null ISC to make sure it was not significant.
| assert D.shape == (4, 5, 2), "Loaded data has incorrect shape" | ||
|
|
||
| ISFC = brainiak.isfc.isfc(D) | ||
| np.random.seed(0) |
There was a problem hiding this comment.
Don't forget to remove this seed setting when you switch to using RandomState.
There was a problem hiding this comment.
Did you actually forget to remove the line? :)
| return ISFC, p | ||
|
|
||
|
|
||
| def phase_randomize(D): |
There was a problem hiding this comment.
This function is not really ISFC specific. I think it fits better in utils/utils.py.
| back into the time domain. This yields timecourses with the same power | ||
| spectrum (and thus the same autocorrelation) as the original timecourses, | ||
| but will remove any meaningful temporal relationships between the | ||
| timecourses. |
There was a problem hiding this comment.
Do you have a paper reference by any chance?
| return np.real(ifft(F, axis=1)) | ||
|
|
||
|
|
||
| def ecdf(x): |
| return ISFC[..., 0] | ||
|
|
||
|
|
||
| def p_from_null(X, two_sided=False): |
There was a problem hiding this comment.
I think this function also belongs in utils/utils.py.
| assert D.shape == (4, 5, 2), "Loaded data has incorrect shape" | ||
|
|
||
| ISFC = brainiak.isfc.isfc(D) | ||
| np.random.seed(0) |
There was a problem hiding this comment.
Did you actually forget to remove the line? :)
| return result | ||
|
|
||
|
|
||
| def phase_randomize(D, random_state=0): |
There was a problem hiding this comment.
Please add tests for the new functions. They can be as simple as you want.
mihaic
left a comment
There was a problem hiding this comment.
Thank you for the prompt changes, @cbaldassano.
Adding statistical testing through phase randomization, as requested by https://groups.google.com/forum/#!topic/brainiak/vZnOgGoV7q4 and as described in Simony et al. (2015, DOI: 10.1038/ncomms12141)