Beispiel #1
0
    def _init_brainflow(self):
        """This function initializes the brainflow backend based on the input device name. It calls
        a utility function to determine the appropriate USB port to use based on the current operating system.
        Additionally, the system allows for passing a serial number in the case that they want to use either
        the BraintBit or the Unicorn EEG devices from the brainflow family.

        Parameters:
             serial_num (str or int): serial number for either the BrainBit or Unicorn devices.
        """
        # Initialize brainflow parameters
        self.brainflow_params = BrainFlowInputParams()

        if self.device_name == "ganglion":
            self.brainflow_id = BoardIds.GANGLION_BOARD.value
            if self.serial_port == None:
                self.brainflow_params.serial_port = get_openbci_usb()
            # set mac address parameter in case
            if self.mac_address is None:
                print(
                    "No MAC address provided, attempting to connect without one"
                )
            else:
                self.brainflow_params.mac_address = self.mac_address

        elif self.device_name == "ganglion_wifi":
            self.brainflow_id = BoardIds.GANGLION_WIFI_BOARD.value
            if self.ip_addr is not None:
                self.brainflow_params.ip_address = self.ip_addr
                self.brainflow_params.ip_port = 6677

        elif self.device_name == "cyton":
            self.brainflow_id = BoardIds.CYTON_BOARD.value
            if self.serial_port is None:
                self.brainflow_params.serial_port = get_openbci_usb()

        elif self.device_name == "cyton_wifi":
            self.brainflow_id = BoardIds.CYTON_WIFI_BOARD.value
            if self.ip_addr is not None:
                self.brainflow_params.ip_address = self.ip_addr
                self.brainflow_params.ip_port = 6677

        elif self.device_name == "cyton_daisy":
            self.brainflow_id = BoardIds.CYTON_DAISY_BOARD.value
            if self.serial_port is None:
                self.brainflow_params.serial_port = get_openbci_usb()

        elif self.device_name == "cyton_daisy_wifi":
            self.brainflow_id = BoardIds.CYTON_DAISY_WIFI_BOARD.value
            if self.ip_addr is not None:
                self.brainflow_params.ip_address = self.ip_addr

        elif self.device_name == "brainbit":
            self.brainflow_id = BoardIds.BRAINBIT_BOARD.value

        elif self.device_name == "unicorn":
            self.brainflow_id = BoardIds.UNICORN_BOARD.value

        elif self.device_name == "callibri_eeg":
            self.brainflow_id = BoardIds.CALLIBRI_EEG_BOARD.value
            if self.other:
                self.brainflow_params.other_info = str(self.other)

        elif self.device_name == "notion1":
            self.brainflow_id = BoardIds.NOTION_1_BOARD.value

        elif self.device_name == "notion2":
            self.brainflow_id = BoardIds.NOTION_2_BOARD.value

        elif self.device_name == "freeeeg32":
            self.brainflow_id = BoardIds.FREEEEG32_BOARD.value
            if self.serial_port is None:
                self.brainflow_params.serial_port = get_openbci_usb()

        elif self.device_name == "synthetic":
            self.brainflow_id = BoardIds.SYNTHETIC_BOARD.value

        # some devices allow for an optional serial number parameter for better connection
        if self.serial_num:
            serial_num = str(self.serial_num)
            self.brainflow_params.serial_number = serial_num

        if self.serial_port:
            serial_port = str(self.serial_port)
            self.brainflow_params.serial_port = serial_port

        # Initialize board_shim
        self.sfreq = BoardShim.get_sampling_rate(self.brainflow_id)
        self.board = BoardShim(self.brainflow_id, self.brainflow_params)
        self.board.prepare_session()
Beispiel #2
0
    def _init_brainflow(self):
        """ This function initializes the brainflow backend based on the input device name. It calls
        a utility function to determine the appropriate USB port to use based on the current operating system.
        Additionally, the system allows for passing a serial number in the case that they want to use either
        the BraintBit or the Unicorn EEG devices from the brainflow family.

        Parameters:
             serial_num (str or int): serial number for either the BrainBit or Unicorn devices.
        """

        # Initialize brainflow parameters
        self.brainflow_params = BrainFlowInputParams()

        if self.device_name == 'ganglion':
	    self.brainflow_id = BoardIds.GANGLION_BOARD.value
            if self.serial_port == None:
	        self.brainflow_params.serial_port = get_openbci_usb()
            # set mac address parameter in case
            if self.mac_address is not None:
                self.brainflow_params.mac_address = self.mac_address
            else:
                print("No MAC address provided, attempting to connect without one")

        elif self.device_name == 'ganglion_wifi':
            brainflow_id = BoardIds.GANGLION_WIFI_BOARD.value
            self.brainflow_params.ip_address, self.brainflow_params.ip_port = get_openbci_ip()

        elif self.device_name == 'cyton':
            self.brainflow_id = BoardIds.CYTON_BOARD.value
            if self.serial_port == None: 
            	self.brainflow_params.serial_port = get_openbci_usb()

        elif self.device_name == 'cyton_wifi':
            self.brainflow_id = BoardIds.CYTON_WIFI_BOARD.value
            self.brainflow_params.ip_address, self.brainflow_params.ip_port = get_openbci_ip()

        elif self.device_name == 'cyton_daisy':
            self.brainflow_id = BoardIds.CYTON_DAISY_BOARD.value
            if self.serial_port == None:
		self.brainflow_params.serial_port = get_openbci_usb()

        elif self.device_name == 'cyton_daisy_wifi':
            self.brainflow_id = BoardIds.CYTON_DAISY_WIFI_BOARD.value
            self.brainflow_params.ip_address, self.brainflow_params.ip_port = get_openbci_ip()

        elif self.device_name == 'brainbit':
            self.brainflow_id = BoardIds.BRAINBIT_BOARD.value

        elif self.device_name == 'unicorn':
            self.brainflow_id = BoardIds.UNICORN_BOARD.value

        elif self.device_name == 'synthetic':
            self.brainflow_id = BoardIds.SYNTHETIC_BOARD.value


        if self.serial_num:
            serial_num = str(self.serial_num)
            self.brainflow_params.other_info = serial_num

        if self.serial_port:
            serial_port=str(self.serial_port)
            self.brainflow_params.serial_port = serial_port


        # Initialize board_shim
        self.sfreq = BoardShim.get_sampling_rate(self.brainflow_id)
        self.board = BoardShim(self.brainflow_id, self.brainflow_params)
        self.board.prepare_session()