How to simply plot a topography

Hello,

Similarly to this thread: 2d disk connectivity plot from script, I'm having difficulty displaying a topography from a script by calling view_topography with a power spectrum file generated in Brainstorm. The call is:
view_topography(PsdFiles{f}, 'MEG', '2DSensorCap', [], 0, 'NewFigure')
and the error is:

Output argument "RowNames" (and maybe others) not assigned during
call to "figure_timefreq>GetFigureData".
Error in figure_timefreq (line 28)
eval(macro_method);
Error in figure_topo>GetFigureData (line 336)
                [Time, Freqs, TfInfo, TF, RowNames] =
                figure_timefreq('GetFigureData', hFig, TimeDef);

Looks like GetFigureData is not finding the iDS, because I presume it's not loaded in memory. But actually we get the same error even if the same file is already displayed (through the GUI).

I've also wanted a few times to just plot from a variable. But it requires a DataFile otherwise we get the error:

Expected one output from a curly brace or dot indexing expression,
but there were 0 results.
Error in panel_display>UpdatePanel (line 400)
        switch
        lower(GlobalData.DataSet(iDS).Timefreq(iTimefreq).Measure)

So the only way I've succeeded in the past was to create a fake data file (not TF) and display the topo from the GUI. :frowning_face: I hope there is a simpler way.

Thanks!
Marc

Looks like GetFigureData is not finding the iDS, because I presume it's not loaded in memory.

I guess you pass the full file paths to view_topography, and this was leading to a wrong registration of the figure, indeed. I fixed this by forcing the use of relative paths within view_topography:
Bugfix: Calling view_topography with full file names · brainstorm-tools/brainstorm3@b75a346 · GitHub

I've also wanted a few times to just plot from a variable. But it requires a DataFile
So the only way I've succeeded in the past was to create a fake data file (not TF) and display the topo from the GUI.

You always need to provide a reference file (data or timefreq) as the input parameter "DataFile", so that it gets all the additional information needed (sensor positions and types, colormap, etc).

You can give directly the data to plot in the figure to override the data from the file. The input parameter F must be a vector with one value for each sensor. It generates a static figure (not updated when changing the current time or frequency). If you want to display the 300th frequency bin in a PSD file, you'd something like this:
view_topography(PsdFile, 'MEG', '2DSensorCap', squeeze(PsdMat.TF(:,:,300)), 0, 'NewFigure')

Does that address your concerns?

Yes that's great thanks François!