Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #1

Merged
merged 19 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build-frontend-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build frontend

on:
push:
branches: ["development"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 17.9.1
- name: switch to frontend branch
run: |
echo switching to branch ${GITHUB_REF_NAME}-frontend
git checkout ${GITHUB_REF_NAME}-frontend || git checkout -b ${GITHUB_REF_NAME}-frontend
git merge ${GITHUB_REF_NAME}-frontend
- name: build frontend
run: |
cd frontend
yarn
cd ..
./build-frontend.sh
- name: config git user
run: |
curl -s -u ${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }} https://api.github.com/users/${GITHUB_ACTOR} > ${GITHUB_ACTOR}.json
git config user.email "$(cat ${GITHUB_ACTOR}.json | jq -r .email)"
git config user.name "frontend-bot"
- name: commit changes
run: |
git add -f bad/static/brain*
git add -f bad/static/index*
git status
git commit -m"build frontend"
- name: push changes
run: |
git push -u origin ${GITHUB_REF_NAME}-frontend

36 changes: 36 additions & 0 deletions .github/workflows/build-frontend-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build frontend

on:
push:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 17.9.1
- name: build frontend
run: |
cd frontend
yarn
cd ..
./build-frontend.sh
- name: config git user
run: |
curl -s -u ${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }} https://api.github.com/users/${GITHUB_ACTOR} > ${GITHUB_ACTOR}.json
git config user.email "$(cat ${GITHUB_ACTOR}.json | jq -r .email)"
git config user.name "frontend-bot"
- name: commit changes
run: |
git add -f bad/static/brain*
git add -f bad/static/index*
git status
git commit -m"build frontend"
- name: push changes
run: |
git push
48 changes: 48 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: test

on:
push:
branches: ["main", "development"]
pull_request:
branches: ["main", "development"]

jobs:

test-ubuntu:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
mongodb-version: ["4.2"]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m venv env
source env/bin/activate
pip install -r requirements.txt
pip install https://github.com/JamesRitchie/scikit-rvm/archive/master.zip

- name: Run tests
run: |
source env/bin/activate
./run-tests.sh
108 changes: 105 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,109 @@
# BrainAGE Designer

[![test](https://github.com/defgsus/brainage-designer/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/defgsus/brainage-designer/actions/workflows/tests.yml)
[![test](https://github.com/defgsus/brainage-designer/actions/workflows/build-frontend-main.yml/badge.svg?branch=main)](https://github.com/defgsus/brainage-designer/actions/workflows/build-frontend-main.yml)

**Brain** **A**ge **G**ap **E**stimation framework with browser-based user interface.

![screenshot](docs/img/screenshot-analysis.png)

Some of the features:

- all experiments are controlled from the web-UI
- supports arbitrary preprocessing pipelines
- fine control over analysis / model creation
- all experiments are stored to database for revisiting them later


## Installation

### Requirements

- [Python](https://www.python.org/) 3.8 or later
- [MongoDB](https://www.mongodb.com/) 3.6 or later
- [Matlab Runtime](https://www.mathworks.com/products/compiler/matlab-runtime.html) v93 (optional)

### Download

Using the git command-line tool:

```shell
cd /my/projects # or where you want to place it
git clone https://github.com/defgsus/brainage-designer.git
cd brainage-designer
git checkout development-frontend
```

or you can download [a zip file](https://github.com/defgsus/brainage-designer/archive/refs/heads/development-frontend.zip)
and extract it.

### Running on localhost

```shell
# create new python environment
python -m venv env
# activate
source env/bin/activate
# install python packages
pip install -r requirements.txt
pip install https://github.com/JamesRitchie/scikit-rvm/archive/master.zip
```

[Install MongoDB](https://www.mongodb.com/docs/manual/installation/)

Start server and worker:

```shell
./start-server.sh
```

visit [http://localhost:9009](http://localhost:9009)

#### Configuration

The local setup can be configure by creating a `.env` file
in the root directory. It can have the following entries:

```shell
# enable debugging mode (mainly for web-server, more text output)
BAD_DEBUG=true

# -- directories --

# the root path below which everything can be accessed
BAD_DATA_PATH=/home/me
# temporary directory to use
TEMP_PATH=/tmp/brainage-designer

# -- matlab --

# path to the matlab runtime
MATLAB_PATH=/home/me/MATLAB_Runtime/v93
# path to the matlab-based CAT12 toolbox
CAT12_PATH=/home/me/CAT12.8.1_r2042_R2017b_MCR_Linux

# -- API server --

# change the address of the API (and frontend) server
SERVER_HOST=localhost
SERVER_PORT=9009

# -- mongodb --

# rename the database
DATABASE_NAME=brainage-designer
# location of the mongodb server
DATABASE_HOST=localhost
DATABASE_PORT=27017
# to handle authentication with mongodb
DATABASE_USER=brainage-user
DATABASE_PASSWORD=brainage-password
```



## Installation via 'Docker'

Install a recent version of [Docker Engine](https://docs.docker.com/engine/install/)
or the **Docker Desktop** if you can't help it.

Expand Down Expand Up @@ -46,13 +148,13 @@ docker run -ti -p 80:9009 brainage-designer
```


## development
# Development

### prepare environments

```shell
# for python the typical
virtualenv -p python3 env
# for python the typical..
python -m venv env
source env/bin/activate
pip install -r requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion bad/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _to_bool(x: str) -> bool:
DATA_PATH: Path = config("BAD_DATA_PATH", default=Path("~/").expanduser(), cast=Path)
TEMP_PATH: Path = config(
"BAD_TEMP_PATH",
default=str(Path(tempfile.gettempdir()) / "brainage-pipeline"),
default=str(Path(tempfile.gettempdir()) / "brainage-designer"),
cast=Path,
)

Expand Down
4 changes: 2 additions & 2 deletions bad/process/processdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import signal
import uuid
import traceback
from typing import Mapping, Any, Optional, Union, Sequence
from typing import Mapping, Any, Optional, Union, Sequence, List

import pymongo
from pymongo.database import Collection, List
from pymongo.database import Collection

from bad.db import DatabaseMixin
from bad import logger
Expand Down
Binary file added docs/img/screenshot-analysis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"source": "src/index.html",
"scripts": {
"start": "parcel",
"build": "parcel build --no-source-maps --no-cache --detailed-report"
},
"config": {
"root": "./src",
"dist": "./dist"
},
"devDependencies": {
"@parcel/transformer-inline-string": "2.8.0",
"@parcel/transformer-sass": "2.8.0",
"buffer": "^5.5.0",
"parcel": "^2.8.0",
"process": "^0.11.10"
},
"dependencies": {
"@ant-design/icons": "^4.8.0",
"@lagunovsky/redux-react-router": "^4.3.0",
"@reduxjs/toolkit": "^1.9.0",
"antd": "^5.0.0",
"axios": "^1.1.3",
"history": "^5.3.0",
"moment": "^2.29.4",
"plotly.js": "^2.24.3",
"react": "^18.2.0",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.4",
"react-plotly.js": "^2.6.0",
"react-redux": "^8.0.5",
"react-router": "^6.4.3",
"react-router-dom": "^6.4.3",
"redux": "^4.2.0",
"redux-toolkit-saga": "^1.2.0",
"three": "^0.147.0"
}
}
23 changes: 12 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# h5py==3.1.0 # requires extra package for mac python docker image
matplotlib==3.6.3
nibabel==3.2.2
nilearn==0.9.2
Pillow==8.4.0
pymongo==4.1.1
python-decouple==3.6
requests==2.27.1
scipy==1.5.4
tornado==6.2
tqdm==4.64.1
matplotlib==3.7.3
nibabel==5.1.0 # 3.2.2
nilearn==0.10.2
numpy==1.24.4
Pillow==10.1.0
pymongo==4.6.0
python-decouple==3.8
requests==2.31.0
scipy==1.10.1
tornado==6.3.3
tqdm==4.66.1
xlrd==2.0.1
https://github.com/JamesRitchie/scikit-rvm/archive/master.zip
# https://github.com/JamesRitchie/scikit-rvm/archive/master.zip
4 changes: 2 additions & 2 deletions tests/modules/test_cat12.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from tests.base import BadTestCase


@unittest.skipIf(not config.CAT12_PATH.exists(), "CAT12 package not at it's place")
@unittest.skipIf(not config.MATLAB_PATH.exists(), "matlab not at it's place")
@unittest.skipIf(len(str(config.CAT12_PATH)) <= 1 or not config.CAT12_PATH.exists(), "CAT12 package not at it's place")
@unittest.skipIf(len(str(config.MATLAB_PATH)) <= 1 or not config.MATLAB_PATH.exists(), "matlab not at it's place")
class TestCat12Modules(BadTestCase):

def test_cat12_version(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/modules/test_cat12_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from tests.base import BadTestCase


@unittest.skipIf(not config.CAT12_PATH.exists(), "CAT12 package not at it's place")
@unittest.skipIf(not config.MATLAB_PATH.exists(), "matlab not at it's place")
@unittest.skipIf(len(str(config.CAT12_PATH)) <= 1 or not config.CAT12_PATH.exists(), "CAT12 package not at it's place")
@unittest.skipIf(len(str(config.MATLAB_PATH)) <= 1 or not config.MATLAB_PATH.exists(), "matlab not at it's place")
class TestCat12PreprocessModule(BadTestCase):

@BadTestCase.tag_long()
Expand Down
Loading