-
Notifications
You must be signed in to change notification settings - Fork 0
/
image2NRRD.sh
executable file
·39 lines (39 loc) · 1.05 KB
/
image2NRRD.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
echo 'before running specify the fiji executable and macro (located in this dir):'
echo 'export FIJI=path/fiji'
echo 'export MACRO=ThisDir/image2NRRD.ijm'
echo 'export EXT=h5j'
echo 'export TIMEOUT="gtimeout 15m "'
echo 'run in the directory above the volume.nrrd files'
echo '-f forces recreation'
echo '-h runs in headless mode using xvfb-run'
for file in $(pwd)/*/*.${EXT}
do
echo $file
if [ -f $file ]
output=${file/.${EXT}/*.nrrd}
output=$(echo $output|sed 's|\(.*\)/|\1/C1-|')
then
if [ -e ${output} ] && [ "$1" != "-f" ]
then
echo recent nrrd file already exists! Skipping..
else
echo processing $(pwd)${file/.\//\/}...
# if forcing overwite then delete the old copy
if [ "$1" == "-f" ]
then
rm ${output/C1-/C*-}
fi
# convert n5j into nrrd
if [[ $1 == *"h"* ]]
then
$TIMEOUT xvfb-run -w 10 $FIJI -macro $MACRO $file
pkill Xvfb
else
$TIMEOUT $FIJI -macro $MACRO $file
fi
sleep 5s
fi
else
echo Broken file ${file}! Skipping...
fi
done