About how to save a picture in a report

Hi Bst Team:
Hello, I found a problem when using Brainstorm today. When I use Script(mainly Snapshot), a report will be generated, as shown in the following figure.So I want to save the pictures in the report. What should I do?
Looking forward to your reply, thank you!

Hello!

The snapshots are saved with the reports created by Brainstorm. You can extract them in two ways

  1. From the report viewer, you can use the Save icon to export the report in HTML. If you open this HTML file with your browser, you can easily save the images on your computer.

  2. You can also export them via a script. All reports are saved as .mat files in your $HOME/.brainstorm/reports folder (You can see the full path at the top of the report window). If you load this with Matlab, you'll find a cell array structure. You can loop its rows and every time the first column says "image", you can save the last column which is a matrix containing your RGB information using the imwrite() function.

Here's a quick and dirty script that exports all images in your last executed report as PNG files in your current directory:

% Get last report
Reports = bst_report('GetReport', 'current');

nRows = size(Reports, 1);
iImage = 1;

% Loop through entries in report
for iRow = 1:nRows
    % Save images
    if strcmp(Reports{iRow,1}, 'image')
        imwrite(Reports{iRow,4}, sprintf('image%#02d.png', iImage));
        iImage = iImage + 1;
    end
end

I hope this helps,
Martin

Hi again!

I thought about it and I feel like this feature could benefit others, so I decided to add this functionality to the Report Viewer. When you have a report open that includes snapshots, just go to the Save icon and change the format in the dropdown from HTML to PNG. Then choose the folder you want to share your snapshots and you're done! Let me know how this works!

image

Cheers,
Martin

1 Like

Dear MartinC,thanks for your reply!

Hello Martin:
I'm sorry to bother you again, but I have a problem and I want to ask you something.When I use Pipeline>Save snapshot,I found that there were only six orientation options,As shown in the second picture, the [L/R,Int/Extern,Top/Bot] I just need is not numbered. May I ask how I can modify this?5 .

.
Cheers,
BLIU

Hi BLIU,

Can you please clarify what you want that is missing from the orientation dropdown? You want to be able to enter a specific orientation number in degrees? If that is the case, I'm not sure that is quite practical from the process options interface. I could make it possible via a script if that would be helpful to you.

Martin

Hi Martin:
Yeah,What I really need is [L/R,Int/Extern,Top/Bot] ,However, there is no number in the orientation option, so I cannot use it in the script. Therefore, I sincerely request you to help me answer this question. You are really a warm-hearted person, and I would like to express my thanks to you.
Yours,
BLIU

I added the medial left and right views to the snapshot process:
https://github.com/brainstorm-tools/brainstorm3/commit/5bec2f8ad09e6fb089425fd38822fe81cd84e7ab

Update Brainstorm and try again.
If you don't see the new menus, you need to reset the options of the processes.

image image

Your answer has helped me a lot. Thank Brainstorm Team from the bottom of my heart

Hi Francois:
There was a problem when I used brainstorm, so I would like to ask for your advice. When I viewed the report files generated by other devices using the Report Viewer on my own device, I can't even view the list of the files through the Report Viewer (although I put them in the path C:\Users\BLIU\.Brainstorm \reports)1

。Figure1 is the list of the files what I want to view.

In the window "Open process report", you can only see the reports related with the current protocol. This is indicated in the report filename: report_PROTOCOLNAME_date_time.mat.
You may need to rename the files if your protocol is not called "Protocol02". Or create a new protocol "Protocol02" to open the reports.

Oh,your advice has helped me a lot,thank you!