Skip to content

Commit

Permalink
Moved files from internal repository
Browse files Browse the repository at this point in the history
  • Loading branch information
vfonov committed Aug 4, 2017
1 parent 415a4d2 commit fc0f9ce
Show file tree
Hide file tree
Showing 230 changed files with 32,241 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/add_configuration/cerebellum_segment_options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"local_linear_register": true,
"non_linear_pairwise": false,
"simple_fusion": false,
"non_linear_register_level": 2,
"resample_order": 2,
"resample_baa": true,
"library_preselect":10,
"fuse_options": {"patch":1,"search":1,"threshold":0.0,"gco_energy":null}
}
3 changes: 3 additions & 0 deletions examples/add_configuration/cv_cerebellum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"library":"manual_library_cerebellum.lst"
}
46 changes: 46 additions & 0 deletions examples/add_configuration/manual_library_cerebellum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"reference_model": "../../models/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c.mnc",
"reference_mask": "../../models/icbm152_model_09c/mni_icbm152_t1_tal_nlin_sym_09c_mask.mnc",
"library":"manual_library_cerebellum.lst",
"build_remap": [ [101,1],
[103,2],
[105,3],
[107,4],
[108,5],
[109,6],
[113,7],
[115,8],
[116,9],
[117,10],
[119,11],
[121,12],
[123,13],
[125,14],
[131,15],
[133,16],
[135,17],
[137,18],
[138,19],
[139,20],
[143,21],
[145,22],
[146,23],
[147,24],
[149,25],
[153,26],
[155,27],
[171,28],
[200,29],
[201,30],
[300,31],
[301,32],
[400,33],
[500,34] ] ,
"classes": 35,
"linear_register": false,
"local_linear_register": true,
"non_linear_register": true,
"non_linear_register_level": 2,
"resample_baa": true,
"resample_order": 2
}
8 changes: 8 additions & 0 deletions examples/real_tests/test_grading/cv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"validation_library":"snipe_library.lst",
"iterations":-1,
"cv":1,
"fuse_variant":"fuse",
"cv_variant":"cv",
"regularize_variant":"reg_1"
}
70 changes: 70 additions & 0 deletions examples/real_tests/test_grading/cv_results.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
library(ggplot2)
library(jsonlite)
library(grid)
library(plyr)
theme_set(theme_bw(base_size = 14, base_family = "Arial"))

cv_slow<-fromJSON("test_cv/cv_stats.json")
cv_fast<-fromJSON("test_cv_fast/cv_stats.json")
cv_lin<-fromJSON("test_cv_lin/cv_stats.json")
cv_v_slow<-fromJSON("test_cv_slow/cv_stats.json")
cv_v_slow_1<-fromJSON("test_cv_slow_1/cv_stats.json")

cv_kappa<-data.frame(
cv_slow=cv_slow$gkappa,
cv_fast=cv_fast$gkappa,
cv_lin=cv_lin$gkappa,
cv_v_slow=cv_v_slow$gkappa,
cv_v_slow_1=cv_v_slow_1$gkappa
)

cvv<-stack(cv_kappa)

names(cvv)=c('GenKappa','Method')

png('cv_kappa.png',width=800,height=400,type='cairo')

ggplot(data=cvv,aes(x=Method,y=GenKappa))+
geom_boxplot(notch=T)+
theme_bw()+
theme(
axis.text = element_text(face = 'bold', vjust = 0.2, size = 18),
axis.title = element_text(face = 'bold', vjust = 0.2, size = 20),
plot.margin = unit(c(0.2,2.8,0.2,0.2), "cm")
)


slen=length(names(cv_slow$result))
lcv <- vector(mode = "list", length = slen)

for(l in seq(slen)) {
i=names(cv_slow$result)[l]
cv_grading<-data.frame(
grad_slow=cv_slow$result[,i]$grad,
grad_fast=cv_fast$result[,i]$grad,
grad_lin=cv_lin$result[,i]$grad,
grad_v_slow=cv_v_slow$result[,i]$grad,
grad_v_slow_1=cv_v_slow_1$result[,i]$grad
)
lcv[[l]]<-stack(cv_grading)
names(lcv[[l]])=c('Grading','Method')
lcv[[l]]$group=rep(cv_slow$group,length(names(cv_grading)))
lcv[[l]]$struct=rep(i,length(lcv[[l]]$group))
}

cvv<-rbind.fill(lcv)
cvv$struct<-as.factor(as.numeric(cvv$struct))
cvv$group<-as.factor(cvv$group)

png('cv_grading.png',width=800,height=800,type='cairo')

ggplot(data=cvv,aes(x=group,y=Grading,colour=Method))+
geom_boxplot(notch=T)+
theme_bw()+
facet_grid(struct~Method)+
geom_abline(intercept=0,slope=0,colour='red',lty=2)+
theme(
axis.text = element_text(face = 'bold', vjust = 0.2, size = 18),
axis.title = element_text(face = 'bold', vjust = 0.2, size = 20),
plot.margin = unit(c(0.2,2.8,0.2,0.2), "cm")
)
35 changes: 35 additions & 0 deletions examples/real_tests/test_grading/grade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"initial_local_register": false,
"non_linear_pairwise": false,
"non_linear_register": true,
"non_linear_register_ants": true,

"non_linear_register_level": 2,
"non_linear_register_start": 8,

"non_linear_register_options": {
"conf": {"8":100,"4":40,"2":40,"1": 20 },
"blur": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"shrink": {"8":8 ,"4":4 ,"2":2, "1": 1 },

"transformation": "SyN[ .25, 1.0 , 1.0 ]",
"use_histogram_matching": true,
"cost_function":"CC",
"cost_function_par":"1,3,Regular,1.0"
},

"simple_fusion": false,
"resample_order": 1,
"resample_baa": true,
"library_preselect": -1,
"segment_symmetric": false,

"fuse_options":
{
"patch": 1,
"search": 1,
"threshold": 0.0,
"top": 4
}

}
50 changes: 50 additions & 0 deletions examples/real_tests/test_grading/library_description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"reference_model": "snipe_library/NC/T1/ADNI.stx_011_S_0002_m00_bbox_snipe.mnc",
"reference_mask": "snipe_library/whole.mnc",

"reference_local_model" : null,
"reference_local_mask" : null,
"library":"snipe_library.lst",

"build_remap": [ [2,1],
[4,2],
[19,3],
[21,4]],

"build_flip_remap": null,
"parts": 0,
"classes": 5,
"groups": 2,
"build_symmetric": false,
"build_symmetric_flip": false,
"symmetric_lut": null,
"denoise": false,
"denoise_beta": null,

"initial_register": false,
"initial_local_register": false,

"non_linear_register": true,
"non_linear_register_type": "ants",

"non_linear_register_level": 2,
"non_linear_register_start": 8,

"non_linear_register_options": {
"conf": {"8":100,"4":40,"2":40,"1": 20 },
"blur": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"shrink": {"8":8 ,"4":4 ,"2":2, "1": 1 },

"transformation": "SyN[ .25, 1.0 , 1.0 ]",
"use_histogram_matching": true,
"cost_function":"CC",
"cost_function_par":"1,3,Regular,1.0"
},

"resample_order": 1,
"resample_baa": true,
"extend_boundary": 4,
"op_mask": "E[2] D[4]",

"create_patch_norm_lib": false
}
131 changes: 131 additions & 0 deletions examples/real_tests/test_grading/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#! /bin/sh
set -e

PREFIX=$(pwd)/../../python

export PYTHONPATH=$PREFIX:$PYTHONPATH


cat - > library_description.json <<END
{
"reference_model": "snipe_library/NC/T1/ADNI.stx_011_S_0002_m00_bbox_snipe.mnc",
"reference_mask": "snipe_library/whole.mnc",
"reference_local_model" : null,
"reference_local_mask" : null,
"library":"snipe_library.lst",
"build_remap": [ [2,1],
[4,2],
[19,3],
[21,4]],
"build_flip_remap": null,
"parts": 0,
"classes": 5,
"groups": 2,
"build_symmetric": false,
"build_symmetric_flip": false,
"symmetric_lut": null,
"denoise": false,
"denoise_beta": null,
"initial_register": false,
"initial_local_register": false,
"non_linear_register": true,
"non_linear_register_type": "ants",
"non_linear_register_level": 2,
"non_linear_register_start": 8,
"non_linear_register_options": {
"conf": {"8":100,"4":40,"2":40,"1": 20 },
"blur": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"shrink": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"transformation": "SyN[ .25, 1.0 , 1.0 ]",
"use_histogram_matching": true,
"cost_function":"CC",
"cost_function_par":"1,3,Regular,1.0"
},
"resample_order": 1,
"resample_baa": true,
"extend_boundary": 4,
"op_mask": "E[2] D[4]",
"create_patch_norm_lib": false
}
END


if [ ! -e test_lib/library.json ];then
# create the library
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1

python -m scoop -n 4 $PREFIX/iplScoopFusionGrading.py \
--create library_description.json --output test_lib --debug
fi
# run cross-validation

cat - > cv.json <<END
{
"validation_library":"snipe_library.lst",
"iterations":-1,
"cv":1,
"fuse_variant":"fuse",
"cv_variant":"cv",
"regularize_variant":"reg_1"
}
END


cat - > grade.json <<END
{
"initial_local_register": false,
"non_linear_pairwise": false,
"non_linear_register": true,
"non_linear_register_ants": true,
"non_linear_register_level": 2,
"non_linear_register_start": 8,
"non_linear_register_options": {
"conf": {"8":100,"4":40,"2":40,"1": 20 },
"blur": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"shrink": {"8":8 ,"4":4 ,"2":2, "1": 1 },
"transformation": "SyN[ .25, 1.0 , 1.0 ]",
"use_histogram_matching": true,
"cost_function":"CC",
"cost_function_par":"1,3,Regular,1.0"
},
"simple_fusion": false,
"resample_order": 1,
"resample_baa": true,
"library_preselect": -1,
"segment_symmetric": false,
"fuse_options":
{
"patch": 1,
"search": 1,
"threshold": 0.0,
"top": 4
}
}
END

mkdir -p test_cv

export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
python -m scoop -n 4 -vvv \
$PREFIX/iplScoopFusionGrading.py \
--output test_cv \
--debug \
--grade test_lib \
--cv cv.json \
--options grade.json
Loading

0 comments on commit fc0f9ce

Please sign in to comment.