User Tools

Site Tools


neuroimagen:fslvbm_test

Probando FSL VBM

Voy a intentar una prueba de ejecucion de FSLVBM con algunos sujetos de FACEHBI. Ver aqui: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLVBM/UserGuide

Nota: Caso real aqui → neuroimagen:fslvbm_real

Paso 0: Preparando el entorno.

Voy a tomar unas pocas imagenes para probar,

[osotolongo@brick01 facehbi]$ mkdir fslvbm
[osotolongo@brick01 facehbi]$ cd fslvbm/
[osotolongo@brick01 fslvbm]$ ls ../bids/sub-000*/anat/sub-000*_T1w.nii.gz
../bids/sub-0001/anat/sub-0001_T1w.nii.gz  ../bids/sub-0004/anat/sub-0004_T1w.nii.gz  ../bids/sub-0007/anat/sub-0007_T1w.nii.gz
../bids/sub-0002/anat/sub-0002_T1w.nii.gz  ../bids/sub-0005/anat/sub-0005_T1w.nii.gz  ../bids/sub-0008/anat/sub-0008_T1w.nii.gz
../bids/sub-0003/anat/sub-0003_T1w.nii.gz  ../bids/sub-0006/anat/sub-0006_T1w.nii.gz  ../bids/sub-0009/anat/sub-0009_T1w.nii.gz
[osotolongo@brick01 fslvbm]$ for x in *.nii.gz; do y=$(echo ${x} | sed 's/sub-//; s/_T1w//'); mv ${x} ${y}; done
[osotolongo@brick01 fslvbm]$ ls
0001.nii.gz  0002.nii.gz  0003.nii.gz  0004.nii.gz  0005.nii.gz  0006.nii.gz  0007.nii.gz  0008.nii.gz  0009.nii.gz

Ahora hago el template_list y el slicesdir

[osotolongo@brick01 fslvbm]$ ls > template_list
[osotolongo@brick01 fslvbm]$ cat template_list
0001.nii.gz
0002.nii.gz
0003.nii.gz
0004.nii.gz
0005.nii.gz
0006.nii.gz
0007.nii.gz
0008.nii.gz
0009.nii.gz
[osotolongo@brick01 fslvbm]$ slicesdir `imglob *`
0001
0002
0003
0004
0005
0006
0007
0008
0009

Matrices

Necesitamos la matriz de diseño y contrastes. Para llenar esto a partir de los datos nos basamos en: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/GLM/CreatingDesignMatricesByHand

Paso 1: BET.

Este paso lo que busca es tener los cerebros en una imagen separada.

siguiendo el script que esta en /usr/local/fsl/bin/fslvbm_1_bet es muy simple lo que se ha de hacer. Pero en lugar de usar este script vamos a sacar las imagenes de la segmentacion de FS. Para esto hacemos un script sencillo,

get_fsbrain.sh
#!/bin/sh
study=$1
shift
id=$1
shift
dir=$1
shift
debug=0
#First get the freesurfer processed MRIs
        ${FREESURFER_HOME}/bin/mri_convert --in_type mgz --out_type nii ${SUBJECTS_DIR}/${study}_${id}/mri/nu.mgz ${dir}/${id}_tmp.nii.gz
        ${FSLDIR}/bin/fslreorient2std ${dir}/${id}_tmp ${dir}/${id}_struc
        ${FREESURFER_HOME}/bin/mri_convert --in_type mgz --out_type nii ${SUBJECTS_DIR}/${study}_${id}/mri/brain.mgz ${dir}/${id}_tmp_brain.nii.gz
        ${FSLDIR}/bin/fslreorient2std ${dir}/${id}_tmp_brain ${dir}/${id}_struc_brain
 
if [ $debug = 0 ] ; then
    rm ${dir}/${id}_tmp*
fi

Ahora solo hay que recorrer las lista de sujetos correctamente,

[osotolongo@detritus vbmtest]$ mkdir struc
[osotolongo@detritus vbmtest]$ for x in `cat subjects.list`; do get_fsbrain.sh facehbi ${x} struc; done
[osotolongo@detritus vbmtest]$ ls struc/
0001_struc_brain.nii.gz  0002_struc.nii.gz        0004_struc_brain.nii.gz  0005_struc.nii.gz        0007_struc_brain.nii.gz  0008_struc.nii.gz
0001_struc.nii.gz        0003_struc_brain.nii.gz  0004_struc.nii.gz        0006_struc_brain.nii.gz  0007_struc.nii.gz        0009_struc_brain.nii.gz
0002_struc_brain.nii.gz  0003_struc.nii.gz        0005_struc_brain.nii.gz  0006_struc.nii.gz        0008_struc_brain.nii.gz  0009_struc.nii.gz
[osotolongo@detritus vbmtest]$ cd struc
[osotolongo@detritus struc]$ for x in `cat ../subjects.list`; do a="$a ${x}_struc ${x}_struc_brain"; done
[osotolongo@detritus struc]$ slicesdir -o $a
0001_struc
0002_struc
0003_struc
0004_struc
0005_struc
0006_struc
0007_struc
0008_struc
0009_struc
 
Finished. To view, point your web browser at
file:/nas/data/facehbi/vbmtest/struc/slicesdir/index.html

Paso 2: Template

A ver que pasa,

[osotolongo@detritus vbmtest]$ fslvbm_2_template -n
0001_struc
0002_struc
0003_struc
0004_struc
0005_struc
0006_struc
0007_struc
0008_struc
0009_struc
Running segmentation: ID=32356
Running initial registration: ID=3874
Creating first-pass template: ID=5237
Running registration to first-pass template: ID=5489
Creating second-pass template: ID=9155
Study-specific template will be created, when complete, check results with:
fslview struc/template_4D_GM
and turn on the movie loop to check all subjects, then run:
fslview  /usr/local/fsl/data/standard/tissuepriors/avg152T1_gray  struc/template_GM
to check general alignment of mean GM template vs. original standard space template.

Paso 3: Procesamiento

Deberiamos tener definidos design.mat y design.con

[osotolongo@detritus vbmtest]$ fslvbm_3_proc
Now running the preprocessing steps and the pre-analyses
0001_struc
0002_struc
0003_struc
0004_struc
0005_struc
0006_struc
0007_struc
0008_struc
0009_struc
Doing registrations: ID=13099
Doing subject concatenation and initial randomise: ID=15317
Once this has finished, run randomise with 5000 permutations on the 'best' smoothed 4D GM_mod_merg. We recommend using the -T (TFCE) option. For example:
randomise -i GM_mod_merg_s3 -o GM_mod_merg_s3 -m GM_mask -d design.mat -t design.con -n 5000 -T -V

Paso 4: randomize

Ejemplo,

[osotolongo@detritus vbmtest]$ randomise -i stats/GM_mod_merg_s3 -o fslvbmtest -m stats/GM_mask.nii.gz -d design.mat -t design.con -n 1000 -T -V
randomise options: -i stats/GM_mod_merg_s3 -o fslvbmtest -m stats/GM_mask.nii.gz -d design.mat -t design.con -n 1000 -T -V
Loading Data:
Data loaded
60480 permutations required for exhaustive test of t-test 1
Doing 1000 random permutations
Starting permutation 1 (Unpermuted data)
Starting permutation 2
Starting permutation 3
Starting permutation 4
Starting permutation 5
Starting permutation 6
...
...
...
Starting permutation 997
Starting permutation 998
Starting permutation 999
Starting permutation 1000
Critical Value for: fslvbmtest_tfce_tstat2 is: 149389
Finished, exiting.
[osotolongo@detritus vbmtest]$ fslview_deprecated $FSLDIR/data/standard/MNI152_T1_2mm fslvbmtest_tfce_corrp_tstat1 -l Red-Yellow

[osotolongo@detritus vbmtest]$ fslview_deprecated $FSLDIR/data/standard/MNI152_T1_2mm fslvbmtest_tfce_corrp_tstat2 -l Red-Yellow

neuroimagen/fslvbm_test.txt · Last modified: 2020/08/04 10:58 (external edit)