Measure how strongly repeated items attract incoming transitions from temporal neighbors.
The incoming (“clean backward”) repetition CRP reverses each recall sequence before computing the standard repetition CRP. This measures the conditional probability of transitioning to a repeated item as a function of lag from each of its study positions. Comparing observed data against shuffled controls isolates repetition-specific attraction from baseline temporal contiguity.
Workflow
Code
import os
import matplotlib.pyplot as plt
import warnings
from jaxcmr.analyses.cleanbackrepcrp import plot_back_rep_crp
from jaxcmr.repetition import make_control_dataset
from jaxcmr.helpers import find_project_root, generate_trial_mask, load_data, save_figure
warnings.filterwarnings("ignore" )
Code
data_path = "data/LohnasKahana2014.h5"
figure_dir = "results/figures"
figure_str = ""
ylim = None
mixed_trial_query = 'data["list_type"] > 2'
control_trial_query = 'data["list_type"] == 1'
control_shuffles = 10
min_lag = 4
max_lag = 5
size = 2
Code
project_root = find_project_root()
figure_dir = os.path.join(project_root, figure_dir)
data_path = os.path.join(project_root, data_path)
data = load_data(data_path)
mixed_mask = generate_trial_mask(data, mixed_trial_query)
control_data = make_control_dataset(data, generate_trial_mask(data, control_trial_query), shuffles= control_shuffles)
control_mask = generate_trial_mask(control_data, "data['subject'] > 0" )
Code
plot_back_rep_crp(data, mixed_mask, max_lag= max_lag, min_lag= min_lag, size= size)
if ylim is not None :
for ax in plt.gcf().axes:
ax.set_ylim(ylim)
save_figure(figure_dir, figure_str)
Interpretation
Each panel shows CRP curves for incoming transitions to a repeated item, indexed by which presentation (first or second) is the target.
Peak near the target’s study position : the repeated item attracts transitions from temporal neighbors.
Observed > control : repetition-specific attraction beyond baseline contiguity.
Second presentation peak > first : more recent occurrence is a stronger attractor.
API Details
Notebook parameters
data_path — path to an HDF5 file containing a RecallDataset with repeated items.
figure_dir — directory for saving figures.
figure_str — base filename for the saved figure. Leave empty to display without saving.
ylim — y-axis limits as a tuple, or None for automatic scaling.
mixed_trial_query — selects trials containing repeated items.
control_trial_query — selects pure (no-repeat) trials for the shuffled control.
control_shuffles — number of shuffled control blocks per subject.
min_lag — minimum spacing between repeated presentations.
max_lag — maximum lag to display on the x-axis.
size — maximum number of study positions a single item can occupy.