Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Nov 28, 2023
1 parent 012faa9 commit a74dbf3
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 9 deletions.
59 changes: 50 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Continuous integration testing for ChRIS Plugin.
# https://github.com/FNNDSC/python-chrisapp-template/wiki/Continuous-Integration
#
# - on push and PR: run pytest
# - on push to main: build and push container images as ":latest"
# - on push to semver tag: build and push container image with tag and
# upload plugin description to https://chrisstore.co

name: build
name: ci

on:
push:
Expand Down Expand Up @@ -76,6 +68,55 @@ jobs:
load: true
cache-from: type=gha

- name: Download example data
run: ./download_example_data.sh example_data_dir/
- name: Run examples
id: run_examples
run: |
mkdir /tmp/outgoing
docker run --rm -u "$(id -u):$(id -g)" \
-v "${{ github.workspace }}/example_data_dir/data:/incoming:ro" \
-v "/tmp/outgoing:/outgoing:rw" \
${{ steps.info.outputs.local_tag }} \
emerald --mask-suffix '_mask.nii' --outputs '0.0:_brain.nii,0.2:_overlay02.nii' /incoming /outgoing
- name: Assert example outputs are found
run: |
expected_outputs=(
/tmp/outgoing/stack-1_brain.nii
/tmp/outgoing/stack-1_mask.nii
/tmp/outgoing/stack-1_overlay02.nii
/tmp/outgoing/stack-2_brain.nii
/tmp/outgoing/stack-2_mask.nii
/tmp/outgoing/stack-2_overlay02.nii
/tmp/outgoing/stack-3_brain.nii
/tmp/outgoing/stack-3_mask.nii
/tmp/outgoing/stack-3_overlay02.nii
/tmp/outgoing/stack-4_brain.nii
/tmp/outgoing/stack-4_mask.nii
/tmp/outgoing/stack-4_overlay02.nii
/tmp/outgoing/stack-5_brain.nii
/tmp/outgoing/stack-5_mask.nii
/tmp/outgoing/stack-5_overlay02.nii
/tmp/outgoing/stack-6_brain.nii
/tmp/outgoing/stack-6_mask.nii
/tmp/outgoing/stack-6_overlay02.nii
/tmp/outgoing/stack-7_brain.nii
/tmp/outgoing/stack-7_mask.nii
/tmp/outgoing/stack-7_overlay02.nii
/tmp/outgoing/stack-8_brain.nii
/tmp/outgoing/stack-8_mask.nii
/tmp/outgoing/stack-8_overlay02.nii
)
for expected_output in "${expected_outputs[@]}"; do
if ! [ -f "$expected_output" ]; then
echo "expected $expected_output to be a file, but it does not."
parent_dir="$(dirname "$expected_output")"
set -ex
ls -lh "$parent_dir"
exit 1
fi
done
- name: Login to DockerHub
if: (github.event_name == 'push' || github.event_name == 'release') && contains(steps.info.outputs.tags_csv, 'docker.io')
uses: docker/login-action@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ __pycache__

.idea
.mambaenv

/example_data_dir
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Automatic Brain Masking

[![GitHub tag](https://img.shields.io/github/v/tag/FNNDSC/pl-emerald?filter=v*.*.*&label=version)](https://github.com/FNNDSC/pl-emerald/pkgs/container/pl-emerald)
[![MIT License](https://img.shields.io/github/license/fnndsc/pl-emerald)](https://github.com/FNNDSC/pl-emerald/blob/master/LICENSE)
[![ci](https://github.com/FNNDSC/pl-emerald/actions/workflows/ci.yml/badge.svg)](https://github.com/FNNDSC/pl-emerald/actions/workflows/ci.yml)

## Description

Deep learning based project made to automatically mask fetal brains.
Expand Down
27 changes: 27 additions & 0 deletions download_example_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

COMMIT='7c8ac54213cecd4fbb15f700b14d73f7086cf11d'
REPO='https://github.com/kevin-keraudren/example-motion-correction'
URL="$REPO/archive/$COMMIT.tar.gz"
DIR_INSIDE_TARBALL="$(basename "$REPO")-$COMMIT"

tarball="$(mktemp --suffix '.tar.gz')"
output_dir="$1"

if [ -z "$output_dir" ]; then
echo "usage: $0 example_data_dir/"
exit 1
fi

if [ -e "$output_dir" ]; then
echo "error: $output_dir exists"
exit 1
fi

set -ex
wget -O "$tarball" "$URL"
tar xvf "$tarball" --directory=/tmp
mv -v "/tmp/$DIR_INSIDE_TARBALL" "$output_dir"
rm -v "$tarball"

find "$output_dir" -name '*.nii.gz' -type f | parallel gzip -d

0 comments on commit a74dbf3

Please sign in to comment.