awacke1 commited on
Commit
99a62a6
Β·
verified Β·
1 Parent(s): 6f800fb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +685 -0
app.py ADDED
@@ -0,0 +1,685 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import random
3
+ import time
4
+
5
+ st.title('Brain Training Exercises')
6
+
7
+ st.write('This app provides a comprehensive survey of brain-training exercises designed to enhance various cognitive skills. Select a category below to view the exercises and try them out!')
8
+
9
+ categories = ['Attention', 'Brain Speed', 'Memory', 'People Skills', 'Intelligence', 'Navigation']
10
+ choice = st.sidebar.selectbox('Select a category', categories)
11
+
12
+ if choice == 'Attention':
13
+ st.header('Attention Exercises')
14
+
15
+ st.subheader('Focus Flexibility Drill')
16
+ st.write('Scientific Principles: Based on the ability of the brain to switch focus from one task to another, enhancing cognitive flexibility.')
17
+ st.write('Cognitive Skills: Focus shifting, sustained attention, and task switching.')
18
+ st.write('Exercise Task: Switch between reading a book and solving a puzzle every 3 minutes for 30 minutes daily.')
19
+
20
+ if st.button('Start Focus Drill'):
21
+ st.write('Read a page from a book for 3 minutes')
22
+ time.sleep(180)
23
+ st.write('Now solve a puzzle for 3 minutes')
24
+ time.sleep(180)
25
+ st.write('Drill complete! Practice this daily to improve your focus flexibility.')
26
+
27
+ st.subheader('Dual N-Back')
28
+ st.write('Scientific Principles: Improves working memory and fluid intelligence by requiring the user to remember two separate sequences of stimuli.')
29
+ st.write('Cognitive Skills: Working memory, attention span, and concentration.')
30
+ st.write('Exercise Task: On a computer program, respond whenever the current visual and auditory stimuli match the one from N steps earlier.')
31
+
32
+ if st.button('Play Dual 2-Back'):
33
+ positions = ['left', 'right']
34
+ sounds = ['high', 'low']
35
+
36
+ if 'score' not in st.session_state:
37
+ st.session_state.score = 0
38
+
39
+ prev_position = ''
40
+ prev_sound = ''
41
+
42
+ for i in range(10):
43
+ position = random.choice(positions)
44
+ sound = random.choice(sounds)
45
+
46
+ st.write(f'Round {i+1}')
47
+ if position == 'left':
48
+ st.write('◀️')
49
+ else:
50
+ st.write('▢️')
51
+
52
+ if sound == 'high':
53
+ st.write('High tone')
54
+ else:
55
+ st.write('Low tone')
56
+
57
+ if i >= 2:
58
+ if st.button('Match', key=f'{i}a'):
59
+ if position == prev_position and sound == prev_sound:
60
+ st.session_state.score += 1
61
+ st.write('Correct! 1 Point')
62
+ else:
63
+ st.write('Incorrect, no points')
64
+ if st.button('No Match', key=f'{i}b'):
65
+ if position != prev_position or sound != prev_sound:
66
+ st.session_state.score += 1
67
+ st.write('Correct! 1 Point')
68
+ else:
69
+ st.write('Incorrect, no points')
70
+ else:
71
+ time.sleep(1)
72
+
73
+ prev_position = position
74
+ prev_sound = sound
75
+
76
+ st.write(f'Game Over. Final Score: {st.session_state.score}/8')
77
+
78
+ st.subheader('Selective Attention Field')
79
+ st.write('Scientific Principles: Enhances the ability to focus on relevant stimuli while ignoring distractions.')
80
+ st.write('Cognitive Skills: Selective attention, focus, and concentration.')
81
+ st.write('Exercise Task: Identify specific letters or numbers within a field of various characters for a set duration daily.')
82
+
83
+ if st.button('Start Attention Field'):
84
+ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
85
+ target = random.choice(chars)
86
+ st.write(f'Your target is: {target}')
87
+
88
+ field = ''
89
+ for i in range(500):
90
+ field += random.choice(chars)
91
+ st.write(field)
92
+
93
+ count = st.number_input('How many times did the target appear?')
94
+ if count == field.count(target):
95
+ st.write('Correct!')
96
+ else:
97
+ st.write(f'Incorrect. The target appeared {field.count(target)} times.')
98
+
99
+ elif choice == 'Brain Speed':
100
+ st.header('Brain Speed Exercises')
101
+
102
+ st.subheader('Rapid Visual Processing')
103
+ st.write('Scientific Principles: Based on the temporal dynamics of visual perception and decision-making.')
104
+ st.write('Cognitive Skills: Processing speed, visual scanning, and quick decision-making.')
105
+ st.write('Exercise Task: Identify and click on sequences of numbers as fast as possible from a larger group.')
106
+
107
+ if st.button('Start RVP Test'):
108
+ numbers = '0123456789'
109
+ sequence = ''
110
+ for i in range(3):
111
+ sequence += random.choice(numbers)
112
+
113
+ st.write('Click when you see this sequence:')
114
+ st.write(sequence)
115
+ time.sleep(2)
116
+
117
+ if 'start_time' not in st.session_state:
118
+ st.session_state.start_time = 0
119
+
120
+ if 'end_time' not in st.session_state:
121
+ st.session_state.end_time = 0
122
+
123
+ stream = ''
124
+ for i in range(200):
125
+ stream += random.choice(numbers)
126
+
127
+ start = stream.index(sequence)
128
+ end = start + len(sequence)
129
+ stream = stream[:start] + sequence + stream[end+1:]
130
+
131
+ display = st.empty()
132
+
133
+ for i in range(len(stream)):
134
+ display.write(stream[i])
135
+ if stream[i:i+len(sequence)] == sequence and st.session_state.start_time == 0:
136
+ st.session_state.start_time = time.time()
137
+
138
+ time.sleep(0.1)
139
+
140
+ st.session_state.end_time = time.time()
141
+
142
+ if st.button('Click Here', key='s') and st.session_state.start_time != 0:
143
+ reaction_time = round(st.session_state.end_time - st.session_state.start_time, 3)
144
+ st.write(f'Reaction Time: {reaction_time} seconds')
145
+
146
+ st.subheader('Reaction Time Ruler Drop Test')
147
+ st.write('Scientific Principles: Measures the speed of response to a visual stimulus.')
148
+ st.write('Cognitive Skills: Reaction time, hand-eye coordination.')
149
+ st.write('Exercise Task: Catch a falling ruler as quickly as possible after it is released without warning.')
150
+
151
+ st.subheader('Speed Trivia')
152
+ st.write('Scientific Principles: Encourages rapid information retrieval and processing.')
153
+ st.write('Cognitive Skills: Processing speed, memory recall, and decision-making under pressure.')
154
+ st.write('Exercise Task: Answer as many trivia questions as possible within a set time limit.')
155
+
156
+ if st.button('Start Speed Trivia'):
157
+ questions = [
158
+ {'question': 'What is the capital of France?', 'answer': 'Paris'},
159
+ {'question': 'What is the largest planet in our solar system?', 'answer': 'Jupiter'},
160
+ {'question': 'What is the smallest country in the world?', 'answer': 'Vatican City'},
161
+ {'question': 'What is the currency of Japan?', 'answer': 'Yen'},
162
+ {'question': 'What is the largest desert in the world?', 'answer': 'Antarctica'},
163
+ {'question': 'What is the tallest mammal?', 'answer': 'Giraffe'},
164
+ {'question': 'What is the most populated country in the world?', 'answer': 'China'},
165
+ {'question': 'What is the chemical symbol for gold?', 'answer': 'Au'},
166
+ {'question': 'What is the largest ocean in the world?', 'answer': 'Pacific'},
167
+ {'question': 'What is the capital of Australia?', 'answer': 'Canberra'}
168
+ ]
169
+
170
+ score = 0
171
+ start_time = time.time()
172
+
173
+ while time.time() - start_time < 60:
174
+ question = random.choice(questions)
175
+ user_answer = st.text_input(question['question'])
176
+
177
+ if user_answer.lower() == question['answer'].lower():
178
+ score += 1
179
+ st.write('Correct!')
180
+ else:
181
+ st.write(f"Incorrect. The answer was {question['answer']}")
182
+
183
+ st.write(f'Time is up! You answered {score} questions correctly.')
184
+
185
+ elif choice == 'Memory':
186
+ st.header('Memory Exercises')
187
+
188
+ st.subheader('Mnemonic Visualization')
189
+ st.write('Scientific Principles: Utilizes vivid imagery and association to enhance recall.')
190
+ st.write('Cognitive Skills: Long-term memory, associative learning, and visualization.')
191
+ st.write('Exercise Task: Create vivid images or stories linking unrelated items in a list to remember them.')
192
+
193
+ if st.button('Try Mnemonic Visualization'):
194
+ items = ['apple', 'bicycle', 'cat', 'dragon', 'elephant']
195
+ st.write(f'Memorize this list of items: {", ".join(items)}')
196
+
197
+ time.sleep(10)
198
+
199
+ st.write('Now visualize a story connecting the items, like:')
200
+ st.write('An APPLE riding a BICYCLE chasing a CAT who is flying on a DRAGON that is stepping on an ELEPHANT.')
201
+
202
+ time.sleep(10)
203
+
204
+ recalled = st.text_input('Type out the original list of items')
205
+ recalled_list = [item.strip() for item in recalled.split(',')]
206
+
207
+ correct = 0
208
+ for item in recalled_list:
209
+ if item in items:
210
+ correct += 1
211
+
212
+ st.write(f'You recalled {correct} out of {len(items)} items correctly!')
213
+
214
+ st.subheader('Chunking Practice')
215
+ st.write('Scientific Principles: Based on the concept of working memory's limited capacity and enhancing it by grouping information.')
216
+ st.write('Cognitive Skills: Short-term memory, organization, and recall efficiency.')
217
+ st.write('Exercise Task: Break down complex information into smaller, manageable chunks for study or memorization.')
218
+
219
+ if st.button('Start Chunking'):
220
+ number = ''
221
+ for i in range(12):
222
+ number += str(random.randint(0,9))
223
+
224
+ st.write(f'Memorize this number: {number}')
225
+ time.sleep(10)
226
+
227
+ chunked = ''
228
+ for i in range(0, len(number), 3):
229
+ chunked += number[i:i+3] + ' '
230
+
231
+ st.write('Now think of it as chunked into groups of 3:')
232
+ st.write(chunked)
233
+
234
+ time.sleep(10)
235
+
236
+ recalled = st.text_input('Enter the original 12-digit number')
237
+
238
+ if recalled == number:
239
+ st.write('Perfect recall! Chunking makes memorization easier.')
240
+ else:
241
+ st.write(f'Not quite, the original number was {number}. Keep practicing chunking!')
242
+
243
+ st.subheader('Spatial Recall')
244
+ st.write('Scientific Principles: Engages and improves spatial memory and visual-spatial reasoning.')
245
+ st.write('Cognitive Skills: Spatial memory, spatial reasoning, and visualization.')
246
+ st.write('Exercise Task: Memorize and recall the location of objects in a space after brief exposure.')
247
+
248
+ if st.button('Test Spatial Recall'):
249
+ grid = [
250
+ ['🍎','','','🍌'],
251
+ ['','πŸ‡','🍊',''],
252
+ ['','','','πŸ“'],
253
+ ['','πŸ‰','','']
254
+ ]
255
+
256
+ for row in grid:
257
+ st.write('|'.join(cell if cell else ' ' for cell in row))
258
+
259
+ time.sleep(10)
260
+
261
+ for row in grid:
262
+ st.write('|'.join(' ' for cell in row))
263
+
264
+ st.write('Enter the coordinates of each fruit, like A1 for top-left')
265
+
266
+ answers = {
267
+ 'apple': 'A1',
268
+ 'banana': 'A4',
269
+ 'grapes': 'B2',
270
+ 'orange': 'B3',
271
+ 'strawberry': 'C4',
272
+ 'watermelon': 'D2'
273
+ }
274
+
275
+ score = 0
276
+ for fruit, location in answers.items():
277
+ answer = st.text_input(f'Where was the {fruit}?')
278
+ if answer.upper() == location:
279
+ score += 1
280
+
281
+ st.write(f'You got {score} out of {len(answers)} correct!')
282
+
283
+
284
+ elif choice == 'People Skills':
285
+ st.header('People Skills Exercises')
286
+
287
+ st.subheader('Emotion Recognition Training')
288
+ st.write('Scientific Principles: Enhances emotional intelligence and empathy by recognizing and interpreting emotions in others.')
289
+ st.write('Cognitive Skills: Emotional intelligence, empathy, and social cues interpretation.')
290
+ st.write('Exercise Task: Identify emotions from facial expressions, tone of voice, or body language in photos, videos, or in-person interactions.')
291
+
292
+ # Coding implementation for emotion recognition omitted here as it would require an image dataset and ML model
293
+
294
+ st.subheader('Perspective-Taking Scenarios')
295
+ st.write('Scientific Principles: Develops empathy and understanding by considering different viewpoints.')
296
+ st.write('Cognitive Skills: Empathy, perspective-taking, and critical thinking.')
297
+ st.write('Exercise Task: Analyze written scenarios from multiple character's viewpoints to understand their perspectives and motivations.')
298
+
299
+ if st.button('Try Perspective-Taking'):
300
+ scenario = '''
301
+ John and Mary are colleagues at work. John has been working on a major project for months, staying late and coming in on weekends. The day before the project is due, Mary points out a significant flaw in John's work that requires him to make major revisions. John gets upset with Mary, accusing her of sabotaging his work at the last minute. Mary is surprised by John's reaction and feels her feedback was necessary for the success of the project.
302
+ '''
303
+
304
+ st.write(scenario)
305
+
306
+ perspective1 = st.text_area("Describe John's perspective")
307
+ perspective2 = st.text_area("Describe Mary's perspective")
308
+
309
+ if perspective1 and perspective2:
310
+ st.write("John's perspective likely centers around feeling overwhelmed, frustrated that a flaw was found last-minute after so much hard work, and possibly betrayed or attacked by Mary's feedback. He may feel Mary was being overly critical or should have brought this up sooner.")
311
+ st.write("Mary's perspective is likely that she was just trying to help ensure the project's success, not attack John. She was doing her job by providing feedback, and didn't intend for it to be last-minute - she may have only just noticed the issue. She seems surprised John took it so personally.")
312
+ st.write("Considering both sides, the conflict likely stems from John perceiving Mary's feedback as a personal slight due to the stress and personal investment he had in the project. Mary didn't intend it that way, but could perhaps work on delivering constructive criticism
313
+
314
+
315
+
316
+ import streamlit as st
317
+ import random
318
+ import time
319
+
320
+ def stroop_test():
321
+ colors = ["RED", "BLUE", "GREEN", "YELLOW"]
322
+ color_text = ["blue", "green", "yellow", "red"]
323
+ score = 0
324
+ for word, color in zip(colors, color_text):
325
+ response = st.text_input(f"Enter the color of the text '{word}': ")
326
+ if response.lower() == color:
327
+ score += 1
328
+ st.write(f"Score: {score} out of {len(colors)}")
329
+
330
+ def flanker_task():
331
+ targets = ["<", ">"]
332
+ conditions = ["congruent", "incongruent"]
333
+ score = 0
334
+ for _ in range(10):
335
+ target = random.choice(targets)
336
+ condition = random.choice(conditions)
337
+ stim = target*5 if condition == "congruent" else target.replace(">","<") + target + target.replace(">","<")*3
338
+ response = st.text_input(f"Enter the central arrow direction in '{stim}': ")
339
+ if response == target:
340
+ score += 1
341
+ st.write(f"Score: {score} out of 10")
342
+
343
+ def attentional_blink():
344
+ letters = "ABCDEFGHJKLMNOPQRSTUVWXYZ"
345
+ target1, target2 = random.sample(letters,2)
346
+ stimuli = random.choices(letters, k=18)
347
+ stimuli.insert(random.randint(3,7), target1)
348
+ stimuli.insert(random.randint(8,15), target2)
349
+ st.write(f"Your targets are: {target1} and {target2}. Press Enter to start...")
350
+ for letter in stimuli:
351
+ st.write(letter)
352
+ time.sleep(0.1)
353
+ response1 = st.text_input("What was the first target letter? ")
354
+ response2 = st.text_input("What was the second target letter? ")
355
+ score = int(response1==target1) + int(response2==target2)
356
+ st.write(f"Score: {score} out of 2")
357
+
358
+ def simple_reaction_time():
359
+ st.write("Press Enter to begin when you see the prompt. Your reaction time will be measured.")
360
+ time.sleep(random.randint(2,5))
361
+ start = time.time()
362
+ st.text_input("Press Enter now!")
363
+ end = time.time()
364
+ rt = round((end - start)*1000)
365
+ st.write(f"Your reaction time: {rt} milliseconds")
366
+
367
+ def go_nogo_task():
368
+ stim = ["Go", "No-Go"]
369
+ score = 0
370
+ st.write("Press Enter for 'Go' stimuli. Do not press for 'No-Go'! You have 0.5s to respond.")
371
+ for _ in range(10):
372
+ stimulus = random.choice(stim)
373
+ st.write(stimulus)
374
+ start = time.time()
375
+ response = st.text_input("")
376
+ end = time.time()
377
+ rt = end - start
378
+ if stimulus == "Go" and rt < 0.5:
379
+ score += 1
380
+ elif stimulus == "No-Go" and response == "":
381
+ score += 1
382
+ st.write(f"Score: {score} out of 10")
383
+
384
+ def choice_reaction_time():
385
+ stim = ["Left", "Right", "Up", "Down"]
386
+ keys = ["a", "d", "w", "s"]
387
+ score = 0
388
+ st.write("Press the correct key (a/d/w/s) depending on the word shown. You have 0.8s to respond.")
389
+ for _ in range(10):
390
+ stimulus = random.choice(stim)
391
+ st.write(stimulus)
392
+ start = time.time()
393
+ response = st.text_input("")
394
+ end = time.time()
395
+ rt = end - start
396
+ if response == keys[stim.index(stimulus)] and rt < 0.8:
397
+ score += 1
398
+ st.write(f"Score: {score} out of 10")
399
+
400
+ def n_back():
401
+ digits = list(range(10))
402
+ n = 2
403
+ sequence = random.choices(digits, k=15)
404
+ st.write(f"Enter 'yes' if the current number is the same as the number {n} steps back in the sequence.")
405
+ score = 0
406
+ for i in range(n,len(sequence)):
407
+ st.write(sequence[i])
408
+ response = st.text_input("")
409
+ if response == "yes" and sequence[i] == sequence[i-n]:
410
+ score += 1
411
+ elif response == "" and sequence[i] != sequence[i-n]:
412
+ score += 1
413
+ st.write(f"Score: {score} out of {len(sequence)-n}")
414
+
415
+ def corsi_block_tapping():
416
+ blocks = list(range(9))
417
+ sequence = []
418
+ for span in range(2,10):
419
+ st.write(f"\nSpan length: {span}. Watch the block sequence...")
420
+ sequence = random.sample(blocks, span)
421
+ st.write(sequence)
422
+ response = st.text_input("Reproduce the sequence (enter digits with spaces): ")
423
+ if response == ' '.join(map(str,sequence)):
424
+ st.write("Correct!")
425
+ else:
426
+ st.write(f"Incorrect. The sequence was {sequence}")
427
+ break
428
+ st.write(f"Your maximum span: {len(sequence)-1}")
429
+
430
+ def paired_associates():
431
+ pairs = [("cat", "meow"), ("dog", "bark"), ("bird", "chirp"), ("pig", "oink"), ("cow", "moo")]
432
+ st.write("Study the word pairs:")
433
+ st.write(*[f"{pair[0]} - {pair[1]}" for pair in pairs], sep='\n')
434
+ st.text_input("\nPress Enter to start the recall test...")
435
+ score = 0
436
+ for i in range(5):
437
+ cue, target = random.choice(pairs)
438
+ pairs.remove((cue, target))
439
+ response = st.text_input(f"\nWhat word was paired with '{cue}'? ")
440
+ if response == target:
441
+ st.write("Correct!")
442
+ score += 1
443
+ else:
444
+ st.write(f"Incorrect. The pair was: {cue} - {target}")
445
+ st.write(f"\nScore: {score} out of 5")
446
+
447
+ def reading_the_mind_in_the_eyes():
448
+ eyes = {
449
+ "Image1": ["playful", "comforting", "irritated", "bored"],
450
+ "Image2": ["terrified", "upset", "arrogant", "annoyed"],
451
+ "Image3": ["joking", "flustered", "desire", "convinced"],
452
+ "Image4": ["joking", "insisting", "amused", "relaxed"],
453
+ "Image5": ["irritated", "sarcastic", "worried", "friendly"]
454
+ }
455
+ score = 0
456
+ for image, words in eyes.items():
457
+ target = words[0]
458
+ random.shuffle(words)
459
+ st.write(f"\n{image}:")
460
+ st.write(*[f"{i+1}. {word}" for i,word in enumerate(words)], sep='\n')
461
+ response = int(st.text_input("Which word best describes the person's mental state? ")) - 1
462
+ if words[response] == target:
463
+ st.write("Correct!")
464
+ score += 1
465
+ else:
466
+ st.write(f"Incorrect. The best answer is: {target}")
467
+ st.write(f"\nScore: {score} out of {len(eyes)}")
468
+
469
+ def faux_pas_recognition():
470
+ stories = [
471
+ ("Alice was at a party when she saw an old friend, Bob. 'Hi, nice to see you!' Alice said. 'You look great! How's the new job going?' Bob looked confused and said, 'I don't have a new job. I've been unemployed for months.'", True),
472
+ ("John was at the grocery store when he ran into his neighbor, Sarah. They chatted for a few minutes about their weekend plans and the nice weather. Then they said goodbye and continued their shopping.", False),
473
+ ("Mary was having lunch with her coworkers. 'I love your new haircut,' she said to Emily. 'It really suits you!' Emily smiled and said, 'Thanks, I got it cut last week.' Then Emily turned to Jane and said, 'I wish I could say the same for you, Jane. Your hair looks like a mess!'", True)
474
+ ]
475
+ score = 0
476
+ for story, faux_pas in stories:
477
+ st.write(f"\n{story}")
478
+ response = st.text_input("\nDid someone say something they shouldn't have? (yes/no): ")
479
+ if response == "yes" and faux_pas == True:
480
+ explanation = st.text_input("Explain what was said that was socially incorrect: ")
481
+ st.write(f"Correct! {explanation}")
482
+ score += 1
483
+ elif response == "no" and faux_pas == False:
484
+ st.write("Correct, there was no faux pas in this story.")
485
+ score += 1
486
+ else:
487
+ st.write("Incorrect. Let's move on to the next story.")
488
+ st.write(f"\nScore: {score} out of {len(stories)}")
489
+
490
+ def interpersonal_perception_task():
491
+ videos = {
492
+ "Video1": (
493
+ "Emma and Liam are sitting at a cafe, drinking coffee and chatting. Emma is smiling and leaning forward while telling a story. Liam has his arms crossed and is frowning slightly as he listens.",
494
+ {
495
+ "How engaged does Emma seem in the conversation?": ["Very engaged", "Somewhat engaged", "Not very engaged", "Not at all engaged"],
496
+ "How interested does Liam seem in what Emma is saying?": ["Very interested", "Somewhat interested", "Not very interested", "Not at all interested"]
497
+ },
498
+ ["Very engaged", "Not very interested"]
499
+ ),
500
+ "Video2": (
501
+ "Olivia and Ethan are in a heated discussion. Olivia is gesturing with her hands and looks frustrated. Ethan has his hands on his hips and is shaking his head.",
502
+ {
503
+ "What emotion is Olivia most likely expressing?": ["Anger", "Sadness", "Fear", "Joy"],
504
+ "Does Ethan seem to agree with what Olivia is saying?": ["Definitely agrees", "Probably agrees", "Probably disagrees", "Definitely disagrees"]
505
+ },
506
+ ["Anger", "Definitely disagrees"]
507
+ )
508
+ }
509
+
510
+ score = 0
511
+ for video, (description, questions, answers) in videos.items():
512
+ st.write(f"\n{video}: {description}")
513
+ for question, choices in questions.items():
514
+ st.write(f"\n{question}")
515
+ st.write(*[f"{i+1}. {choice}" for i,choice in enumerate(choices)], sep='\n')
516
+ response = int(st.text_input("Enter the number of your answer: ")) - 1
517
+ if choices[response] == answers[list(questions.keys()).index(question)]:
518
+ st.write("Correct!")
519
+ score += 1
520
+ else:
521
+ st.write(f"Incorrect. The best answer is: {answers[list(questions.keys()).index(question)]}")
522
+ st.write(f"\nScore: {score} out of {sum([len(q) for _,q,_ in videos.values()])}")
523
+
524
+ def ravens_progressive_matrices():
525
+ matrices = [
526
+ (
527
+ ["πŸ”΄πŸ”΄πŸ”΄","🟒🟒🟒","πŸ”΅πŸ”΅πŸ”΅"],
528
+ ["🟒🟒🟒","πŸ”΅πŸ”΅πŸ”΅",""],
529
+ ["πŸ”΄πŸ”΄πŸ”΄","🟠🟠🟠","🟑🟑🟑","βšͺβšͺβšͺ"]
530
+ ),
531
+ (
532
+ ["πŸ”Ί","πŸ”ΊπŸ”Ί","πŸ”ΊπŸ”ΊπŸ”Ί"],
533
+ ["πŸŸ₯","πŸŸ₯πŸŸ₯",""],
534
+ ["πŸ”»","πŸ”»πŸ”»","πŸ”»πŸ”»πŸ”»","⬜"]
535
+ )
536
+ ]
537
+ score = 0
538
+ for matrix, problem, choices in matrices:
539
+ st.write("\nComplete the matrix:")
540
+ for row in matrix:
541
+ st.write("".join(row))
542
+ for row in problem:
543
+ st.write("".join(row))
544
+ st.write("\nChoices:")
545
+ for i, choice in enumerate(choices):
546
+ st.write(f"{i+1}. {choice}")
547
+ response = int(st.text_input("Enter the number of your answer: ")) - 1
548
+ if choices[response] == choices[-1]:
549
+ st.write("Correct!")
550
+ score += 1
551
+ else:
552
+ st.write(f"Incorrect. The correct answer is: {choices[-1]}")
553
+ st.write(f"\nScore: {score} out of {len(matrices)}")
554
+
555
+ def main():
556
+ st.title("Brain Training Exercises")
557
+ st.sidebar.title("Select an Exercise")
558
+
559
+ exercise = st.sidebar.selectbox("", [
560
+ "Stroop Test",
561
+ "Flanker Task",
562
+ "Attentional Blink",
563
+ "Simple Reaction Time",
564
+ "Go/No-Go Task",
565
+ "Choice Reaction Time",
566
+ "N-Back",
567
+ "Corsi Block Tapping",
568
+ "Paired Associates",
569
+ "Reading the Mind in the Eyes",
570
+ "Faux Pas Recognition",
571
+ "Interpersonal Perception Task",
572
+ "Raven's Progressive Matrices"
573
+ ])
574
+
575
+ st.header(exercise)
576
+
577
+ if exercise == "Stroop Test":
578
+ st.markdown("""
579
+ ## 🎨 Stroop Test
580
+ - πŸ“ Words for colors are shown in different colored text
581
+ - πŸ–±οΈ Select the color of the text, not the word itself
582
+ - 🧠 Tests selective attention and inhibitory control
583
+ """)
584
+ stroop_test()
585
+ elif exercise == "Flanker Task":
586
+ st.markdown("""
587
+ ## 🎯 Flanker Task
588
+ - β¬…οΈβž‘οΈ Targets (arrows) are flanked by distractors facing the same or opposite direction
589
+ - πŸ–±οΈ Select the central target quickly while ignoring the flankers
590
+ - 🧠 Tests focused attention and filtering out irrelevant stimuli
591
+ """)
592
+ flanker_task()
593
+ elif exercise == "Attentional Blink":
594
+ st.markdown("""
595
+ ## 😡 Attentional Blink
596
+ - πŸ”  Detect two targets in a rapid stream of letters
597
+ - ⏱️ The second target follows shortly after the first
598
+ - 🧠 Tests temporal limitations of attention in processing successive targets
599
+ """)
600
+ attentional_blink()
601
+ elif exercise == "Simple Reaction Time":
602
+ st.markdown("""
603
+ ## ⏰ Simple Reaction Time
604
+ - ▢️ Respond as quickly as possible to a stimulus
605
+ - πŸ–±οΈ Press Enter when you see the prompt
606
+ - 🧠 Measures basic psychomotor speed
607
+ """)
608
+ simple_reaction_time()
609
+ elif exercise == "Go/No-Go Task":
610
+ st.markdown("""
611
+ ## 🚦 Go/No-Go Task
612
+ - βœ… Respond quickly to 'Go' stimuli
613
+ - ❌ Withhold response to 'No-Go' stimuli
614
+ - 🧠 Measures action restraint and response inhibition
615
+ """)
616
+ go_nogo_task()
617
+ elif exercise == "Choice Reaction Time":
618
+ st.markdown("""
619
+ ## πŸŽ›οΈ Choice Reaction Time
620
+ - πŸ”  Make the appropriate response depending on the stimulus shown
621
+ - ⌨️ Press the correct key (a/d/w/s) for each word
622
+ - 🧠 Measures decision speed and response selection
623
+ """)
624
+ choice_reaction_time()
625
+ elif exercise == "N-Back":
626
+ st.markdown("""
627
+ ## πŸ”™ N-Back
628
+ - πŸ”’ Stimuli are presented sequentially
629
+ - πŸ–±οΈ Respond when the current stimulus matches the one from N steps back
630
+ - 🧠 Tests working memory updating and monitoring
631
+ """)
632
+ n_back()
633
+ elif exercise == "Corsi Block Tapping":
634
+ st.markdown("""
635
+ ## 🧱 Corsi Block Tapping
636
+ - πŸ“‹ Blocks are tapped in a sequence
637
+ - πŸ–±οΈ Reproduce the sequence by tapping the blocks in the same order
638
+ - 🧠 Tests visuospatial sketchpad capacity in working memory
639
+ """)
640
+ corsi_block_tapping()
641
+ elif exercise == "Paired Associates":
642
+ st.markdown("""
643
+ ## 🀝 Paired Associates
644
+ - πŸ“š Study a list of word pairs
645
+ - πŸ–±οΈ When cued with one word, recall the paired associate
646
+ - 🧠 Tests associative memory and encoding/retrieval processes
647
+ """)
648
+ paired_associates()
649
+ elif exercise == "Reading the Mind in the Eyes":
650
+ st.markdown("""
651
+ ## πŸ‘€ Reading the Mind in the Eyes
652
+ - πŸ˜”πŸ˜„πŸ˜ πŸ˜Œ View images of eyes expressing a mental state
653
+ - πŸ–±οΈ Select the word that best describes the person's feelings or thoughts
654
+ - 🧠 Tests theory of mind and emotion recognition
655
+ """)
656
+ reading_the_mind_in_the_eyes()
657
+ elif exercise == "Faux Pas Recognition":
658
+ st.markdown("""
659
+ ## 😳 Faux Pas Recognition
660
+ - πŸ“– Read brief stories, some containing a social faux pas
661
+ - πŸ–±οΈ Detect the faux pas and explain why it occurred
662
+ - 🧠 Tests understanding of social norms and recognition of social errors
663
+ """)
664
+ faux_pas_recognition()
665
+ elif exercise == "Interpersonal Perception Task":
666
+ st.markdown("""
667
+ ## πŸ—£οΈ Interpersonal Perception Task
668
+ - πŸŽ₯ Watch brief videos of social interactions
669
+ - πŸ–±οΈ Answer questions about the thoughts, feelings, and intentions of the people
670
+ - 🧠 Tests social perception and understanding of nonverbal cues
671
+ """)
672
+ interpersonal_perception_task()
673
+ elif exercise == "Raven's Progressive Matrices":
674
+ st.markdown("""
675
+ ## 🧩 Raven's Progressive Matrices
676
+ - πŸ”³πŸ”² Complete a matrix or pattern by identifying the missing element
677
+ - πŸ–±οΈ Select the choice that satisfies the rule
678
+ - οΏ½οΏ½οΏ½οΏ½ Tests abstract reasoning and fluid intelligence
679
+ """)
680
+ ravens_progressive_matrices()
681
+
682
+ if __name__ == "__main__":
683
+ main()
684
+
685
+