Exemple #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
    }
Exemple #2
0
// geo = geometry
// mat = storage for Ferguson Matrix
// pts = where the magnetic field is to be computed
// n   = numbers of places where magnetic field is to be computed
void assemble_ferguson(const Geometry& geo, Matrix& mat, const Matrix& pts)
{
    unsigned miit = 0; // for progressbar: mesh index iterator
    // Computation of blocks of Ferguson's Matrix
    for ( Geometry::const_iterator mit = geo.begin(); mit != geo.end(); ++mit, ++miit) {
        unsigned offsetI = 0;
        unsigned n = pts.nlin();
        double coeff = geo.sigma_diff(*mit)*MU0/(4.*M_PI);
        for ( unsigned i = 0; i < n; ++i) {
            PROGRESSBAR(miit*n+i, geo.nb_meshes()*n);
            Vect3 p(pts(i, 0), pts(i, 1), pts(i, 2));
            operatorFerguson(p, *mit, mat, offsetI, coeff);
            offsetI += 3;
        }
    }
}
    // geo = geometry 
    // mat = storage for ferguson Matrix
    // pts = where the magnetic field is to be computed 
    // n   = numbers of places where magnetic field is to be computed
    void assemble_ferguson(const Geometry &geo, Matrix &mat, const Matrix &pts)
    {
        int offsetJ = 0;
        // Computation of blocks of Ferguson's Matrix
        for(int c=0; c < geo.nb(); c++) {
            int offsetI = 0;
            int n = pts.nlin();
            for (int i=0; i < n; i++) {
                PROGRESSBAR(c*i, geo.nb()*n);
                Vect3 p(pts(i,0), pts(i,1), pts(i,2));
                operatorFerguson(p, geo.getM(c), mat, offsetI, offsetJ);
                offsetI += 3;
            }
            offsetJ += geo.getM(c).nbPts();
        }

        // Blocks multiplications
        offsetJ = 0;
        for(int c=0;c<geo.nb();c++) {
            mult(mat,0,offsetJ,mat.nlin(),offsetJ+geo.getM(c).nbPts(),(geo.sigma_in(c)-geo.sigma_out(c))*MU0/(4*M_PI));
            offsetJ += geo.getM(c).nbPts();
        }
    }