Newer
Older
notebooks / python / attentional_blink_sequence_generator.py

#%% [markdown]
# to run the web app, change the current directory to where the file is located and use the following command:
# `streamlit run attentional_blink_sequence_generator.py`
#
# You need to install `streamlit` package before running the web app:
# `pip install streamlit`

#%%

import random

import streamlit as st

st.title('Attentional Blink Sequence Generator')

num_of_sequences = st.sidebar.slider('Number of sequences', value=10)
sequence_size = st.sidebar.slider('Sequence size', value=20, min_value=10, max_value=22)
lag = st.sidebar.selectbox('Lag', [1,7])
items = st.sidebar.text_input('Items','ABCDEFGHIJKLMNOPQRSTUVWY')
T1_position = st.sidebar.selectbox('T1 Position', [4,9])
T2 = st.sidebar.selectbox('T2', ['X', 'Z'])
T2_position = T1_position + lag

# randomlized raw python parameters
#num_of_sequences = 10
#sequence_size = 20
#T1_positions = [4, 9]
#T2_options = ['X', 'Z']
#lags= [1, 7]
#items = 'ABCDEFGHIJKLMNOPQRSTUVWY'
#T1_position = T1_positions[random.randint(0,1)]
#T2 = T2_options[random.randint(0,1)]


st.header('Sequences')

for i in range(num_of_sequences):
  sequence = list(items)
  random.shuffle(sequence)
  sequence.insert(T2_position, T2)
  T1 = sequence[T1_position]
  sequence = sequence[0:sequence_size]

  # insert markdown signs to highlight T1 and T2
  sequence[T1_position] = f' **{T1}** '
  sequence[T2_position] = f' **{T2}** '
  st.write(''.join(sequence))