Skip to content

Commit

Permalink
Delete any reference to Feilong Ma #streisandeffect
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Fouchard committed Jan 9, 2024
1 parent f6a3950 commit 2fd46d3
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ venv.bak/

# Rope project settings
.ropeproject
examples/plot_srm_alignment.py
22 changes: 11 additions & 11 deletions examples/plot_int_alignment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
Hyperalignment-base prediction using Feilong Ma's IndividualNeuralTuning Model.
Hyperalignment-base prediction using the IndividualNeuralTuning Model.
See article : https://doi.org/10.1162/imag_a_00032
==========================
Expand Down Expand Up @@ -113,11 +113,13 @@


train_index = range(53)
model = IndividualizedNeuralTuning(n_jobs=10, alignment_method="parcelation")
model = IndividualizedNeuralTuning(
n_jobs=10, alignment_method="parcelation", n_components=20
)

if False: # Use Parcellation
if True: # Use Parcellation
parcels = compute_parcels(
niimg=template_train[0], mask=masker, n_parcels=1000, n_jobs=5
niimg=template_train[0], mask=masker, n_parcels=200, n_jobs=5
)
model.fit(np.array(masked_imgs)[:, train_index, :], parcels=parcels, verbose=False)
else:
Expand All @@ -144,7 +146,7 @@
# 0, to 53, and then the PA contrasts from 53 to 106.
#
test_index = range(53, 106)
if False:
if True:
model.fit(np.array(masked_imgs)[:, test_index, :], parcels=parcels, verbose=False)
test_stimulus = np.copy(model.shared_response)

Expand Down Expand Up @@ -185,14 +187,12 @@
# made from group average and from template with the real PA contrasts of sub-07

average_score = masker.inverse_transform(
np.abs(score_voxelwise(target_test, prediction_from_average, masker, loss="corr"))
score_voxelwise(target_test, prediction_from_average, masker, loss="corr")
)

# I choose abs value in reference to the work we did with the INT
template_score = masker.inverse_transform(
np.abs(
score_voxelwise(target_test, prediction_from_template[0], masker, loss="corr")
)
score_voxelwise(target_test, prediction_from_template[0], masker, loss="corr")
)


Expand All @@ -205,11 +205,11 @@
from nilearn import plotting

baseline_display = plotting.plot_stat_map(
average_score, display_mode="z", vmax=1, cut_coords=[-15, -5], cmap="hot"
average_score, display_mode="z", vmax=1, cut_coords=[-15, -5]
)
baseline_display.title("Group average correlation wt ground truth")
display = plotting.plot_stat_map(
template_score, display_mode="z", cut_coords=[-15, -5], vmax=1, cmap="hot"
template_score, display_mode="z", cut_coords=[-15, -5], vmax=1
)
display.title("Hyperalignment-based prediction correlation wt ground truth")

Expand Down
2 changes: 1 addition & 1 deletion fmralign/alignment_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _tuning_estimator(shared_response, target):
array-like: The estimated tuning weights.
"""
return np.linalg.pinv(shared_response).dot(target).astype(np.float32)
return np.linalg.pinv(shared_response) @ target

@staticmethod
def _stimulus_estimator(full_signal, n_t, n_s, latent_dim=None):
Expand Down
9 changes: 8 additions & 1 deletion fmralign/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ def generate_dummy_signal(
S_train = np.sqrt(Sigma)[:, None] * rng.randn(n_t, latent_dim)
S_test = np.sqrt(Sigma)[:, None] * rng.randn(n_t, latent_dim)

elif generative_method == "multiviewica":
S_train = np.random.laplace(size=(n_t, latent_dim))
S_test = np.random.laplace(size=(n_t, latent_dim))

else:
raise ValueError("Unknown generative method")

# Generate indiivdual spatial components
data_train, data_test = [], []
Ts = []
for _ in range(n_s):
if generative_method == "custom":
if generative_method == "custom" or generative_method == "multiviewica":
W = T_mean + T_std * np.random.randn(latent_dim, n_v)
else:
W = projection(rng.randn(latent_dim, n_v))
Expand Down
2 changes: 1 addition & 1 deletion fmralign/hyperalignment/individualized_neural_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IndividualizedNeuralTuning(BaseINT):
Wrapper for the IndividualTuningModel class to be used in fmralign with Niimg objects.
Preprocessing and searchlight/parcellation alignment are done without any user input.
Method of alignment based on the Individualized Neural Tuning model, by Feilong Ma et al. (2023).
Method of alignment based on the Individualized Neural Tuning model.
It uses searchlight/parcelation alignment to denoise the data, and then computes the stimulus response matrix.
See article : https://doi.org/10.1162/imag_a_00032
"""
Expand Down
1 change: 0 additions & 1 deletion fmralign/hyperalignment/local_template.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" Local template computation functions. Those functions are part of the warp hyperalignment
introducted by Feilong Ma et al. 2023. The functions are adapted from the original code and
adapted for more general regionations approches.
Authors: Feilong Ma (Haxby lab, Dartmouth College), Denis Fouchard (MIND, INRIA Saclay).
"""


Expand Down
18 changes: 15 additions & 3 deletions fmralign/hyperalignment/toy_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@


n_s = 10
n_t = 200
n_t = 100
n_v = 200
S_std = 1
T_std = 1
SNR = 100
latent_dim = 6 # if None, latent_dim = n_t
latent_dim = None # if None, latent_dim = n_t
decomposition_method = None # if None, SVD is used


Expand All @@ -50,9 +50,18 @@
latent_dim=latent_dim,
SNR=SNR,
seed=0,
generative_method="fastsrm",
)

searchlights, dists = generate_dummy_searchlights(n_searchlights=12, n_v=n_v, radius=5)
SEARCHLIGHT = False

if SEARCHLIGHT:
searchlights, dists = generate_dummy_searchlights(
n_searchlights=12, n_v=n_v, radius=5
)
else:
searchlights = [np.arange(n_v)]
dists = [np.zeros((n_v,))]

#############################################################################
# Test INT on the two parts of the data (ie different runs of the experiment)
Expand Down Expand Up @@ -139,6 +148,9 @@

# Stimulus matrix

print("stimulus_pred_run_1.shape", stimulus_pred_run_1.shape)
print("stimulus_run_1.shape", stimulus_run_1.shape)

correlation_stimulus_true_est_first_part = stimulus_correlation(
stimulus_pred_run_1.T, stimulus_run_1.T
)
Expand Down

0 comments on commit 2fd46d3

Please sign in to comment.