Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions brainiak/fcma/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,25 @@ class Classifier(BaseEstimator):
----------

training_data_: 2D numpy array in shape [num_samples, num_features]
training_data\_ is None except clf is SVM.SVC with precomputed kernel,
training_data\\_ is None except clf is SVM.SVC with precomputed kernel,
in which case training data is needed to compute
the similarity vector for each sample to be classified.
However, if the test samples are also provided during the fit,
the similarity vectors can be precomputed too
and then training_data\ is None
and then training_data\\_ is None

test_raw_data_: a list of 2D array in shape [num_TRs, num_voxels]
default None
test_raw_data\_ is set after a prediction is called,
if the new input data equals test_raw_data\_,
test_data\_ can be reused
test_raw_data\\_ is set after a prediction is called,
if the new input data equals test_raw_data\\_,
test_data\\_ can be reused

test_data_: 2D numpy array in shape [num_samples, num_features]
default None
test_data\_ is set after a prediction is called,
test_data\\_ is set after a prediction is called,
so that the test data does not need to be regenerated in the
subsequent operations, e.g. getting decision values of the prediction.
test_data\_ may also be set in the fit method
test_data\\_ may also be set in the fit method
if sklearn.svm.SVC with precomputed kernel
and the test samples are known.
NOTE: the test samples will never be used to fit the model.
Expand All @@ -103,7 +103,7 @@ class Classifier(BaseEstimator):
The dimension of correlation data, normally is the product of
the number of voxels of brain region 1 and
the number of voxels of brain region 2.
num_features\_ must be consistent in both training and classification
num_features\\_ must be consistent in both training and classification

num_samples_: int
The number of samples
Expand Down Expand Up @@ -597,10 +597,10 @@ def _is_equal_to_test_raw_data(self, X):
def decision_function(self, X=None):
"""Output the decision value of the prediction.

if X is not equal to self.test_raw_data\_, i.e. predict is not called,
if X is not equal to self.test_raw_data\\_, i.e. predict is not called,
first generate the test_data
after getting the test_data, get the decision value via self.clf.
if X is None, test_data\_ is ready to be used
if X is None, test_data\\_ is ready to be used

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion brainiak/fcma/mvpa_voxelselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MVPAVoxelSelector:
contains the labels of the epochs.
It is generated by .io.prepare_searchlight_mvpa_data

num\_folds: int
num_folds: int
the number of folds to be conducted in the cross validation

sl: Searchlight
Expand Down
2 changes: 1 addition & 1 deletion brainiak/fcma/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def generate_epochs_info(epoch_list):

Parameters
----------
epoch\_list: list of 3D (binary) array in shape [condition, nEpochs, nTRs]
epoch_list: list of 3D (binary) array in shape [condition, nEpochs, nTRs]
Contains specification of epochs and conditions, assuming
1. all subjects have the same number of epochs;
2. len(epoch_list) equals the number of subjects;
Expand Down
9 changes: 5 additions & 4 deletions brainiak/funcalign/rsrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class RSRM(BaseEstimator, TransformerMixin):

The model is estimated solving the following optimization problem:

.. math:: \\min_{W_i, S_i, R}\\sum_i \\frac{1}{2}\|X_i - W_i R - S_i\|_F^2
.. math:: + \\gamma\|S_i\|_1
.. math::
\\min_{W_i, S_i, R}\\sum_i \\frac{1}{2}\\|X_i - W_i R - S_i\\|_F^2
.. math:: + \\gamma\\|S_i\\|_1
.. math:: s.t. \\qquad W_i^TW_i = I \\quad \\forall i=1 \\dots N

The solution to this problem is obtained by applying a Block-Coordinate
Expand Down Expand Up @@ -345,8 +346,8 @@ def _init_transforms(self, subjs, voxels, features, random_state):
def _objective_function(X, W, R, S, gamma):
"""Evaluate the objective function.

.. math:: \sum_{i=1}^{N} 1/2 \| X_i - W_i R - S_i \|_F^2
.. math:: + /\gamma * \|S_i\|_1
.. math:: \\sum_{i=1}^{N} 1/2 \\| X_i - W_i R - S_i \\|_F^2
.. math:: + /\\gamma * \\|S_i\\|_1

Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions brainiak/funcalign/sssrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ def _objective_function_subject(self, data_align, data_sup, labels, w, s,
"""Compute the objective function for one subject.

.. math:: (1-C)*Loss_{SRM}_i(W_i,S;X_i)
.. math:: + C/\gamma * Loss_{MLR_i}(\theta, bias; {(W_i^T*Z_i, y_i})
.. math:: + R(\theta)
.. math:: + C/\\gamma * Loss_{MLR_i}(\\theta, bias; {(W_i^T*Z_i, y_i})
.. math:: + R(\\theta)

Parameters
----------
Expand Down
34 changes: 17 additions & 17 deletions brainiak/reprsimil/brsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class BRSA(BaseEstimator, TransformerMixin):
A time course of constant 1 will be included to the nuisance
regressor regardless of whether the user requests.
If baseline_single is set to False, one such regressor is included
for each fMRI run, but a single component in beta0\_ will be
for each fMRI run, but a single component in beta0\\_ will be
computed as the average of the weight maps corresponding to
these regressors. This might cause underestimation of noise variance.
If baseline_single is True, only one regressor of constant 1 will be
Expand Down Expand Up @@ -455,15 +455,15 @@ class BRSA(BaseEstimator, TransformerMixin):
The correlation matrix derived from the shared covariance matrix.
This is the estimated similarity matrix between neural patterns
to your task conditions. Notice that it is recommended that
you also check U\_, which is the covariance matrix underlying
you also check U\\_, which is the covariance matrix underlying
this correlation matrix. In cases there is almost no response
to your task conditions, the diagonal values of U\_ would become
very small and C\_ might contain many correlation coefficients
to your task conditions, the diagonal values of U\\_ would become
very small and C\\_ might contain many correlation coefficients
close to 1 or -1. This might not reflect true strong correlation
or strong negative correlation, but a result of lack of
task-related neural activity, design matrix that does not match
true neural response, or not enough data.
It is also recommended to check nSNR\_ after mapping it back to
It is also recommended to check nSNR\\_ after mapping it back to
the brain. A "reasonable" map should at least have higher values
in gray matter in than white matter.
nSNR_ : numpy array, shape=[voxels,].
Expand Down Expand Up @@ -497,10 +497,10 @@ class BRSA(BaseEstimator, TransformerMixin):
The estimated time course that is shared across voxels but
unrelated to the events of interest (design matrix).
beta0_null_: numpy array, shape=[n_nureg + n_base, voxels]
The equivalent of beta0\_ in a null model which does not
The equivalent of beta0\\_ in a null model which does not
include the design matrix and response pattern beta.
X0_null_: numpy array, shape=[time_points, n_nureg + n_base]
The equivalent of X0\_ in a null model which does not
The equivalent of X0\\_ in a null model which does not
include the design matrix and response pattern beta
n_nureg_: int
Number of nuisance regressor in addition to such
Expand Down Expand Up @@ -2743,7 +2743,7 @@ class GBRSA(BRSA):
you might want to start with specifying a lower rank and use metrics
such as AIC or BIC to decide the optimal rank. The log likelihood
for the fitted data can be retrieved through private attributes
_LL_train\_. Note that this log likelihood score is only used
_LL_train\\_. Note that this log likelihood score is only used
here for selecting hyperparameters such as rank. For any formal
model comparison, we recommend using score() function on left-out
data.
Expand Down Expand Up @@ -2795,7 +2795,7 @@ class GBRSA(BRSA):
A time course of constant 1 will be included to the nuisance
regressor for each participant. If baseline_single is set to False,
one such regressor is included for each fMRI run, but at the end of
fitting, a single component in beta0\_ will be computed as the average
fitting, a single component in beta0\\_ will be computed as the average
of the weight maps corresponding to these regressors. This might
cause underestimation of noise variance.
If baseline_single is True, only one regressor of constant 1 will be
Expand Down Expand Up @@ -2907,21 +2907,21 @@ class GBRSA(BRSA):
The correlation matrix derived from the shared covariance matrix.
This is the estimated similarity matrix between neural patterns
to your task conditions. Notice that it is recommended that
you also check U\_, which is the covariance matrix underlying
you also check U\\_, which is the covariance matrix underlying
this correlation matrix. In cases there is almost no response
to your task conditions, the diagonal values of U\_ would become
very small and C\_ might contain many correlation coefficients
to your task conditions, the diagonal values of U\\_ would become
very small and C\\_ might contain many correlation coefficients
close to 1 or -1. This might not reflect true strong correlation
or strong negative correlation, but a result of lack of
task-related neural activity, design matrix that does not match
true neural response, or not enough data.
It is also recommended to check nSNR\_ after mapping it back to
It is also recommended to check nSNR\\_ after mapping it back to
the brain. A "reasonable" map should at least have higher values
in gray matter in than white matter.
nSNR_ : list of numpy arrays, shape=[voxels,] for each subject in the list.
The pseuso-SNR of all voxels. If SNR_prior='lognormal',
the geometric mean of nSNR\_ would be approximately 1.
If SNR_prior='unif', all nSNR\_ would be in the range of (0,1).
the geometric mean of nSNR\\_ would be approximately 1.
If SNR_prior='unif', all nSNR\\_ would be in the range of (0,1).
If SNR_prior='exp' (default), the range of values would vary
depending on the data and SNR_bins, but many should have low
values with few voxels with high values.
Expand Down Expand Up @@ -2949,11 +2949,11 @@ class GBRSA(BRSA):
unrelated to the events of interest (design matrix).
beta0_null_: list of numpy arrays, shape=[n_nureg + n_base, voxels]
for each subject.
The equivalent of beta0\_ in a null model which does not
The equivalent of beta0\\_ in a null model which does not
include the design matrix and response pattern beta
X0_null_: list of numpy arrays, shape=[time_points, n_nureg + n_base]
for each subject.
The equivalent of X0\_ in a null model which does not
The equivalent of X0\\_ in a null model which does not
include the design matrix and response pattern beta
n_nureg_: 1-d numpy array
Number of nuisance regressor used to model the spatial noise
Expand Down
16 changes: 8 additions & 8 deletions brainiak/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,12 @@ def read_afni(self, fname):
int(split_by_at[1])
curr_idx += n_this_cond
elif len(split_by_at) == 1 and \
not re.search('\..', split_by_at[0]):
not re.search(r'\..', split_by_at[0]):
# Just a number, and not the type like '1..4'
self.column_types[curr_idx] = int(split_by_at[0])
curr_idx += 1
else: # must be a single stimulus condition
split_by_dots = re.split('\..', CG)
split_by_dots = re.split(r'\..', CG)
n_this_cond = int(split_by_dots[1])
self.column_types[curr_idx:curr_idx + n_this_cond] = 1
curr_idx += n_this_cond
Expand All @@ -346,7 +346,7 @@ def gen_design(stimtime_files, scan_duration, TR, style='FSL',
'undershoot_scale': 0.035}):
""" Generate design matrix based on a list of names of stimulus
timing files. The function will read each file, and generate
a numpy array of size [time_points \* condition], where
a numpy array of size [time_points \\* condition], where
time_points equals duration / TR, and condition is the size of
stimtime_filenames. Each column is the hypothetical fMRI response
based on the stimulus timing in the corresponding file
Expand Down Expand Up @@ -401,14 +401,14 @@ def gen_design(stimtime_files, scan_duration, TR, style='FSL',
Each line has a few triplets in the format of
stim_onsets*weight:duration
(or simpler, see below), separated by spaces.
For example, 3.2\*2.0:1.5 means that one event starts at 3.2s,
For example, 3.2\\*2.0:1.5 means that one event starts at 3.2s,
modulated by weight of 2.0 and lasts for 1.5s.
If some run does not include a single event
of a condition (stimulus type), then you can put \*,
of a condition (stimulus type), then you can put \\*,
or a negative number, or a very large number in that line.
Either duration or weight can be neglected. In such
cases, they will default to 1.0.
For example, 3.0, 3.0\*1.0, 3.0:1.0 and 3.0\*1.0:1.0 all
For example, 3.0, 3.0\\*1.0, 3.0:1.0 and 3.0\\*1.0:1.0 all
means an event starting at 3.0s, lasting for 1.0s, with
amplitude modulation of 1.0.

Expand Down Expand Up @@ -489,7 +489,7 @@ def gen_design(stimtime_files, scan_duration, TR, style='FSL',
def _read_stimtime_FSL(stimtime_files, n_C, n_S, scan_onoff):
""" Utility called by gen_design. It reads in one or more
stimulus timing file comforming to FSL style,
and return a list (size of [#run \* #condition])
and return a list (size of [#run \\* #condition])
of dictionary including onsets, durations and weights of each event.

Parameters
Expand Down Expand Up @@ -557,7 +557,7 @@ def _read_stimtime_FSL(stimtime_files, n_C, n_S, scan_onoff):
def _read_stimtime_AFNI(stimtime_files, n_C, n_S, scan_onoff):
""" Utility called by gen_design. It reads in one or more stimulus timing
file comforming to AFNI style, and return a list
(size of ``[number of runs \* number of conditions]``)
(size of ``[number of runs \\* number of conditions]``)
of dictionary including onsets, durations and weights of each event.

Parameters
Expand Down