Esempio n. 1
0
    // MEG patches positions are reported line by line in the positions Matrix (same for positions)
    // mat is supposed to be filled with zeros
    // mat is the linear application which maps x (the unknown vector in symmetric system) -> binf (contrib to MEG response)
    void assemble_SurfSource2MEG(Matrix& mat, const Mesh& sources_mesh, const Sensors& sensors)
    {
        Matrix positions = sensors.getPositions();
        Matrix orientations = sensors.getOrientations();
        const unsigned nsquids = positions.nlin();

        mat = Matrix(nsquids, sources_mesh.nb_vertices());
        mat.set(0.0);

        for ( unsigned i = 0; i < nsquids; ++i) {
            PROGRESSBAR(i, nsquids);
            Vect3 p(positions(i, 0), positions(i, 1), positions(i, 2));
            Matrix FergusonMat(3, mat.ncol());
            FergusonMat.set(0.0);
            operatorFerguson(p, sources_mesh, FergusonMat, 0, 1.);
            for ( unsigned j = 0; j < mat.ncol(); ++j) {
                Vect3 fergusonField(FergusonMat(0, j), FergusonMat(1, j), FergusonMat(2, j));
                Vect3 normalizedDirection(orientations(i, 0), orientations(i, 1), orientations(i, 2));
                normalizedDirection.normalize();
                mat(i, j) = fergusonField * normalizedDirection;
            }
        }

        mat = sensors.getWeightsMatrix() * mat; // Apply weights
    }
Esempio n. 2
0
    // Creates the DipSource2MEG Matrix with unconstrained orientations for the sources.
    // MEG patches positions are reported line by line in the positions Matrix (same for positions)
    // mat is supposed to be filled with zeros
    // sources is the name of a file containing the description of the sources - one dipole per line: x1 x2 x3 n1 n2 n3, x being the position and n the orientation.
    void assemble_DipSource2MEG(Matrix& mat, const Matrix& dipoles, const Sensors& sensors)
    {
        Matrix positions = sensors.getPositions();
        Matrix orientations = sensors.getOrientations();

        if ( dipoles.ncol() != 6) {
            std::cerr << "Dipoles File Format Error" << std::endl;
            exit(1);
        }

        // this Matrix will contain the field generated at the location of the i-th squid by the j-th source
        mat = Matrix(positions.nlin(), dipoles.nlin());

        // the following routine is the equivalent of operatorFerguson for pointlike dipoles.
        for ( unsigned i = 0; i < mat.nlin(); ++i) {
            for ( unsigned j = 0; j < mat.ncol(); ++j) {
                Vect3 r(dipoles(j, 0), dipoles(j, 1), dipoles(j, 2));
                Vect3 q(dipoles(j, 3), dipoles(j, 4), dipoles(j,5));
                Vect3 diff(positions(i, 0), positions(i, 1), positions(i, 2));
                diff -= r;
                double norm_diff = diff.norm();
                Vect3 fergusonField = q ^ diff / (norm_diff * norm_diff * norm_diff);
                Vect3 normalizedDirection(orientations(i, 0), orientations(i, 1), orientations(i, 2));
                normalizedDirection.normalize();
                mat(i, j) = fergusonField * normalizedDirection * MU0 / (4.0 * M_PI);
            }
        }

        mat = sensors.getWeightsMatrix() * mat; // Apply weights
    }
Esempio n. 3
0
    // MEG patches positions are reported line by line in the positions Matrix (same for positions)
    // mat is supposed to be filled with zeros
    // mat is the linear application which maps x (the unknown vector in symmetric system) -> bFerguson (contrib to MEG response)
    void assemble_Head2MEG(Matrix& mat, const Geometry& geo, const Sensors& sensors) 
    {
        Matrix positions = sensors.getPositions();
        Matrix orientations = sensors.getOrientations();
        const unsigned nbIntegrationPoints = sensors.getNumberOfPositions();
        unsigned p0_p1_size = (geo.size() - geo.outermost_interface().nb_triangles());

        Matrix FergusonMat(3*nbIntegrationPoints, geo.nb_vertices());

        assemble_ferguson(geo, FergusonMat, positions);

        mat = Matrix(nbIntegrationPoints, p0_p1_size);
        mat.set(0.0);

        for ( unsigned i = 0; i < nbIntegrationPoints; ++i) {
            PROGRESSBAR(i, nbIntegrationPoints);
            for ( Vertices::const_iterator vit = geo.vertex_begin(); vit != geo.vertex_end(); ++vit) {
                Vect3 fergusonField(FergusonMat(3*i, vit->index()), FergusonMat(3*i+1, vit->index()), FergusonMat(3*i+2, vit->index()));
                Vect3 normalizedDirection(orientations(i, 0), orientations(i, 1), orientations(i, 2));
                normalizedDirection.normalize();
                mat(i, vit->index()) = fergusonField * normalizedDirection;
            }
        }
        mat = sensors.getWeightsMatrix() * mat; // Apply weights
    }