Brainstorm on a cluster

Hi all,

I'm trying to run Brainstorm on a cluster. Currently I'm getting the following error message:
"Error in bst_startup (line 476)
java_dialog('msgbox', ['It is the first time you run Brainstorm on this
Matlab installation.' 10 10 ...
Error in brainstorm (line 159)
bst_startup(BrainstormHomeDir, -1, BrainstormDbDir);
Error in freq_av_cluster (line 23)
brainstorm server"

So far I was creating a brainstorm_db folder on the cluster, including a data and an anat-folder and copying the brainstorm3 folder.
Also I tried to set up BrainstormDbDir using bst_set but it is not working.

Does anyone knows how to set up Brainstorm for the first time without using the gui or could solve a similar problem?

Greetings,
Matthias

Hi Matthias,

The headless mode of Brainstorm is still very much a work in progress, and as such you are very likely to run into some issues. Indeed, no one had tested it on a cluster where Brainstorm wasn’t even configured yet. I added some fixes to make it possible to set the Brainstorm database directory directly from the headless mode: https://github.com/brainstorm-tools/brainstorm3/commit/9e31088c2b735c013d8a6d65c149a670467f5a83

Go ahead and update Brainstorm. Do keep in mind that you are very likely to run into more issues. Please continue to post them so we can improve this mode.

Thank you for beta testing this for us!

Cheers,
Martin

Hi Martin,

thanks a lot for the quick response.
Your fixes were already helpful.
After I used your fixes I got the following error message:

{Error using freq_av_cluster (line 30)
Unknown protocol: STN_COR_OFF
}
This occurred because of this:
% Get the protocol index
iProtocol = bst_get(‘Protocol’, ProtocolName);
if isempty(iProtocol)
error(['Unknown protocol: ’ ProtocolName]);
end
% Select the current procotol
gui_brainstorm(‘SetCurrentProtocol’, iProtocol);

I could fix this with the following command:

ProtocolName = ‘STN_COR_OFF’;
sProtocol.Comment = ProtocolName;
sProtocol.SUBJECTS = [home ‘anat’];
sProtocol.STUDIES = [home ‘data’];
db_edit_protocol(‘load’,sProtocol);

The next error message occurred after brainstorm should have been started:

{Error using bst_process>CallProcess (line 2086)
Please start Brainstorm before calling bst_process().

Error in bst_process (line 36)
eval(macro_method);

Error in freq_av_cluster (line 186)
sFiles_etime = bst_process(‘CallProcess’,
‘process_extract_time’, sFiles, [], …

}

In the following I looked into the bst_process script.
I was taking out the lines 2085-2087:
% if ~brainstorm(‘status’)%~isappdata(0, ‘BrainstormRunning’)
% error(‘Please start Brainstorm before calling bst_process().’);
% end

At first I tried to interchange ~isappdata(0, ‘BrainstormRunning’) with ~brainstorm(‘status’) but I got the same massage.
After taking out these lines I got some first data back from the cluster.
What is your opinion?

Greetings,
Matthias

Hi Matthias,

Thanks for the update.

I do not have the file you are referring to (freq_av_cluster.m), so it is difficult for me to see what the issue is. It does make sense that you need to select the appropriate protocol though before processing, so I am not sure this is a Brainstorm bug.

As for your issue with bst_process(), I cannot reproduce it on my end. I think your solution is fine for your needs.

Cheers,
Martin

For creating, selecting and deleting protocols, I recommend you look at existing script examples, eg. https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/script/tutorial_introduction.m#L65

To set the database folder, in which all the protocols are created:
bst_set(‘BrainstormDbDir’, BrainstormDbDir);

Please start Brainstorm before calling bst_process().

Have you started brainstorm with “brainstorm server” first?

Thanks a lot for the response.

No, at first I was using the bst_set command and afterwards I was using “brainstorm server”.

Please find below the lines I was using to set up Brainstorm for the cluster. Afterwards my normal script continues.

Greetings,
Matthias

BrainstormDbDir = ‘/gpfs/project/sumat100/brainstorm_db’;
bst_set(‘BrainstormDbDir’,BrainstormDbDir)

if ~brainstorm(‘status’)
brainstorm server
brainstorm setpath
end
ProtocolName = ‘STN_COR_OFF’;
sProtocol.Comment = ProtocolName;
sProtocol.SUBJECTS = [home ‘anat’];
sProtocol.STUDIES = [home ‘data’];
db_edit_protocol(‘load’,sProtocol);
% Get the protocol index
iProtocol = bst_get(‘Protocol’, ProtocolName);
if isempty(iProtocol)
error(['Unknown protocol: ’ ProtocolName]);
end
% Select the current procotol
gui_brainstorm(‘SetCurrentProtocol’, iProtocol);

A few comments:

  • You should not call any brainstorm function before starting brainstorm (it is most likely useless as all the data structures are initialized when starting Brainstorm).
  • At the first execution of Brainstorm: after Martin’s recent update, it should ask in the command line the path to the brainstorm_db folder (instead of crashing)
  • If you need to change the database folder after that, use bst_set(‘BrainstormDbDir’,BrainstormDbDir), but only once Brainstorm is started.
  • No need to call “brainstorm setpath”, this is called during “brainstorm server”
  • Create the protocols with gui_brainstorm(‘CreateProtocol’, ProtocolName, 0, 0), as in the example script I pointed at previously
  • All the part about the protocol selection is not ncessary: CreateProtocol() should select the new protocol already.

Please let us know if our startup scripts in headless mode need further adjustments.

Sorry that is took me so long to reply.

If I’m using the command gui_brainstorm(‘CreateProtocol’, ProtocolName, 0, 0) I’m getting the response:
'Error using gui_brainstorm>CreateProtocol (line 1051)
Could not create protocol.

Error in gui_brainstorm (line 33)
eval(macro_method);’
While I’m using:
‘sProtocol.Comment = ProtocolName;
sProtocol.SUBJECTS = [home ‘anat’];
sProtocol.STUDIES = [home ‘data’];
db_edit_protocol(‘load’,sProtocol);’
it is working fine.

Is it that your folders already exist?
The anat and data folders should not exist before you call CreateProtocol, the protocol ProtocolName should not exist in the database and the database folder should be set correctly.

The “load” option you are using is meant to load and existing protocol, it is not what you are supposed to use to create a new protocol. If it works, it is also probably because your data and anat folders already exist.

Yes the anat and the data folder already exist on the hard-drive. Since I already have data in these folders which I want to process. I moved the brainstorm_db folder to the hard-drive of the cluster and was starting brainstorm server with the above mentioned commands.

OK it makes sense then!
What you are doing with db_edit_protocol(‘load’,…) is the only way to properly load an existing protocol from a script.

Do you still have issues/question/suggestions on how to work with Brainstorm a on cluster?
Do you think it would require a specific dedicated tutorial page for helping other to do it?
If you took notes, don’t hesitate to share them. If you are interested in putting them online, I could create an account for you to edit the website, just let me know.

It took a while (since the cluster was busy) but no every code I tried was running.
At the moment I don’t have any issues but as soon I have some I will share them.

Anyhow I guess it could be helpful to have a little bit of more information on the brainstorm page.
A specific tutorial is not needed but the tutorial “Scripting” could be extended at the part “Starting Brainstorm”.
At least the option “brainstorm server” should be mentioned since I couldn’t find it somewhere in the tutorials.
Also that at a server java functions may not work. E.g. I had one problem towards the anat and the data folder for one protocol. For one subject i had an entry in the anat folder but not in the data folder, so they did not match. On the desktop computer brainstorm can work this out but not on the server. So it is important that data data and the anat folder match.

I have done just a few notes (regarding the errors which occurred to me) but I could bring them in order and share it.

1 Like

Thank you for testing this Matthias. You are right, we will add the “brainstorm server” option to our documentation. It would be very beneficial to us if you could share with us the little issues you encountered so we can improve the software.

Thanks!
Martin

Thanks for suggesting this. I added a shot paragraph to describe this mode in the Scripting tutorial:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Starting_Brainstorm
Let us know if you think we should add more information.

I had one problem towards the anat and the data folder for one protocol. For one subject i had an entry in the anat folder but not in the data folder, so they did not match. On the desktop computer brainstorm can work this out but not on the server. So it is important that data data and the anat folder match.

I am not sure I understand what is wrong here. Could you point at what is not working properly and how we could reproduce it on our end?

I have done just a few notes (regarding the errors which occurred to me) but I could bring them in order and share it.

All comments are welcome. If you have more advices or guidelines to share, we could also add a section “Brainstorm on a distant server” with various tips and tricks that could be useful. Send me all the text you’d like to share on this tutorial page. Or if you prefer editing this directly by yourself, I can give you the instruction to create an account to edit the wiki page directly.

Thanks

I tested a little bit more on the cluster because I had some commands which worked sometimes but not everytime.Brainstorm on a cluster.pdf (275.5 KB)
The file attached shows some notes which indicates how my code (including brainstorm functions) was running stable at the cluster.
Although some brainstorm functions seems to be more stable than others.
E.g.: I wanted to extract some data. At first I used function 'process_extract_time' which was working fine at first. When I wanted to rerun the same code it stopped with the error 'Error using strcmpi
Too many input arguments. ...' I switched to the function 'process_extract_values' which was working fine (at least till now).

When the file protocol.m was missing in the brainstorm/data folder the code always stopped, because it couldn't use java functions (I mentioned it in the attached file).

In the attached file is everything which was helpful for me. If during further testing I find more I will add it. If you prefer I could rewrite it and edit the wiki page directly.

Greetings,
Matthias

1 Like

Thank you for the very valuable feedback. The following commit should fix the java_dialog issue (item #7 in your document): https://github.com/brainstorm-tools/brainstorm3/commit/8fb7e7ad5cadb1d920885762e72429fcf157dd46

Thank you very much for the quick response. A quick test ended up with a different Error: “Output argument “res” (and maybe others) not assigned during call to
“java_dialog”.”

Can you please post the full error message? When does this error happen exactly?

Thanks,
Martin

{Output argument “res” (and maybe others) not assigned during call to
“java_dialog”.

Error in db_fix_protocol (line 236)
res = java_dialog(‘question’, [‘Folder "’
bst_fileparts(missingStudy{iStudy}) ‘" is missing in the database.’ 10
‘Create the missing files and folders in the data folder?’], …

Error in db_reload_database (line 65)
isError(i) = db_fix_protocol();

Error in db_load_protocol (line 78)
db_reload_database(iProtocols(i));

Error in gui_brainstorm>SetCurrentProtocol (line 1020)
db_load_protocol(iProtocol);

Error in gui_brainstorm (line 33)
eval(macro_method);

Error in freq_av_cluster_3_test (line 39)
gui_brainstorm(‘SetCurrentProtocol’, iProtocol);

}

This ‘freq_av_cluster_3_test’ is just the name of my script. And this are the not commended lines till the error occurs:
home = ‘/user/brainstorm_db/test/’;
BrainstormDbDir = ‘/user/brainstorm_db’;
if ~brainstorm(‘status’)
brainstorm server
end
bst_set(‘BrainstormDbDir’,BrainstormDbDir)
ProtocolName = ‘test’;
sProtocol.Comment = ProtocolName;
sProtocol.SUBJECTS = [home ‘anat’];
sProtocol.STUDIES = [home ‘data’];
db_edit_protocol(‘load’,sProtocol);
% Get the protocol index
iProtocol = bst_get(‘Protocol’, ProtocolName);
if isempty(iProtocol)
error(['Unknown protocol: ’ ProtocolName]);
end
% Select the current procotol
gui_brainstorm(‘SetCurrentProtocol’, iProtocol);

Do you need some other information?

Greetings,
Matthias

Sorry, I cannot reproduce your error. I made sure my instance reached line 236 of db_fix_protocol, but it works fine on my test server. Are you sure you properly updated your Brainstorm instance and Matlab path?

Edit: What’s your Matlab version? Sometimes old versions can be weird, I’m testing on latest (2018b).