Skip to content

Surface Sampling Using CIVET 2.x surfaces

parent41 edited this page Nov 24, 2023 · 1 revision

If you have multi-modal data, this page will take you through some steps on how to use surfaces generated through CIVET on T1 scans (ex: MPRAGE) to sample surfaces of other scans (ex: MP2RAGE, fMRI, etc).

1. Align your T1 scan with other scan

The first step is to make sure that your t1 scan and the scan you are interested in sampling from are aligned. To do so, you can use bestlinreg_g. You will use the input file from CIVET to perform the alignment. -nmi option: instead of using the default cross correlation you use normalized mutual information, which is helpful when aligning two scans from different scan types. -lsq6: because these scans are from the same subject, you only use rigid registration -close: assumes scans were taken in the same session so they should be mostly overlapping

> module load minc-toolkit 
> bestlinreg_g -nmi -lsq6 -close path_to/CIVET/subject_t1.mnc path_to/other_scan/MP2RAGE.mnc transform_t1_to_otherscan.xfm  

2. To get the inverse of the linear transform from CIVET

CIVET does its processing in MNI space. We need to transform the surface from MNI space back to our native space. In order to do so, we can invert the linear transform produced by CIVET to get from native to MNI space. You will need to generate an inverse of the linear transform generated from you CIVET run, using the command xfminvert. You will list the path to the linear transform followed by the name you wish to give the inverted transform you are creating:

> xfminvert path_to/CIVET/output/subject/transforms/linear/subject_t1_tal.xfm subject_t1_tal_invert.xfm

3. Apply your transforms to the CIVET mid surface

Now you will use the transform you just created to transform both the left and right CIVET mid surface onto the other (target) scan. Once you've done this, you can use Display to see if your new objects align well with your "other scan".

> transform_objects path_to/CIVET/output/subject/surfaces/subject_mid_surface_left_81920.obj subject_combined.xfm subject_transformed_left.obj 
> transform_objects path_to/CIVET/output/subject/surfaces/subject_mid_surface_right_81920.obj subject_combined.xfm subject_transformed_right.obj 

4. Evaluate scan values on the mid surface

Now that you've checked that your objects are well aligned, you will use the volume_object_evaluate command to collect values from the "other scan" onto your surface:

> volume_object_evaluate path_to/otherscan.mnc subject_transformed_left.obj subject_sampled_values_left.txt 
> volume_object_evaluate path_to/otherscan.mnc subject_transformed_right.obj subject_sampled_values_right.txt 

5. Smooth your text files

If you are interested in performing statistics on your sampled values, you need to smooth your values on the surface. We will be using a CIVET tool to do the smoothing so you will need to open a new terminal window and load the appropriate modules. The amount of smoothing can be changed with the smooth parameter, with usual values being between 5 and 30 (lower means less smoothing).

> module load anaconda/2.3 
> module load CIVET
> depth_potential -smooth 20 subject_sampled_values_left.txt subject_transformed_left.obj subject_sampled_values_left_smooth.txt 
> depth_potential -smooth 20 subject_sampled_values_right.txt subject_transformed_right.obj subject_sampled_values_right_smooth.txt 

6. Resample the smoothed text files into RSL space

This will give you homology with the CIVET vertices between your subjects. You first need to copy-paste the CIVET common space surfaces into your own directory before running the resample step.

> scp /data/chamal/projects/paroli/ressources/icbm_avg_mid_sym_mc_*.obj your/directory/
> surface-resample your/directory/icbm_avg_mid_sym_mc_left.obj path_to/CIVET/output/subject/surfaces/subject_mid_surface_left_81920.obj subject_sampled_values_left_smooth.txt path_to/CIVET/output/subject/transforms/surfreg/subject_left_surfmap.sm subject_surface_values_rsl.txt 
> surface-resample your/directory/icbm_avg_mid_sym_mc_right.obj path_to/CIVET/output/subject/surfaces/subject_mid_surface_right_81920.obj subject_sampled_values_right_smooth.txt path_to/CIVET/output/subject/transforms/surfreg/subject_right_surfmap.sm subject_surface_values_rsl.txt 

These files are now ready for statistics. If you are using R, they are suitable for vertexLm or vertexLmer

Clone this wiki locally