Example #1
0
def main():
    eeg_device, experiment, record_duration, save_fn = intro_prompt()

    # run experiment
    if experiment == 'visual-N170':
        n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-P300':
        p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-SSVEP':
        ssvep.present(duration=record_duration,
                      eeg=eeg_device,
                      save_fn=save_fn)
    elif experiment == 'auditory_oddball':
        conditions_file = 'MUSE_conditions.mat'
        F = h5py.File(conditions_file, 'r')  #['museEEG']
        highPE = np.squeeze(F['museEEG']['design']['highPE'][:]).astype(int)
        lowPE = np.squeeze(F['museEEG']['design']['lowPE'][:]).astype(int)
        inputs = np.squeeze(F['museEEG']['design']['inputs'][:]).astype(int)
        oddball = np.squeeze(F['museEEG']['design']['oddball'][:]).astype(int)
        oddball -= 1
        stim_types = oddball
        itis = np.ones_like(oddball) * 0.5
        newAdditionalMarkers = []
        for i in range(0, len(highPE)):
            newAdditionalMarker = str(stim_types[i]) + str(highPE[i]) + str(
                lowPE[i])
            newAdditionalMarkers.append(newAdditionalMarker)
        additional_labels = {'labels': newAdditionalMarkers}
        auditoryaMMN.present(
            record_duration=record_duration,
            stim_types=stim_types,
            itis=itis,
            additional_labels={'labels': newAdditionalMarkers},
            eeg=eeg_device,
            save_fn=save_fn)
Example #2
0
def run_experiment(experiment, record_duration, eeg_device, save_fn):
    if experiment == "visual-N170":
        n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == "visual-P300":
        p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == "visual-SSVEP":
        ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == "auditory-SSAEP":
        ssaep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == "auditory-oddball":
        # conditions_file = os.path.join(eegnb_file, 'experiments', 'auditory-oddball', "MUSE_conditions.mat")
        F = h5py.File(mcond_file, "r")  # ['museEEG']
        highPE = np.squeeze(F["museEEG"]["design"]["highPE"][:]).astype(int)
        lowPE = np.squeeze(F["museEEG"]["design"]["lowPE"][:]).astype(int)
        inputs = np.squeeze(F["museEEG"]["design"]["inputs"][:]).astype(int)

        # based on inputs, creating oddball paradigms markers depending on "switch"
        tonenums = maketonesnums(1800)
        oddball3 = makeoddball(inputs, 3)
        oddball4 = makeoddball(inputs, 4)
        oddball5 = makeoddball(inputs, 5)
        oddball6 = makeoddball(inputs, 6)

        # modifying 0s in PE definitions of tones that represent markers to 3s to avoid loss of trials instead of ignoring them
        for i in range(len(highPE)):
            if highPE[i] == 0:
                highPE[i] = 3
            if lowPE[i] == 0:
                lowPE[i] = 3

        # 1 is standard/bottom, 2 is deviant/high, 3 is "baseline trial"

        stim_types = inputs
        itis = np.ones_like(inputs) * 0.5

        newAdditionalMarkers = []

        for i in range(0, len(highPE)):
            newAdditionalMarker = (
                str(oddball3[i])
                + str(oddball4[i])
                + str(oddball5[i])
                + str(oddball6[i])
                + str(highPE[i])
                + str(lowPE[i])
            )
            newAdditionalMarkers.append(newAdditionalMarker)

        additional_labels = {"labels": newAdditionalMarkers}
        aMMN.present(
            record_duration=record_duration,
            stim_types=stim_types,
            itis=itis,
            additional_labels={"labels": newAdditionalMarkers},
            eeg=eeg_device,
            save_fn=save_fn,
        )
Example #3
0
def run_experiment(experiment, record_duration, eeg_device, save_fn):

    if experiment == 'visual-N170':
        n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-P300':
        p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-SSVEP':
        ssvep.present(duration=record_duration,
                      eeg=eeg_device,
                      save_fn=save_fn)
Example #4
0
def main():
    eeg_device, experiment, record_duration, save_fn = intro_prompt()

    # run experiment
    if experiment == 'visual-N170':
        n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-P300':
        p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-SSVEP':
        ssvep.present(duration=record_duration,
                      eeg=eeg_device,
                      save_fn=save_fn)
Example #5
0
def run_experiment(experiment, record_duration, eeg_device, save_fn):
    if experiment == 'visual-N170':
        n170.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-P300':
        p300.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'visual-SSVEP':
        ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'auditory-SSAEP':
        ssaepupdate.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)
    elif experiment == 'auditory_oddball':
        conditions_file = os.path.join(os.path.dirname(os.path.abspath("__file__")), "MUSE_conditions.mat")
        F = h5py.File(conditions_file, 'r')#['museEEG']
        highPE = np.squeeze(F['museEEG']['design']['highPE'][:]).astype(int)
        lowPE = np.squeeze(F['museEEG']['design']['lowPE'][:]).astype(int)
        inputs = np.squeeze(F['museEEG']['design']['inputs'][:]).astype(int)

        #based on inputs, creating oddball paradigms markers depending on "switch"
        tonenums = maketonesnums(1800)
        oddball3 = makeoddball(inputs, 3)
        oddball4 = makeoddball(inputs, 4)
        oddball5 = makeoddball(inputs, 5)
        oddball6 = makeoddball(inputs, 6)

        #modifying 0s in PE definitions of tones that represent markers to 3s to avoid loss of trials instead of ignoring them
        for i in range(len(highPE)):
            if highPE[i] == 0:
                highPE[i] = 3
            if lowPE[i] == 0:
                lowPE[i] = 3  
           
        #1 is standard/bottom, 2 is deviant/high, 3 is "baseline trial"

        stim_types = inputs
        itis = np.ones_like(inputs)*0.5 

        newAdditionalMarkers = [];

        for i in range(0, len(highPE)):
            newAdditionalMarker = str(oddball3[i]) + str(oddball4[i]) + str(oddball5[i]) + str(oddball6[i]) + str(highPE[i]) + str(lowPE[i])
            newAdditionalMarkers.append(newAdditionalMarker)

        additional_labels = {'labels' : newAdditionalMarkers}
        auditoryaMMN.present(record_duration=record_duration,stim_types=stim_types,itis=itis, additional_labels = {'labels' : newAdditionalMarkers}, eeg=eeg_device, save_fn=save_fn)
Example #6
0
#
# Imports
import os
from eegnb import generate_save_fn
from eegnb.devices.eeg import EEG
from eegnb.experiments.visual_ssvep import ssvep

# Define some variables
board_name = "muse"
experiment = "visual_ssvep"
subject_id = 0
session_nb = 0
record_duration = 120

###################################################################################################
# Initiate EEG device
# ---------------------
#
# Start EEG device
eeg_device = EEG(device=board_name)

# Create save file name
save_fn = generate_save_fn(board_name, experiment, subject_id, session_nb)
print(save_fn)

###################################################################################################
# Run experiment
# ---------------------
#
ssvep.present(duration=record_duration, eeg=eeg_device, save_fn=save_fn)