To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / doSegmentation.sh @ 0:4182672fd6f8
History | View | Annotate | Download (1.45 KB)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
if [ $# -lt 2 ] ; then |
| 4 |
echo "Usage: $0 [-s] LISTFILENAME OUTPUTDIR" |
| 5 |
exit 1 |
| 6 |
fi |
| 7 |
|
| 8 |
retainstructure=0 |
| 9 |
|
| 10 |
while [ $# -gt 2 ] ; do |
| 11 |
case $1 in |
| 12 |
-d) retainstructure=1 ; shift 1 ; echo here;; |
| 13 |
*) shift 1 ;; |
| 14 |
esac |
| 15 |
done |
| 16 |
|
| 17 |
listfile="$1" |
| 18 |
echo listfile "$listfile" |
| 19 |
outputdir="$2" |
| 20 |
|
| 21 |
|
| 22 |
while read infile; do |
| 23 |
if [ "$infile" -a -f "$infile" ]; then |
| 24 |
before="$(date +%s)" |
| 25 |
echo "_____________________________________________________" |
| 26 |
echo " " |
| 27 |
echo Processing file "$infile" |
| 28 |
echo " " |
| 29 |
if [ $retainstructure -eq 0 ]; then |
| 30 |
pathandfile=`basename "$infile"` |
| 31 |
else |
| 32 |
pathandfile="`echo "$infile" | egrep -o '[^/]*/[^/]*/[^/]*$'`" |
| 33 |
echo pathandfile "$pathandfile" |
| 34 |
fi |
| 35 |
outfile="$outputdir"/"$pathandfile".txt |
| 36 |
|
| 37 |
logfile=_logfiles/"$pathandfile".log |
| 38 |
chromafile=_chromadata/"$pathandfile".csv |
| 39 |
|
| 40 |
mkdir -p "`dirname "$outfile"`" |
| 41 |
|
| 42 |
echo "[sonic annotator] ..." |
| 43 |
VAMP_PATH=. ./sonic-annotator-unix -d vamp:matthiasm:nnls_chroma:bothchroma -w csv --csv-stdout "$infile" 2> "$logfile" | cut -d ',' -f 2- > "$chromafile" |
| 44 |
infile="`echo "$infile" | sed "s/'/''/g"`" |
| 45 |
outfile="`echo "$outfile" | sed "s/'/''/g"`" |
| 46 |
chromafile="`echo "$chromafile" | sed "s/'/''/g"`" |
| 47 |
matlab -nodisplay -nojvm -r run_segmentation\(\'"$infile"\',\'"$outfile"\'\,\'"$chromafile"\'\) >> "$logfile" |
| 48 |
after="$(date +%s)" |
| 49 |
elapsed_seconds="$(expr $after - $before)" |
| 50 |
echo " -->" time elapsed: $elapsed_seconds seconds |
| 51 |
echo " " |
| 52 |
else if [ ! "$infile" ]; then echo ...; fi |
| 53 |
fi |
| 54 |
done < "$listfile" |