Skip to content

Latest commit

 

History

History
179 lines (118 loc) · 8.56 KB

render-ws-example.md

File metadata and controls

179 lines (118 loc) · 8.56 KB

Render Web Services Example

The following workflow steps demonstrate how the render web services and Java clients can be used for a small example project.

The example assumes that:

  • you have completed the render web services basic installation steps,
  • you are running on the installation server, and
  • you run the first (Setup Environment) step from the cloned render repository root directory (./render).

URL Note

The 'localhost:8080' URL links below will only work if your browser (or http client) is running on the same host as the web services. If this is not the case, simply replace 'localhost' with name (or IP address) of your render web services host.

1. Setup Environment

Define common script invocation variables first to simplify subsequent steps.

# assumes current directory is still the cloned render repository root (./render)

export CLIENT_SCRIPTS=`readlink -m ./render-ws-java-client/src/main/scripts`
export EXAMPLE_1_PARAMS="--baseDataUrl http://localhost:8080/render-ws/v1 --owner demo --project example_1"
export EXAMPLE_1_DIR=`readlink -m ./examples/example_1`

2. Import Acquisition Data (Acquire)

Import tile specs and shared transform specs created by the acquisition system.

# create v1_acquire stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --action CREATE --cycleNumber 1 --cycleStepNumber 1 

# import v1_acquire tile and transform data
${CLIENT_SCRIPTS}/import_json.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --transformFile ${EXAMPLE_1_DIR}/cycle1_step1_acquire_transforms.json ${EXAMPLE_1_DIR}/cycle1_step1_acquire_tiles.json 

# complete v1_acquire stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --action SET_STATE --stackState COMPLETE

The following URLs** can be used to view dynamic renderings of the imported data:

3. Import Intra-Layer Alignment Data (Montage)

Import transform data generated by an alignment process that montages tiles "perfectly" within each layer. The alignment of layers relative to each other is irrelevant.

# create v1_montage stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_montage --action CREATE --cycleNumber 1 --cycleStepNumber 2

# apply v1_montage transform data to existing v1_acquire data, storing results in v1_montage stack
${CLIENT_SCRIPTS}/import_transform_changes.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --targetStack v1_montage --transformFile ${EXAMPLE_1_DIR}/cycle1_step2_montage_changes.json 

# complete v1_montage stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_montage --action SET_STATE --stackState COMPLETE

The following URLs** can be used to view dynamic renderings of the imported data:

4. Import Inter-Layer Alignment Data (Align)

Import transform data generated by a multi-layer-mosaic alignment process that approximates a global alignment of all tiles through a rigid transformation per tile.

# create v1_align stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_align --action CREATE --cycleNumber 1 --cycleStepNumber 3

# apply v1_align transform data to existing v1_acquire data, storing results in v1_align stack
${CLIENT_SCRIPTS}/import_transform_changes.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --targetStack v1_align --transformFile ${EXAMPLE_1_DIR}/cycle1_step3_align_changes.json 

# complete v1_align stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_align --action SET_STATE --stackState COMPLETE

The following URLs** can be used to view dynamic renderings of the imported data:

5. Refine Alignment Data (Align TPS)

Use Thin Plate Spline algorithm to warp all v1_montage layers such that the center points of all tiles are transferred to where they are in the v1_align stack.
The result v1_align_tps stack contains the warped v1_montage tiles so that they resemble the alignment result of the multi-layer-mosaic alignment of the v1_align stack.

# create v1_align_tps stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_align_tps --action CREATE --cycleNumber 1 --cycleStepNumber 4

# warp v1_montage stack to v1_align stack, storing results in v1_align_tps stack
${CLIENT_SCRIPTS}/generate_warp_transforms.sh ${EXAMPLE_1_PARAMS} --stack v1_montage --alignStack v1_align --targetStack v1_align_tps 3407 3408  

# complete v1_align_tps stack
${CLIENT_SCRIPTS}/manage_stacks.sh ${EXAMPLE_1_PARAMS} --stack v1_align_tps --action SET_STATE --stackState COMPLETE

The following URLs** can be used to view dynamic renderings of the refined data:

6. View Data Dashboards

At this point, you've created 4 stacks: one for each major reconstruction step of an acquisition cycle. The following URL** can be used to view metadata and aggregate statistics about each of these stacks:

7. Render Results to Disk for Review

Render full scale uniform boxes (derived tiles) and corresponding down-sampled mipmaps to disk. All generated images have the same dimensions and pixel count and are stored within a CATMAID LargeDataTileSource directory structure that looks like this:

  [root directory]/[tile width]x[tile height]/[level]/[z]/[row]/[col].[format]

The rendered results will be stored within the ./examples/example_1/boxes directory. You can view them using CATMAID or any tile/image viewing tool.

# render 2048-x-2048 boxes for layers 3407 and 3408
${CLIENT_SCRIPTS}/render_catmaid_boxes.sh ${EXAMPLE_1_PARAMS} --stack v1_align_tps --rootDirectory ${EXAMPLE_1_DIR}/boxes --height 2048 --width 2048 --format jpg --maxLevel 9 --maxOverviewWidthAndHeight 192 3407 3408 

8. Map Trace Coordinates

Map trace coordinates from v1_acquire to v1_align_tps. Coordinates are typically mapped from one reconstruction cycle to the next (e.g. v1_align_tps to v2_align_tps). To keeps things simple, the mapping demonstrated here is for a few points between stacks within the same cycle.

The fromJson v1_acquire_s3407_world_points.json file includes:

  • 2 coordinates (1000.0, 1000.0) and (4000.0, 4000.0) that map to only one tile,
  • 1 coordinate (2300.0, 2300.0) that maps to four overlapping tiles, and
  • 1 coordinate (7777.0, 8888.0) that does not map to any tile.

Run the initial world-to-local mapping process:

${CLIENT_SCRIPTS}/map_coordinates.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --z 3407 --fromJson ${EXAMPLE_1_DIR}/v1_acquire_s3407_world_points.json --toJson ${EXAMPLE_1_DIR}/v1_acquire_s3407_local_points.json  

The result mappings (and error) get saved to v1_acquire_s3407_local_points.json which can then be specified as input to map from the tile local values to v1_align_tps world coordinates:

${CLIENT_SCRIPTS}/map_coordinates.sh ${EXAMPLE_1_PARAMS} --stack v1_acquire --z 3407 --localToWorld --fromJson ${EXAMPLE_1_DIR}/v1_acquire_s3407_local_points.json --toJson ${EXAMPLE_1_DIR}/v1_align_tps_s3407_world_points.json  

The final results are saved to v1_align_tps_s3407_world_points.json and should include 3 mapped coordinates plus one error for the original coordinate (7777.0, 8888.0) that did not map to any v1_acquire tile.