Table of Contents
Notas para Pet-Tau
Plan
- Registro a native space
- SUVR no PVC: 2 refROIs (inferior CerebWM, eroded hemispheric WM)
- PVC Geometric Transfer Matrix? Ver https://github.com/UCL/PETPVC y https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5814575/
Teoria
Revision: https://pubs.rsna.org/doi/10.1148/radiol.2020200028
Unidades de tau: (https://jamanetwork.com/journals/jamaneurology/article-abstract/2604134) standardized uptake value ratio (SUVR) using the cerebellar gray matter ROI as a reference
ROIs para tau: https://www.nature.com/articles/mp2017108 Regions of interest For regional quantification, we used regions of interest (ROIs) derived from a probabilistic atlas,24 spatially warped in each patient’s native T1-MRI space, after application of an individual grey matter mask, as previously described.12 Our choice of ROIs was based on previously published cross-sectional data on tau PET imaging—12,25 parahippocampal gyrus, fusiform gyrus, middle and inferior temporal gyrus, posterior cingulate cortex and orbitofrontal cortex for patients with AD, and putamen for patients with CBS. A composite isocortical ROI was created for quantifying [11C]PIB retention.
Mas info:
ROIs were based on the parcellation of the T1-weighted MRI using FreeSurfer v6.0 (https://surfer.nmr.mgh.harvard.edu/). Standardized uptake value ratio (SUVR) images were calculated using an inferior cerebellar reference region [37]. For comparison, SUVR images were also created using the whole cerebellum and an eroded white matter reference region. Partial volume correction (PVC) was performed using the geometric transfer matrix method [38]; both corrected and uncorrected data were analyzed. Composite ROIs were created for regions corresponding to image-based tau stages, as defined in [39]—I/II (entorhinal), III/IV (temporal/limbic), V/VI (neocortical), and I–IV (temporal meta-ROI)—and the basal ganglia (caudate nucleus, putamen, and globus pallidus).
The cerebellar cortex was used as a reference region to create standardized uptake value ratio (SUVR) images. Finally, we measured PVE-uncorrected and corrected regional SUVR values for 25 cortical regions (inferior, middle and superior frontal, orbitofrontal, paracentral, precentral, inferior and superior parietal, postcentral, precuneus, supramarginal, medial and lateral occipital, lingual, insula, inferior, middle and superior temporal, fusiform, parahippocampal, anterior and posterior cingulate cortices, amygdala, and hippocampus).
A surface-based SUVR map was created with the cerebellar cortex SUVs obtained by volume-based approach and spatially normalized to the average surface. The spatially normalized surface-based SUVR maps were then convoluted by Gaussian kernel with 8 mm full-width half maximum (FWHM) to reduce noise
Tau accumulation was most frequently observed in the medial temporal regions and stepwise spread to the basal and lateral temporal, inferior parietal, posterior cingulate, and the other association cortices, and then ultimately to the primary cortical regions. In contrast, amyloid accumulation was found with similar frequency in the diffuse neocortical areas and then finally spread to the medial temporal regions. The image-based tau stage correlated with the general cognitive status, while cortical thinning was found only in the advanced tau stages; medial temporal region in stage V and widespread cortex in stage VI.
The cortex was parcellated using FreeSurfer [29, 30] on all subject MR data. Binary masks of volumes of interest (VOIs) were generated using the FreeSurfer parcellations on a per-subject basis. The parcellations were combined into 14 larger anatomical regions. These included ten GM volumes and four other regions. A background mask was also generated by inverting the summation of the 14 VOI masks. The GM volumes consisted of frontal, central, parietal, temporal, occipital, cingulate, insula, subcortical GM (caudate, putamen, thalamus, amygdala, pallidum), hippocampi and cerebellum. The other VOIs were subcortical WM, cerebellar WM, brain stem and ventricular and CSF space. The regions were selected in order to firstly separate the tissue types and then to divide the tissues into clinically relevant regions (e.g. frontal, parietal and temporal) and those that could suffer from severe PVEs (e.g. the occipital lobe and cingulate). A central lobule (pre-, para- and postcentral gyrus) was created as this region is thought to be relatively spared in AD [31] and is surrounded by ‘hotter’ GM regions.
The PET scans (both PV-corrected and uncorrected) were normalized by the mean cerebellar GM uptake value, found using the cerebellar GM mask. These normalized images are the SUVR images.
Care should be taken when applying PVC to amyloid PET images. Assumptions made in existing PVC strategies can induce biases that could lead to erroneous inferences about uptake in certain regions. The proposed RBV PVC technique accounts for within-compartment variability, with the potential to reduce errors of this kind.
PETPVC
Esto es de https://github.com/UCL/PETPVC
Notes on input and output files
The applications in this toolbox use ITK image readers and writers and can therefore accept common medical imaging formats such as Nifti, ANALYZE and Nrrd, and raw data with an associated meta-data header (mhd) file.
The tissue classification maps (referred to as mask files) can either be binary or probabilistic. All voxel values in a 3-D volume must be 0 ⇐ x ⇐ 1. The PVC applications expect the mask file to be input as a single 4-D volume, where each 3-D volume consists of a single segmented region.
The use of 4-D volumes facilitates the use of probabilistic segmentations during the PVC. In addition to the constraint that all voxels must be ⇐ 1, The sum of a voxel location across the fourth dimension should be ⇐ 1. Ideally it should be 1, which requires the background to be included as a segmented region.
Special cases where the inputs/outputs are different
Muller-Gartner (MG): The Muller-Gartner correction requires only the grey matter and white matter masks. Technically, the CSF space should be included as a third region, but the contribution of this region is assumed to be zero. The MG application still requires a 4-D mask volume, where the first volume is grey matter and the second is white matter. The order is important. The 4-D mask file can contain more than two 3-D volumes, but these will be ignored by the MG PVC.
Geometric Transfer Matrix (GTM) method: GTM cannot produce an image. The output of the GTM is a comma-separated value (CSV) file of regional mean values. The order of the mean values for each region is written in the same order as they appear in the fourth dimension of the mask file.
Single Target Correction (STC) method: The STC method corrects a single region. The mask image should be a 3-D volume, where each voxel in the target region should be 1. All other voxels should be 0.
Prueba PETPVC
[osotolongo@brick03 rois]$ fslmerge -t braak_4d braak_1 braak_2 braak_12 braak_3 braak_4 braak_34 [osotolongo@brick03 test]$ petpvc -i tau01_mean.nii.gz -m rois/braak_4d.nii.gz -o tau_pvc_test.csv -p GTM -x 6.0 -y 6.0 -z 6.0 Performing Geometric matrix method... 330.082 -0.537796 329.544 130.753 229.274 360.027
Ver explicacion de porque la ROI 2 es una mierda (braak_2)
Notas sueltas para metricas
label del Left-Hippocampus:
[osotolongo@brick03 ~]$ mri_vol2label --c /nas/data/subjects/f5cehbi_0001/mri/aseg.mgz --id 17 --l $SUBJECTS_DIR/f5cehbi_0001/labels/17.label
Los corticales hay que añadirlos a esto:
[osotolongo@brick03 neuro.dev]$ cat bin/prepare_fs_labels.sh #!/bin/sh subject=$1 shift tmp_dir=$1 shift mri_annotation2label --subject ${subject} --hemi lh --outdir $SUBJECTS_DIR/${subject}/labels tkregister2 --mov $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --noedit --s ${subject} --regheader --reg ${tmp_dir}/lh.register.dat mri_annotation2label --subject ${subject} --hemi rh --outdir $SUBJECTS_DIR/${subject}/labels tkregister2 --mov $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --noedit --s ${subject} --regheader --reg ${tmp_dir}/rh.register.dat
Registro
No lineal + Correccion de movimiento
La imagen tau tiene 6 slices,
[osotolongo@brick03 test]$ fslsplit tau01_tau.nii.gz tau01_piece_ -t [osotolongo@brick03 test]$ for x in tau01_piece_*; do > ${ANTS_PATH}/antsRegistrationSyNQuick.sh -d 3 -f tau01_struc.nii.gz -m ${x} -t s -o ${x%.nii.gz}_movingToFixed_ > ${ANTS_PATH}/antsApplyTransforms -d 3 -r tau01_struc.nii.gz -i ${x} -t ${x%.nii.gz}_movingToFixed_0GenericAffine.mat -t ${x%.nii.gz}_movingToFixed_1Warp.nii.gz -o ${x%.nii.gz}_reg.nii.gz > done [osotolongo@brick03 test]$ a=`for i in *_reg.nii.gz; do echo " $i"; done` [osotolongo@brick03 test]$ fslmerge -t tau01_corr.nii.gz $a [osotolongo@brick03 test]$ fslmaths tau01_corr.nii.gz -Tmean tau01_mean.nii.gz
supuestamente despues solo tendria que hacer esto,
[osotolongo@brick03 test]$ ${ANTS_PATH}/antsRegistrationSyNQuick.sh -d 3 -f tau01_struc.nii.gz -m tau01_mean.nii.gz -t s -o tau01_movingToFixed_ [osotolongo@brick03 test]$ ${ANTS_PATH}/antsApplyTransforms -d 3 -r tau01_struc.nii.gz -i tau01_mean.nii.gz -t tau01_movingToFixed_0GenericAffine.mat -t tau01_movingToFixed_1Warp.nii.gz -o tau01_2ns.nii.gz
Normalmente es muy error prone. Urge hacer comparacion entre correccion por movimiento y simple media temporal. EL sujeto del ejemplo esta mal registrado.
No lineal + raw mean
Si excluyo la correccion de movimiento queda mejor. Hago solo,
[osotolongo@brick03 test]$ fslmaths tau01_tau.nii.gz -Tmean tau01_mean.nii.gz [osotolongo@brick03 test]$ ${ANTS_PATH}/antsRegistrationSyNQuick.sh -d 3 -f tau01_struc.nii.gz -m tau01_mean.nii.gz -t s -o tau01_movingToFixed_ [osotolongo@brick03 test]$ ${ANTS_PATH}/antsApplyTransforms -d 3 -r tau01_struc.nii.gz -i tau01_mean.nii.gz -t tau01_movingToFixed_0GenericAffine.mat -t tau01_movingToFixed_1Warp.nii.gz -o tau01_2ns.nii.gz
correcion de movimiento + mean
[osotolongo@brick03 test]$ ${FREESURFER_HOME}/bin/mri_convert --in_type mgz --out_type nii ${SUBJECTS_DIR}/tau01/mri/rawavg.mgz tau01_struc.nii.gz [osotolongo@brick03 test]$ for x in tau01_piece_*; do ${ANTS_PATH}/antsRegistrationSyNQuick.sh -d 3 -f tau01_struc.nii.gz -m ${x} -t a -o ${x%.nii.gz}_movingToFixed_; ${ANTS_PATH}/antsApplyTransforms -d 3 -r tau01_struc.nii.gz -i ${x} -t ${x%.nii.gz}_movingToFixed_0GenericAffine.mat -o ${x%.nii.gz}_reg.nii.gz; done [osotolongo@brick03 test]$ a=`for i in *_reg.nii.gz; do echo " $i"; done` [osotolongo@brick03 test]$ fslmerge -t tau01_corr.nii.gz $a [osotolongo@brick03 test]$ fslmaths tau01_corr.nii.gz -Tmean tau01_mean.nii.gz
Mascaras
- get_troi.sh
#!/bin/sh subject=$1 shift tmp_dir=$1 shift roi=$1 shift if [ ! -f ${tmp_dir}/rois/register.dat ]; then mkdir ${tmp_dir}/rois/; tkregister2 --mov $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --noedit --s ${subject} --regheader --reg ${tmp_dir}/rois/register.dat; fi mri_label2vol --seg $SUBJECTS_DIR/${subject}/mri/aparc+aseg.mgz --temp $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --o ${tmp_dir}/all_aseg.nii.gz --reg ${tmp_dir}/rois/register.dat mkdir ${tmp_dir}/rois/${roi}; for x in `cat ${PIPEDIR}/lib/tau/${roi}.roi`; do rlabel=$(echo ${x} | awk -F"," '{print $1}'); nlabel=$(echo ${x} | awk -F"," '{print $2}'); ${FSLDIR}/bin/fslmaths ${tmp_dir}/all_aseg.nii.gz -uthr ${rlabel} -thr ${rlabel} -div ${rlabel} ${tmp_dir}/rois/${roi}/${nlabel} done a=$(for x in ${tmp_dir}/rois/${roi}/*.nii.gz; do echo "${x} -add "; done) a=$(echo ${a} | sed 's/\(.*\)-add$/\1/') #echo ${a} ${FSLDIR}/bin/fslmaths ${a} ${tmp_dir}/rois/${roi}
probando una ROI,
[osotolongo@brick03 tau]$ cat meta_temporal.roi 18,L_amygdala 1006,L_entorhinal 1007,L_fusiform 1009,L_inferiortemporal 1015,L_middletemporal 54,R_amygdala 2006,R_entorhinal 2007,R_fusiform 2009,R_inferiortemporal 2015,R_middletemporal [osotolongo@brick03 tau]$ get_troi.sh tau01 /old_nas/tau/tmp meta_temporal
Esto al menos, funciona bien
normalizacion
Problema : No puedo usar nu.mgz y rawavg.nii.gz en el mismo procesamiento. He de decidir por uno. En este caso funciona mucho mejor si registro el sujeto de FS usando rawavg.mgz. .
Hay dos opciones de normalizacion,
- Eroded hemisferic WM
- Cerebellum inferior GM
La primera es mas facil,
- get_tref_ewm.sh
#!/bin/sh subject=$1 shift tmp_dir=$1 shift roi=scwm.ref if [ ! -f ${tmp_dir}/rois/register.dat ]; then mkdir ${tmp_dir}/rois/; tkregister2 --mov $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --noedit --s ${subject} --regheader --reg ${tmp_dir}/rois/register.dat; fi if [ ! -f ${tmp_dir}/all_aseg.nii.gz ]; then mri_label2vol --seg $SUBJECTS_DIR/${subject}/mri/aparc+aseg.mgz --temp $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --o ${tmp_dir}/all_aseg.nii.gz --reg ${tmp_dir}/rois/register.dat; fi mkdir ${tmp_dir}/rois/${roi%.ref}; for x in `cat ${PIPEDIR}/lib/tau/${roi}`; do rlabel=$(echo ${x} | awk -F"," '{print $1}'); nlabel=$(echo ${x} | awk -F"," '{print $2}'); ${FSLDIR}/bin/fslmaths ${tmp_dir}/all_aseg.nii.gz -uthr ${rlabel} -thr ${rlabel} -div ${rlabel} ${tmp_dir}/rois/${roi%.ref}/${nlabel} done a=$(for x in ${tmp_dir}/rois/${roi%.ref}/*.nii.gz; do echo "${x} -add "; done) a=$(echo ${a} | sed 's/\(.*\)-add$/\1/') ${FSLDIR}/bin/fslmaths ${a} -kernel gauss 3.3973 -fmean -thr 0.7 ${tmp_dir}/rois/${roii%.ref}
La segunda implica tomar la GM del cerebelo de FS, y con una mascara de la parte inferior, hecha con SUIT tomar solo esa parte.
Nota: Hay un template de SUIT en espacio MNI proporcionado por AFNI (http://afni.nimh.nih.gov/pub/dist/atlases/SUIT_Cerebellum//SUIT_2.6_1/AFNI_SUITCerebellum.tgz). Ver https://afni.nimh.nih.gov/afni/community/board/read.php?1,142026,142026
Asi, que debo llevar este template a espacio nativo.
[osotolongo@brick03 test]$ ${ANTSPATH}/antsRegistrationSyNQuick.sh -d 3 -f /usr/local/fsl/data/standard/MNI152_T1_1mm.nii.gz -m tau01_struc.nii.gz -o structToMNI_ -t s [osotolongo@brick03 test]$ ${ANTSPATH}/antsApplyTransforms -d 3 -i /nas/software/neuro.dev/lib/tau/Cerebellum-MNIsegment.nii.gz -r tau01_struc.nii.gz -t [structToMNI_0GenericAffine.mat, 1] -t structToMNI_1InverseWarp.nii.gz -n GenericLabel -o CerebinNS.nii.gz
De aqui tengo que escoger las regiones inferiores. (Zonas 6,8-28,33,34)
#Ahora sacar el mapa de cerebelo de SUIT ${FREESURFER_HOME}/bin/mri_convert --in_type mgz --out_type nii ${SUBJECTS_DIR}/${subject}/mri/rawavg.mgz ${tmp_dir}/${subject}_tmp.nii.gz ${FSLDIR}/bin/fslreorient2std ${tmp_dir}/${subject}_tmp ${tmp_dir}/${subject}_struc ${ANTSPATH}/antsRegistrationSyNQuick.sh -d 3 -f ${FSLDIR}/data/standard/MNI152_T1_1mm.nii.gz -m ${tmp_dir}/${subject}_struc.nii.gz -o ${tmp_dir}/structToMNI_ -t s ${ANTSPATH}/antsApplyTransforms -d 3 -i ${PIPEDIR}/lib/tau/Cerebellum-MNIsegment.nii.gz -r ${tmp_dir}/${subject}_struc.nii.gz -t [${tmp_dir}/structToMNI_0GenericAffine.mat, 1] -t ${tmp_dir}/structToMNI_1InverseWarp.nii.gz -n GenericLabel -o ${tmp_dir}/CerebinNS.nii.gz #Dejar solo a parte de abajo? mkdir ${tmp_dir}/incsuit for x in `cat ${PIPEDIR}/lib/tau/incsuit.ref`; do ${FSLDIR}/bin/fslmaths ${tmp_dir}/CerebinNS.nii.gz -uthr ${x} -thr ${x} -div ${x} ${tmp_dir}/incsuit/${x}; done a=$(for x in ${tmp_dir}/incsuit/*.nii.gz; do echo "${x} -add "; done) a=$(echo ${a} | sed 's/\(.*\)-add$/\1/') ${FSLDIR}/bin/fslmaths ${a} ${tmp_dir}/incsuit.nii.gz
y aplicar esta mascara en el Cerebelo de FS,
${FSLDIR}/bin/fslmaths ${tmp_dir}/rois/${roii%.ref} -mas ${tmp_dir}/incsuit.nii.gz ${tmp_dir}/inferior_cereb.nii.gz
entendiendo las metricas
Meta-temporal ROI [8] 18 L_amygdala 1006 L_entorhinal 1007 L_fusiform 1009 L_inferiortemporal 1015 L_middletemporal 54 R_amygdala 2006 R_entorhinal 2007 R_fusiform 2009 R_inferiortemporal 2015 R_middletemporal
[8] Jack CR Jr , Wiste HJ, Weigand SD, Therneau TM, Lowe VJ, Knopman DS, et al. Defining imaging biomarker cut points for brain aging and Alzheimer's disease. Alzheimers & Dementia. 2017; 13: 205–16.
si hago algo como,
[osotolongo@brick03 test]$ tkregister2 --mov /nas/data/subjects/tau01/mri/rawavg.mgz --noedit --s tau01 --regheader --reg rois/register.dat [osotolongo@brick03 test]$ mri_label2vol --seg /nas/data/subjects/tau01/mri/aparc+aseg.mgz --temp /nas/data/subjects/tau01/mri/rawavg.mgz --o rois/all_aseg.nii.gz --reg rois/register.dat
solo tendria que hacer una mascara para cada zona y sumar las mascaras luego.
- get_troi.sh
#!/bin/sh subject=$1 shift tmp_dir=$1 shift roi=$1 shift if [ ! -f ${tmp_dir}/rois/register.dat ]; then mkdir ${tmp_dir}/rois/; tkregister2 --mov $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --noedit --s ${subject} --regheader --reg ${tmp_dir}/rois/register.dat; fi if [ ! -f ${tmp_dir}/all_aseg.nii.gz ]; then mri_label2vol --seg $SUBJECTS_DIR/${subject}/mri/aparc+aseg.mgz --temp $SUBJECTS_DIR/${subject}/mri/rawavg.mgz --o ${tmp_dir}/all_aseg.nii.gz --reg ${tmp_dir}/rois/register.dat; fi mkdir ${tmp_dir}/rois/${roi}; for x in `cat ${PIPEDIR}/lib/tau/${roi}.roi`; do rlabel=$(echo ${x} | awk -F"," '{print $1}'); nlabel=$(echo ${x} | awk -F"," '{print $2}'); ${FSLDIR}/bin/fslmaths ${tmp_dir}/all_aseg.nii.gz -uthr ${rlabel} -thr ${rlabel} -div ${rlabel} ${tmp_dir}/rois/${roi}/${nlabel} done a=$(for x in ${tmp_dir}/rois/${roi}/*.nii.gz; do echo "${x} -add "; done) a=$(echo ${a} | sed 's/\(.*\)-add$/\1/') #echo ${a} ${FSLDIR}/bin/fslmaths ${a} ${tmp_dir}/rois/${roi}
esto lo ejecuto como,
[osotolongo@brick03 test]$ get_troi.sh tau01 /old_nas/tau/tmp braak_34
TO DO
- Definir VOI en FS (subcort ROIs + cort ROIs)
- bulk processing (BIDS, Registro, Metricas)
- DCM a BIDs para PET-tau (debe variar para cada estudio)
- Registro (con correccion de movimiento)
- Metricas calcular VOI y aplicar, normalizar por cerebellum GM o eroded WM
- bajar imagenes de ADNI (PET-tau ↔ T1w)
- evaluar importancia de la correccion de movimiento
Building blocks
ADNI
[osotolongo@brick03 ADNI]$ for x in *; do f=$(find ${x}/ADNI_Brain_PET__Raw_Tau/ -type f | grep -v xml | head -n 1); sd=$(dckey -k "SeriesDescription" ${f} 2>&1); echo "${x} -> ${sd}"; done 002_S_6007 -> ADNI Brain PET: Raw 002_S_6009 -> ADNI Brain PET: Raw 002_S_6030 -> ADNI Brain PET: Raw 002_S_6053 -> ADNI Brain PET: Raw 002_S_6103 -> ADNI Brain PET: Raw 002_S_6695 -> ADNI Brain PET: Raw [osotolongo@brick03 ADNI]$ for x in *; do f=$(find ${x}/Accelerated_Sagittal_MPRAGE/ -type f | grep -v xml | head -n 1); sd=$(dckey -k "SeriesDescription" ${f} 2>&1); echo "${x} -> ${sd}"; done 002_S_6007 -> Accelerated Sagittal MPRAGE 002_S_6009 -> Accelerated Sagittal MPRAGE 002_S_6030 -> Accelerated Sagittal MPRAGE 002_S_6053 -> Accelerated Sagittal MPRAGE 002_S_6103 -> Accelerated Sagittal MPRAGE 002_S_6695 -> Accelerated Sagittal MPRAGE
Test project
[osotolongo@brick03 bin]$ make_proj.pl atau /old_nas/tau/ADNI [osotolongo@brick03 bin]$ tree /nas/data/atau /nas/data/atau ├── bids └── working 2 directories, 0 files [osotolongo@brick03 bin]$ cd /nas/data/atau/bids/ [osotolongo@brick03 bids]$ dcm2bids_scaffold [osotolongo@brick03 bids]$ dcm2bids_helper -d /old_nas/tau/ADNI/002_S_6007/ Example in: /old_nas/atau/bids/tmp_dcm2bids/helper
conversion,
- conversion.json
{ "descriptions": [ { "dataType": "anat", "modalityLabel": "T1w", "criteria": { "SeriesDescription": "Accelerated_Sagittal_MPRAGE" } }, { "dataType": "pet", "modalityLabel": "tau", "criteria": { "SeriesDescription": "ADNI_Brain_PET:_Raw" } } ] }
[osotolongo@brick03 bids]$ bulk2bids.pl atau Submitted batch job 19443 Submitted batch job 19444 Submitted batch job 19445 Submitted batch job 19446 Submitted batch job 19447 Submitted batch job 19448 Submitted batch job 19449
[osotolongo@brick03 atau]$ tree bids/sub-0001/ bids/sub-0001/ ├── anat │ ├── sub-0001_T1w.json │ └── sub-0001_T1w.nii.gz └── pet ├── sub-0001_tau.json └── sub-0001_tau.nii.gz 2 directories, 4 files
[osotolongo@brick03 atau]$ precon.pl atau Submitted batch job 19464 Submitted batch job 19465 Submitted batch job 19466 Submitted batch job 19467 Submitted batch job 19468 Submitted batch job 19469 Submitted batch job 19470
Registro
- tau_reg.sh
#!/bin/sh study=$1 shift id=$1 shift wdir=$1 shift src=$1 shift td=${wdir}'/.tmp_pet_'${id} if [ ! -d "$td" ]; then mkdir $td fi debug=1 ${FREESURFER_HOME}/bin/mri_convert --in_type mgz --out_type nii ${SUBJECTS_DIR}/${study}_${id}/mri/rawavg.mgz ${td}/${id}_struc.nii.gz ${FSLDIR}/bin/fslsplit ${src} ${td}/${id}_piece_ -t for x in ${td}/${id}_piece_*; do ${ANTS_PATH}/antsRegistrationSyNQuick.sh -d 3 -f ${td}/${id}_struc.nii.gz -m ${x} -t a -o ${x%.nii.gz}_movingToFixed_; ${ANTS_PATH}/antsApplyTransforms -d 3 -r ${td}/${id}_struc.nii.gz -i ${x} -t ${x%.nii.gz}_movingToFixed_0GenericAffine.mat -o ${x%.nii.gz}_reg.nii.gz; done a=`for i in ${td}/*_reg.nii.gz; do echo " $i"; done` ${FSLDIR}/bin/fslmerge -t ${td}/${id}_corr.nii.gz $a ${FSLDIR}/bin/fslmaths ${td}/${id}_corr.nii.gz -Tmean ${td}/${id}_mean.nii.gz if [ $debug = 0 ] ; then rm -rf ${td} fi
Tau Report
- make_tau_report.pl
#!/usr/bin/perl # Copyright 2021 O. Sotolongo <asqwerty@gmail.com> use strict; use warnings; use File::Slurp qw(read_file); use File::Find::Rule; use File::Basename qw(basename); use Data::Dump qw(dump); use File::Copy::Recursive qw(dirmove); use NEURO4 qw(load_project print_help); my $full = 0; @ARGV = ("-h") unless @ARGV; while (@ARGV and $ARGV[0] =~ /^-/) { $_ = shift; last if /^--$/; if (/^-f/) {$full = 1} if (/^-h/) { print_help $ENV{'PIPEDIR'}.'/doc/make_fbb_report.hlp'; exit;} } my $study = shift; unless ($study) { print_help $ENV{'PIPEDIR'}.'/doc/make_pet_report.hlp'; exit;} my %std = load_project($study); my $w_dir=$std{'WORKING'}; my $d_dir=$std{'DATA'}; # Redirect ouput to logfile (do it only when everything is fine) my $debug = "$d_dir/.debug_report.log"; open STDOUT, ">$debug" or die "Can't redirect stdout"; open STDERR, ">&STDOUT" or die "Can't dup stdout"; my $order = "slicesdir -o "; my @names = find(file => 'name' => "*_tau.nii.gz", in => $w_dir); foreach my $name (sort @names){ (my $struc = $name) =~ s/tau/struc/; $order .= $name.' '.$struc." "; if ($full) { (my $base = $name) =~ s/\.nii\.gz$//; $base=basename($base); my @regs = find(file => 'name' => "$base*reg.nii.gz", in => $w_dir); dump @regs; foreach my $reg (sort @regs){ $order .= $reg.' '.$struc." "; } } } chdir $w_dir; print "$order\n"; system($order); dirmove('slicesdir', 'taus');
Tau preproc
- tau_proc.pl
#!/usr/bin/perl # Copyright 2021 O. Sotolongo <asqwerty@gmail.com> use strict; use warnings; use Data::Dump qw(dump); use File::Find::Rule; use File::Copy::Recursive qw(dirmove); use NEURO4 qw(check_pet check_subj load_project print_help check_or_make cut_shit); my $cfile=""; my $time = '8:0:0'; @ARGV = ("-h") unless @ARGV; while (@ARGV and $ARGV[0] =~ /^-/) { $_ = shift; last if /^--$/; if (/^-cut/) { $cfile = shift; chomp($cfile);} if (/^-time/) {$time = shift; chomp($time)} if (/^-h/) { print_help $ENV{'PIPEDIR'}.'/doc/tau_reg.hlp'; exit;} } my $study = shift; unless ($study) { print_help $ENV{'PIPEDIR'}.'/doc/tau_reg.hlp'; exit;} my %std = load_project($study); my $subj_dir = $ENV{'SUBJECTS_DIR'}; my $w_dir=$std{'WORKING'}; my $db = $std{'DATA'}.'/'.$study.'_pet.csv'; my $data_dir=$std{'DATA'}; my $outdir = "$std{'DATA'}/slurm"; check_or_make($outdir); print "Collecting needed files\n"; my @pets = cut_shit($db, $data_dir.'/'.$cfile); foreach my $subject (@pets){ my %spet = check_pet($std{'DATA'},$subject); my %smri = check_subj($std{'DATA'},$subject); if($spet{'tau'} && $smri{'T1w'}){ my $order = $ENV{'PIPEDIR'}."/bin/tau_reg.sh ".$study." ".$subject." ".$w_dir." ".$spet{'tau'}; my $orderfile = $outdir.'/'.$subject.'_tau_reg.sh'; open ORD, ">$orderfile"; print ORD '#!/bin/bash'."\n"; print ORD '#SBATCH -J tau_reg_'.$study."\n"; print ORD '#SBATCH --time='.$time."\n"; #si no ha terminado en X horas matalo print ORD '#SBATCH --mail-type=FAIL,STAGE_OUT'."\n"; #no quieres que te mande email de todo print ORD '#SBATCH -o '.$outdir.'/tau_reg_'.$subject.'-%j'."\n"; print ORD '#SBATCH -c 4'."\n"; print ORD '#SBATCH --mem-per-cpu=4G'."\n"; print ORD '#SBATCH --mail-user='."$ENV{'USER'}\n"; print ORD "srun $order\n"; close ORD; system("sbatch $orderfile"); } } my $order = $ENV{'PIPEDIR'}."/bin/make_tau_report.pl ".$study; my $orderfile = $outdir.'/tau_report.sh'; open ORD, ">$orderfile"; print ORD '#!/bin/bash'."\n"; print ORD '#SBATCH -J tau_reg_'.$study."\n"; print ORD '#SBATCH --time=2:0:0'."\n"; #si no ha terminado en X horas matalo print ORD '#SBATCH --mail-type=FAIL,END'."\n"; #email cuando termine o falle print ORD '#SBATCH --mail-user='."$ENV{'USER'}\n"; print ORD '#SBATCH -o '.$outdir.'/tau_report-%j'."\n"; print ORD "srun $order\n"; close ORD; my $xorder = 'sbatch --dependency=singleton'.' '.$orderfile; exec($xorder);
[osotolongo@brick03 atau]$ tau_proc.pl atau Collecting needed files Submitted batch job 19478 Submitted batch job 19479 Submitted batch job 19480 Submitted batch job 19481 Submitted batch job 19482 Submitted batch job 19483 Submitted batch job 19484 [osotolongo@brick03 atau]$ squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 19484 fast tau_reg_ osotolon PD 0:00 1 (Dependency) 19478 fast tau_reg_ osotolon R 0:02 1 brick01 19479 fast tau_reg_ osotolon R 0:02 1 brick01 19480 fast tau_reg_ osotolon R 0:02 1 brick01 19481 fast tau_reg_ osotolon R 0:02 1 brick01 19482 fast tau_reg_ osotolon R 0:02 1 brick01 19483 fast tau_reg_ osotolon R 0:02 1 brick01