Repository navigation
Add recent work to BRSA - #194
Conversation
Resolved conflict in examples/reprsimil/brsa_representational_similarity_estimate_example.ipynb.
Merge brainiak/master and resolve conflict
| current_GP, X0 | ||
| current_GP, X_res | ||
|
|
||
| def _fit_null(self, Y, X_base, scan_onsets=None): |
There was a problem hiding this comment.
For future refactoring it may be possible to just call fit here with a design matrix of 1's rather than have separate method (though it will require changing the error checking in fit also).
There was a problem hiding this comment.
I have not verified that such calling would replace _fit_null. But there is no urgency for this.
| assert np.all(SNR_grids >= 0) and np.isclose(np.sum(SNR_weights), 1) and np.all(SNR_weights > 0) \ | ||
| and np.all(np.diff(SNR_grids) > 0), \ | ||
| 'SNR_grids or SNR_weights not correct for exponential prior' | ||
|
|
There was a problem hiding this comment.
Somewhere around here there need to be tests of the numerical integration (against known closed-form, or against code validated elsewhere like from scipy.integrate), and/or there should be math somewhere showing that the numerical integration tricks are correct.
There was a problem hiding this comment.
Thanks @mshvartsman This is now added as test_grid_flatten_num_int() in test_gbrsa.py. Unfortunately this is a long test function. Additional check for flattening 2-D grids to 1-D grid is included in this function as well.
|
With addition of tests of the numerical integration code, plus some changes to the eigenvalue cutoff code @lcnature is doing now, I am happy to have this merged. Sorry it took so long. |
…ng rho_grids and rho_weights, and flattening 2-D grids to 1-D grid to two new functions. Added test for numerical integration
… of setting up some variables that are reused for each test to a function
mshvartsman
left a comment
There was a problem hiding this comment.
I'm sure more issues will come up as this gets out in the world, but looks good enough to push for me.
|
Thank you, @mshvartsman. @lcnature, now we only need a blurb for the release notes in a new RST file named "docs/newsfragments/194.feature". It can be as simple as single sentence naming the new method added. |
|
@mihaic Done. Please check it out. Thanks! |
mihaic
left a comment
There was a problem hiding this comment.
Hopefully this is the last you will hear from me on this. Mostly minor changes to make the code fit better with BrainIAK. However, I think you must address the comment about differences from the NIPS paper.
| Advances in Neural Information Processing Systems 29, 2016, 4952--4960 | ||
| Available at: | ||
| http://papers.nips.cc/paper/6131-a-bayesian-method-for-reducing-bias-in-neural-representational-similarity-analysis.pdf | ||
| Some extensions not described in the paper have been made here. |
There was a problem hiding this comment.
Could you please describe the extensions as much as possible?
| return ncomp | ||
|
|
||
|
|
||
| def CoM_exp(a, b, scale=1.0): |
There was a problem hiding this comment.
Please follow naming conventions (e.g., lower case). Add to __all__ if it is not private; better yet, move it to brainiak.utils.utils given that it is not connected to BRSA.
| n_nureg: int, default: 6 | ||
| not provided, DC components for each run will be included as nuisance | ||
| regressor regardless of the auto_nuisance parameter. | ||
| n_nureg: int or string. Default: 'opt' |
There was a problem hiding this comment.
Instead of allowing str, you should have None as the default, in which case you compute it from the data. If in the future you want to add other methods for computing it than Gavish & Donoho, you can add another parameter specifying the method.
| this parameter is used in a half-Cauchy prior | ||
| on the standard deviation, or an inverse-Gamma prior | ||
| on the variance of the GP. | ||
| tau2_prior: callable[[float, int, float], [float, float]], |
There was a problem hiding this comment.
There was a problem hiding this comment.
Thanks @mihaic I forgot how I wrote this line. It looks like it only takes [float, int, float]. So I will delete the second part of the line as well.
| if auto_nuisance: | ||
| assert (type(n_nureg) is str and | ||
| n_nureg in ['opt']) \ | ||
| or (type(n_nureg) is int and n_nureg > 0), \ |
There was a problem hiding this comment.
These type tests should go away when making the suggested change to None as default, but for future reference:
The isinstance() built-in function is recommended for testing the type of an object, because it takes subclasses into account.
There was a problem hiding this comment.
fixed. But the test for being positive integer is still kept.
…il.brsa to utils.utils, and changed the default of n_nureg from opt to None, and added description of the extension of BRSA work from that of the NIPS paper.
mihaic
left a comment
There was a problem hiding this comment.
Just a couple of typos and nitpicking.
| More specifically: | ||
| (1) spatial noise correlation (or alternatively | ||
| considered as signals of intrinsic fluctuation not related to tasks); | ||
| (2) new fitting procedure which marginalize all voxel-specific |
| not provided, DC components for each run will be included as nuisance | ||
| regressor regardless of the auto_nuisance parameter. | ||
| n_nureg: int or string. Default: 'opt' | ||
| n_nureg: int or None. Default: None |
There was a problem hiding this comment.
You do not really need to address this; only commenting to remind you of the format for type annotations.
There is no need to mention None here because it is implied by the default value. If you do want to mention it anyway, please use the Optional[int] notation from PEP 484:
https://docs.python.org/3/library/typing.html#typing.Optional
There was a problem hiding this comment.
Do you mean, writing it as:
n_nureg: Optional[int], period?
Does it also apply to other parameters whose defaults are None, such as rank, random_state, space_smooth_range and inten_smooth_range?
There was a problem hiding this comment.
I would write:
n_nureg: int
This is also what the documentation I linked says ("An optional argument with a default needn’t use the Optional qualifier on its type annotation (although it is inferred if the default is None).") And also what you have already for inten_smooth_range and space_smooth_range.
| on the standard deviation, or an inverse-Gamma prior | ||
| on the variance of the GP. | ||
| tau2_prior: callable[[float, int, float], [float, float]], | ||
| tau2_prior: Callable[[float, int, float]], |
There was a problem hiding this comment.
The return type of the Callable is missing:
https://docs.python.org/3/library/typing.html#typing.Callable
| depending on the data and SNR_bins, but many should have low | ||
| values with few voxels with high values. | ||
| Note that this attribute can not be interpreted as true SNR, | ||
| but the relative ratios between voxel indicates the contribution |
| is calculated for exponential distribution. | ||
| b: float | ||
| The ending point of the interval in which the center of mass | ||
| is calculated for exponential distribution. |
|
Thank you very much for this massive contribution, @lcnature! After keeping you waiting so long for the merge, I hope you find some consolation in knowing you helped us improve the BrainIAK contribution process. |
Uh oh!
There was an error while loading. Please reload this page.