CoBrALab / optimized_antsMultivariateTemplateConstruction

A re-implementation of antsMultivariateTemplateConstruction2.sh using optimized image pyramid scale-space and qbatch support
Other
22 stars 8 forks source link

(optional) initial COM alignment before initial template construction #4

Closed gdevenyi closed 3 years ago

gdevenyi commented 3 years ago

Without an initial average, the first average can be a mess if subjects don't actually overlap in space, probably implement something like this (using the median?)

quick-com-align.sh

#!/bin/bash

set -euo pipefail

tmpdir=$(mktemp -d)

moving=$1
fixed=$2
output=$3

antsAI -d 3 --convergence 0 --verbose 1 -m Mattes[${fixed},${moving},32,None] -o ${tmpdir}/transform.mat -t AlignCentersOfMass

antsApplyTransforms -d 3 -r ${fixed} -i ${moving} -t ${tmpdir}/transform.mat -o ${output} --verbose

rm -rf ${tmpdir}

make-dumb-average.sh

#!/bin/bash

tmpdir=$(mktemp -d)

output=$1
shift
inputs="$@"

AverageImages 3 ${output} 1 ${inputs}

for file in "$@"; do
  echo ./quick-com-align.sh ${file} ${output} ${tmpdir}/$(basename ${file}) | parallel
done

AverageImages 3 ${output} 1 ${tmpdir}/*

for file in "$@"; do
  echo ./quick-com-align.sh ${file} ${output} ${tmpdir}/$(basename ${file}) | parallel
done

AverageImages 3 ${output} 1 ${tmpdir}/*

rm -rf ${tmpdir}
gdevenyi commented 3 years ago

Fixed by #20