Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
rcassani committed Aug 21, 2024
1 parent 8c490dd commit 764b8a0
Show file tree
Hide file tree
Showing 154 changed files with 8,481 additions and 1,566 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/startup_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Workflow to perform a minimal startup test of Brainstorm source

# Workflow name
name: Startup test

# Environment variables
env:
MATLAB_VER: R2021b # Oldest "b" available (Feb2024)
TMP_ERROR_FILE: tmp_error.txt # Flag file to indicate error
MATLAB_SCRIPT_FILE: scripto.m # Matlab script to handle errors

# Run manually from GitHub Actions tab, it must be in the default branch
on:
workflow_dispatch:

# Name for each run
run-name: "Startup test: ${{ github.ref_name }}"
jobs:
Run-Ubuntu:
name: Run on Linux (Ubuntu 20.04)
runs-on: ubuntu-20.04
steps:
# Get the Brainstorm code to test
- name: Checkout 'brainstorm3'
uses: actions/checkout@v3
# Setting Matlab
- name: Set up Matlab
uses: matlab-actions/setup-matlab@v1
with:
release: ${{ env.MATLAB_VER }}
# Create error file and Matlab test script
- name: Create required files
run: |
touch $TMP_ERROR_FILE
echo "function scripto()" > $MATLAB_SCRIPT_FILE
MATLAB_SCRIPT_TEXT="try brainstorm server local; catch ME; disp(getReport(ME)); exit; end; delete('$TMP_ERROR_FILE'); brainstorm stop; exit;"
echo $MATLAB_SCRIPT_TEXT >> $MATLAB_SCRIPT_FILE
cat $MATLAB_SCRIPT_FILE
ls -al
pwd
# Run test script
- name: Run test script
uses: matlab-actions/run-command@v1
with:
command: scripto()
startup-options: -nodisplay
# Check error file was deleted
- id: startuptest
name: Check error file
continue-on-error: true
run: |
if [ -f "$TMP_ERROR_FILE" ]; then
echo "ERROR: Brainstorm could not start on GitHub runner"
exit 1
fi
# Actions depending of outcome
- id: succeeded
if: steps.startuptest.outcome == 'success'
run: |
echo "Success action"
- id: failed
if: steps.startuptest.outcome == 'failure'
run: |
echo "Failure action"
exit 1
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ This is a brief list of resources to get started with MATLAB if you are new or c
- [Introduction to MATLAB for Python Users](https://blogs.mathworks.com/student-lounge/2021/02/19/introduction-to-matlab-for-python-users/)
- [MATLAB for Brain and Cognitive Scientists](https://mitpress.mit.edu/9780262035828/)
- [Brainstorm scripting](https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting)
- [Debug MATLAB Code Files](https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html)
- [MATLAB Debugging Tutorial (video)](https://www.youtube.com/watch?v=PdNY9n8lV1Y)

## Git and GitHub resources
Before starting a new contribution, you need to be familiar with [Git](https://git-scm.com/) and [GitHub](https://github.com/) concepts like: ***commit, branch, push, pull, remote, fork, repository***, etc. There are plenty resources online to learn Git and GitHub, for example:
Expand Down Expand Up @@ -101,7 +103,7 @@ See: [Git tools rewriting history](https://git-scm.com/book/en/v2/Git-Tools-Rewr
6. ### **Create a new Pull Request**

Once you're **happy** with all the changes that you have done, and you have pushed them to your remote repo, using the GitHub website, create a [Pull Request (PR)](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) from your **remote branch** to the **master** branch in the official Brainstorm repo.

> :warning: For greater collaboration, select the option [Allow edits by maintainers](https://docs.github.com/en/github/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) before creating your PR. This will allow Brainstorm maintainers to add commits to your PR branch before merging it. You can always change this setting later.
![image](https://user-images.githubusercontent.com/8238803/135626746-aaaac892-8c44-494e-a79d-b7195e3b2b5e.png)
Expand Down
6 changes: 3 additions & 3 deletions bin/R2022b/brainstorm3.bat → bin/R2023a/brainstorm3.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@ECHO.
@SET MATLABROOT=
@SET VER_NAME=R2022b
@SET VER_NUMBER=9.13
@SET MCR_FOLDER=v913
@SET VER_NAME=R2023a
@SET VER_NUMBER=9.14
@SET MCR_FOLDER=R2023a


@REM ===== SKIP DETECTION =====
Expand Down
53 changes: 31 additions & 22 deletions bin/R2022b/brainstorm3.command → bin/R2023a/brainstorm3.command
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# brainstorm3.command <MATLABROOT> <script.m> <arguments>
#
# If MATLABROOT argument is specified, the Matlab root path is saved
# in the file ~/.brainstorm/MATLABROOTXX.txt.
# in the file ~/.brainstorm/MATLABROOT_R20YYx.txt
# Else, MATLABROOT is read from this file
#
# AUTHOR: Francois Tadel, 2011-2022
# Raymundo Cassani, 2024

# Configuration
VER_NAME="2022b"
VER_NUMBER="9.13"
VER_DIR="913"
VER_YEAR_VERSION="2023a"
VER_NAME="R$VER_YEAR_VERSION"
MDIR="$HOME/.brainstorm"
MFILE="$MDIR/MATLABROOT$VER_DIR.txt"
MFILE="$MDIR/MATLABROOT_$VER_NAME.txt"

#########################################################################
# Detect system type
Expand All @@ -38,7 +38,7 @@ SH_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# JAR is in the same folder (Linux)
if [ -f "$SH_DIR/brainstorm3.jar" ]; then
JAR_FILE=$SH_DIR/brainstorm3.jar
# JAR is 3 levels up (on MacOSX: brainstorm3.app/Contents/MacOS/brainstorm3.command)
# JAR is 3 levels up (on macOS: brainstorm3.app/Contents/MacOS/brainstorm3.command)
elif [ -f "$SH_DIR/../../../brainstorm3.jar" ]; then
JAR_FILE=$SH_DIR/../../../brainstorm3.jar
else
Expand All @@ -52,14 +52,21 @@ if [ "$1" ]; then
# Read the folder from the file
elif [ -f $MFILE ]; then
MATLABROOT=$(<$MFILE)
# MacOS: Try the default installation folders for Matlab or the MCR
elif [ $SYST == "maci64" ] && [ -d "/Applications/MATLAB/MATLAB_Runtime/v$VER_DIR" ]; then
MATLABROOT="/Applications/MATLAB/MATLAB_Runtime/v$VER_DIR"
echo "MATLAB Runtime library was found in folder:"
echo "$MATLABROOT"
# macOS: Try the default installation folder for Matlab
elif [ $SYST == "maci64" ] && [ -d "/Applications/MATLAB_$VER_NAME.app" ]; then
MATLABROOT="/Applications/MATLAB_$VER_NAME.app"
# macOS: Try the default installation folder for Matlab Runtime
elif [ $SYST == "maci64" ] && [ -d "/Applications/MATLAB/MATLAB_Runtime/$VER_NAME" ]; then
MATLABROOT="/Applications/MATLAB/MATLAB_Runtime/$VER_NAME"
# Linux: Try the default installation folder for Matlab
elif ([ $SYST == "glnx86" ] || [ $SYST == "glnxa64" ]) && [ -d "/usr/local/MATLAB/$VER_NAME" ]; then
MATLABROOT="/usr/local/MATLAB/$VER_NAME"
# Linux: Try the default installation folder for Matlab Runtime
elif ([ $SYST == "glnx86" ] || [ $SYST == "glnxa64" ]) && [ -d "/usr/local/MATLAB/MATLAB_Runtime/$VER_NAME" ]; then
MATLABROOT="/usr/local/MATLAB/MATLAB_Runtime/$VER_NAME"
# Run the java file selector
else
java -classpath "$JAR_FILE" org.brainstorm.file.SelectMcr$VER_NAME
java -classpath "$JAR_FILE" org.brainstorm.file.SelectMcr$VER_YEAR_VERSION
# Read again the folder from the file
if [ -f $MFILE ]; then
MATLABROOT=$(<$MFILE)
Expand All @@ -73,17 +80,16 @@ if [ -z "$MATLABROOT" ]; then
echo "USAGE: brainstorm3.command <MATLABROOT>"
echo " brainstorm3.command <MATLABROOT> <script.m> <arguments>"
echo " "
echo "MATLABROOT is the installation folder of the Runtime $VER_NUMBER (R$VER_NAME)"
echo "The Matlab Runtime $VER_NUMBER is the library needed to"
echo "MATLABROOT is the installation folder of the Runtime ($VER_NAME)"
echo "The Matlab Runtime $VER_NAME is the library needed to"
echo "run executables compiled with Matlab $VER_NAME."
echo " "
echo "Examples:"
echo " Linux: /usr/local/MATLAB_Runtime/v$VER_DIR"
echo " Linux: $HOME/MATLAB_Runtime_$VER_NAME"
echo " MacOSX: /Applications/MATLAB/MATLAB_Runtime/v$VER_DIR"
echo "Default Matlab Runtime installation folders:"
echo " Linux: /usr/local/MATLAB_Runtime/$VER_NAME"
echo " macOS: /Applications/MATLAB/MATLAB_Runtime/v$VER_NAME"
echo " "
echo "MATLABROOT has to be specified only at the first call,"
echo "then it is saved in the file ~/.brainstorm/MATLABROOT$VER_DIR.txt"
echo "then it is saved in the file ~/.brainstorm/MATLABROOT_$VER_NAME.txt"
echo " "
exit 1
# If folder not a valid Matlab root path
Expand All @@ -110,6 +116,9 @@ fi
if [ ! -d "$MDIR" ]; then
mkdir $MDIR
fi
# Matlab path found
echo "Matlab $VER_NAME found:"
echo "$MATLABROOT"
# Save Matlab path in user folder
echo "$MATLABROOT" > $MFILE

Expand All @@ -119,10 +128,10 @@ export JVM_DIR=$MATLABROOT/sys/java/jre/$SYST/jre
export JAVA_EXE=$JVM_DIR/bin/java

##########################################################################
# Setting library path for MACOSX
# Setting library path for macOS
if [ $SYST == "maci64" ]; then
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MATLABROOT/runtime/maci64:$MATLABROOT/sys/os/maci64:$MATLABROOT/bin/maci64
# Setting library path for LINUX
# Setting library path for Linux
else
export PATH=$PATH:$MATLABROOT/runtime/$SYST
JAVA_SUBDIR=$(find $MATLABROOT/sys/java/jre -type d | tr '\n' ':')
Expand All @@ -144,7 +153,7 @@ echo " "
# Run Brainstorm
"$JAVA_EXE" -jar "$JAR_FILE" "${@:2}"

# Force shell death on MacOSX
# Force shell death on macOS
if [ $SYST == "maci64" ]; then
exit 0
fi
Expand Down
13 changes: 8 additions & 5 deletions brainstorm.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
javaaddpath(BstJar);
end

% Default anatomy template
TemplateName = 'ICBM152_2023b';

% Default action : start
if (nargin == 0)
action = 'start';
Expand All @@ -120,17 +123,17 @@
switch action
case 'start'
bst_set_path(BrainstormHomeDir);
bst_startup(BrainstormHomeDir, 1, BrainstormDbDir);
bst_startup(BrainstormHomeDir, 1, BrainstormDbDir, TemplateName);
case 'nogui'
bst_set_path(BrainstormHomeDir);
bst_startup(BrainstormHomeDir, 0, BrainstormDbDir);
bst_startup(BrainstormHomeDir, 0, BrainstormDbDir, TemplateName);
case 'server'
bst_set_path(BrainstormHomeDir);
bst_startup(BrainstormHomeDir, -1, BrainstormDbDir);
bst_startup(BrainstormHomeDir, -1, BrainstormDbDir, TemplateName);
case 'autopilot'
if ~isappdata(0, 'BrainstormRunning')
bst_set_path(BrainstormHomeDir);
bst_startup(BrainstormHomeDir, 2, BrainstormDbDir);
bst_startup(BrainstormHomeDir, 2, BrainstormDbDir, TemplateName);
end
res = bst_autopilot(varargin{2:end});
case 'digitize'
Expand Down Expand Up @@ -211,7 +214,7 @@
% Runs Brainstorm normally (asks for brainstorm_db)
if ~isappdata(0, 'BrainstormRunning')
bst_set_path(BrainstormHomeDir);
bst_startup(BrainstormHomeDir, 1, BrainstormDbDir);
bst_startup(BrainstormHomeDir, 1, BrainstormDbDir, TemplateName);
end
% Message
java_dialog('msgbox', 'Brainstorm will now download additional files needed for the workshop.', 'Workshop');
Expand Down
28 changes: 23 additions & 5 deletions deploy/bst_compile.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,26 @@ function bst_compile(isPlugs)
error('You must install the toolboxes "Matlab Compiler" and "Matlab Compiler SDK" to run this function.');
end
% Start brainstorm without the GUI
isNogui = ~brainstorm('status');
if isNogui
wasBstRunning = brainstorm('status');
if ~wasBstRunning
brainstorm nogui
end
isGUI = bst_get('isGUI');
% Delete current default anatomy and download it
templateDir = bst_fullfile(bst_get('BrainstormHomeDir'), 'defaults', 'anatomy');
if exist(templateDir, 'dir')
brainstorm stop
try
rmdir(templateDir, 's');
catch
disp(['COMPILE> Error: Could not delete folder: ' templateDir]);
end
if isGUI
brainstorm start
else
brainstorm nogui
end
end
% Remove .brainstorm from the path
rmpath(bst_get('UserMexDir'));
rmpath(bst_get('UserProcessDir'));
Expand Down Expand Up @@ -258,13 +274,15 @@ function bst_compile(isPlugs)
delete(bstJar);
end
if ispc
cmdSeparator = '&';
cdCall = 'cd /d';
cmdSeparator = '&&';
jarExePath = '\bin\jar.exe';
else
else
cdCall = 'cd';
cmdSeparator = ';';
jarExePath = '/bin/jar';
end
system(['cd "' jarDir '" ' cmdSeparator ' "' JdkDir, jarExePath '" cmf manifest.txt "' bstJar '" bst_javabuilder_' ReleaseName(2:end) ' org com']);
system([cdCall ' "' jarDir '" ' cmdSeparator ' "' JdkDir, jarExePath '" cmf manifest.txt "' bstJar '" bst_javabuilder_' ReleaseName(2:end) ' org com']);



Expand Down
Loading

0 comments on commit 764b8a0

Please sign in to comment.