datacite.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. Accurate non-linear registration of cortical and subcortical labelling from Mindboggle 101 to the symmetric MNI-ICBM2009c atlas followed by manual editing.
  2. ants_nl_registration.sh
  3. #! /bin/bash
  4. if [ $# -eq 3 ];then
  5. src=$1
  6. trg=$2
  7. outp=$3
  8. elif [ $# -eq 5 ];then
  9. src=$1
  10. trg=$2
  11. src_mask=$3
  12. trg_mask=$4
  13. outp=$5
  14. else
  15. echo "Usage $0 <source> <target> [source mask] [target mask] <output_prefix>"
  16. echo "Output will be <output_prefix>0_NL.xfm and <output_prefix>0NL_inverse.xfm with corresponding grid files"
  17. exit 1
  18. fi
  19. if [ ! -z $trg_mask ];then
  20. mask="-x [${src_mask},${trg_mask}] "
  21. fi
  22. antsRegistration -v -d 3 --float 1 \
  23. --output "[${outp}]" \
  24. --use-histogram-matching 0 --winsorize-image-intensities "[0.005,0.995]" \
  25. --transform "SyN[0.7,3,0]" \
  26. --metric "CC[${src},${trg},1,4]" \
  27. --convergence "[50x50x30,1e-6,10]" \
  28. --shrink-factors 4x2x1 --smoothing-sigmas 2x1x0vox \
  29. ${mask} --minc
  30. bestlinreg_s2
  31. #! /usr/bin/env perl
  32. #
  33. # linear fitting using parameters optimised by Claude Lepage,
  34. # using a brain mask for the source and the target. This was
  35. # greatly inspired by best1stepnlreg.pl by Steve Robbins.
  36. #
  37. # Claude Lepage - claude@bic.mni.mcgill.ca
  38. # Andrew Janke - rotor@cmr.uq.edu.au
  39. # Center for Magnetic Resonance
  40. # The University of Queensland
  41. # http://www.cmr.uq.edu.au/~rotor
  42. #
  43. # Copyright Andrew Janke, The University of Queensland.
  44. # Permission to use, copy, modify, and distribute this software and its
  45. # documentation for any purpose and without fee is hereby granted,
  46. # provided that the above copyright notice appear in all copies. The
  47. # author and the University of Queensland make no representations about the
  48. # suitability of this software for any purpose. It is provided "as is"
  49. # without express or implied warranty.
  50. use strict;
  51. use warnings "all";
  52. use Getopt::Tabular;
  53. use File::Basename;
  54. use File::Temp qw/ tempdir /;
  55. my @conf = (
  56. { type => "blur",
  57. trans => [qw/-est_translations/],
  58. blur_fwhm => 16,
  59. steps => [qw/8 8 8/],
  60. tolerance => 0.01,
  61. simplex => 32 },
  62. { type => "blur",
  63. trans => undef,
  64. blur_fwhm => 8,
  65. steps => [qw/4 4 4/],
  66. tolerance => 0.004,
  67. simplex => 16 },
  68. { type => "blur",
  69. trans => undef,
  70. blur_fwhm => 4,
  71. steps => [qw/4 4 4/],
  72. tolerance => 0.004,
  73. simplex => 8 },
  74. { type => "dxyz",
  75. trans => undef,
  76. blur_fwhm => 8,
  77. steps => [qw/4 4 4/],
  78. tolerance => 0.004,
  79. simplex => 4 },
  80. { type => "dxyz",
  81. trans => undef,
  82. blur_fwhm => 4,
  83. steps => [qw/4 4 4/],
  84. tolerance => 0.004,
  85. simplex => 2 }
  86. );
  87. my($Help, $Usage, $me);
  88. my(@opt_table, %opt, $source, $target, $outxfm, $outfile, @args, $tmpdir);
  89. $me = &basename($0);
  90. %opt = (
  91. 'verbose' => 1,
  92. 'clobber' => 0,
  93. 'fake' => 0,
  94. 'init_xfm' => undef,
  95. 'source_mask' => undef,
  96. 'target_mask' => undef,
  97. 'lsqtype' => "-lsq9",
  98. 'work_dir' => undef,
  99. 'sec_source' => undef,
  100. 'sec_target' => undef,
  101. 'cost_function' => '-xcorr',
  102. 'noshear' => 0,
  103. 'noscale' => 0,
  104. 'norot' => 0,
  105. 'noshift' => 0,
  106. 'close' => 0,
  107. );
  108. $Help = <<HELP;
  109. | $me does hierachial linear fitting between two files.
  110. | you will have to edit the script itself to modify the
  111. | fitting levels themselves
  112. |
  113. | Problems or comments should be sent to: claude\@bic.mni.mcgill.ca
  114. HELP
  115. $Usage = "Usage: $me [options] source.mnc target.mnc output.xfm [output.mnc]\n".
  116. " $me -help to list options\n\n";
  117. @opt_table = (
  118. ["-verbose", "boolean", 0, \$opt{verbose},
  119. "be verbose" ],
  120. ["-clobber", "boolean", 0, \$opt{clobber},
  121. "clobber existing check files" ],
  122. ["-fake", "boolean", 0, \$opt{fake},
  123. "do a dry run, (echo cmds only)" ],
  124. ["-init_xfm", "string", 1, \$opt{init_xfm},
  125. "initial transformation (default identity)" ],
  126. ["-source_mask", "string", 1, \$opt{source_mask},
  127. "source mask to use during fitting" ],
  128. ["-target_mask", "string", 1, \$opt{target_mask},
  129. "target mask to use during fitting" ],
  130. ["-lsq9", "const", "-lsq9", \$opt{lsqtype},
  131. "use 9-parameter transformation (default)" ],
  132. ["-lsq12", "const", "-lsq12", \$opt{lsqtype},
  133. "use 12-parameter transformation (default -lsq9)" ],
  134. ["-lsq6", "const", "-lsq6", \$opt{lsqtype},
  135. "use 6-parameter transformation" ],
  136. ["-lsq7", "const", "-lsq7", \$opt{lsqtype},
  137. "use 7-parameter transformation" ],
  138. ["-quaternions","const",'-quaternions', \$opt{lsqtype},
  139. "use quaternion transformation" ],
  140. ["-mi","const",'-mi', \$opt{cost_function},
  141. "Mutual information cost function" ],
  142. ["-xcorr","const",'-xcorr', \$opt{cost_function},
  143. "Cross-correlation cost function" ],
  144. ["-work_dir", "string", 1, \$opt{work_dir},
  145. "Directory to keep blurred files" ],
  146. ["-sec_source", "string", 1, \$opt{sec_source},
  147. "secondaty source" ],
  148. ["-sec_target", "string", 1, \$opt{sec_target},
  149. "secondary target" ],
  150. ["-noshear", "boolean", 1, \$opt{noshear},
  151. "lsq12 w/o shear" ],
  152. ["-noscale", "boolean", 1, \$opt{noscale},
  153. "lsq12 w/o scale" ],
  154. ["-norot", "boolean", 1, \$opt{norot},
  155. "lsq12 w/o rotations" ],
  156. ["-noshift", "boolean", 1, \$opt{noshift},
  157. "lsq12 w/o shifts" ],
  158. ["-close", "boolean", 1, \$opt{close},
  159. "Samples are close" ],
  160. );
  161. delete $ENV{MINC_COMPRESS} if $ENV{MINC_COMPRESS};
  162. # Check arguments
  163. &Getopt::Tabular::SetHelp($Help, $Usage);
  164. &GetOptions (\@opt_table, \@ARGV) || exit 1;
  165. die $Usage if(! ($#ARGV == 2 || $#ARGV == 3));
  166. $source = shift(@ARGV);
  167. $target = shift(@ARGV);
  168. $outxfm = shift(@ARGV);
  169. $outfile = (defined($ARGV[0])) ? shift(@ARGV) : undef;
  170. # check for files
  171. die "$me: Couldn't find input file: $source\n\n" if (!-e $source);
  172. die "$me: Couldn't find input file: $target\n\n" if (!-e $target);
  173. if(-e $outxfm && !$opt{clobber}){
  174. die "$me: $outxfm exists, -clobber to overwrite\n\n";
  175. }
  176. if(defined($outfile) && -e $outfile && !$opt{clobber}){
  177. die "$me: $outfile exists, -clobber to overwrite\n\n";
  178. }
  179. # make tmpdir
  180. $tmpdir = &tempdir( "$me-XXXXXXXX", TMPDIR => 1, CLEANUP => 1 );
  181. $opt{work_dir}=$tmpdir unless $opt{work_dir};
  182. # set up filename base
  183. my($i, $s_base, $t_base, $tmp_xfm, $tmp_source, $tmp_target, $prev_xfm,
  184. $tmp_sec_source, $tmp_sec_target);
  185. $s_base = &basename($source);
  186. $s_base =~ s/\.mnc(.gz)?$//;
  187. $s_base = 's_'.$s_base;
  188. $t_base = &basename($target);
  189. $t_base =~ s/\.mnc(.gz)?$//;
  190. $t_base = 't_'.$t_base;
  191. # Mask the source and target once before blurring. Both masks must exist.
  192. my $source_masked = $source;
  193. my $target_masked = $target;
  194. # initial transformation supplied by the user, applied to both the
  195. # source image and its mask.
  196. #if( defined $opt{init_xfm} ) {
  197. # my $source_resampled = "${tmpdir}/${s_base}_resampled.mnc";
  198. # &do_cmd( 'mincresample',
  199. # '-clobber',
  200. # '-like', $target_masked,
  201. # '-transform', $opt{init_xfm},
  202. # $source_masked, $source_resampled );
  203. # $source_masked = $source_resampled;
  204. # #apply it to the mask, if it's defined
  205. # if(defined($opt{source_mask}))
  206. # {
  207. # my $mask_resampled = "${tmpdir}/${s_base}_mask_resampled.mnc";
  208. # &do_cmd( 'mincresample', '-clobber', '-like', $target_masked,
  209. # '-nearest_neighbour', '-transform', $opt{init_xfm},
  210. # $opt{source_mask}, $mask_resampled );
  211. # $opt{source_mask} = $mask_resampled;
  212. # }
  213. #}
  214. $prev_xfm = undef;
  215. # a fitting we shall go...
  216. for ($i=0; $i<=$#conf; $i++){
  217. # set up intermediate files
  218. $tmp_xfm = "$tmpdir/$s_base\_$i.xfm";
  219. $tmp_source = "$opt{work_dir}/$s_base\_$conf[$i]{blur_fwhm}";
  220. $tmp_target = "$opt{work_dir}/$t_base\_$conf[$i]{blur_fwhm}";
  221. $tmp_source = "$opt{work_dir}/$s_base\_$conf[$i]{blur_fwhm}";
  222. $tmp_target = "$opt{work_dir}/$t_base\_$conf[$i]{blur_fwhm}";
  223. if($opt{close})
  224. {
  225. next if($conf[$i]{blur_fwhm}>8);
  226. $conf[$i]{simplex}=1;
  227. $conf[$i]{steps}=[qw/2 2 2/];
  228. }
  229. print STDOUT "-+-------------------------[$i]-------------------------\n".
  230. " | steps: @{$conf[$i]{steps}}\n".
  231. " | blur_fwhm: $conf[$i]{blur_fwhm}\n".
  232. " | simplex: $conf[$i]{simplex}\n".
  233. " | source: $tmp_source\_$conf[$i]{type}.mnc\n".
  234. " | target: $tmp_target\_$conf[$i]{type}.mnc\n".
  235. " | xfm: $tmp_xfm\n".
  236. "-+-----------------------------------------------------\n".
  237. "\n";
  238. # blur the masked source and target images
  239. my @grad_opt = ();
  240. push( @grad_opt, '-gradient' ) if( $conf[$i]{type} eq "dxyz" );
  241. if($conf[$i]{blur_fwhm}>0) # actually this should be 1
  242. {
  243. if(!-e "$tmp_source\_$conf[$i]{type}.mnc") {
  244. &do_cmd('mincblur', '-clobber', '-no_apodize', '-fwhm', $conf[$i]{blur_fwhm},
  245. @grad_opt, $source_masked, $tmp_source);
  246. }
  247. if(!-e "$tmp_target\_$conf[$i]{type}.mnc") {
  248. &do_cmd('mincblur', '-clobber', '-no_apodize', '-fwhm', $conf[$i]{blur_fwhm},
  249. @grad_opt, $target_masked, $tmp_target);
  250. }
  251. if(defined($opt{sec_source}) && defined($opt{sec_target}) )
  252. {
  253. $tmp_sec_source = "$opt{work_dir}/sec_$s_base\_$conf[$i]{blur_fwhm}";
  254. $tmp_sec_target = "$opt{work_dir}/sec_$t_base\_$conf[$i]{blur_fwhm}";
  255. if(! -e "$tmp_sec_source\_$conf[$i]{type}.mnc")
  256. {
  257. &do_cmd('mincblur', '-clobber', '-no_apodize', '-fwhm',
  258. $conf[$i]{blur_fwhm},
  259. @grad_opt, $opt{sec_source}, $tmp_sec_source);
  260. }
  261. if(! -e "$tmp_sec_target\_$conf[$i]{type}.mnc")
  262. {
  263. &do_cmd('mincblur', '-clobber', '-no_apodize', '-fwhm',
  264. $conf[$i]{blur_fwhm},
  265. @grad_opt, $opt{sec_target}, $tmp_sec_target);
  266. }
  267. $tmp_sec_source="$tmp_sec_source\_$conf[$i]{type}.mnc";
  268. $tmp_sec_target="$tmp_sec_target\_$conf[$i]{type}.mnc";
  269. }
  270. } else { # noop
  271. if(!-e "$tmp_source\_$conf[$i]{type}.mnc") {
  272. do_cmd('ln','-s',$source_masked,"$tmp_source\_$conf[$i]{type}.mnc");
  273. }
  274. if(!-e "$tmp_target\_$conf[$i]{type}.mnc") {
  275. &do_cmd('ln', '-s', $target_masked, "$tmp_target\_$conf[$i]{type}.mnc");
  276. }
  277. if(defined($opt{sec_source}) && defined($opt{sec_target}) )
  278. {
  279. $tmp_sec_source =$opt{sec_source};
  280. $tmp_sec_target =$opt{sec_target};
  281. }
  282. }
  283. # set up registration
  284. @args = ('minctracc', '-clobber', $opt{lsqtype},
  285. '-step', @{$conf[$i]{steps}}, '-simplex', $conf[$i]{simplex},
  286. '-tol', $conf[$i]{tolerance});
  287. # Initial transformation will be computed from the from Principal axis
  288. # transformation (PAT).
  289. push(@args, @{$conf[$i]{trans}}) if( defined $conf[$i]{trans} && !$opt{init_xfm} );
  290. # Current transformation at this step
  291. if( defined $prev_xfm )
  292. {
  293. push(@args, '-transformation', $prev_xfm ) ;
  294. } elsif( defined $opt{init_xfm} ) {
  295. push(@args, '-transformation', $opt{init_xfm} ) ;
  296. #push(@args, '-est_center' ) ;
  297. } elsif($opt{close}) {
  298. push(@args, '-identity') ;
  299. }
  300. # masks (even if the blurred image is masked, it's still preferable
  301. # to use the mask in minctracc)
  302. push(@args, '-source_mask', $opt{source_mask} ) if defined($opt{source_mask});
  303. push(@args, '-model_mask', $opt{target_mask}) if defined($opt{target_mask});
  304. if($tmp_sec_source && $tmp_sec_target )
  305. {
  306. push(@args, $opt{cost_function},
  307. "$tmp_source\_$conf[$i]{type}.mnc",
  308. "$tmp_target\_$conf[$i]{type}.mnc");
  309. push(@args, '-feature_vol',$tmp_sec_source,$tmp_sec_target,'xcorr',1.0);
  310. } else {
  311. push(@args, $opt{cost_function},"$tmp_source\_$conf[$i]{type}.mnc",
  312. "$tmp_target\_$conf[$i]{type}.mnc");
  313. }
  314. push @args,'-w_shear',0,0,0 if $opt{noshear};
  315. push @args,'-w_scales',0,0,0 if $opt{noscale};
  316. push @args,'-w_translations',0,0,0 if $opt{noshift};
  317. push @args,'-w_rotations',0,0,0 if $opt{norot};
  318. # add files and run registration
  319. push(@args, $tmp_xfm);
  320. &do_cmd(@args);
  321. $prev_xfm = $tmp_xfm;
  322. }
  323. # Concatenate transformations if an initial transformation was given.
  324. #if( defined $opt{init_xfm} ) {
  325. # &do_cmd( 'xfmconcat', $prev_xfm, $opt{init_xfm}, $outxfm );
  326. #} else {
  327. do_cmd( 'mv', '-f', $prev_xfm, $outxfm );
  328. #}
  329. # resample if required
  330. if(defined($outfile)){
  331. print STDOUT "-+- creating $outfile using $outxfm\n".
  332. &do_cmd( 'mincresample', '-clobber', '-like', $target,
  333. '-transformation', $outxfm, $source, $outfile );
  334. }
  335. sub do_cmd {
  336. print STDOUT "@_\n" if $opt{verbose};
  337. if(!$opt{fake}){
  338. system(@_) == 0 or die;
  339. }
  340. }
  341. linear_registration.sh
  342. bestlinreg_s2 DKT_Atlas.mnc mni_icbm152_t1_tal_nlin_sym_09c.mnc DKT2icbm.xfm --lsq9
  343. resampling.sh
  344. itk_resample DKT_Atlas.mnc --like mni_icbm152_t1_tal_nlin_sym_09c.mnc --transform DKT2icbmnl.xfm DKT_Atlas_icbm_nl.mnc --label --clobber
  345. CerebrA_LabelDetails.csv
  346. Mindboggle ID,Label Name,CerebrA ID,,Notes,Dice Kappa
  347. ,,RH Labels,LH Labels,,
  348. 2002,Caudal Anterior Cingulate,30,81,,0.79
  349. 2003,Caudal Middle Frontal,42,93,Improved distinction from Precentral ,0.73
  350. 2005,Cuneus,43,94,,0.67
  351. 2006,Entorhinal,36,87,Improved delimitation ,0.78
  352. 2007,Fusiform,24,75,,0.77
  353. 2008,Inferior Parietal,10,61,,0.75
  354. 2009,Inferior temporal,3,54,Removed dorsal part MT,0.72
  355. 2010,Isthmus Cingulate,33,84,,0.79
  356. 2011,Lateral Occipital,34,85,,0.76
  357. 2012,Lateral Orbitofrontal,7,58,,0.8
  358. 2013,Lingual,12,63,,0.75
  359. 2014,Medial Orbitofrontal,15,66,,0.72
  360. 2015,Middle Temporal,28,79,Added dorsal part,0.72
  361. 2016,Parahippocampal,18,69,,0.86
  362. 2017,Paracentral,16,67,,0.77
  363. 2018,Pars Opercularis,32,83,,0.77
  364. 2019,Pars Orbitalis,44,95,,0.8
  365. 2020,Pars Triangularis,22,73,,0.76
  366. 2021,Pericalcarine,6,57,,0.6
  367. 2022,Postcentral,13,64,,0.82
  368. 2023,Posterior Cingulate,47,98,,0.8
  369. 2024,Precentral,35,86,,0.84
  370. 2025,Precuneus,31,82,,0.8
  371. 2026,Rostral Anterior Cingulate,8,59,,0.72
  372. 2027,Rostral Middle Frontal,1,52,Improved delimitation from CMF,0.74
  373. 2028,Superior Frontal,38,89,,0.82
  374. 2029,Superior Parietal,9,60,Improved delimitation from Precuneus and IP,0.72
  375. 2030,Superior Temporal,45,96,Added dorsal part limiting with IP and Supramarginal,0.87
  376. 2031,Supramarginal,51,102,,0.81
  377. 2034,Transverse Temporal,14,65,,0.85
  378. 2035,Insula,23,74,,0.88
  379. 16,Brainstem,11,62,"Completed filling, removed labelled voxels out of actual brainstem and removed CWM labels in brainstem area. ",0.65
  380. 14,Third Ventricle,29,80,,0.68
  381. 15,Fourth Ventricle,37,88,Missing label. Manually delimited using CSF threshold. ,0.39
  382. 85,Optic Chiasm,17,68,Almost inexistent label and out of place in original labelling Completed OC and tracts (originally labelled as Ventral Diencephalon),0
  383. 43,Lateral Ventricle,41,92,Improved continuity of labelled voxels,0.89
  384. 44,Inferior Lateral Ventricle,5,56,,0.12
  385. 45,Cerebellum Gray Matter,46,97,"Completed filling using threshold for CGM, removed cerebellum labels out of area (within brainstem and vermis area)",0.83
  386. 46,Cerebellum White Matter,39,90,"Improved according threshold for CWM, removed labels in brainstem and vermis. ",0.73
  387. 49,Thalamus,40,91,,0.97
  388. 50,Caudate,49,100,Completed filling using threshold ,0.84
  389. 51,Putamen,21,72,Corrected uniformity using threshold,0.87
  390. 52,Pallidum,27,78,Improved delimitation between putamen and pallidum,0.83
  391. 53,Hippocampus,48,99,,0.69
  392. 54,Amygdala,19,70,,0.64
  393. 58,Accumbens Area,4,55,,0.76
  394. 60,Ventral Diencephalon,26,77,,0.93
  395. 92,Basal Forebrain,25,76,,0.82
  396. 630,Vermal lobules I-V,50,101,Improved delimitation with other vermal lobules and cerebellar hemispheres,0.66
  397. 631,Vermal lobules VI-VII,2,53,Improved delimitation with other vermal lobules and cerebellar hemispheres,0.38
  398. 632,Vermal lobules VIII-X,20,71,Improved delimitation with other vermal lobules and cerebellar hemispheres,0.44