Spaces:
Sleeping
Sleeping
Upload 8 files
Browse files- tasks/__init__.py +0 -0
- tasks/__pycache__/__init__.cpython-312.pyc +0 -0
- tasks/__pycache__/cpt.cpython-312.pyc +0 -0
- tasks/__pycache__/symbol_match.cpython-312.pyc +0 -0
- tasks/__pycache__/trail_making.cpython-312.pyc +0 -0
- tasks/cpt.py +42 -0
- tasks/symbol_match.py +58 -0
- tasks/trail_making.py +28 -0
tasks/__init__.py
ADDED
|
File without changes
|
tasks/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (154 Bytes). View file
|
|
|
tasks/__pycache__/cpt.cpython-312.pyc
ADDED
|
Binary file (3.21 kB). View file
|
|
|
tasks/__pycache__/symbol_match.cpython-312.pyc
ADDED
|
Binary file (3.5 kB). View file
|
|
|
tasks/__pycache__/trail_making.cpython-312.pyc
ADDED
|
Binary file (2.38 kB). View file
|
|
|
tasks/cpt.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
def run_cpt():
|
| 5 |
+
st.subheader("🎯 Continuous Performance Task (CPT)")
|
| 6 |
+
st.write("Click the button ONLY if the current letter is **X**.")
|
| 7 |
+
|
| 8 |
+
if 'cpt_letters' not in st.session_state:
|
| 9 |
+
st.session_state.cpt_letters = random.choices(['A', 'B', 'X', 'C', 'D'], k=6)
|
| 10 |
+
st.session_state.cpt_index = 0
|
| 11 |
+
st.session_state.correct_hits = 0
|
| 12 |
+
st.session_state.false_hits = 0
|
| 13 |
+
st.session_state.clicked_this_round = False # NEW
|
| 14 |
+
|
| 15 |
+
if st.session_state.cpt_index < len(st.session_state.cpt_letters):
|
| 16 |
+
current_letter = st.session_state.cpt_letters[st.session_state.cpt_index]
|
| 17 |
+
st.markdown(f"### Letter: `{current_letter}`")
|
| 18 |
+
|
| 19 |
+
col1, col2 = st.columns(2)
|
| 20 |
+
with col1:
|
| 21 |
+
if st.button("Click if 'X'"):
|
| 22 |
+
if not st.session_state.clicked_this_round:
|
| 23 |
+
if current_letter == 'X':
|
| 24 |
+
st.session_state.correct_hits += 1
|
| 25 |
+
else:
|
| 26 |
+
st.session_state.false_hits += 1
|
| 27 |
+
st.session_state.clicked_this_round = True
|
| 28 |
+
|
| 29 |
+
with col2:
|
| 30 |
+
if st.button("Next Letter"):
|
| 31 |
+
st.session_state.cpt_index += 1
|
| 32 |
+
st.session_state.clicked_this_round = False # reset for next round
|
| 33 |
+
|
| 34 |
+
st.write(f"Progress: {st.session_state.cpt_index + 1} / {len(st.session_state.cpt_letters)}")
|
| 35 |
+
|
| 36 |
+
else:
|
| 37 |
+
st.success("✅ Task Finished")
|
| 38 |
+
st.write(f"🎯 Correct Hits: {st.session_state.correct_hits}")
|
| 39 |
+
st.write(f"❌ False Hits: {st.session_state.false_hits}")
|
| 40 |
+
if st.button("Restart CPT Task"):
|
| 41 |
+
for key in ['cpt_letters', 'cpt_index', 'correct_hits', 'false_hits', 'clicked_this_round']:
|
| 42 |
+
del st.session_state[key]
|
tasks/symbol_match.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import random
|
| 3 |
+
import time
|
| 4 |
+
|
| 5 |
+
def run_symbol_match():
|
| 6 |
+
st.subheader("🧠 Symbol Match Task")
|
| 7 |
+
|
| 8 |
+
# Step 1: Define symbols and labels
|
| 9 |
+
symbols = ['@', '#', '$', '%', '&', '*']
|
| 10 |
+
label_map = {
|
| 11 |
+
'@': 'Symbol: @',
|
| 12 |
+
'#': 'Symbol: #',
|
| 13 |
+
'$': 'Symbol: $',
|
| 14 |
+
'%': 'Symbol: %',
|
| 15 |
+
'&': 'Symbol: &',
|
| 16 |
+
'*': 'Symbol: *'
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
if "phase" not in st.session_state:
|
| 20 |
+
st.session_state.phase = "show"
|
| 21 |
+
st.session_state.target_symbol = random.choice(symbols)
|
| 22 |
+
st.session_state.start_time = None
|
| 23 |
+
st.session_state.reaction_time = None
|
| 24 |
+
|
| 25 |
+
if st.session_state.phase == "show":
|
| 26 |
+
st.write("Memorize this symbol:")
|
| 27 |
+
st.markdown(f"<h1 style='text-align: center;'>{st.session_state.target_symbol}</h1>", unsafe_allow_html=True)
|
| 28 |
+
|
| 29 |
+
if st.button("I saw it"):
|
| 30 |
+
st.session_state.phase = "match"
|
| 31 |
+
st.session_state.start_time = time.time()
|
| 32 |
+
st.rerun()
|
| 33 |
+
|
| 34 |
+
elif st.session_state.phase == "match":
|
| 35 |
+
st.write("Pick the symbol you just saw:")
|
| 36 |
+
|
| 37 |
+
# Build list of tuples: (label, actual value)
|
| 38 |
+
options = [(label_map[s], s) for s in symbols]
|
| 39 |
+
choice = st.radio("Options:", options, format_func=lambda x: x[0])
|
| 40 |
+
|
| 41 |
+
if st.button("Submit"):
|
| 42 |
+
end = time.time()
|
| 43 |
+
st.session_state.reaction_time = round(end - st.session_state.start_time, 2)
|
| 44 |
+
selected_symbol = choice[1]
|
| 45 |
+
|
| 46 |
+
if selected_symbol == st.session_state.target_symbol:
|
| 47 |
+
st.success(f"✅ Correct! Reaction time: {st.session_state.reaction_time}s")
|
| 48 |
+
else:
|
| 49 |
+
st.error(f"❌ Incorrect. It was {st.session_state.target_symbol}")
|
| 50 |
+
st.session_state.phase = "done"
|
| 51 |
+
|
| 52 |
+
elif st.session_state.phase == "done":
|
| 53 |
+
if st.button("Try Again"):
|
| 54 |
+
st.session_state.phase = "show"
|
| 55 |
+
st.session_state.target_symbol = random.choice(symbols)
|
| 56 |
+
st.session_state.start_time = None
|
| 57 |
+
st.session_state.reaction_time = None
|
| 58 |
+
st.rerun()
|
tasks/trail_making.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import time
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
def run_trail_making():
|
| 6 |
+
st.subheader("🔗 Trail Making Task")
|
| 7 |
+
st.write("Click the numbers in ascending order as fast as you can!")
|
| 8 |
+
|
| 9 |
+
if 'trail_sequence' not in st.session_state:
|
| 10 |
+
st.session_state.trail_sequence = random.sample(range(1, 6), 5)
|
| 11 |
+
st.session_state.clicked_numbers = []
|
| 12 |
+
st.session_state.trail_start_time = time.time()
|
| 13 |
+
|
| 14 |
+
cols = st.columns(5)
|
| 15 |
+
for idx, num in enumerate(st.session_state.trail_sequence):
|
| 16 |
+
if cols[idx].button(str(num), key=f"btn_{num}"):
|
| 17 |
+
if num not in st.session_state.clicked_numbers:
|
| 18 |
+
st.session_state.clicked_numbers.append(num)
|
| 19 |
+
|
| 20 |
+
if len(st.session_state.clicked_numbers) == 5:
|
| 21 |
+
if st.session_state.clicked_numbers == sorted(st.session_state.trail_sequence):
|
| 22 |
+
rt = round(time.time() - st.session_state.trail_start_time, 2)
|
| 23 |
+
st.success(f"✅ Correct order! Time taken: {rt} seconds")
|
| 24 |
+
else:
|
| 25 |
+
st.error("❌ Incorrect order. Try again.")
|
| 26 |
+
if st.button("Restart"):
|
| 27 |
+
for key in ['trail_sequence', 'clicked_numbers', 'trail_start_time']:
|
| 28 |
+
del st.session_state[key]
|