Skip to content

Commit

Permalink
added files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Close committed Jun 30, 2012
0 parents commit 21f75c3
Show file tree
Hide file tree
Showing 624 changed files with 169,940 additions and 0 deletions.
1,287 changes: 1,287 additions & 0 deletions Doxyfile

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions algorithm_outline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
MR::Math::Matrix(points, point_conv, strand.matrix())
MR::Math::Matrix(tang, tang_conv, strand.matrix())

(VoxelSize, ResponseFunction, parameters to Image class)

BTS::Image<Interpolator>::Neighbourhood::reserve() --set initially to some reasonable number
BTS::Image<Interpolator>::Neighbourhood::add_section(points.row(x), tang.row(x), *strand, point_conv.row(x), tang_conv.row(x)) (maybe include pointers to intermediately generated structures as well)

BTS::Image<Interpolator>::Neighbourhood::calculate_intensities()
internally store points in a Nx3 matrix and tangents in a Nx3 matrices
have the list of voxel centres as Lx3 matrix and dw orientations as a 3xQ matrix
Then should have a LxNx3 distance array, Nx1 length vector, and a NxQ angle matrix.

response_functions as a NxQ matrix (will need to to column-wise multiplication and collecting on angle matrix) to produce another NxQ response matrix.

columnwise multiplication of length_vector and angle matrix produces another NxQ matrix (probably could be incorporated into response function step I think)

interpolation function operates on LxNx3 to produce LxN interpolation intensities

matrix multiplication produces LxQ intensity matrix.

BTS::Image<Interpolator>::collate_neighbourhoods(Neighbourhood)

takes LxQ matrices from neighbourhoods and collates them into L'xQ image data matrix.

BTS::Image<Interpolator>::Neighbourood::calculate_gradients_hessians
Then take collated intensities and put them back into the calculate the gradient + Hessian
reusing the precalculated interpolation and response matrices.


BTS::Image<Interpolator>::collate_gradients_hessians(Neighbourhood)
this is done per neighbourhood calculation to prevent large memory allocation problems
25 changes: 25 additions & 0 deletions bash/add_base_intensity
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

DIR=$1

if [ "${#DIR}" = 0 ]; then
DIR='.'
fi

for f in `ls $DIR/*.tck`; do

if [ -h $f ]; then
file=`readlink $f`
else
file=$f
fi

file_strip=${file##*/}

select_fibres $file /tmp/$file_strip.txt

sed -i 's/base_intensity: 0/base_intensity: 1/g' /tmp/$file_strip.txt

select_fibres /tmp/$file_strip.txt $file

done
25 changes: 25 additions & 0 deletions bash/add_density
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

DIR=$1

if [ "${#DIR}" = 0 ]; then
DIR='.'
fi

for f in `ls $DIR/*.tckx`; do

if [ -h $f ]; then
file=`readlink $f`
else
file=$f
fi

if [ `grep -c "density" $file` = 0 ]; then

sed -i 's/^/1\t/g' $file

sed -i 's/1\t%%% Extended Properties File %%% - keys: /%%% Extended Properties File %%% - keys: density\t/g' $file

fi

done
30 changes: 30 additions & 0 deletions bash/create_fibres
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

#if [ $# -le 1 ]; then
# echo "At least 1 argument need to be supplied to $0 ($# supplied)."
# exit -1
#fi

if [ ${1##*.} == 'txt' ]; then

new_fibres $1 ${@:2}

vi $1

else

TEMP_TXT_FILE=/tmp/${1##*/}.txt

#Export fibres file to a temporary text equivalent.
new_fibres $TEMP_TXT_FILE ${@:2}

#Edit with vi
vi $TEMP_TXT_FILE

#Import fibres back to output location
select_fibres $TEMP_TXT_FILE $1

#Cleanup temporary file
rm $TEMP_TXT_FILE

fi
28 changes: 28 additions & 0 deletions bash/edit_fibres
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ $# == 0 ]; then
echo "No arguments supplied to $0 (at least 1 required)."
exit -1
elif [ $# == 1 ]; then
OUTPUT_LOCATION=$1
elif [ $# == 2 ]; then
OUTPUT_LOCATION=$2
else
echo "Too many arguments ($#) supplied to $0 (max 2, input and output locations)."
exit -1
fi


TEMP_TXT_FILE=/tmp/${1##*/}.txt

#Export fibres file to a temporary text equivalent.
select_fibres $1 $TEMP_TXT_FILE

#Edit with vi
vi $TEMP_TXT_FILE

#Import fibres back to output location
select_fibres $TEMP_TXT_FILE $OUTPUT_LOCATION

#Cleanup temporary file
rm $TEMP_TXT_FILE
1 change: 1 addition & 0 deletions bash/metropolis
43 changes: 43 additions & 0 deletions bash/process_collections
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

export neigh_count=0

neigh_size=3
vox_size=0.15
extent=3
neigh_bounds=0.61
cube_size=1.05

input_dir=/data/home/tclose/Data/Fifty_phantoms/
output_dir=/data/home/tclose/Data/Tractography/chunked

for collection_path in `ls $input_dir`; do

extension=${collection_path##*.}

if [ $extension = "tck" ]; then
coll_name=${collection_path##*/}
coll_name=${coll_name%.*}

echo "--$coll_name--"

# rm -r $output_dir/${coll_name}/vox_${vox_size}
# mkdir $output_dir/${coll_name}/vox_${vox_size}

# chunk_strands $input_dir/$collection_path $output_dir/${coll_name}/vox_${vox_size}/cube_${cube_size}.tck -extent $extent -voxel_size $vox_size -map_to_origin -save_separate -half_offset -neigh_bounds $neigh_bounds

# rm -r $output_dir/${coll_name}/vox_${vox_size}/ball_combined
# mkdir $output_dir/${coll_name}/vox_${vox_size}/ball_combined

process_neighbourhoods $output_dir/${coll_name}/vox_${vox_size}/cube_${cube_size} $output_dir/${coll_name}/vox_${vox_size}

# ls $output_dir/${coll_name}/vox_${vox_size}/prepared_strands $output_dir/prepared_strands/${coll_name}.frr

#combine_strands $output_dir/${coll_name}/vox_${vox_size}/ball_combined $output_dir/ball_combined/${coll_name}.frr

fi

done


#combine_strands $output_dir/ball_combined/ $output_dir/ball_combined.frr
79 changes: 79 additions & 0 deletions bash/process_neighbourhoods
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

new_sphere_r=0.34
length_reject_threshold=0.005
inclusion_radius=0.13
perturb=0.0075
degree=3
ref_image_degree=20
neigh_size=3
vox_size=0.15

new_sphere_d=0.78
inclusion_diameter=0.26


neigh_pattern=${1##*/}
base_path=${1%/$neigh_pattern}
output_path=$2

for neigh_path in `ls $1*`; do

neigh_file=${neigh_path##*/}

neigh=${neigh_file:$(( ${#neigh_pattern} + 1 )):$(( ${#neigh_file} - 5 - ${#neigh_pattern} ))}
echo $neigh



# rm -r $base_path/$neigh

# mkdir $base_path/$neigh
# mkdir $base_path/$neigh/images
# mkdir $base_path/$neigh/metropolis_hastings
# mkdir $base_path/$neigh/strands


# mkdir $base_path/$neigh/metropolis_hastings/A


# cp $base_path/$neigh_file $base_path/$neigh/strands/cube.tck


# trim_tcks $base_path/$neigh/strands/cube.tck $base_path/$neigh/strands/ball.tck -new_sphere_r ${new_sphere_r} -length_reject_threshold ${length_reject_threshold}

# peel_tcks $base_path/$neigh/strands/ball.tck $base_path/$neigh/strands/peeled.tck -inclusion_radius $inclusion_radius

# tck2fourier $base_path/$neigh/strands/peeled.tck $base_path/$neigh/strands/peeled.frr -degree ${degree}

# perturb_fouriers $base_path/$neigh/strands/peeled.frr $base_path/$neigh/metropolis_hastings/A/initial.frr -perturb $perturb

# rm $base_path/$neigh/images/tophat.mif

# tck2fourier $base_path/$neigh/strands/$neigh_pattern.tck $base_path/$neigh/strands/cube_for_ref.frr -degree $ref_image_degree

# expected_image $base_path/$neigh/strands/cube_for_ref.frr /data/home/tclose/Data/Gradient_directions/encoding_60.b $base_path/$neigh/images/tophat.mif -vox_size ${vox_size} -num_voxels 3 -points 100

# tck2fourier $base_path/$neigh/strands/sphere_0.78.tck $base_path/$neigh/strands/ball.frr -degree 3

# cp $base_path/$neigh/strands/ball.frr $output_path/ball_combined/$neigh.frr

#echo $neigh_count

#mv $base_path/$neigh/strands/cube_1.05.tck $base_path/$neigh/strands/cube.tck

#mv $base_path/$neigh/strands/sphere_0.78.tck $base_path/$neigh/strands/ball.tck

#rm $base_path/$neigh/strands/cube_1.05-frr_20.frr

#rm $base_path/$neigh/strands/sphere_0.78*

#tcks2fouriers $base_path/$neigh/strands/ball.tck $base_path/$neigh/strands/ball.frr -degree 3

ln -s $base_path/$neigh/strands /data/home/tclose/Data/Tractography/chunked/vox_0.15/strands/$neigh_count

#ls $base_path/$neigh/strands

#neigh_count=$(( $neigh_count + 1 ))

done
24 changes: 24 additions & 0 deletions bash/rename_frr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

directory_name=$1

for file in `ls $directory_name/*.frr`; do

svn move $file ${file/%.frr/.str};

done

for file in `ls $directory_name/*.frrx`; do

svn move $file ${file/%.frrx/.strx};

done

for file in `ls $directory_name/*.frrxx`; do

svn move $file ${file/%.frrxx/.strxx};

done


svn commit -m "renaming '.frr' to '.str' in directory $directory_name"
1 change: 1 addition & 0 deletions bash/test_bed
16 changes: 16 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

#TARGET='src/bts/fibre/base.o'
#TARGET='bin/stress_tester'

if [ ${#TARGET} -gt 0 ]; then

echo
echo "WARNING!! Only building for target $TARGET"
echo


fi

/home/tclose/Code/MRtrix/build $TARGET $@

26 changes: 26 additions & 0 deletions build_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

#CMD_TARGET='dummy'
#OBJ_TARGET='fibre/tractlet/set/walker'

if [ ${#CMD_TARGET} -gt 0 ]; then

echo
echo "WARNING!! Only building for target $CMD_TARGET"
echo

TARGET=bin/${CMD_TARGET}__debug

elif [ ${#OBJ_TARGET} -gt 0 ]; then

echo
echo "WARNING!! Only building for target $OBJ_TARGET"
echo

TARGET=src/bts/${OBJ_TARGET}__debug.o

fi

echo $TARGET

/home/tclose/Code/MRtrix/build debug $TARGET $@
Loading

0 comments on commit 21f75c3

Please sign in to comment.