Created
July 8, 2024 18:13
-
-
Save rcassani/42747cabf0e15077d625ee0900ef3031 to your computer and use it in GitHub Desktop.
[Brainstorm] Plot values per Scout for a given cortical parcellation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Example of how to plot values on a given surface Atlas in Brainstorm | |
% Source is created using the 'Default anatomy' with its default cortex | |
% See: https://neuroimage.usc.edu/forums/t/46834 | |
% Raymundo Cassani, 2024 | |
%% Parameters | |
atlasName = 'Desikan-Killiany'; | |
scoutPlotNames = {'postcentral L', 'postcentral R', 'precentral L', 'precentral R'}; | |
scoutPlotValues = [-20, -10, 10, 20]; | |
%% Create "source" file to display values for each Scout | |
% Get default cortex surface for subject | |
[sSubject, iSubject] = bst_get('NormalizedSubject'); | |
sSurfFile = sSubject.Surface(sSubject.iCortex); | |
sSurfMat = in_tess_bst(sSurfFile.FileName); | |
iAtlas = find(ismember({sSurfMat.Atlas.Name}, atlasName)); | |
if isempty(iAtlas) | |
error('Default surface in "%s" does not contain "%s" atlas', subjectName, atlasName); | |
end | |
sAtlas = sSurfMat.Atlas(iAtlas); | |
if ~all(ismember(scoutPlotNames, {sAtlas.Scouts.Label})) | |
error('Atlas "%s" in "%s" does not contain the same scouts as ICC', atlasName, subjectName); | |
end | |
% Create "source" file for plotting Scout values | |
sSourcePlotMat = db_template('resultsmat'); | |
sSourcePlotMat.SurfaceFile = sSurfFile.FileName; | |
sSourcePlotMat.ImageGridAmp = nan(size(sSurfMat.Vertices, 1), 1); | |
sSourcePlotMat.Comment = 'PlotScoutValues'; | |
sSourcePlotMat.Time = [0, 1]; | |
% Set vertices for Scouts to it value | |
for ix = 1 : length(scoutPlotValues) | |
iScout = find(ismember({sAtlas.Scouts.Label}, scoutPlotNames(ix))); | |
sSourcePlotMat.ImageGridAmp(sAtlas.Scouts(iScout).Vertices) = deal(scoutPlotValues(ix)); | |
end | |
% Study to save "source" file | |
[sOutputStudy, iOutputStudy] = bst_get('DefaultStudy', iSubject); | |
% Output filename | |
sourcePlotFile = bst_process('GetNewFilename', bst_fileparts(sOutputStudy.FileName), 'results'); | |
% Save file | |
bst_save(sourcePlotFile, sSourcePlotMat, 'v6'); | |
% Add file to database structure | |
db_add_data(iOutputStudy, sourcePlotFile, sSourcePlotMat); | |
% Reload database | |
db_reload_studies(iOutputStudy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result:
