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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/bin/sh
#
#
# This file is part of MIA - a toolbox for medical image analysis
# Copyright (c) Leipzig, Madrid 1999-2015 Gert Wollny
#
# MIA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
# call this program like:
#
# brainmash.sh <input-image> <output-image>
#
#supported file formats (all only gray scale)
# Analyze
# inria
# vff
# vista
# vtk
print_usage() {
echo Usage:
echo " brainmash.sh <input-image> <output-image>"
echo
exit 1
}
if [ "x$1" = "x" ]; then
echo Error: input file missing
print_usage
fi
if [ "x$2" = "x" ]; then
echo Error: output file missing
print_usage
fi
infile=$1
outfile=$2
#white matter probability \in [0,1]
wmprob=0.7
#erode shape for initial wm mask,
# possible values: 6n 18n 26n, [sphere:r=N] (N > 0)
erode_shape=6n
#growmask shape, possible values see erode_shape
shape=18n
#intensity threshhold for mask growing
thresh=30
#final closing shape, possible values see erode_shape
close_shape=[sphere:r=3]
#final opening shape, possible values see erode_shape
open_shape=[sphere:r=3]
# segment the input image into 3 classes
mia-fuzzysegment3d -i $infile -o b0.v -c cls.v -n 3 -V message && \
mia-3dimageselect -i cls.v -o wmprob.v -n 2 && \
mia-3dimagefilter -i wmprob.v -o $outfile \
-V message \
binarize:min=$wmprob \
erode:shape=${erode_shape} \
label \
selectbig \
growmask:ref=b0.v,min=${thresh},shape=${shape} \
close:shape=${close_shape}\
open:shape=${open_shape}\
mask:input=b0.v || \
echo "Error processing '$infile'"
#rm -f b0.v cls.v wmprob.v
|