Skip to content

Surface Sampling Using CIVET surfaces

raihaan edited this page Aug 5, 2019 · 10 revisions

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. To get the transform from the cosine direction correction (only CIVET 1.1.12):

CIVET 1.1.12 will set all cosine direction angles to be 90 degrees, which is equivalent to a transform, so we want the inverse of this transform as well. Ignore this step if using CIVET 2.1.0. You will use the command dircos_to_xfm, list the path to the t1 image you used as inputs for your CIVET run, followed by the name for the transform you are creating:

> dircos_to_xfm path_to/CIVET/input/subject_t1.mnc subject_dircos.xfm; done

4. Combine the transforms you just created in steps 1-3

Now you will combine the transforms you just created into one using the command xfmconcat. The example below is for CIVET 1.1.12, if you used CIVET 2.1.0, you don't need the subject_dircos.xfm:

> xfmconcat subject_t1_tal_invert.xfm subject_dircos.xfm transform_t1_to_otherscan.xfm subject_cobmined.xfm

5. 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 

6. 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 

7. 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:

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

8. Resample the smoothed text files into RSL space

This will give you homology with the CIVET vertices between your subjects. You will use the surf_reg_model_left for both the left and right!

> surface-resample /opt/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/surf_reg_model_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 /opt/quarantine/CIVET/1.1.12/build/CIVET-1.1.12/models/surf_reg_model_left.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