def launch(self, sensors_file, sensors_type): """ Creates required sensors from the uploaded file. :param sensors_file: the file containing sensor data :param sensors_type: a string from "EEG Sensors", "MEG sensors", "Internal Sensors" :returns: a list of sensors instances of the specified type :raises LaunchException: when * no sensors_file specified * sensors_type is invalid (not one of the mentioned options) * sensors_type is "MEG sensors" and no orientation is specified """ if sensors_file is None: raise LaunchException( "Please select sensors file which contains data to import") self.logger.debug("Create sensors instance") if sensors_type == SensorsEEG.sensors_type.default: sensors_inst = SensorsEEG() elif sensors_type == SensorsMEG.sensors_type.default: sensors_inst = SensorsMEG() elif sensors_type == SensorsInternal.sensors_type.default: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) locations = self.read_list_data(sensors_file, usecols=[1, 2, 3]) # NOTE: TVB has the nose pointing -y and left ear pointing +x # If the sensors are in CTF coordinates : nose pointing +x left ear +y # to rotate the sensors by -90 along z uncomment below # locations = numpy.array([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]).dot(locations.T).T sensors_inst.locations = locations sensors_inst.labels = self.read_list_data(sensors_file, dtype=MEMORY_STRING, usecols=[0]) sensors_inst.number_of_sensors = sensors_inst.labels.size if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = self.read_list_data( sensors_file, usecols=[4, 5, 6]) sensors_inst.has_orientation = True except IndexError: raise LaunchException( "Uploaded file does not contains sensors orientation.") sensors_inst.configure() self.logger.debug("Sensors instance ready to be stored") sensors_idx = h5.store_complete(sensors_inst, self.storage_path) self.generic_attributes.user_tag_1 = sensors_inst.sensors_type return sensors_idx
def launch(self, sensors_file, sensors_type): """ Creates required sensors from the uploaded file. :param sensors_file: the file containing sensor data :param sensors_type: a string from "EEG Sensors", "MEG sensors", "Internal Sensors" :returns: a list of sensors instances of the specified type :raises LaunchException: when * no sensors_file specified * sensors_type is invalid (not one of the mentioned options) * sensors_type is "MEG sensors" and no orientation is specified """ if sensors_file is None: raise LaunchException( "Please select sensors file which contains data to import") self.logger.debug("Create sensors instance") if sensors_type == self.EEG_SENSORS: sensors_inst = SensorsEEG() elif sensors_type == self.MEG_SENSORS: sensors_inst = SensorsMEG() elif sensors_type == self.INTERNAL_SENSORS: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) sensors_inst.storage_path = self.storage_path locations = self.read_list_data(sensors_file, usecols=[1, 2, 3]) # NOTE: TVB has the nose pointing -y and left ear pointing +x # If the sensors are in CTF coordinates : nose pointing +x left ear +y # to rotate the sensors by -90 along z uncomment below # locations = numpy.array([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]).dot(locations.T).T sensors_inst.locations = locations sensors_inst.labels = self.read_list_data(sensors_file, dtype=numpy.str, usecols=[0]) if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = self.read_list_data( sensors_file, usecols=[4, 5, 6]) except IndexError: raise LaunchException( "Uploaded file does not contains sensors orientation.") self.logger.debug("Sensors instance ready to be stored") return [sensors_inst]
def launch(self, sensors_file, sensors_type): """ Creates required sensors from the uploaded file. :param sensors_file: the file containing sensor data :param sensors_type: a string from "EEG Sensors", "MEG sensors", "Internal Sensors" :returns: a list of sensors instances of the specified type :raises LaunchException: when * no sensors_file specified * sensors_type is invalid (not one of the mentioned options) * sensors_type is "MEG sensors" and no orientation is specified """ if sensors_file is None: raise LaunchException( "Please select sensors file which contains data to import") sensors_inst = None self.logger.debug("Create sensors instance") if sensors_type == self.EEG_SENSORS: sensors_inst = SensorsEEG() elif sensors_type == self.MEG_SENSORS: sensors_inst = SensorsMEG() elif sensors_type == self.INTERNAL_SENSORS: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) sensors_inst.storage_path = self.storage_path sensors_inst.locations = read_list_data(sensors_file, usecols=[1, 2, 3]) sensors_inst.labels = read_list_data(sensors_file, dtype=numpy.str, usecols=[0]) if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = read_list_data(sensors_file, usecols=[4, 5, 6]) except IndexError: raise LaunchException( "Uploaded file does not contains sensors orientation.") self.logger.debug("Sensors instance ready to be stored") return [sensors_inst]
def launch(self, sensors_file, sensors_type): """ Creates required sensors from the uploaded file. :param sensors_file: the file containing sensor data :param sensors_type: a string from "EEG Sensors", "MEG sensors", "Internal Sensors" :returns: a list of sensors instances of the specified type :raises LaunchException: when * no sensors_file specified * sensors_type is invalid (not one of the mentioned options) * sensors_type is "MEG sensors" and no orientation is specified """ if sensors_file is None: raise LaunchException("Please select sensors file which contains data to import") self.logger.debug("Create sensors instance") if sensors_type == self.EEG_SENSORS: sensors_inst = SensorsEEG() elif sensors_type == self.MEG_SENSORS: sensors_inst = SensorsMEG() elif sensors_type == self.INTERNAL_SENSORS: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) sensors_inst.storage_path = self.storage_path locations = self.read_list_data(sensors_file, usecols=[1, 2, 3]) # NOTE: TVB has the nose pointing -y and left ear pointing +x # If the sensors are in CTF coordinates : nose pointing +x left ear +y # to rotate the sensors by -90 along z uncomment below # locations = numpy.array([[0, 1, 0], [-1, 0, 0], [0, 0, 1]]).dot(locations.T).T sensors_inst.locations = locations sensors_inst.labels = self.read_list_data(sensors_file, dtype=numpy.str, usecols=[0]) if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = self.read_list_data(sensors_file, usecols=[4, 5, 6]) except IndexError: raise LaunchException("Uploaded file does not contains sensors orientation.") self.logger.debug("Sensors instance ready to be stored") return [sensors_inst]
def launch(self, sensors_file, sensors_type): """ Creates required sensors from the uploaded file. :param sensors_file: the file containing sensor data :param sensors_type: a string from "EEG Sensors", "MEG sensors", "Internal Sensors" :returns: a list of sensors instances of the specified type :raises LaunchException: when * no sensors_file specified * sensors_type is invalid (not one of the mentioned options) * sensors_type is "MEG sensors" and no orientation is specified """ if sensors_file is None: raise LaunchException ("Please select sensors file which contains data to import") sensors_inst = None self.logger.debug("Create sensors instance") if sensors_type == self.EEG_SENSORS: sensors_inst = SensorsEEG() elif sensors_type == self.MEG_SENSORS: sensors_inst = SensorsMEG() elif sensors_type == self.INTERNAL_SENSORS: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) sensors_inst.storage_path = self.storage_path sensors_inst.locations = read_list_data(sensors_file, usecols=[1,2,3]) sensors_inst.labels = read_list_data(sensors_file, dtype=numpy.str, usecols=[0]) if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = read_list_data(sensors_file, usecols=[4,5,6]) except IndexError: raise LaunchException("Uploaded file does not contains sensors orientation.") self.logger.debug("Sensors instance ready to be stored") return [sensors_inst]
def launch(self, sensors_file, sensors_type): """ Created required sensors from the uploaded file. """ if sensors_file is None: raise LaunchException( "Please select sensors file which contains data to import") sensors_inst = None self.logger.debug("Create sensors instance") if sensors_type == self.EEG_SENSORS: sensors_inst = SensorsEEG() elif sensors_type == self.MEG_SENSORS: sensors_inst = SensorsMEG() elif sensors_type == self.INTERNAL_SENSORS: sensors_inst = SensorsInternal() else: exception_str = "Could not determine sensors type (selected option %s)" % sensors_type raise LaunchException(exception_str) sensors_inst.storage_path = self.storage_path sensors_inst.locations = read_list_data(sensors_file, usecols=[1, 2, 3]) sensors_inst.labels = read_list_data(sensors_file, dtype=numpy.str, usecols=[0]) if isinstance(sensors_inst, SensorsMEG): try: sensors_inst.orientations = read_list_data(sensors_file, usecols=[4, 5, 6]) except IndexError: raise LaunchException( "Uploaded file does not contains sensors orientation.") self.logger.debug("Sensors instance ready to be stored") return [sensors_inst]