This shows you the differences between two versions of the page.
neuroimagen:centiloid [2019/04/16 09:18] osotolongo [Usando el cluster] |
neuroimagen:centiloid [2020/08/04 10:58] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SUVR a Centiloid ===== | ||
- | [[https:// | ||
- | |||
- | ===== Modelo lineal ===== | ||
- | |||
- | Segun [[https:// | ||
- | |||
- | $ CL = 153.4 \times SUVR_{FBB} - 154.9 $ | ||
- | |||
- | Esto es sencillo de implementar pero antes hay que calibrar el metodo de obtencion de //SUVR// de la pipeline con las imagenes procedentes de [[http:// | ||
- | |||
- | ==== Procesando GAAIN ===== | ||
- | Basicamente descargamos las imagenes y los valores de centiloid calculados en GAAIN, | ||
- | |||
- | https:// | ||
- | |||
- | https:// | ||
- | |||
- | https:// | ||
- | |||
- | Y hemos de compara los valores de centiloid obtenidos por nuestra pipeline con los valores obtenidos en GAAIN. | ||
- | |||
- | Voy a hacer un proyecto nuevo para esto y voy a copiar alli todos los archivos. Las imagenes vienen DICOM, asi que hay que convertirlas, | ||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ tree MRDCM/ | ||
- | MRDCM/ | ||
- | ├── 1008_MR | ||
- | │ ├── 100.dcm | ||
- | │ ├── 101.dcm | ||
- | │ ├── 102.dcm | ||
- | │ ├── 103.dcm | ||
- | │ ├── 104.dcm | ||
- | │ ├── 105.dcm | ||
- | │ ├── 106.dcm | ||
- | │ ├── 107.dcm | ||
- | │ ├── 108.dcm | ||
- | │ ├── 109.dcm | ||
- | │ ├── 10.dcm | ||
- | ........ | ||
- | |||
- | [osotolongo@detritus centiloid]$ tree FBBDCM/ | ||
- | FBBDCM/ | ||
- | ├── 1008_PET_FBB | ||
- | │ ├── 10.dcm | ||
- | │ ├── 11.dcm | ||
- | │ ├── 12.dcm | ||
- | │ ├── 13.dcm | ||
- | │ ├── 14.dcm | ||
- | │ ├── 15.dcm | ||
- | │ ├── 16.dcm | ||
- | │ ├── 17.dcm | ||
- | │ ├── 18.dcm | ||
- | │ ├── 19.dcm | ||
- | │ ├── 1.dcm | ||
- | .............. | ||
- | |||
- | </ | ||
- | |||
- | Alla vamos. Creo el csv del proyecto, | ||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ ls MRDCM/ | sed ' | ||
- | </ | ||
- | |||
- | A ver como convertimos, | ||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ dcm2niix -z y -o tmp/ MRDCM/ | ||
- | Chris Rorden' | ||
- | Found 176 DICOM file(s) | ||
- | Convert 176 DICOM as tmp/ | ||
- | compress: "/ | ||
- | Conversion required 1.217848 seconds (0.450000 for core code). | ||
- | [osotolongo@detritus centiloid]$ ls tmp/ | ||
- | 1008_MR_t1_mprage_sag_p2_iso_1.0_20161003101650_2.json 1008_MR_t1_mprage_sag_p2_iso_1.0_20161003101650_2.nii.gz | ||
- | |||
- | [osotolongo@detritus centiloid]$ for x in MRDCM/*; do y=$(echo ${x} | sed ' | ||
- | |||
- | [osotolongo@detritus centiloid]$ ls mri | ||
- | sub1008s0001.json | ||
- | sub1008s0001.nii.gz | ||
- | sub1009s0001.json | ||
- | sub1009s0001.nii.gz | ||
- | sub1010s0001.json | ||
- | sub1010s0001.nii.gz | ||
- | |||
- | [osotolongo@detritus centiloid]$ dcm2niix -z y -o tmp/ FBBDCM/ | ||
- | Chris Rorden' | ||
- | Found 90 DICOM file(s) | ||
- | Convert 90 DICOM as tmp/ | ||
- | compress: "/ | ||
- | Conversion required 1.233496 seconds (0.170000 for core code). | ||
- | [osotolongo@detritus centiloid]$ ls tmp | ||
- | 1008_PET_FBB_Austin_18F_Neuro_Res_20160627143414_43180.json | ||
- | |||
- | [osotolongo@detritus centiloid]$ for x in FBBDCM/*; do y=$(echo ${x} | sed ' | ||
- | [osotolongo@detritus centiloid]$ ls fbb | ||
- | sub1008s0001.json | ||
- | sub1008s0001.nii.gz | ||
- | sub1009s0001.json | ||
- | sub1009s0001.nii.gz | ||
- | sub1010s0001.json | ||
- | sub1010s0001.nii.gz | ||
- | </ | ||
- | |||
- | Preparamos y lanzamos FS, | ||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ fsl2fs.pl centiloid | ||
- | |||
- | [osotolongo@detritus centiloid]$ precon.pl centiloid | ||
- | Submitted batch job 15673 | ||
- | [osotolongo@detritus centiloid]$ squeue | ||
- | JOBID PARTITION | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | </ | ||
- | |||
- | Ahora, las imagenes PEt vieen en formato distinto al usado habitualmente (1 solo slice de 20 min) por lo que hay que retocar el script // | ||
- | |||
- | <code bash fbbtemp_reg.sh> | ||
- | #!/bin/sh | ||
- | |||
- | study=$1 | ||
- | shift | ||
- | |||
- | id=$1 | ||
- | shift | ||
- | |||
- | tdir=$1 | ||
- | shift | ||
- | |||
- | wdir=$1 | ||
- | shift | ||
- | |||
- | items=(`ls ${tdir}/ | ||
- | #shift | ||
- | |||
- | debug=0 | ||
- | |||
- | #Now get the uncorrected PETs and register to user space MRI | ||
- | for i in ${!items[*]}; | ||
- | tf=`printf " | ||
- | # | ||
- | ${FSLDIR}/ | ||
- | ${FSLDIR}/ | ||
- | # | ||
- | done | ||
- | if [ ${# | ||
- | echo ${# | ||
- | a=`for i in ${!items[*]}; | ||
- | ${FSLDIR}/ | ||
- | # | ||
- | # | ||
- | |||
- | ${FSLDIR}/ | ||
- | ${PIPEDIR}/ | ||
- | ${FSLDIR}/ | ||
- | else | ||
- | tf=`printf " | ||
- | ${FSLDIR}/ | ||
- | ${FSLDIR}/ | ||
- | fi | ||
- | |||
- | if [ $debug = 0 ] ; then | ||
- | rm ${tdir}/ | ||
- | rm ${wdir}/ | ||
- | fi | ||
- | </ | ||
- | De aqui se puede hacer lo usual, | ||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ fbb_correct.pl centiloid | ||
- | </ | ||
- | Y podemos revisar el report, | ||
- | {{: | ||
- | Todo parece ir bien asi que, | ||
- | <code bash> | ||
- | [osotolongo@detritus ~]$ parallel_fbb_rois_metrics.pl centiloid | ||
- | </ | ||
- | |||
- | Ahora solo hay que compara los valores globales de SUVR con los de la tabla de GAAIN. | ||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ awk -F ";" | ||
- | [osotolongo@detritus centiloid]$ join calcs.dat reference.dat > toreview.dat | ||
- | </ | ||
- | |||
- | A ver que tal ese modelo, | ||
- | |||
- | < | ||
- | > d <- read.csv(" | ||
- | > m <- lm(d$Global ~ d$WC_suvr) | ||
- | > summary(m) | ||
- | |||
- | Call: | ||
- | lm(formula = d$Global ~ d$WC_suvr) | ||
- | |||
- | Residuals: | ||
- | Min 1Q Median | ||
- | -0.121024 -0.042402 | ||
- | |||
- | Coefficients: | ||
- | Estimate Std. Error t value Pr(> | ||
- | (Intercept) | ||
- | d$WC_suvr | ||
- | --- | ||
- | Signif. codes: | ||
- | |||
- | Residual standard error: 0.07003 on 22 degrees of freedom | ||
- | Multiple R-squared: | ||
- | F-statistic: | ||
- | |||
- | </ | ||
- | Voy a hacer con //gnuplot// que es mas facil, | ||
- | |||
- | < | ||
- | gnuplot> f(x) = m*x +n | ||
- | gnuplot> fit f(x) " | ||
- | iter chisq | ||
- | 0 3.6936711672e+01 | ||
- | 1 3.6992605848e-01 | ||
- | 2 7.9414981509e-02 | ||
- | 3 7.9329087727e-02 | ||
- | 4 7.9329087724e-02 | ||
- | iter chisq | ||
- | |||
- | After 4 iterations the fit converged. | ||
- | final sum of squares of residuals : 0.0793291 | ||
- | rel. change during last iteration : -3.5012e-11 | ||
- | |||
- | degrees of freedom | ||
- | rms of residuals | ||
- | variance of residuals (reduced chisquare) = WSSR/ | ||
- | |||
- | Final set of parameters | ||
- | ======================= | ||
- | m = 0.846741 | ||
- | n = 0.0186989 | ||
- | |||
- | correlation matrix of the fit parameters: | ||
- | m n | ||
- | m | ||
- | n -0.969 | ||
- | </ | ||
- | |||
- | {{: | ||
- | |||
- | Tengo un ajuste con $r^2 = 0.97$ y una pendiente de $0.85 \pm 0.02$. La diferencia en los procedimientos esta en que en nuestra pipeline, siguiendo el metodo de ADNI, se toma como region de referencia la materia gris del cerebelo y en el caso de GAAIN se toma todo el cerebelo. No obstante la correspondencia entre las mediciones es buena. | ||
- | |||
- | |||
- | ==== Implementando pipeline Centiloid ===== | ||
- | |||
- | Con el objetivo de compara con otros estudios hemos de implementar el metodo usando las plantillas originales de [[https:// | ||
- | |||
- | De cualquier manera voy a reescribir el proceso de registro para integrarlo en el cluster, | ||
- | |||
- | <code perl fbb_correct.pl> | ||
- | # | ||
- | |||
- | use strict; use warnings; | ||
- | use Data::Dump qw(dump); | ||
- | use File:: | ||
- | use File:: | ||
- | |||
- | use NEURO qw(populate check_subj load_study print_help get_petdata get_pair achtung shit_done check_or_make); | ||
- | |||
- | #my $study; | ||
- | my $cfile; | ||
- | my $sok = 0; | ||
- | |||
- | @ARGV = (" | ||
- | while (@ARGV and $ARGV[0] =~ /^-/) { | ||
- | $_ = shift; | ||
- | last if /^--$/; | ||
- | #if (/^-e/) { $study = shift; chomp($study); | ||
- | if (/^-cut/) { $cfile = shift; chomp($cfile); | ||
- | if (/^-h/) { print_help $ENV{' | ||
- | } | ||
- | my $study = shift; | ||
- | unless ($study) { print_help $ENV{' | ||
- | |||
- | my %std = load_study($study); | ||
- | |||
- | my $subj_dir = $ENV{' | ||
- | |||
- | #Run this script ONLY on " | ||
- | #or change the paths to the correct ones | ||
- | |||
- | my $w_dir=$std{' | ||
- | #my $pet_dir = $spect? | ||
- | my $pet_dir = $std{' | ||
- | #my $petnc_dir = $std{' | ||
- | my $db = $std{' | ||
- | my $data_dir=$std{' | ||
- | my $outdir = " | ||
- | check_or_make($outdir); | ||
- | |||
- | my %plist = populate($db); | ||
- | my @ok_pets; | ||
- | |||
- | print " | ||
- | my %pets; | ||
- | |||
- | if ($cfile){ | ||
- | my %cuts = get_pair($data_dir."/" | ||
- | foreach my $cut (keys %cuts){ | ||
- | if(grep {/$cut/} %plist){ | ||
- | $pets{$cut} = $plist{$cut}; | ||
- | } | ||
- | } | ||
- | }else{ | ||
- | %pets = %plist; | ||
- | } | ||
- | |||
- | my $err_file = $data_dir."/ | ||
- | open ERRF, "> | ||
- | |||
- | foreach my $subject (sort keys %pets){ | ||
- | my @names = find(file => ' | ||
- | dump @names; | ||
- | if(@names){ | ||
- | my @mri = find(file => ' | ||
- | if(@mri){ | ||
- | push @ok_pets, $subject; | ||
- | }else{ | ||
- | print ERRF " | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | foreach my $subject (@ok_pets){ | ||
- | #my @mri = find(file => ' | ||
- | my $orderfile = $outdir.'/' | ||
- | my $order = $ENV{' | ||
- | open ORD, "> | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD "srun $order\n"; | ||
- | close ORD; | ||
- | my $jobid = `sbatch $orderfile`; | ||
- | $jobid = ( split ' ', $jobid )[ -1 ]; | ||
- | $order = $ENV{' | ||
- | $orderfile = $outdir.'/' | ||
- | open ORD, "> | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD "srun $order\n"; | ||
- | close ORD; | ||
- | my $xorder = ' | ||
- | system(" | ||
- | } | ||
- | |||
- | my $order = $ENV{' | ||
- | my $orderfile = $outdir.'/ | ||
- | open ORD, "> | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD "srun $order\n"; | ||
- | close ORD; | ||
- | my $xorder = ' | ||
- | exec($xorder); | ||
- | </ | ||
- | |||
- | **Y ahora la parte nueva ** | ||
- | |||
- | Primero hago un script sencillo que registre con ANTS al espacio MNI, | ||
- | |||
- | <code bash fbb2std.sh> | ||
- | #!/bin/sh | ||
- | |||
- | id=$1 | ||
- | shift | ||
- | |||
- | wdir=$1 | ||
- | shift | ||
- | |||
- | echo "I need the FBB image at MNI space" | ||
- | ANTS 3 -m CC[${FSLDIR}/ | ||
- | WarpImageMultiTransform 3 ${wdir}/ | ||
- | |||
- | </ | ||
- | |||
- | la relacion reportada en el paper de referencia es tomando como ROI de referencia el cerebelo completo. Asi que solo vale la pena calcular esa. | ||
- | |||
- | <code perl fbb_cl_masks.pl> | ||
- | # | ||
- | # Copyright 2019 O. Sotolongo < | ||
- | use strict; use warnings; | ||
- | |||
- | use File:: | ||
- | use NEURO qw(print_help get_pair load_study achtung shit_done get_lut check_or_make centiloid_fbb); | ||
- | use Data::Dump qw(dump); | ||
- | use File:: | ||
- | use File:: | ||
- | |||
- | my $ref_roi = " | ||
- | my $ctx_roi = " | ||
- | |||
- | my $roi_paths = $ENV{' | ||
- | my $withstd = 0; | ||
- | my $cfile; | ||
- | |||
- | @ARGV = (" | ||
- | |||
- | while (@ARGV and $ARGV[0] =~ /^-/) { | ||
- | $_ = shift; | ||
- | last if /^--$/; | ||
- | if (/^-cut/) { $cfile = shift; chomp($cfile); | ||
- | } | ||
- | |||
- | my $study = shift; | ||
- | unless ($study) { print_help $ENV{' | ||
- | my %std = load_study($study); | ||
- | my $w_dir=$std{' | ||
- | my $data_dir=$std{' | ||
- | |||
- | our %subjects; | ||
- | |||
- | my @plist = find(file => ' | ||
- | my $ofile = $data_dir."/" | ||
- | my $patt = ' | ||
- | |||
- | my @pets; | ||
- | |||
- | if ($cfile){ | ||
- | my %cuts = get_pair($data_dir."/" | ||
- | foreach my $cut (keys %cuts){ | ||
- | if(grep {/$cut/} @plist){ | ||
- | $pets[$cut] = $plist[$cut]; | ||
- | } | ||
- | } | ||
- | }else{ | ||
- | @pets = @plist; | ||
- | } | ||
- | |||
- | foreach my $pet (sort @pets){ | ||
- | (my $dg,my $subject) = $pet =~ /$patt/; | ||
- | if($subject){ | ||
- | $subjects{$subject}{' | ||
- | $subjects{$subject}{' | ||
- | } | ||
- | } | ||
- | my %sdata; | ||
- | foreach my $subject (sort keys %subjects){ | ||
- | my $care; | ||
- | my $norm; | ||
- | my $dg = $subjects{$subject}{' | ||
- | # Apply masks to FBB | ||
- | my $roi_mask = $roi_paths.$ctx_roi; | ||
- | my $order = " | ||
- | my $ctx = qx/$order/; | ||
- | my $roi_mask = $roi_paths.$ctx_roi; | ||
- | $order = " | ||
- | print " | ||
- | my $norm = qx/$order/; | ||
- | $subjects{$subject}{$npf.' | ||
- | } | ||
- | |||
- | open OF, "> | ||
- | print OF " | ||
- | print OF " | ||
- | foreach my $subject (sort keys %subjects){ | ||
- | print OF " | ||
- | my $mean = $subjects{$subject}{$npf.' | ||
- | print OF "; | ||
- | print OF ";", | ||
- | print OF " | ||
- | } | ||
- | close OF; | ||
- | </ | ||
- | |||
- | Ahora hago un wrapper que lance todo, | ||
- | |||
- | <code perl fbb_cl_metrics.pl> | ||
- | # | ||
- | # Copyright 2019 O. Sotolongo < | ||
- | use strict; use warnings; | ||
- | |||
- | use File:: | ||
- | use NEURO qw(print_help get_pair load_study achtung shit_done get_lut check_or_make centiloid_fbb); | ||
- | use Data::Dump qw(dump); | ||
- | use File:: | ||
- | use File:: | ||
- | |||
- | my $wcut = 0; | ||
- | my $cfile; | ||
- | |||
- | @ARGV = (" | ||
- | |||
- | while (@ARGV and $ARGV[0] =~ /^-/) { | ||
- | $_ = shift; | ||
- | last if /^--$/; | ||
- | if (/^-cut/) { $cfile = shift; chomp($cfile); | ||
- | if (/^-h$/) { print_help $ENV{' | ||
- | } | ||
- | |||
- | my $study = shift; | ||
- | unless ($study) { print_help $ENV{' | ||
- | my %std = load_study($study); | ||
- | my $w_dir=$std{' | ||
- | my $data_dir=$std{' | ||
- | my $outdir = " | ||
- | check_or_make($outdir); | ||
- | our %subjects; | ||
- | |||
- | my @plist = find(file => ' | ||
- | my $ofile = $data_dir."/" | ||
- | my $patt = ' | ||
- | |||
- | my @pets; | ||
- | |||
- | if ($cfile){ | ||
- | my %cuts = get_pair($data_dir."/" | ||
- | foreach my $cut (keys %cuts){ | ||
- | if(grep {/$cut/} @plist){ | ||
- | $pets[$cut] = $plist[$cut]; | ||
- | } | ||
- | } | ||
- | }else{ | ||
- | @pets = @plist; | ||
- | } | ||
- | |||
- | |||
- | foreach my $pet (sort @pets){ | ||
- | (my $dg,my $subject) = $pet =~ /$patt/; | ||
- | if($subject){ | ||
- | $subjects{$subject}{' | ||
- | $subjects{$subject}{' | ||
- | } | ||
- | } | ||
- | |||
- | foreach my $subject (sort keys %subjects){ | ||
- | my $norm; | ||
- | my $dg = $subjects{$subject}{' | ||
- | my $subj = $dg.$subject; | ||
- | #Making sbatch scripts | ||
- | # Get FBB image into MNI space | ||
- | my $order = $ENV{' | ||
- | my $orderfile = $outdir.'/' | ||
- | open ORD, "> | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD "srun $order\n"; | ||
- | close ORD; | ||
- | system(" | ||
- | } | ||
- | my $order = $ENV{' | ||
- | my $orderfile = $outdir.'/ | ||
- | open ORD, "> | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD '# | ||
- | print ORD "srun $order\n"; | ||
- | close ORD; | ||
- | my $xorder = ' | ||
- | exec($xorder); | ||
- | </ | ||
- | |||
- | |||
- | |||
- | <code bash> | ||
- | [osotolongo@detritus centiloid]$ fbb_cl_metrics.pl centiloid | ||
- | ..... | ||
- | [osotolongo@detritus centiloid]$ squeue | ||
- | JOBID PARTITION | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | </ |