I want to collect the brainwaves of the subjects, and then convert them into square stroboscopic stimuli of the same frequency through psychopy to show them to the subjects,but I don’t know how to do it
Yes this can be done. You might start with some of the other “real-time EEG” threads:
Depending on your EEG system, you can stream the data out via Python or LSL, do an FFT or other frequency conversion, and then scale that to a value for the stimulus properties.