Hi, I would like to know how the volume of scouts, that is shown in the graphical interface, is calculated. I need to implement the computation for a large number of scouts and would like to use matlab directly. How can I do?
Brainstorm uses function stlVolumeNormals
to compute the volume defined by a closed patch:
if isVolumeAtlas
totalVol = 0;
for i = 1:length(sScouts)
patchVol = 0;
if (length(sScouts(i).Vertices) > 3) && ~isempty(sScouts(i).Handles) && ~isempty(sScouts(i).Handles(1).hPatch)
% Get the faces and vertices of the patch
Vertices = double(get(sScouts(i).Handles(1).hPatch, 'Vertices'));
Faces = double(get(sScouts(i).Handles(1).hPatch, 'Faces'));
% Compute patch volume
if (size(Faces,1) > 1)
patchVol = stlVolumeNormals(Vertices', Faces') * 1e6;
end
end
% Use the maximum of 0.03cm3 and the compute volume of the patch
minVol = 0.01 * length(sScouts(i).Vertices);
if (minVol > patchVol)
patchVol = minVol;
end
% Sum with the other scouts
totalVol = totalVol + patchVol;
end
function [totalVolume,totalArea] = stlVolumeNormals(p,t, normals)
% Given a surface triangulation, compute the volume enclosed using
% divergence theorem.
% Assumption:Triangle nodes are ordered correctly, i.e.,computed normal is outwards
% Input: p: (3xnPoints), t: (3xnTriangles)
% Output: total volume enclosed, and total area of surface
% Author: K. Suresh; suresh@engr.wisc.edu
% Copyright (c) 2012, Dimid Duchovny
% Copyright (c) 2010, Krishnan Suresh
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
This file has been truncated. show original
Hi Francois, thank you for providing me with this information.
One last thing I would like to ask you about this topic is how brainstorm builds the closed patch of the scout from the points I provided to it.
With this information, I could go directly to the scripting phase to construct the 'Faces' that appear in the function you mentioned. I was thinking of taking an N-D Voronoi diagram approach but there will probably be other more optimized ways in brainstorm.
It uses Matlab's boundary
or convhulln
functions:
sTemplate = db_template('scout');
[sAtlas.Scouts.Handles] = deal(sTemplate.Handles);
% Save new scout
iNewScouts = SetScouts([], 'Add', sAtlas.Scouts);
% Display new scout
PlotScouts(iNewScouts);
% Update "Scouts Manager" panel
UpdateScoutsList();
% Select last scout in list (new scout)
SetSelectedScouts(iNewScouts);
% Close progress bar
bst_progress('stop');
end
%% ===== EXPORT SCOUTS TO MRI MASK =====
function ExportScoutsToMri()
% Get selected scouts
[sScouts, iScouts, sSurf] = GetSelectedScouts();
% If nothing selected, take all scouts