-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRRD2PNGthumbnail.sh
executable file
·51 lines (51 loc) · 1.62 KB
/
NRRD2PNGthumbnail.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
echo 'before running specify the fiji executable and macro (located in this dir):'
echo 'export FIJI=path/fiji'
echo 'export MACRO=ThisDir/createThumbnail.ijm'
echo 'export TEMPLATE=path/VFB/t/001/background.nrrd'
echo 'run in the directory above the volume.nrrd files'
echo '-f forces thumbnail recreation'
echo '-h runs in headless mode using xvfb-run'
OPTIONS=$1
for file in $(pwd)/*/volume.nrrd
do
echo "Checking $file"
if [ -f $file ]
then
if [ -f "${file/volume.nrrd/thumbnail.png}" ] && [[ "$OPTIONS" != *"f"* ]] && [ "$MACRO" -ot "${file/volume.nrrd/thumbnail.png}" ]
then
echo PNG file already exists! Skipping..
else
echo processing ${file}...
# if forcing overwite then delete the old copy
if [[ "$OPTIONS" = *"f"* ]]
then
rm -v "${file/volume.nrrd/thumbnail.png}"
fi
export MatchTP=$file
for background in ${TEMPLATE/001/00*}
do
if [ "$(head $file | grep sizes)" == "$(head $background | grep sizes)" ]
then
export MatchTP=$background
echo "$file = $MatchTP"
break
fi
done
if [ "$(head $file | grep sizes)" == "$(head $MatchTP | grep sizes)" ]
then
# generate thumbnail using Fiji/ImageJ
echo "Generating thumbnail from $MatchTP,$file"
if [[ "$OPTIONS" = *"h"* ]]
then
$FIJI --headless --console -macro $MACRO "$MatchTP,$file"
else
$FIJI -macro $MACRO "$MatchTP,$file"
fi
else
echo "Template not found for ${file}! Skipping.."
fi
fi
else
echo "Broken link for ${file}! Skipping.."
fi
done