Thanks you. It's working. I have another question regarding the creation of figures from scripts (hope it's ok to regroup all of them here).
Questions:
- When creating a 2D layout. How can I display the channel label from this script?
[hFig, iDS, iFig] = view_topography(data.FileName, 'NIRS', '2DLayout');
panel_montage('SetCurrentMontage',hFig, sprintf('%s[tmp]', 'NIRS overlay'))
bst_figures('SetBackgroundColor',hFig, [1 1 1])
- The figure is quite hard to read with a white background; is there any way to avoid the black background while still making the graph nice to read?
Black Background:
subject_HW_105_task_Dual_pre_2D_layout.tiff (117.4 KB)
White Background:
subject_HW_105_task_Dual_pre_2D_layout.tiff (125.0 KB)
-
The file I am trying to display is an average with standard deviation. Would it be possible to have also the std displayed on the graph for each channel?
-
Is it possible to change the orientation of the graph. (see bellow). In general it seems very hard to make the correspondance between the montage and the 2D layout as left is right and top is front. (I never realised that until now)
Solutions:
- The two followings code works (i prefer the second one :p)
global GlobalData;
set(GlobalData.DataSet(iDS).Figure(iFig).Handles.hSensorLabels, 'Visible', 1);
or
set(findobj(gcf,'Tag','SensorsLabels'),'Visible', 'on');
- The following code help; but don't know if it possible to do better

set(findobj(gcf,'Tag','SensorsLabels'),'Color',[0,0,0]);
set(findobj(gcf,'Tag','SensorsLabels'),'FontSize',FontSize); % 14 instead of 9
set(findobj(gcf, 'Tag' , 'Lines2DLayout'),'LineWidth', 2);
subject_HW_105_task_Dual_pre_2D_layout.tiff (193.9 KB)
-
WIP
-
Current WIP:
The 2D layout make sense if we look at the montage from at top view; but still for a montage on the frontal lobe; that's a bit weird and it would be great to be able to change it 
axis ij correct the left-right orientation
I tried to play with set ( gca, 'xdir' / 'ydir', /'zdir', 'normal' / 'reverse') but doesn't work. Still x is always up:
What is really weird is that with this toy example (see bellow), it is very easy to change axis direction in any way we want; but with brainstorm figure it seems that x- and y- axis are linked so X is always pointing up.
figure;
hold on;
quiver3(0,0,0,1,0,0); text(0.8,0,0,'x');
quiver3(0,0,0,0,1,0); text(0,0.8,0,'y');
quiver3(0,0,0,0,0,1); text(0,0,0.8,'z');
set(gca, 'XDir','normal') % or 'reverse'
set(gca, 'YDir','normal')
set(gca, 'ZDir','normal')
Following code correctly place the plots but then all the curve are also inverted (eg an increase is plot as a decrease)... An easy solution would be to multiply all data by -1 before the plot 
tmp = findobj(gcf, 'Tag' ,'Axes3D')
set(tmp, 'CameraUpVector', [-1 0 0])
ok; it's 1am now; I think I spent way too much time on this ahah but following code works(almost) (it's ugly - however) :
panel_montage('SetCurrentMontage',hFig, sprintf('%s[tmp]', 'NIRS overlay'))
bst_figures('SetBackgroundColor',hFig, [1 1 1]) %- white background is ugly
set(findobj(gcf,'Tag','SensorsLabels'),'Visible', 'on');
set(findobj(gcf,'Tag','SensorsLabels'),'Color',[0,0,0]);
set(findobj(gcf,'Tag','SensorsLabels'),'FontSize',FontSize);
set(findobj(gcf, 'Tag' , 'Lines2DLayout'),'LineWidth', 2);
set(findobj(gcf, 'Tag' ,'Axes3D'),'CameraUpVector', [-1 0 0])
tmp = findobj(gcf, 'Tag' ,'Lines2DLayout');
tmp2 = findobj(gcf, 'Tag','2DLayoutZeroLines');
for i_curve = 1:length(tmp)
set(tmp(i_curve),'XData', 2*tmp2(i_curve).XData(1) -1*(tmp(i_curve).XData))
set(tmp(i_curve),'YData', tmp(i_curve).YData(end:-1:1))
end
panel_time('SetCurrentTime', 25);
Note: we have to specify 25 instead of 0 because the X axis is reversed now...
actually, here is final code (for some reason, some change are not applied the first time; so need to execute code twice; also need to adjust the coordinate of the label)....
% Figure 3. 2D Layout
for wtf = 1:2 % for some reason the code needs to be repeated 2 times; otherwise background doesnt work
[hFig, iDS, iFig] = view_topography(data.FileName, 'NIRS', '2DLayout');
pause(1)
panel_montage('SetCurrentMontage',hFig, sprintf('%s[tmp]', 'NIRS overlay'))
set(findobj(gcf,'Tag','SensorsLabels'),'Visible', 'on');
set(findobj(gcf,'Tag','SensorsLabels'),'Color',[0,0,0]);
set(findobj(gcf,'Tag','SensorsLabels'),'FontSize',FontSize);
bst_figures('SetBackgroundColor',hFig, [1 1 1]) %- white background is ugly
set(findobj(gcf, 'Tag' , 'Lines2DLayout'),'LineWidth', 2);
set(findobj(gcf, 'Tag' ,'Axes3D'),'CameraUpVector', [-1 0 0])
tmp = findobj(gcf, 'Tag' ,'Lines2DLayout');
tmp2 = findobj(gcf, 'Tag','2DLayoutZeroLines');
tmp3 = findobj(gcf,'Tag','SensorsLabels');
for i_curve = 1:length(tmp)
set(tmp(i_curve),'XData', 2*tmp2(i_curve).XData(1) -1*(tmp(i_curve).XData))
set(tmp(i_curve),'YData', tmp(i_curve).YData(end:-1:1))
if wtf == 2
label_newPos = tmp3(i_curve).Position;
label_newPos(1) = 2*tmp2(i_curve).XData(1) - 1.01*(tmp3(i_curve).Position(1));
set(tmp3(i_curve),'Position', label_newPos);
end
end
panel_time('SetCurrentTime', 25);
end
out_figure_image( hFig, fullfile(reports_dir, fname(subject_name,task,cond,'2D_layout')),'');
close(hFig)
and final figure 
subject_HW_105_task_Dual_pre_2D_layout.tiff (193.7 KB)
Edouard
Edit: fix formating