This shows you the differences between two versions of the page.
neuroimagen:centiloid [2019/04/12 08:56] osotolongo [Implementando pipeline Centiloid] |
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 | ||
- | </ | ||
- | |||
- | Lo voy a hacer con //gnuplot// que es mas facil, | ||
- | |||
- | < | ||
- | gnuplot> fit f(x) " | ||
- | iter chisq | ||
- | 0 2.2640655922e+00 | ||
- | 1 1.5434204471e-01 | ||
- | 2 1.5172756904e-01 | ||
- | 3 1.3453722070e-01 | ||
- | 4 1.3400723332e-01 | ||
- | 5 1.3400723101e-01 | ||
- | iter chisq | ||
- | |||
- | After 5 iterations the fit converged. | ||
- | final sum of squares of residuals : 0.134007 | ||
- | rel. change during last iteration : -1.72206e-08 | ||
- | |||
- | degrees of freedom | ||
- | rms of residuals | ||
- | variance of residuals (reduced chisquare) = WSSR/ | ||
- | |||
- | Final set of parameters | ||
- | ======================= | ||
- | m = 1.0835 | ||
- | n = -0.0967593 | ||
- | |||
- | correlation matrix of the fit parameters: | ||
- | m n | ||
- | m | ||
- | n -0.969 | ||
- | </ | ||
- | |||
- | {{: | ||
- | Y con pendiente de $1.08 \pm 0.04$ creo que estamos bien. | ||
- | |||
- | Resumen: Hemos validado correctamente el metodo que se usapara sacar los SUVR. | ||
- | |||
- | ==== Implementando pipeline Centiloid ===== | ||
- | |||
- | Con el objetivo de compara con otros estudios hemos de implementar el metodo usando las plantillas originales de [[https:// | ||
- | |||
- | Voy a hacer un script nuevo para esto, reutilizando el antiguo. 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}/ | ||
- | |||
- | </ | ||
- | |||
- | y despues hago un //wrapper// que lo lance en paralelo y haga las metricas, | ||
- | <code perl parallel_fbb_cl_metrics.pl> | ||
- | # | ||
- | |||
- | 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:: | ||
- | use Parallel:: | ||
- | |||
- | my %ROI_Comps = ( | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | ); | ||
- | |||
- | my $roi_paths = $ENV{' | ||
- | my $attach = 1; | ||
- | my $reduce = 0; | ||
- | my $withstd = 0; | ||
- | my $cfile; | ||
- | |||
- | @ARGV = (" | ||
- | |||
- | while (@ARGV and $ARGV[0] =~ /^-/) { | ||
- | $_ = shift; | ||
- | last if /^--$/; | ||
- | if (/^-l$/) { $attach = 0;} | ||
- | if (/^-r$/) { $reduce = 1;} | ||
- | if (/^-std$/) {$withstd = 1;} | ||
- | 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 $max_processes = 20; | ||
- | |||
- | # Redirect ouput to logfile (do it only when everything is fine) | ||
- | #my $debug = " | ||
- | #open STDOUT, "> | ||
- | #open STDERR, ">& | ||
- | |||
- | my $pm = new Parallel:: | ||
- | our %subjects; | ||
- | |||
- | $pm-> | ||
- | sub { my ($pid, $exit_code, $ident, $exit_signal, | ||
- | foreach my $tag (sort keys %{$data}){ | ||
- | $subjects{$ident}{$tag}=${$data}{$tag} | ||
- | } | ||
- | } | ||
- | ); | ||
- | 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 $care; | ||
- | my $norm; | ||
- | my $dg = $subjects{$subject}{' | ||
- | my @care; | ||
- | my %sdata; | ||
- | $pm-> | ||
- | |||
- | # Get FBB image into MNI space | ||
- | my $order = " | ||
- | print " | ||
- | system($order); | ||
- | # Apply masks to FBB | ||
- | foreach my $npf (sort keys %ROI_Comps){ | ||
- | my $roi_mask = $roi_paths.$ROI_Comps{$npf}; | ||
- | # get mean and std for mask | ||
- | $order = " | ||
- | print " | ||
- | (my $mean, my $std) = map{/ | ||
- | $sdata{$npf.' | ||
- | $sdata{$npf.' | ||
- | } | ||
- | $pm-> | ||
- | # remove temp dir | ||
- | #remove( \1, ($mdir)); | ||
- | } | ||
- | $pm-> | ||
- | |||
- | open OF, "> | ||
- | |||
- | print OF " | ||
- | |||
- | foreach my $npf (sort keys %ROI_Comps){ | ||
- | if($withstd){ | ||
- | print OF "; | ||
- | }else{ | ||
- | print OF "; | ||
- | } | ||
- | } | ||
- | print OF " | ||
- | foreach my $subject (sort keys %subjects){ | ||
- | print OF " | ||
- | foreach my $npf (sort keys %ROI_Comps){ | ||
- | my $mean = $subjects{$subject}{$npf.' | ||
- | my $std = $subjects{$subject}{$npf.' | ||
- | if($withstd){ | ||
- | print OF "; | ||
- | print OF ";", | ||
- | }else{ | ||
- | print OF "; | ||
- | print OF ";", | ||
- | } | ||
- | } | ||
- | print OF " | ||
- | } | ||
- | close OF; | ||
- | |||
- | my $zfile = $ofile.' | ||
- | system(" | ||
- | |||
- | if ($attach){ | ||
- | shit_done basename($ENV{_}), | ||
- | }else{ | ||
- | achtung basename($ENV{_}), | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | **Problemas: | ||
- | |||