Skip to content

Commit

Permalink
Merge pull request #13 from magnostherobot/trh/utility-scripts
Browse files Browse the repository at this point in the history
Refresh `Makefile`s and batch-utility scripts
  • Loading branch information
magnostherobot authored Aug 1, 2018
2 parents 4222127 + 608487d commit 5164930
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export CFLAGS = -O1

.PHONY: all default clean test
.PHONY: all default clean test bin

default: all

Expand All @@ -11,7 +11,12 @@ all:
clean:
$(MAKE) clean -C src/regions
$(MAKE) clean -C src/czinspect
$(RM) ./bin/get_region ./bin/czinspect

test:
$(MAKE) test -C src/regions
$(MAKE) test -C src/czinspect

bin: all
ln -s ./src/regions/get_region ./bin/get_region
ln -s ./src/czinspect/czinspect ./bin/czinspect
41 changes: 25 additions & 16 deletions bin/batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

set -e

DECZI="deczi.sh"
CZINSPECT="czinspect"

usage () {
cat<<EOF
Usage: $0 [options] input_folder
Usage: batch.sh [operation] <in_folder>
Options:
-d <dir> Directory to extract image tiles to (implies extraction should be performed)
-f <level> Specify subsampling level to filter for
-p Convert extracted images to PNG after converting from JXR to TIFF
-h Print this help message
This a wrapper script around czinspect, and will pass most options directly to
czinspect.
czinspect's help text:
---
$($CZINSPECT $opts -h $*)
---
EOF
}

Expand All @@ -21,21 +23,24 @@ error () {
exit 1
}

while getopts ":d:f:ph" opt; do
outdir=""
opts=""

while getopts "Ehd:aes:" opt; do
case $opt in
d)
outdir="$OPTARG"
;;
f)
decziopts="$decziopts -$opt $OPTARG"
;;
p)
decziopts="$decziopts -$opt"
;;
h)
usage
exit 0
;;
E|a|e)
opts="$opts -$opt"
;;
s)
opts="$opts -$opt $OPTARG"
;;
esac
done

Expand All @@ -45,10 +50,14 @@ if (( $# == 0 )); then
error "Missing input directory"
fi

if [[ -z "$outdir" ]]; then
error "Missing output directory"
fi

INDIR="$1"
indirsafe="$(echo $INDIR | sed 's/[[\.*^$,]/\\&/g')"

find $INDIR -name '*.czi' \
find $INDIR -maxdepth 1 -name '*.czi' \
| xargs -I'{}' sh -c "out=\"\$(echo '{}' \
| sed 's,$indirsafe/*\(.*\).czi\$,$outdir/\1,g')\" ; \
mkdir -p \"\$out\" ; '$DECZI' -d\"\$out\" '{}'"
mkdir -p \"\$out\" ; '$CZINSPECT' $opts -d\"\$out\" '{}'"
File renamed without changes.

0 comments on commit 5164930

Please sign in to comment.