Skip to content

ROI Analysis in CIVET

tulste edited this page Sep 15, 2017 · 18 revisions

ROI analysis in CIVET

At the moment is quite difficult due to RMINC, but Gabriel made a small workaround.

  • Take a look at the AAL readme, and figure out which ROIs are of interest, note their numbers. See:
#At CIC
/opt/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/AAL_atlas_left.txt /opt/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/AAL_atlas_right.txt
#On Scinet
/project/m/mchakrav/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/AAL_atlas_left.txt /project/m/mchakrav/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/AAL_atlas_right.txt
  • Create a "masking AAL" file, by using sed code to replace all labels not of interest with 0 in the AAL_left and AAL_right, while setting all numbers of interest to 1.

Example:

Copy the AAL_atlas TXT and rename it to MASK.

$ cp AAL_atlas_left.txt AAL_atlas_left_mask.txt

Repĺace every label with 1s and 0s.

$ sed -r -i 's/^(1)$/0/g' AAL_atlas_right_mask.txt (label 1 has to be 0 first otherwise it will pass as part of your mask)
$ sed -r -i 's/^(31|5|9|15|3|6|10|16|32|4)$/1/g' AAL_atlas_right_mask.txt (ROIs)
$ sed -r -i 's/^.*[^1].*$/0/g' AAL_atlas_right_mask.txt (rest of the labels)
  • Clip the AAL_atlas_left_mask.txt files. They are too long for the next step, clip them to be 40962 lines long, this might be longer if you do hi-res surfaces in CIVET 2.0 head -n 40962 AAL_atlas_left_mask.txt > AAL_atlas_left_mask_short.txt

  • Use vertstats_math to multiply your thickness/SA files by the mask.

Example:

Left hemisphere

Example loop

for file in output/*/thickness/*_native_rms_rsl_tlink_28.28mm_left.txt output/*/surfaces/*_mid_surface_rsl_left_native_area_56.57mm.txt; do vertstats_math -mult AAL_atlas_left_mask_short.txt $file -old_style_file $(dirname $file)/$(basename $file .txt)_roi.txt; done

Make sure the output has the flag -old_style_file or it will create it with a header.

  • Use those files to do your statistics in R.

As in, make a new column with the ROI files in R.

R> database_8_forR_noCC$left_thick_rois <- paste("/media/INP_MRI_Backup/projects/INP/conectome_inp/analysis/structural/ct2/roi_thickness/","addimex_",database_8_forR_noCC$id,"_native_rms_rsl_tlink_28.28mm_left_rois.txt", sep="")

  • Load the mask into R, AAL_left_mask = read.table("/path/to/mask/AAL_atlas_left_mask_short.txt")

  • Use the "mask" file you've created in vertexFDR(....., mask=mask) to limit FDR calculations to only that area.

R> vertexFDR(vs_rthick_rois, mask = AAL_atlas_right_mask)

  • Write the ROI data to visualize

write.table(x=vs_lthick_rois[,"tvalue-groupHC"], col.names=FALSE, row.names=FALSE, file="ROI_test.txt")

  • The output file (i.e. "ROI_test.txt") will have NA values in the non-ROI areas, so replace with "0".

sed -i 's/NA/0/g' ROI_test.txt

If all went well, you should get only the ROI data.

Clone this wiki locally