Esempio n. 1
0
    def sensors_to_surface(self, sensors_gid, surface_to_map_gid):
        """
        Map EEG sensors onto the head surface (skin-air).

        EEG sensor locations are typically only given on a unit sphere, that is,
        they are effectively only identified by their orientation with respect
        to a coordinate system. This method is used to map these unit vector
        sensor "locations" to a specific location on the surface of the skin.

        Assumes coordinate systems are aligned, i.e. common x,y,z and origin.

        """
        # Normalize sensor and vertex locations to unit vectors
        sensors_h5_class, sensors_h5_path = self._load_h5_of_gid(sensors_gid)
        sensors_dt = Sensors()
        with sensors_h5_class(sensors_h5_path) as sensors_h5:
            sensors_h5.load_into(sensors_dt)

        surface_h5_class, surface_h5_path = self._load_h5_of_gid(
            surface_to_map_gid)
        surface_dt = Surface()
        with surface_h5_class(surface_h5_path) as surface_h5:
            surface_h5.load_into(surface_dt)

        return sensors_dt.sensors_to_surface(surface_dt).tolist()
def test_store_load_partial_sensors(tmph5factory):
    sensors = Sensors(sensors_type="SEEG",
                      labels=numpy.array(["s1", "s2", "s3"]),
                      locations=numpy.zeros((3, 3)),
                      number_of_sensors=3)

    tmp_file = tmph5factory("Sensors_{}.h5".format(sensors.gid))
    with SensorsH5(tmp_file) as f:
        f.store(sensors)

    sensors_stored = Sensors()
    with pytest.raises(TraitAttributeError):
        sensors_stored.labels
    with SensorsH5(tmp_file) as f:
        f.load_into(sensors_stored)
    assert sensors_stored.labels is not None
Esempio n. 3
0
 def from_tvb_file(self, filepath, remove_leading_zeros_from_labels=False):
     self._tvb = TVBSensors.from_file(filepath, self._tvb)
     if len(self._tvb.labels) > 0:
         if remove_leading_zeros_from_labels:
             self.remove_leading_zeros_from_labels()
     self.file_path = filepath
     return self
Esempio n. 4
0
 def build(type="EEG", nr_sensors=3):
     return Sensors(sensors_type=type,
                    labels=numpy.array(["s"] * nr_sensors),
                    locations=numpy.ones((nr_sensors, 3)),
                    number_of_sensors=nr_sensors,
                    has_orientation=True,
                    orientations=numpy.zeros((nr_sensors, 3)),
                    usable=numpy.array([True] * nr_sensors))
def test_store_load_sensors(tmph5factory, sensors_factory):
    sensors = sensors_factory("SEEG", 3)
    tmp_file = tmph5factory("Sensors_{}.h5".format(sensors.gid))
    with SensorsH5(tmp_file) as f:
        f.store(sensors)

    sensors_stored = Sensors()
    with pytest.raises(TraitAttributeError):
        sensors_stored.labels

    with SensorsH5(tmp_file) as f:
        f.load_into(sensors_stored)
        assert sensors_stored.labels is not None
Esempio n. 6
0
    number_of_triangles=3,
    edge_mean_length=1.0,
    edge_min_length=0.0,
    edge_max_length=2.0,
    zero_based_triangles=False,
    split_triangles=numpy.arange(0),
    number_of_split_slices=1,
    split_slices=dict(),
    bi_hemispheric=False,
    # surface_type="surface",
    valid_for_simulations=True)

sensors = Sensors(sensors_type="SEEG",
                  labels=numpy.array(["s1", "s2", "s3"]),
                  locations=numpy.zeros((3, 3)),
                  number_of_sensors=3,
                  has_orientation=True,
                  orientations=numpy.zeros((3, 3)),
                  usable=numpy.array([True, False, True]))

volume = Volume(origin=numpy.zeros((3, 3)), voxel_size=numpy.zeros((3, 3)))

projection_matrix = ProjectionMatrix(projection_type="projSEEG",
                                     sources=cortical_surface,
                                     sensors=sensors,
                                     projection_data=numpy.zeros((5, 3)))

local_connectivity = LocalConnectivity(
    surface=cortical_surface,
    matrix=scipy.sparse.csc_matrix(numpy.eye(8) + numpy.eye(8)[:, ::-1]),
    cutoff=12,