Skip to content

Commit

Permalink
1.0.0 (#1)
Browse files Browse the repository at this point in the history
* 1.0.0: Initial commit

* ENH: Update manifest.

* DOC: minor manifest formatting

* FIX: manifest typo

* FIX: typo

* ENH: Generate PNG montage from each map

* add suite key + doc/ignore cleanup
  • Loading branch information
lmperry authored Sep 4, 2020
1 parent cffc0da commit 77eb7f3
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output
testdata
.git
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Create Docker container that can run dtiError analysis.

# Start with the Matlab runtime container
FROM flywheel/matlab-mcr:v92.1

MAINTAINER Michael Perry <[email protected]>

# ADD the Matlab Stand-Alone (MSA) into the container
COPY src/bin/*dtiinitDiffusionMaps* /usr/local/bin/

# Ensure that the executable files are executable
RUN chmod +x /usr/local/bin/*dtiinitDiffusionMaps*

# Copy and configure run script and metadata code
COPY manifest.json ${FLYWHEEL}/manifest.json

# Configure entrypoint
ENTRYPOINT ["/usr/local/bin/run_dtiinitDiffusionMaps.sh"]
103 changes: 102 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,102 @@
# fw-gear-dtiinit-diffusion-maps
# vistalab/fw-gear-dtiinit-diffusion-maps

Generate diffusion maps (in NIfTI format), including Fractional Anisotropy (FA), Axial Diffusivity (AD), Mean Diffusivity (MD), and Radial Diffusivity (RD). The input to this Gear is a dtiInit archive, generated from either [dtiInit](https://github.com/scitran-apps/dtiinit), or as part of the [AFQ](https://github.com/scitran-apps/afq-pipeline) processing pipeline.

## Inputs
The input to this Gear is a dtiInit archive, containing a 'dt6.mat' file. This archive is generated from either [dtiInit](https://github.com/scitran-apps/dtiinit), or as part of the [AFQ](https://github.com/scitran-apps/afq-pipeline) processing pipeline.

```bash
dtiInit_29-Aug-2018_17-34-24.zip
```

## Outputs
Diffusion maps (in NIfTI format), including Fractional Anisotropy (FA), Axial Diffusivity (AD), Mean Diffusivity (MD), and Radial Diffusivity (RD).

```bash
fa.nii.gz
md.nii.gz
ad.nii.gz
rd.nii.gz
```

## Example Usage/Testing

To run/test this Gear you will need to:
1. Download the Flywheel CLI and login to your Flywheel Instance
2. Build the Docker image
3. Execute the Gear using the Flywheel CLI


#### 1. Download the Flywheel CLI and login
Visit: Flywheel for instruction on dowloading the CLIhttps://docs.flywheel.io/hc/en-us/articles/360008162214-Installing-the-Command-Line-Interface-CLI-

Once you have that, you can login:
```bash
fw login <your_flywheel_api_key>
```

#### 2. Build the image with Docker
```#bash
git clone https://github.com/vistalab/fw-gear-dtiinit-diffusion-maps
docker build -t vistalab/dtiinit-diffusion-maps:1.0.0
```
_Important note: The version (`1.0.0` in the example above) should be read from the `version` key within [manifest.json](manifest.json) file.

#### 3. Run the Gear locally with the test data
```bash
fw gear local --dtiinit_archive ./testdata/dtiInit_29-Aug-2018_17-34-24.zip
```
Example output:

```
lmperry@warrior:/Users/lmperry/dtiinit-diffusion-maps:$ fw gear local --dtiinit_archive ./testdata/dtiInit_29-Aug-2018_17-34-24.zip
Checking if vistalab/dtiinit-diffusion-maps:1.0.0 is available locally...
Found tag locally.
Creating container from vistalab/dtiinit-diffusion-maps:1.0.0 ...
Created de36f2efba27
Attaching to logs...
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/opt/mcr/v92/runtime/glnxa64:/opt/mcr/v92/bin/glnxa64:/opt/mcr/v92/sys/os/glnxa64:/opt/mcr/v92/sys/opengl/lib/glnxa64
archive_path =
'/flywheel/v0/input/dtiinit_archive/dtiInit_29-Aug-2018_17-34-24.zip'
Unpacking archive...
Locating dt6.mat file from archive...
Found /tmp/dtiInit_29-Aug-2018_17-34-24/dti90trilin/dt6.mat!
Generating diffusion maps...
Generating fa map ... Writing /flywheel/v0/output/fa.nii.gz...Done.
Generating md map ... Writing /flywheel/v0/output/md.nii.gz...Done.
Generating ad map ... Writing /flywheel/v0/output/ad.nii.gz...Done.
Generating rd map ... Writing /flywheel/v0/output/rd.nii.gz...Done.
Complete!
Removing container de36f2efba27 ...
Removed container
```

### Developer's Corner: Compiling the Matlab Executable
This Gear runs a Matlab Executable via the Matlab Compiler Runtime, which is build in the base image. __Note that the image uses MCR v92 (Matlabr2017a)__ - this MCR versions used to maintain Docker image compatibility with the other tools generating the dtiInit_Archives.

If you find that need to make changes to the [source code](src/dtiinitDiffusionMaps_build.m) you will need to recompile the [executable](src/bin/run_dtiinitDiffusionMaps) and re-build the Docker image.

In order to recompile the Matlab executable you can use the provided [`.m`](src/dtiinitDiffusionMaps_build.m) file (you need to use Matlabr2017a for the binary to be compatible with the [Docker image](Dockerfile) we generate here).

The [`dtiinitDiffusionMaps_build.m`](src/dtiinitDiffusionMaps_build.m) file contains all the required instruction to compile the binary, including downloading the source code and setting required paths.

You can run the code from the command line like so:
```bash
/<path_to_your_matlabr2017a_binary> -nodesktop -r 'dtiinitDiffusionMaps_build.m'
```

If you already have your Matlab 2017a terminal open, you can simply run [the code](src/dtiinitDiffusionMaps_build.m):
```Matlab
dtiinitDiffusionMaps_build
```

38 changes: 38 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "dtiinit-diffusion-maps",
"label": "dtiInit: Diffusion Map Generation",
"description": "Generate diffusion maps, including Fractional Anisotropy (FA), Axial Diffusivity (AD), Mean Diffusivity (MD), and Radial Diffusivity (RD). The input to this Gear is a dtiInit archive, containing a 'dt6.mat' file. This archive is generated from either the dtiInit Flywheel Gear, or from the Flywheel Gear which executes the AFQ processing pipeline. Outputs are fa, md, rd, and ad files (in gzipped NIfTI format).",
"maintainer": "Michael Perry <[email protected]>",
"author": "Stanford VISTA Lab (vistalab.stanford.edu)",
"url": "https://github.com/vistalab/vistasoft/wiki",
"source": "https://github.com/vistalab/fw-gear-dtiinit-diffusion-maps",
"license": "GPL-2.0",
"flywheel": "0",
"version": "1.0.0",
"custom": {
"flywheel": {
"suite": "VISTA Lab"
},
"gear-builder": {
"image": "vistalab/dtiinit-diffusion-maps:1.0.0",
"category": "analysis"
}
},
"inputs": {
"dtiinit_archive": {
"base": "file",
"description": "Output archive (.zip) from dtiinit gear run, or AFQ.",
"type": {
"enum": [
"archive"
]
}
}
},
"config": {},
"environment": {
"LD_LIBRARY_PATH": "/opt/mcr/v92/runtime/glnxa64:/opt/mcr/v92/bin/glnxa64:/opt/mcr/v92/sys/os/glnxa64",
"XAPPLRESDIR": "XAPPLRESDIR"
},
"command": "/usr/local/bin/run_dtiinitDiffusionMaps.sh /opt/mcr/v92 /flywheel/v0/config.json"
}
Binary file added src/bin/dtiinitDiffusionMaps
Binary file not shown.
2 changes: 2 additions & 0 deletions src/bin/mccExcludedFiles.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The List of Excluded Files
Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule
115 changes: 115 additions & 0 deletions src/bin/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
MATLAB Compiler

1. Prerequisites for Deployment

. Verify the MATLAB Runtime is installed and ensure you
have installed version 9.2 (R2017a).

. If the MATLAB Runtime is not installed, do the following:
(1) enter

>>mcrinstaller

at MATLAB prompt. The MCRINSTALLER command displays the
location of the MATLAB Runtime installer.

(2) run the MATLAB Runtime installer.

Or download the Linux 64-bit version of the MATLAB Runtime for R2017a
from the MathWorks Web site by navigating to

http://www.mathworks.com/products/compiler/mcr/index.html


For more information about the MATLAB Runtime and the MATLAB Runtime installer, see
Package and Distribute in the MATLAB Compiler documentation
in the MathWorks Documentation Center.


2. Files to Deploy and Package

Files to package for Standalone
================================
-dtiinitDiffusionMaps
-run_dtiinitDiffusionMaps.sh (shell script for temporarily setting environment variables
and executing the application)
-to run the shell script, type

./run_dtiinitDiffusionMaps.sh <mcr_directory> <argument_list>

at Linux or Mac command prompt. <mcr_directory> is the directory
where version 9.2 of the MATLAB Runtime is installed or the directory where
MATLAB is installed on the machine. <argument_list> is all the
arguments you want to pass to your application. For example,

If you have version 9.2 of the MATLAB Runtime installed in
/mathworks/home/application/v92, run the shell script as:

./run_dtiinitDiffusionMaps.sh /mathworks/home/application/v92

If you have MATLAB installed in /mathworks/devel/application/matlab,
run the shell script as:

./run_dtiinitDiffusionMaps.sh /mathworks/devel/application/matlab
-MCRInstaller.zip
-if end users are unable to download the MATLAB Runtime using the above
link, include it when building your component by clicking
the "Runtime downloaded from web" link in the Deployment Tool
-This readme file

3. Definitions

For information on deployment terminology, go to
http://www.mathworks.com/help. Select MATLAB Compiler >
Getting Started > About Application Deployment >
Deployment Product Terms in the MathWorks Documentation
Center.


4. Appendix

A. Linux x86-64 systems:
In the following directions, replace MCR_ROOT by the directory where the MATLAB Runtime
is installed on the target machine.

(1) Set the environment variable XAPPLRESDIR to this value:

MCR_ROOT/v92/X11/app-defaults


(2) If the environment variable LD_LIBRARY_PATH is undefined, set it to the concatenation
of the following strings:

MCR_ROOT/v92/runtime/glnxa64:
MCR_ROOT/v92/bin/glnxa64:
MCR_ROOT/v92/sys/os/glnxa64:
MCR_ROOT/v92/sys/opengl/lib/glnxa64

If it is defined, set it to the concatenation of these strings:

${LD_LIBRARY_PATH}:
MCR_ROOT/v92/runtime/glnxa64:
MCR_ROOT/v92/bin/glnxa64:
MCR_ROOT/v92/sys/os/glnxa64:
MCR_ROOT/v92/sys/opengl/lib/glnxa64

For more detail information about setting the MATLAB Runtime paths, see Package and
Distribute in the MATLAB Compiler documentation in the MathWorks Documentation Center.



NOTE: To make these changes persistent after logout on Linux
or Mac machines, modify the .cshrc file to include this
setenv command.
NOTE: The environment variable syntax utilizes forward
slashes (/), delimited by colons (:).
NOTE: When deploying standalone applications, it is possible
to run the shell script file run_dtiinitDiffusionMaps.sh
instead of setting environment variables. See
section 2 "Files to Deploy and Package".






1 change: 1 addition & 0 deletions src/bin/requiredMCRProducts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
35000 35010
33 changes: 33 additions & 0 deletions src/bin/run_dtiinitDiffusionMaps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
# script for execution of deployed applications
#
# Sets up the MATLAB Runtime environment for the current $ARCH and executes
# the specified command.
#
exe_name=$0
exe_dir=`dirname "$0"`
echo "------------------------------------------"
if [ "x$1" = "x" ]; then
echo Usage:
echo $0 \<deployedMCRroot\> args
else
echo Setting up environment variables
MCRROOT="$1"
echo ---
LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/bin/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/os/glnxa64;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/opengl/lib/glnxa64;
export LD_LIBRARY_PATH;
echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
shift 1
args=
while [ $# -gt 0 ]; do
token=$1
args="${args} \"${token}\""
shift
done
eval "\"${exe_dir}/dtiinitDiffusionMaps\"" $args
fi
exit

Loading

0 comments on commit 77eb7f3

Please sign in to comment.