This is a generic framework for building real-time fMRI processing pipelines in the cloud.
There are three general components:
- File Server
- Watches for new dicom images written by the MRI scanner.
- Sends the dicom images to the projectInterface in the cloud.
- Listens for requests from the cloud projectInterface to either read or write files (within restricted directories) on the scanner computer.
- Project Interface
- Runs in the cloud.
- Provides a user interface to start/stop and configure a run.
- Is the communication link between the fileServer and the project specific code that runs in the cloud.
- Project Specific Script
- Code specific to the fMRI study being done.
- Waits for dicom files to arrive, creates a data model, returns classification results to the fileServer for feedback purposes.
Fig2: Overview of Where Scripts Run
A projectInterface is started on the cloud computer. The projectInterface has a web interface which a browser can connect to and allows configuring and starting a run. The web interface is configured so that the browser start button starts the project specific script. Wherever the projectInterface is installed is where your project specific python script will also run. The projectInterface also serves as the intermediary for communication between the the fileserver (running in the control room) and the project specific script (running in the cloud).
A fileServer is started on the scanner computer that can watch for files within specified directories. The fileServer connects to the projectInterface. The fileServer requires a username and password to connect to and login to the projectInterface.
- Wrapping Your Experiment Script with the RealTime Framework
- Running a Realtime Experiment
- Run Project in a Docker Container
On the cloud computer where processing will take place, do these steps
- Check if you have mini-conda already installed. In a terminal run
conda -V- Mac Specific: Install Mini-Conda
- Linux Specific: Install Mini-Conda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.shbash Miniconda3-latest-Linux-x86_64.sh -b
- Check if you have Node.js and NPM installed. In a terminal run
node -vandnpm -v- Mac Specific: Install Node.js
- Check if Homebrew 'brew' is installed run
brew -h- Install Homebrew if it is not installed
- Run
brew update - Run
brew install node
- Check if Homebrew 'brew' is installed run
- Linux Specific (CentOS): Install Node.js
sudo yum install epel-releasesudo yum install nodejs
- Mac Specific: Install Node.js
On the cloud computer where processing will take place, do these steps
- Pull the source code
git clone https://github.com/brainiak/rt-cloud.git cd rt-cloud/- Get the local ip address <local_ip_addr>
- Mac Specific: Google "what's my ip address"
- Linux Specific:
hostname -i
- Make a private key and an ssl certificate or copy an existing one into the certs directory
mkdir certs; openssl genrsa -out certs/rtcloud_private.key 2048bash scripts/make-sslcert.sh -ip [local_ip_addr]
- Create the conda environment
conda env create -f environment.ymlconda activate rtcloud
- Install node module dependencies
cd web; npm install; cd ..
- Create a user:
bash scripts/add-user.sh -u [new_username] -p [password]
On the console computer where dicoms are written, do these steps
- Repeat Step 1.1 above to install Mini-Conda
- Clone the rt-cloud code
git clone https://github.com/brainiak/rt-cloud.git - Copy the ssl certificate created in Step 2.4 above to this computer's rt-cloud/certs directory
- Copy rt-cloud/certs/rtcloud.crt from the cloud computer
- Copy it into the rt-cloud/certs directory on the fileServer computer
For the sample we will run both the projectInterface and fileServer on the same computer. Follow the above installation steps but install both the fileServer and projectInterface on the same computer. In a production deployment the projectInterface would typically run in a cloud VM and the fileServer would run in the control room console computer.
Note: The --test option runs in test mode which doesn't use SSL encryption and accepts a default username and password, both are 'test'. Never run with the --test option in production.
- Open a terminal
- Start the projectInterface
conda activate rtcloudbash scripts/run-projectInterface.sh -p sample --test
- Start the projectInterface
- Open another terminal
- Start the fileServer
conda activate rtcloudbash scripts/run-fileserver.sh -s localhost:8888 --test
- Start the fileServer
- Optional - Open another terminal to start the feedbackReciever
- Start the feedbackReceiver
conda activate rtcloudpython rtCommon/feedbackReceiver.py -s localhost:8888 --test
- Start the feedbackReceiver
- Navigate web browser to URL http://localhost:8888
- If prompted for username and password enter:
username 'test', password 'test'
- If prompted for username and password enter:
- Alternate step 4 - Run sample project from the command line connecting to remote fileServer
python projects/sample/sample.py --filesremote
- Alternate to step 1 above
- Start the projectInterface
conda activate rtcloudbash scripts/run-projectInterface.sh -p sample -c projects/sample/conf/sample-synthetic.toml --test
- Start the projectInterface
- Alternate to step 2 above
- Start the fileServer
conda activate rtcloudbash scripts/run-fileserver.sh -s localhost:8888 --allow_synthetic_data --test
- Start the fileServer
- Same as step 3 above
- Run the sample project without the --test options. This will require the following steps. See Running a Realtime Experiment for instructions on accomplishing these steps.
- Add the SSL certificate rtcloud/certs/rtcloud.crt that was created in install step 2 above into your web browser.
- Include the -ip [local_ip_addr] option when starting the projectInterface.
- Include the -u [username] and -p [password] options when starting the fileServer. Use the username and password created in install step 2 above.
- Navigate web browser to https://localhost:8888 for a SSL connecton
- i.e. instead of the non-SSL http:// address used above for testing
- When prompted for login by Web browser use the username and password created in install step 2 above.
- Install and run the projectInterface on a remote computer. Run the fileServer on the computer where the dicoms are written.
- Create your own project python script and wrap it with the real-time framework. See Wrapping Your Experiment Script with the RealTime Framework
- Run Project in a Docker Container
- Details - coming soon